func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /STACK:60000000 )   using namespace std;   const long double eps = 1e-9;   const int inf = (1 << 30) - 1;   const long long inf64 = ((long long)1 << 62) - 1;   const long double pi = 3.1415926535897932384626433832795;   template <class T>   T sqr(T x) {     return x * x;   }   int n, m;   long long w[300300];   long long t[300300];   vector<pair<pair<int, int>, int> > Q;   long long ans[300300];   int main() {     memset(w, 0, sizeof(w));     scanf( %d , &n);     for (int i = 0; i < (int)(n); i++) {       int x;       scanf( %d , &x);       w[i] = x;     }     scanf( %d , &m);     Q.resize(m);     for (int i = 0; i < (int)(m); i++) {       int a, b;       scanf( %d%d , &a, &b);       a--;       Q[i] = make_pair(make_pair(b, a), i);     }     sort(Q.begin(), Q.end());     int cur = 0;     for (int i = 0; i < (int)(Q.size()); i++) {       int a = Q[i].first.second;       int b = Q[i].first.first;       int num = Q[i].second;       if (b > 1000) {         ans[num] = 0;         while (a < n) {           ans[num] += w[a];           a += b;         }       } else {         if (b > cur) {           cur = b;           memset(t, 0, sizeof(t));           for (int i = n - 1; i >= 0; i--) {             t[i] = w[i];             if (i + cur < n) t[i] += t[i + cur];           }         }         if (a < n)           ans[num] = t[a];         else           ans[num] = 0;       }     }     for (int i = 0; i < (int)(m); i++) printf( %I64d n , ans[i]);     return 0;   }   