func_code_string: #include <bits/stdc++.h>   using namespace std;   double eps = 1e-9;   const int INF = 1e9 + 7;   const int MAXN = int(3e5 + 7);   vector<pair<int, int> > v[MAXN];   int n, p, a[MAXN];   long long ans[MAXN], dp[MAXN];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     scanf( %d , &p);     for (int i = 0; i < p; i++) {       int x, y;       scanf( %d%d , &x, &y);       v[y].push_back(make_pair(x, i));     }     for (int i = 1; i <= 500; i++) {       for (int j = n; j > 0; j--) {         dp[j] += a[j];         if (j + i <= n) dp[j] += dp[j + i];       }       for (int j = 0; j < v[i].size(); j++)         ans[v[i][j].second] = dp[v[i][j].first];       memset(dp, 0, sizeof(dp));     }     for (int i = 501; i <= 300000; i++) {       for (int j = 0; j < v[i].size(); j++) {         long long cur = 0;         for (int k = v[i][j].first; k <= n; k += i) cur += a[k];         ans[v[i][j].second] = cur;       }     }     for (int i = 0; i < p; i++) printf( %I64d n , ans[i]);     return 0;   }   