malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long m;   long long p(long long x) {     long long kmx = 0;     while ((kmx * kmx * kmx) <= x) kmx++;     kmx--;     long long ret = 0;     for (long long i = 2; i <= kmx; i++) ret += x / (i * i * i);     return ret;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> m;     long long ans = 0;     long long lo = 1, hi = 1e16;     while (lo <= hi) {       long long mi = (lo + hi) / 2;       if (p(mi) >= m) {         ans = mi;         hi = mi - 1;       } else         lo = mi + 1;     }     if (p(ans) != m) ans = -1;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxx = 200010;   unsigned long long t, n;   unsigned long long ans = 0, total = 0, sum = 0;   unsigned long long a[maxx], b[maxx], bj[maxx];   int main() {     scanf( %lld , &t);     while (t--) {       scanf( %lld , &n);       ans = 0, total = 0, sum = 1;       while (n >= sum) {         unsigned long long opt = sum;         total++;         sum *= 2;         ans += total + (n - opt) / sum * total;       }       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 5;   const long long inf = 1e18 + 9;   int n, m, k, q;   vector<pair<int, int> > g[maxn];   pair<long long, pair<int, int> > edges[maxn];   pair<int, int> query[maxn];   struct data {     int id;     long long val;     bool operator<(const data& other) const { return val > other.val; }   };   long long d[maxn];   int lab[maxn];   int low[maxn], high[maxn];   vector<int> vec[maxn];   void read_input() {     cin >> n >> m >> k >> q;     for (int i = 1; i <= m; ++i) {       int u, v, w;       cin >> u >> v >> w;       edges[i] = make_pair(w, pair<int, int>(u, v));       g[u].push_back(pair<int, int>(v, w));       g[v].push_back(pair<int, int>(u, w));     }     for (int i = 1; i <= q; ++i) {       int u, v;       cin >> u >> v;       query[i] = pair<int, int>(u, v);     }   }   void dijkstra() {     priority_queue<data> pq;     fill(d + 1, d + n + 1, inf);     for (int i = 1; i <= k; ++i) {       d[i] = 0;       pq.push({i, 0});     }     while (!pq.empty()) {       data tp = pq.top();       pq.pop();       if (tp.val != d[tp.id]) continue;       int u = tp.id;       for (auto& to : g[u]) {         int v = to.first, w = to.second;         if (d[v] > d[u] + w) {           d[v] = d[u] + w;           pq.push({v, d[v]});         }       }     }   }   int find_set(int u) { return lab[u] < 0 ? u : lab[u] = find_set(lab[u]); }   void union_sets(int u, int v) {     if (lab[u] < lab[v]) swap(u, v);     lab[v] += lab[u];     lab[u] = v;   }   void solve() {     dijkstra();     for (int i = 1; i <= m; ++i) {       int u = edges[i].second.first, v = edges[i].second.second;       edges[i].first += d[u] + d[v];     }     sort(edges + 1, edges + m + 1);     for (int i = 1; i <= q; ++i) {       low[i] = 1;       high[i] = m;     }     while (true) {       bool stop = true;       for (int i = 1; i <= q; ++i)         if (low[i] <= high[i]) {           stop = false;           int mid = (low[i] + high[i]) / 2;           vec[mid].push_back(i);         }       if (stop) break;       fill(lab + 1, lab + n + 1, -1);       for (int i = 1; i <= m; ++i) {         int u = edges[i].second.first, v = edges[i].second.second;         u = find_set(u);         v = find_set(v);         if (u != v) union_sets(u, v);         while ((int)vec[i].size()) {           int id = vec[i].back();           vec[i].pop_back();           if (find_set(query[id].first) == find_set(query[id].second))             high[id] = i - 1;           else             low[id] = i + 1;         }       }     }     for (int i = 1; i <= q; ++i) cout << edges[low[i]].first <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     read_input();     solve();   }
#include <bits/stdc++.h>   using namespace std;   bool in_range(long long l, long long v, long long r) {     return (l <= v && v <= r);   }   int main() {     long long x;     cin >> x;     x = ((-x) % 360 + 360) % 360;     int ans = 0;     if (x >= 225 && x < 315)       ans = 1;     else if (x >= 135 && x < 225)       ans = 2;     else if (x > 45 && x < 135)       ans = 3;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline pair<int, int> best(pair<int, int> a, pair<int, int> b) {     if ((a.first > b.first) || ((a.first == b.first) && (a.second < b.second)))       return a;     return b;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     string s;     cin >> n;     cin >> s;     cin >> m;     vector<vector<int> > ka(n, vector<int>(2));     vector<vector<int> > kb(n, vector<int>(2));     vector<int> kv(n);     vector<int> preva(n, -1);     if (s[0] ==  a ) {       preva[0] = 0;       ka[0][0] = 1;     }     if (s[0] ==  b ) kb[0][0] = 1;     if (s[0] ==  ? ) kv[0] = 1, preva[0] = 0;     for (int i = 1; i < n; i++) {       ka[i][0] = ka[i - 1][0];       ka[i][1] = ka[i - 1][1];       if (s[i] ==  a ) ka[i][i % 2]++;       kb[i][0] = kb[i - 1][0];       kb[i][1] = kb[i - 1][1];       if (s[i] ==  b ) kb[i][i % 2]++;       if ((s[i] ==  a ) || (s[i] ==  ? ))         preva[i] = i;       else         preva[i] = preva[i - 1];       kv[i] = kv[i - 1];       if (s[i] ==  ? ) kv[i]++;     }     vector<vector<pair<int, int> > > dp(n, vector<pair<int, int> >(2));     if (((s[0] ==  a ) || (s[0] ==  ? )) && (m <= n) && (kb[m - 1][0] == 0) &&         (ka[m - 1][1] == 0))       dp[0][1] = {1, kv[m - 1]};     for (int i = 1; i < n; i++) {       dp[i][0] = best(dp[i - 1][0], dp[i - 1][1]);       if (i + m - 1 >= n) continue;       int bada = ka[i + m - 1][(i % 2) ^ 1] - ka[i - 1][(i % 2) ^ 1];       int badb = kb[i + m - 1][i % 2] - kb[i - 1][i % 2];       if ((bada != 0) || (badb != 0)) continue;       if (i < m) {         dp[i][1] = {1, kv[i + m - 1] - kv[i - 1]};       } else {         int p = preva[i - m];         if (p < 0) {           dp[i][1] = {1, kv[i + m - 1] - kv[i - 1]};         } else {           dp[i][1] = best(dp[p][0], dp[p][1]);           dp[i][1].first++;           dp[i][1].second += kv[i + m - 1] - kv[i - 1];         }       }     }     pair<int, int> rez = best(dp[n - 1][0], dp[n - 1][1]);     cout << rez.second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class Solution {    public:     void solve(std::istream& in, std::ostream& out) {       long long n, k, b, c, a, d;       in >> n >> k >> b >> c;       b = min(b, 5 * c);       vector<pair<long long, long long>> x(n);       for (int i = 0; i < n; i++) {         in >> a;         x[i] = make_pair(a, 0);       }       for (int i = 0; i < n; i++) {         for (int j = 1; j < 5; j++) {           x.push_back(make_pair(x[i].first + j, -j));         }       }       n = x.size();       vector<vector<pair<long long, long long>>> y(5), z(5);       for (int i = 0; i < n; i++) {         a = x[i].first % 5;         if (a < 0) {           a = a + 5;         }         y[a].push_back(x[i]);       }       for (int i = 0; i < 5; i++) {         sort(begin(y[i]), end(y[i]));         int t = y[i].size();         long long h = y[i].back().first;         z[i] = vector<pair<long long, long long>>(t);         for (int j = 0; j < t; j++) {           z[i][j] =               make_pair(-((h - y[i][j].first) / 5 * b - y[i][j].second * c), j);         }         sort(begin(z[i]), end(z[i]));       }       long long m = 100000000000000000;       for (int i = 0; i < 5; i++) {         int t = y[i].size();         priority_queue<pair<int, int>> q;         long long p = 0;         int l = t - 1, r = t - 1;         long long h;         while (l >= 0) {           if (r < 0) break;           d = y[i][r].first;           if (q.size()) {             a = q.top().first;             p -= (h - a) / 5 * b * q.size();             h = a;           }           while (q.size() && d < q.top().first) {             p += q.top().second * c;             q.pop();             if (q.size()) {               a = q.top().first;               p -= (h - a) / 5 * b * q.size();               h = a;             } else               p = 0;           }           if (q.size()) {             a = q.top().first;             p += (d - a) / 5 * b * q.size();           }           while (l >= 0 && q.size() < k) {             a = z[i][l].second;             if (y[i][a].first > d) {               l--;               continue;             }             p -= y[i][a].second * c;             p += (d - y[i][a].first) / 5 * b;             q.push(y[i][a]);             l--;           }           if (q.size() == k) m = min(m, p);           h = d;           r--;           while (r >= 0 && y[i][r].first == y[i][r + 1].first) r--;         }       }       out << m;     }   };   void solve(std::istream& in, std::ostream& out) {     out << std::setprecision(12);     Solution solution;     solution.solve(in, out);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     istream& in = cin;     ostream& out = cout;     solve(in, out);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a[100000], s = 0, nz = 0;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     for (int i = 0; i < n; i++) {       if (a[i] == a[i + 1] && a[i] != 0) s++;       if (a[i] == 0) nz++;     }     cout << n - s - nz << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string now, st;   vector<int> num[26];   int main(void) {     int n, k;     cin >> n >> k;     cin >> st;     for (int i = 0; i < (k); i++) {       num[st[i] -  a ].push_back(i);     }     for (int Case = 0; Case < (n); Case++) {       cin >> now;       long long res = 0;       int len = now.size();       for (int i = 0; i < (len); i++) {         if (i >= k || st[i] != now[i]) {           int alpha = now[i] -  a ;           if (num[alpha].empty()) {             res += len;             continue;           }           int left = 0, right = num[alpha].size() - 1, mid;           while (left < right) {             mid = (left + right + 1) >> 1;             if (num[alpha][mid] <= i)               left = mid;             else               right = mid - 1;           }           int tmp = abs(i - num[alpha][left]);           if (left + 1 < num[alpha].size())             tmp = min(tmp, abs(i - num[alpha][left + 1]));           res += tmp;         }       }       cout << res << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int mn = 500005;   int n, fp, ln;   pair<double, double> inp[mn];   bool f(double mid) {     double ma = -(int)1e9;     for (int i = fp; i < ln + 1; i++) {       double pos = inp[i].first + mid * inp[i].second;       if (inp[i].second < 0) {         if (pos <= ma) return 1;       } else         ma = max(ma, pos);     }     return 0;   }   int main() {     n = ({       int t;       scanf( %d , &t);       t;     });     for (int i = 0; i < n; i++)       inp[i].first = ({         int t;         scanf( %d , &t);         t;       }),       inp[i].second = ({         int t;         scanf( %d , &t);         t;       });     fp = ln = -1;     for (int i = n - 1; i >= 0; i--)       if (inp[i].second > 0) fp = i;     for (int i = 0; i < n; i++)       if (inp[i].second < 0) ln = i;     if (fp == -1 || ln == -1 || fp > ln) {       printf( -1 n );       return 0;     }     double lo = 0, hi = double(1e9) + 5, mid = (lo + hi) / 2;     for (int times = 0; times < 100; times++) {       if (f(mid))         hi = mid;       else         lo = mid;       mid = (lo + hi) / 2;     }     printf( %.15lf n , mid);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   using pll = pair<ll, ll>;   using ld = long double;   const int mod = 1e9 + 7;   const ll inf = 2e9;   const ll INF = 2e18;   const ld EPS = 1e-7;   const int N = 1e5 + 55;   ll sx[N], sy[N];   void solve() {     int n, m;     cin >> n >> m;     vector<vector<int>> a(n, vector<int>(m));     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         cin >> a[i][j];         sx[i] += a[i][j];         sy[j] += a[i][j];       }     }     ll mx = 0;     vector<ll> v;     for (int i = 0; i < n; ++i) {       v.clear();       for (int j = 0; j < m; ++j) {         v.push_back(sy[j] - a[i][j]);         sort(v.rbegin(), v.rend());         while (v.size() > 3) {           v.pop_back();         }       }       ll cur = sx[i];       for (ll a : v) {         cur += a;       }       mx = max(mx, cur);     }     for (int j = 0; j < m; ++j) {       v.clear();       for (int i = 0; i < n; ++i) {         v.push_back(sx[i] - a[i][j]);         sort(v.rbegin(), v.rend());         while (v.size() > 3) {           v.pop_back();         }       }       ll cur = sy[j];       for (ll a : v) {         cur += a;       }       mx = max(mx, cur);     }     if (n > m) {       for (int i = 0; i < m; ++i) {         for (int k = i + 1; k < m; ++k) {           v.clear();           for (int j = 0; j < n; ++j) {             v.push_back(sx[j] - a[j][i] - a[j][k]);             sort(v.rbegin(), v.rend());             while (v.size() > 2) {               v.pop_back();             }           }           ll cur = sy[i] + sy[k];           for (ll a : v) {             cur += a;           }           mx = max(mx, cur);         }       }     } else {       for (int i = 0; i < n; ++i) {         for (int k = i + 1; k < n; ++k) {           v.clear();           for (int j = 0; j < m; ++j) {             v.push_back(sy[j] - a[i][j] - a[k][j]);             sort(v.rbegin(), v.rend());             while (v.size() > 2) {               v.pop_back();             }           }           ll cur = sx[i] + sx[k];           for (ll a : v) {             cur += a;           }           mx = max(mx, cur);         }       }     }     sort(sx, sx + n);     sort(sy, sy + m);     for (ll i = n - 1, sum = 0; i >= max(0, n - 4); --i) {       sum += sx[i];       mx = max(mx, sum);     }     for (ll i = m - 1, sum = 0; i >= max(0, m - 4); --i) {       sum += sy[i];       mx = max(mx, sum);     }     cout << mx;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     ;     int tt = 1;     while (tt--) {       solve();       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6, M = 1e9 + 7;   int gcd(int a, int b) {     if (!b) return a;     return gcd(b, a % b);   }   int n, x[N], y[N];   map<pair<long double, long double>, int> mp;   int t(int i, int j) {     long double dX = x[i] - x[j];     long double dY = y[i] - y[j];     long double g = gcd(dX, dY);     dX /= g, dY /= g;     vector<int> r;     for (int k = 0; k < n; k++) {       if (k == i || k == j) continue;       long double tmpx = x[i] - x[k];       long double tmpy = y[i] - y[k];       long double g = gcd(tmpx, tmpy);       tmpx /= g, tmpy /= g;       if (tmpx == dX && tmpy == dY)         continue;       else         r.push_back(k);     }     if (r.size() < 2) return true;     long double x2 = x[r[0]] - x[r[1]];     long double y2 = y[r[0]] - y[r[1]];     g = gcd(x2, y2);     if (g) x2 /= g, y2 /= g;     for (int i = 1; i < r.size(); i++) {       long double tmpx = x[r[0]] - x[r[i]];       long double tmpy = y[r[0]] - y[r[i]];       long double g = gcd(tmpx, tmpy);       if (g) tmpx /= g, tmpy /= g;       if (x2 != tmpx || y2 != tmpy) return false;     }     return true;   }   int main() {     scanf( %d , &n);     int cnt = 0;     for (int i = 0; i < n; i++) scanf( %d%d , &x[i], &y[i]);     for (int i = 1; i < n; i++) {       long double dX = x[i] - x[0];       long double dY = y[i] - y[0];       long double g = gcd(dX, dY);       dX /= g, dY /= g;       if (!mp[{dX, dY}]) mp[{dX, dY}] = i, cnt++;       if (cnt == 2) break;     }     if (cnt < 2) {       return puts( YES ), 0;     } else {       vector<int> v;       for (auto it = mp.begin(); it != mp.end(); it++) {         v.push_back(it->second);         if (t(0, it->second)) return puts( YES );       }       if (t(v[0], v[1])) return puts( YES );     }     puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   long long n, a, b;   int main() {     cin >> n;     a = (n + 2) * (n + 1) / 2 * n / 3;     b = (n + 4) * (n + 3) / 2 * (n + 2) / 3 * (n + 1) / 4 * n / 5;     cout << a * b;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   const int MOD = 1e9 + 7;   vector<pair<long long int, long long int> > vp;   map<long long int, long long int> mp, mpp;   vector<long long int> v, v1, v2;   long long int dp[N], visit[N];   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cerr << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<     ;     __f(comma + 1, args...);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long int n, m, val, k, d, mi = 1e9, mx(0);     long long int sum(0), ct(0), p(0), q(0);     cin >> n >> m;     if (n <= 2 * m)       cout << 0 <<    ;     else       cout << n - 2 * m <<    ;     long long int low = 0, high = n;     while (low <= high) {       long long int mid = (low + high) >> 1;       if (((mid * (mid - 1) / 2)) >= m) {         high = mid - 1;       } else {         low = mid + 1;       }     }     cout << n - (high + 1);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &(n));     static long long a[int(5e3 + 5)];     set<int> s;     for (int i = 1, __R = n; i <= __R; i++) {       scanf( %lld , &(a[i]));       s.insert(a[i]);     }     static long long b[int(5e3 + 5)], k = 0;     for (long long x : s) b[++k] = x;     static long long dp[2][int(5e3 + 5)];     int lst = 0, cur = 1;     dp[lst][1] = abs(a[1] - b[1]);     for (int j = 2, __R = k; j <= __R; j++)       dp[lst][j] = min(dp[lst][j - 1], abs(a[1] - b[j]));     for (int i = 2, __R = n; i <= __R; i++) {       dp[cur][1] = dp[lst][1] + abs(a[i] - b[1]);       for (int j = 2, __R = k; j <= __R; j++)         dp[cur][j] = min(dp[cur][j - 1], dp[lst][j] + abs(a[i] - b[j]));       swap(lst, cur);     }     cout << dp[lst][k] << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimization( unroll-loops )   std::pair<int, int> DR[] = {{-1, 0}, {0, 1},   {1, 0}, {0, -1},                               {-1, 1}, {-1, -1}, {1, 1}, {1, -1}};   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     ~debug() { cerr << endl; }     template <class c>     typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {       cerr << boolalpha << i;       return *this;     }     template <class c>     typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {       return *this << range(begin(i), end(i));     }     template <class c, class b>     debug& operator<<(pair<b, c> d) {       return *this <<  (  << d.first <<  ,   << d.second <<  ) ;     }     template <class c>     debug& operator<<(rge<c> d) {       *this <<  [ ;       for (auto it = d.b; it != d.e; ++it) *this <<  ,   + 2 * (it == d.b) << *it;       return *this <<  ] ;     }   };   long long gcd(long long a, long long b) {     if (b) return gcd(b, a % b);     return a;   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   long long n, m, a, b, g[3005 * 3005], val[3005][3005], mn[3005][3005], x, y, z,       ans;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cerr.tie(0);     cout.tie(0);     cin >> n >> m >> a >> b;     cin >> g[0] >> x >> y >> z;     for (long long i = 1; i < n * m; i++) {       g[i] = (g[i - 1] * x + y) % z;     }     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < m; j++) {         val[i][j] = g[i * m + j];       }     }     for (long long j = 0; j < m; j++) {       deque<long long> dq;       for (long long i = 0; i < a; i++) {         while ((long long)((dq).size()) && val[dq.back()][j] >= val[i][j])           dq.pop_back();         dq.push_back(i);       }       mn[0][j] = val[dq.front()][j];       for (long long i = 1; i <= n - a; i++) {         if (dq.front() == i - 1) dq.pop_front();         while ((long long)((dq).size()) && val[dq.back()][j] >= val[i + a - 1][j])           dq.pop_back();         dq.push_back(i + a - 1);         mn[i][j] = val[dq.front()][j];       }     }     for (long long i = 0; i <= n - a; i++) {       deque<long long> dq;       for (long long j = 0; j < b; j++) {         while ((long long)((dq).size()) && mn[i][dq.back()] >= mn[i][j])           dq.pop_back();         dq.push_back(j);       }       ans += mn[i][dq.front()];       for (long long j = 1; j <= m - b; j++) {         if (dq.front() == j - 1) dq.pop_front();         while ((long long)((dq).size()) && mn[i][dq.back()] >= mn[i][j + b - 1])           dq.pop_back();         dq.push_back(j + b - 1);         ans += mn[i][dq.front()];       }     }     return cout << ans, 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   inline int rand(int x, int y) {     ++y;     return (rng() % (y - x)) + x;   }   string to_string(char c) {     string second(1, c);     return second;   }   string to_string(bool b) { return (b ?  true  :  false ); }   template <typename A, typename B>   string to_string(pair<A, B> p) {     return  (  + to_string(p.first) +  ,   + to_string(p.second) +  ) ;   }   template <typename A>   string to_string(A v) {     bool first = true;     string res =  { ;     for (const auto &x : v) {       if (!first) {         res +=  ,  ;       }       first = false;       res += to_string(x);     }     res +=  } ;     return res;   }   void degug_out() { cerr << endl; }   template <typename Head, typename... Tail>   void degug_out(Head H, Tail... T) {     cerr <<     << to_string(H);     degug_out(T...);   }   inline int gcd(int a, int b) {     if (a > b) swap(a, b);     if (a == 0) return b;     return gcd(b % a, a);   }   int n;   int read() {     bool neg = false;     int res = 0;     char c = getchar();     while (true) {       if (c ==  - ) break;       if ( 0  <= c && c <=  9 ) break;       c = getchar();     }     if (c ==  - )       neg = true;     else       res = c -  0 ;     while (true) {       c = getchar();       if (c <  0  || c >  9 ) break;       res = (res << 1) + (res << 3) + (c -  0 );     }     if (neg) return -res;     return res;   }   const int sz = 670;   int store[sz + 2][sz + 2];   int A[(500006)];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     n = read();     for (int i = (0); i <= (int)(n - 1); ++i) {       int op, x, y;       op = read(), x = read(), y = read();       if (op == 1) {         for (int i = (1); i <= (int)(sz); ++i) {           store[i][x % i] += y;         }         A[x] += y;       } else {         if (x > sz) {           int ans = 0;           for (int i = y; i <= 500000; i += x) ans += A[i];           cout << ans <<   n ;         } else {           cout << store[x][y] <<   n ;         }       }     }   }