func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 9;   vector<pair<int, int> > barr[N];   int n, q, arr[N], a, b;   long long t[N], ans[N];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> arr[i];     scanf( %d , &q);     int kok = sqrt(n);     for (int i = 1; i <= q; i++) {       scanf( %d %d , &a, &b);       if (b > kok) {         for (int j = a; j <= n; j += b) ans[i] += arr[j];       } else         barr[b].push_back(make_pair(a, i));     }     for (int i = 1; i <= kok; i++) {       if (barr[i].size()) {         for (int j = n; j >= 1; j--) t[j] = arr[j] + t[(i + j) * (i + j <= n)];         for (int j = 0; j < barr[i].size(); j++)           ans[barr[i][j].second] = t[barr[i][j].first];       }     }     for (int i = 1; i <= q; i++) printf( %lld n , ans[i]);     return 0;   }   