malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <map>   #include <queue>   #include <cmath>   #include <vector>   #include <cstdio>   #include <cstring>   #include <algorithm>   #define itt map<int,int>::iterator    #define ll long long   #define ull unsigned long long    #define dd double   using namespace std;   const int maxn=5000,N1=maxn+5; const int inf=0x3f3f3f3f,p=998244353;      template <typename _T> void read(_T &ret)   {       ret=0; _T fh=1; char c=getchar();       while(c< 0 ||c> 9 ){ if(c== - ) fh=-1; c=getchar(); }       while(c>= 0 &&c<= 9 ){ ret=ret*10+c- 0 ; c=getchar(); }       ret=ret*fh;   }      int T,n,q;    int tag[N1];   ll f[2][N1] ,g[N1], s[N1];      int main()   {       scanf( %d ,&T);       while(T--){                  scanf( %d ,&n);       for(int i=1;i<=n;i++) read(tag[i]);;       for(int i=1;i<=n;i++) read(s[i]);       for(int i=1;i<=n;i++) f[0][i]=f[1][i]=g[i]=0;       int now=1, pst=0;       f[pst][1]=0;       for(int i=2;i<=n;i++)       {           for(int j=1;j<i;j++) f[now][j]=f[pst][j], g[j]=0;           for(int j=1;j<i;j++)            {               if(tag[i]==tag[j]) continue;               f[now][i]=max(f[now][i],f[pst][j]+abs(s[i]-s[j]));               if(j>1) g[j-1]=f[pst][j]+abs(s[i]-s[j]);           }           for(int j=i-1;j>=1;j--)           {               g[j]=max(g[j],g[j+1]);               if(tag[i]==tag[j]) continue;               f[now][j]=max(f[pst][j],g[j]+abs(s[i]-s[j]));           }           // for(int j=1;j<=i;j++) printf( %d  ,f[now][j]); puts(  );           swap(now,pst);       }       ll ans=0;       for(int i=1;i<=n;i++) ans=max(ans,f[pst][i]);       printf( %lld n ,ans);              }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i, j, a;   int main() {     for (i = 1; i <= 5; i++) {       for (j = 1; j <= 5; j++) {         cin >> a;         if (a == 1) cout << (abs(3 - i) + abs(3 - j)) << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   signed long long p[1000005] = {0};   void sieve() {     p[0] = 1;     p[1] = 1;     for (signed long long i = 2; i * i <= 1000000; i++) {       if (p[i] == 0) {         for (signed long long j = 2 * i; j <= 1000000; j = j + i) p[j] = 1;       }     }   }   int main() {     signed long long n, m, wt;     cin >> n >> m;     sieve();     for (signed long long i = n - 1; i <= 1000000; i++) {       if (p[i] == 0) {         wt = i;         break;       }     }     cout << wt <<     << wt << endl;     ;     for (signed long long i = 1; i < n - 1; i++)       cout << i <<     << i + 1 <<                <<  1  << endl;     cout << n - 1 <<     << n <<     << wt - (n - 2) << endl;     signed long long cnt = n - 1;     for (signed long long i = 1; i <= n; i++) {       for (signed long long j = i + 2; j <= n; j++) {         if (cnt == m) return 0;         cout << i <<     << j <<     << wt + 5 << endl;         cnt++;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long base, long long e) {     long long answer = 1;     while (e) {       if (e % 2 == 1) {         answer *= base;       }       base *= base;       e /= 2;     }     return answer;   }   int main() {     long long i, n, m, k, j;     cin >> n >> m;     string s[n];     for (i = 0; i < n; i++) {       cin >> s[i];     }     long long a[m];     for (i = 0; i < m; i++) {       cin >> a[i];     }     long long sum = 0;     for (i = 0; i < m; i++) {       long long f[5] = {0};       for (j = 0; j < n; j++) {         f[s[j][i] -  A ]++;       }       long long max = f[0];       for (j = 1; j < 5; j++) {         if (max <= f[j]) max = f[j];       }       sum += (max * a[i]);     }     cout << sum;   }
#include <bits/stdc++.h>   using namespace std;   bool isPrime(int n) {     if (n <= 1) {       return false;     }     for (int i = 2; i < n; i++) {       if (n % i == 0) {         return false;       }     }     return true;   }   vector<long long int> inisum;   long long int binary(long long int target) {     long long int end = inisum.size() - 1;     long long int start = 0;     long long int ans = -1;     while (start <= end) {       long long int mid = (start + end) / 2;       if (inisum[mid] <= target) {         start = mid + 1;       } else {         ans = mid;         end = mid - 1;       }     }     return ans;   }   bool isSum(long long int n) {     long long int sum = 0;     while (n != 0) {       sum += n % 10;       n /= 10;     }     if (sum == 10) {       return true;     } else {       return false;     }   }   int main(void) {     long long int t;     cin >> t;     while (t--) {       long long int x1, y1, z1;       long long int x2, y2, z2;       cin >> x1 >> y1 >> z1;       cin >> x2 >> y2 >> z2;       long long int count = 0;       if (z1 > y2) {         count += y2;         z1 -= y2;         y2 = 0;       } else {         count += z1;         y2 -= z1;         z1 = 0;       }       if (y1 > x2) {         y1 -= x2;         x2 = 0;       } else {         x2 -= y1;         y1 = 0;       }       if (y1 > y2) {         y1 -= y2;         y2 = 0;       } else {         y2 -= y1;         y1 = 0;       }       if (z1 > x2) {         z1 -= x2;         x2 = 0;       } else {         x2 -= z1;         z1 = 0;       }       if (z1 > y2) {         z1 -= y2;         y2 = 0;       } else {         y2 -= z1;         z1 = 0;       }       count -= min(y1, z2);       cout << count * 2 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int a, b;     int c[4];     int minC = INT_MAX;     for (int i = 0; i < 4; i++) {       cin >> c[i];       if (minC > c[i]) minC = c[i];     }     cin >> a >> b;     int minXX = min(minC, b);     int ans = minXX - a;     bool baal = 0;     if (minXX != minC) baal = 1;     if (ans < 0)       cout << 0 << endl;     else if (a == b && minC > a)       cout << 1 << endl;     else if (baal == 1)       cout << ans + 1 << endl;     else       cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   string s[1111];   int c[1111];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> s[i];     int ans = 0;     for (int j = 0; j < m; j++) {       bool ret = false;       for (int i = 0; i < n - 1; i++)         if (s[i][j] > s[i + 1][j] && c[i] == 0) ret = true;       if (ret)         ans++;       else {         for (int i = 0; i < n - 1; i++)           if (s[i][j] < s[i + 1][j]) c[i] = 1;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   vector<pair<int, int> > dp(101);   int cntr[101] = {0};   int getIndexes(int &a, int &b, int &c, int &i, int &m, int x, int &xc, int &k) {     int res1 = 0;     int res2 = 0;     int f1 = 0, f2 = 0, j;     if (cntr[x] == 0) {       for (j = xc - m / 2; j <= xc + m / 2 + m % 2 - 1; j++)         res1 = res1 + (j > xc ? j - xc : xc - j) + i;       a = x;       b = dp[x].first = xc - m / 2;       c = dp[x].second = xc + m / 2 + m % 2 - 1;       return res1;     } else {       if (dp[x].first <= m) {         f1 = 1;         res1 = (1000 * 1000 * 1000 + 5);       } else {         for (j = dp[x].first - 1; j >= dp[x].first - m && j >= 1; j--)           res1 = res1 + (j > xc ? j - xc : xc - j) + i;       }       if (k - dp[x].second < m) {         f2 = 1;         res2 = (1000 * 1000 * 1000 + 5);       } else {         for (j = dp[x].second + 1; j <= dp[x].second + m && j <= k; j++)           res2 = res2 + (j > xc ? j - xc : xc - j) + i;       }       if (f1 == 1 && f2 == 1) return (1000 * 1000 * 1000 + 5);       if (res1 <= res2) {         a = x;         b = dp[x].first - m;         c = dp[x].first - 1;         return res1;       } else {         a = x;         b = dp[x].second + 1;         c = dp[x].second + m;         return res2;       }     }   }   int main() {     int n, k;     cin >> n >> k;     int xc = k / 2 + 1;     int yc = xc;     cntr[xc] = 0;     while (n--) {       int m, i;       cin >> m;       if (m > k) {         cout <<  -1  << endl;       } else {         int x, yl, yr;         int mfv = (1000 * 1000 * 1000 + 5);         for (i = 0; i < xc; i++) {           int a, b, c;           int mfu = (1000 * 1000 * 1000 + 5);           int mfd = (1000 * 1000 * 1000 + 5);           mfu = getIndexes(a, b, c, i, m, xc - i, xc, k);           if (mfv >= mfu) {             mfv = mfu;             x = a;             yl = b;             yr = c;           }           mfd = getIndexes(a, b, c, i, m, xc + i, xc, k);           if (mfv > mfd) {             mfv = mfd;             x = a;             yl = b;             yr = c;           }           if (cntr[xc - i] == 0 || cntr[xc + i] == 0) break;         }         if (mfv < (1000 * 1000 * 1000 + 5)) {           if (dp[x].first > yl || dp[x].first == 0) dp[x].first = yl;           if (dp[x].second < yr || dp[x].second == 0) dp[x].second = yr;           if (cntr[x] != 1) cntr[x] = 1;           cout << x <<     << yl <<     << yr << endl;         } else           cout <<  -1  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       int n;       string s;       cin >> n >> s;       int ans = 100;       for (int i = 0; i < n; i++) {         if (s[i] ==  > ) {           ans = min(ans, i);           break;         }       }       for (int i = n - 1; i >= 0; i--) {         if (s[i] ==  < ) {           ans = min(ans, n - i - 1);           break;         }       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e4 + 7, M = 2e2 + 7;   bool fl[N];   int n, k, tot, fs[N], sum[N], pos[M], f[M][N];   map<int, bool> s[N];   struct edge {     int u, v;   } ed[N * M];   struct node {     int ch[M], num;   } qt[N];   inline int read() {     int num = 0;     char g = getchar();     while (g < 48 || 57 < g) g = getchar();     while (47 < g && g < 58)       num = (num << 1) + (num << 3) + g - 48, g = getchar();     return num;   }   inline int find(int u) {     if (fs[u] == u) return u;     return fs[u] = find(fs[u]);   }   inline bool equals(node a, node b) {     for (int i = 1; i <= k; i++)       if (a.ch[i] + 1 != b.ch[i]) return false;     return true;   }   inline bool cmp(node a, node b) {     for (int i = 1; i <= k; i++) {       if (a.ch[i] < b.ch[i]) return false;       if (a.ch[i] > b.ch[i]) return true;     }     return false;   }   int main() {     n = read(), k = read();     for (int i = 1; i <= k; i++)       for (int x = 1; x <= n; x++) f[i][x] = read();     for (int i = 1; i <= k; i++)       for (int x = 1; x <= n; x++)         if (!f[i][x]) pos[i] = x;     for (int i = 2; i <= k; i++) {       memset(sum, 0, sizeof(sum));       for (int c = 1; c <= n; c++)         if (f[i][c] + f[1][c] == f[1][pos[i]]) sum[f[1][c]] = c;       for (int c = 0; c <= f[1][pos[i]]; c++)         if (!sum[c]) {           puts( -1 );           return 0;         }       for (int c = 0; c < f[1][pos[i]]; c++)         if (!s[sum[c]][sum[c + 1]])           s[sum[c]][sum[c + 1]] = s[sum[c + 1]][sum[c]] = 1, ed[++tot].u = sum[c],                             ed[tot].v = sum[c + 1];     }     for (int i = 1; i <= n; i++) fs[i] = i;     for (int i = 1; i <= tot; i++) {       int a = ed[i].u, b = ed[i].v;       fl[a] = fl[b] = 1, fs[a] = find(a), fs[b] = find(b);       if (fs[a] == fs[b]) {         puts( -1 );         return 0;       }       fs[fs[a]] = find(b);     }     int tp = 1;     for (int x = 1; x <= n; x++) {       qt[x].num = x;       for (int i = 1; i <= k; i++) qt[x].ch[i] = f[i][x];     }     for (int i = 1; i <= k; i++) fl[pos[i]] = 1;     sort(qt + 1, qt + n + 1, cmp);     for (int i = 1; i <= n; i++) {       int c = qt[i].num;       if (fl[c]) continue;       while ((!equals(qt[tp], qt[i])) && tp <= n) tp++;       if (tp > n) {         puts( -1 );         return 0;       }       tot++, ed[tot].u = c, ed[tot].v = qt[tp].num;     }     for (int i = 1; i <= tot; i++) printf( %d %d n , ed[i].u, ed[i].v);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void debug_out() { cerr << endl; }   template <typename Head, typename... Tail>   void debug_out(Head H, Tail... T) {     cerr <<     << H;     debug_out(T...);   }   const int INF = 1e9;   const long long MOD = 1e9 + 7;   const int N = 1e5 + 5, MO = 320, SQ = 600;   int n, q, A[N], QL[N], QR[N], P[N], T[N], C[N], K[N], Q[N];   vector<int> B, X, Y;   bool CMP(int i, int j) {     if (QL[i] / MO != QL[j] / MO) return QL[i] < QL[j];     return (QL[i] / MO) % 2 ? QR[i] < QR[j] : QR[i] > QR[j];   }   void Update(int x, int y) { T[C[x]]--, C[x] += y, T[C[x]]++; }   void Insert(int x, int y) {     if (x >= SQ && !K[x]) Y.push_back(x);     K[x] += y;   }   int Huf() {     X.clear(), Y.clear();     for (int i : B)       if (C[i] >= SQ) X.push_back(C[i]), K[C[i]]++;     sort(X.begin(), X.end());     int huf = 0, c = 0, x = 0, y = 0;     for (int i = 1; i < SQ; i++)       if (K[i] + T[i]) {         K[i] += T[i];         if (c) huf += i + c, K[i]--, Insert(i + c, 1), c = 0;         if (K[i] & 1) c = i, K[i]--;         if (K[i]) huf += i * K[i], Insert(i + i, K[i] >> 1), K[i] = 0;       }     while (x < (int)(X.size()) || y < (int)(Y.size())) {       while (x + 1 < (int)(X.size()) && X[x + 1] == X[x]) x++;       while (y + 1 < (int)(Y.size()) && Y[y + 1] == Y[y]) y++;       int i = 0;       if (x == (int)(X.size()))         i = Y[y++];       else if (y == (int)(Y.size()))         i = X[x++];       else if (X[x] < Y[y])         i = X[x++];       else         i = Y[y++];       if (c) huf += i + c, K[i]--, Insert(i + c, 1), c = 0;       if (K[i] & 1) c = i, K[i]--;       if (K[i]) huf += i * K[i], Insert(i + i, K[i] >> 1), K[i] = 0;     }     return huf;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     mt19937 Rnd(time(0));     cin >> n;     for (int i = 0; i < n; i++) cin >> A[i], C[A[i]]++;     for (int i = 0; i < N; i++)       if (C[i] >= SQ) B.push_back(i);     for (int i = 0; i < n; i++) C[A[i]]--;     cin >> q;     for (int i = 0; i < q; i++) cin >> QL[i] >> QR[i], QL[i]--, P[i] = i;     sort(P, P + q, CMP);     int L = 0, R = 0;     for (int i = 0; i < q; i++) {       int l = QL[P[i]], r = QR[P[i]];       while (l < L) Update(A[--L], +1);       while (R < r) Update(A[R++], +1);       while (L < l) Update(A[L++], -1);       while (r < R) Update(A[--R], -1);       Q[P[i]] = Huf();     }     for (int i = 0; i < q; i++) cout << Q[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000000;   const int prime = 9241;   const long double pi = acos(-1.);   int in[100005];   int masks[1000005];   bool used[1 << 22];   int main() {     int n, m, d;     scanf( %d%d%d , &n, &m, &d);     for (int i = 0; i < m; i++) {       int s;       scanf( %d , &s);       for (int j = 0; j < s; j++) {         int a;         scanf( %d , &a);         a--;         in[a] = i;       }     }     int cur[25] = {};     for (int i = 0; i < m; i++) cur[i] = 0;     for (int i = 0; i < d; i++) cur[in[i]]++;     int mcnt = 0;     masks[0] = 0;     for (int i = 0; i < m; i++)       if (cur[i] > 0) masks[0] |= 1 << i;     mcnt++;     for (int i = d; i < n; i++) {       cur[in[i - d]]--;       cur[in[i]]++;       masks[mcnt] = 0;       for (int j = 0; j < m; j++)         if (cur[j] > 0) masks[mcnt] |= 1 << j;       mcnt++;     }     queue<int> q;     for (int i = 0; i < (1 << m); i++) used[i] = 0;     for (int i = 0; i < mcnt; i++) {       q.push(masks[i]);       used[masks[i]] = 1;     }     while (!q.empty()) {       int cur = q.front();       q.pop();       for (int i = 0; i < m; i++) {         if (cur & (1 << i)) continue;         int nw = cur | (1 << i);         if (!used[nw]) {           used[nw] = 1;           q.push(nw);         }       }     }     int ans = 1000;     for (int i = 0; i < (1 << m); i++)       if (!used[i]) ans = min(ans, m - __builtin_popcount(i));     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int len = s.size();     int cnt = 0;     for (int i = 0; i < len; i++) {       if (s[i] ==  a  || s[i] ==  e  || s[i] ==  i  || s[i] ==  o  || s[i] ==  u )         cnt++;       if (s[i] ==  1  || s[i] ==  3  || s[i] ==  5  || s[i] ==  7  || s[i] ==  9 )         cnt++;     }     cout << cnt << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long Labs(long long first) { return first < 0 ? -first : first; }   int main() {     long long n, d;     cin >> n >> d;     long long a[n];     for (int i = (0); i < (int)(n); i++) cin >> a[i];     long long ans = 0;     for (int i = (0); i < (int)(n); i++)       for (int j = (0); j < (int)(n); j++)         if (i != j && Labs(a[i] - a[j]) <= d) {           ++ans;         }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double inf = 1e18 + 7;   const long double eps = 1e-18;   long long gcd(long long a, long long b) {     while (a || b) a %= b, swap(a, b);     return a + b;   }   int main() {     ios_base::sync_with_stdio(0);     long long t;     cin >> t;     for (long long tt = 0; tt < t; ++tt) {       long long x, y, p, q;       cin >> x >> y >> p >> q;       long long ok = y - x;       long long wa = y - ok;       long long nok = q - p;       long long nwa = q - nok;       if (nok == nwa) {         cout << abs(ok - wa) << endl;         continue;       }       if (nok == 0) {         if (ok != 0) {           cout << -1 << endl;           continue;         } else {           cout << 0 << endl;           continue;         }       }       if (nwa == 0) {         if (wa != 0) {           cout << -1 << endl;           continue;         } else {           cout << 0 << endl;           continue;         }       }       if (nok < nwa) {         long long xx = ok + nok - 1;         xx /= nok;         xx *= nok;         long long l = -1;         long long r = 1e10;         while (l != r - 1) {           long long m = (l + r) / 2ll;           long long lx = xx + nok * m;           long long rx = lx / nok * nwa;           if (rx >= wa)             r = m;           else             l = m;         }         long long lx = xx + nok * r;         long long rx = lx / nok * nwa;         long long ans = lx - ok;         ans += rx - wa;         cout << ans << endl;       } else {         long long xx = wa + nwa - 1;         xx /= nwa;         xx *= nwa;         long long l = -1;         long long r = 1e10;         while (l != r - 1) {           long long m = (l + r) / 2;           long long lx = xx + m * nwa;           long long rx = lx / nwa * nok;           if (rx >= ok)             r = m;           else             l = m;         }         long long lx = xx + r * nwa;         long long rx = lx / nwa * nok;         long long ans = (lx - wa) + (rx - ok);         cout << ans << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x[30000001];   int main() {     int n, a;     cin >> a >> n;     long long sum = 0, limit = n + a + 1;     memset((x), 0, sizeof(x));     for (long long i = 1; i * i < limit; i++)       for (long long j = i * i; j < limit; j += i * i) x[j] = i * i;     for (int i = a, j = 0; i < a + n; i++, j++) sum += (a + j) / x[i];     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t;     cin >> t;     while (t--) {       long long n, a, b;       cin >> n >> a >> b;       string s, ans;       for (long long i = 0; i < b; i++) {         long long m =  a ;         char c = m + i;         s += c;       }       for (long long i = 0; i < (n / b); i++) {         ans += s;       }       long long m = ans.length();       for (long long i = 0; i < n - m; i++) {         ans += s[i];       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long t, v;     cin >> t >> v;     long long a[t];     for (int i = 0; i < t; i++) cin >> a[i];     long long minx = 0;     sort(a, a + t);     for (int z = 0; z < t - 1; z++) {       minx = max(a[z + 1] - a[z], minx);     }     long long diff = max(a[0] - 0, v - a[t - 1]);     double re;     re = max(double(diff), double(minx) / 2.0);     cout << setprecision(10) << fixed << re;   }
//-->FIVAR_RoX   #include <bits/stdc++.h>   #include <vector>   #include <set>   #include <string>   #include <queue>   #define lli long long int   #define ld long double   //loops   #define dfloop(count1,count2,count3) for(lli i=count1;i>count2;i+=count3)   #define floop(count1,count2,count3) for(lli i=count1;i<count2;i+=count3)   #define floop1(count1,count2,count3) for(lli j=count1;j<count2;j+=count3)   #define vfloop(count1,count2,count3,i) for(lli i=count1;i<count2;i+=count3)   #define dvfloop(count1,count2,count3,i) for(lli i=count1;i>count2;i+=count3)   //outputs   #define qwe(x) cout<<x<<endl;   #define qw(x) cout<<x<<    ;   //for inputs   #define in(x) lli x; cin>>x;   #define make(a,x) lli a[x]; floop(0,x,1) cin>>a[i];   #define make1(a,x,y) lli a[x][y]; floop(0,x,1) floop1(0,y,1) cin>>a[i][j];   //for pairs   #define mkp make_pair   #define fst first   #define scd second   //vectors   #define pb push_back   //sets   #define sloop(s,i) for(auto i=s.begin();i!=s.end();i++)      using namespace std;   lli sum(lli* a,lli n){       lli s=0;       while(n--){           s+=a[n];    }       return s;   }   void print_Vector(vector<lli> Vec)    {        for (lli i = 0; i < Vec.size(); i++) {            cout << Vec[i] <<    ;        }        cout << endl;        return;    }    lli min_array(lli* a,lli n){       lli maxi=INT_MAX;       for (int i=0;i<n;i++){           if (maxi>a[i]) maxi=a[i];       }       return maxi;   }      void print_array(lli* a,lli n)   {       for (int i=0;i<n;i++){           cout<<a[i]<<   ;       }       cout<<endl;   }      void answer_fin(){       in(n)       lli k=n/2,k1,m1;       lli m=n-k;       k1=k+1;       m1=m+1;       lli ans;       if(n&1){           ans=k1*m1*2;       }       else ans=k1*m1;       qwe(ans)   }      int main()   {       lli test=1;      // cin>>test;       while(test--)       answer_fin();   }
#include <bits/stdc++.h>   using namespace std;   bool sieve[100000 + 5];   vector<long long> primes;   int inf[100000 + 5];   vector<vector<int> > g;   vector<vector<int> > h;   vector<int> rab;   vector<int> rtb;   vector<int> res;   void rec(int id, int del) {     if (id == rab.size()) {       res.push_back(del);       return;     }     int cum = 1;     for (int i = 0; i <= rab[id]; i++) {       rec(id + 1, del * cum);       cum *= rtb[id];     }   }   void gen1(int i) {     res.clear();     rab = g[i];     rtb = h[i];     rec(0, 1);   }   void fill() {     int san;     int cnt;     for (int i = 2; i < 100000 + 1; i++) {       san = i;       for (int j = 0; primes[j] <= san; j++) {         cnt = 0;         while (san % primes[j] == 0) {           san /= primes[j];           cnt++;         }         if (cnt > 0) {           g[i].push_back(cnt);           h[i].push_back(primes[j]);         }         if (san == 0) break;         if (sieve[san]) {           g[i].push_back(1);           h[i].push_back(san);           break;         }       }     }   }   void oku() {     memset(sieve, true, sizeof sieve);     g.assign(100000 + 1, vector<int>(0));     h.assign(100000 + 1, vector<int>(0));     sieve[1] = sieve[0] = false;     for (long long i = 2; i * i <= 100000; i++)       if (sieve[i])         for (long long j = i * i; j <= 100000; j += i) sieve[j] = false;     int cnt = 0;     for (int i = 0; i < 100000; i++)       if (sieve[i]) primes.push_back(i);     fill();     int n, x, y, id;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d%d , &x, &y);       gen1(x);       id = i + 1 - y;       cnt = 0;       for (int j = 0; j < int((res).size()); j++) {         if (inf[res[j]] < id) cnt++;         inf[res[j]] = i + 1;       }       printf( %d n , cnt);     }   }   int main() {     oku();     return 0;   }