malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000 * 1000 * 1000;   const double EPS = 1e-9;   const double PI = 2 * acos(0.);   const int N = 10;   const int dx[] = {-2, -1, 1, 2, 2, 1, -1, -2};   const int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};   char a[N][N];   bool r[N];   int main() {     int ans = 0;     for (int i = 0; i < int(8); ++i) {       for (int j = 0; j < int(8); ++j) scanf( %c , &a[i][j]);       scanf(  n );     }     for (int i = 0; i < int(8); ++i) {       bool flag = true;       for (int j = 0; j < int(8); ++j)         if (a[i][j] !=  B ) {           flag = false;           break;         }       if (flag) {         r[i] = true;         ++ans;       }     }     for (int j = 0; j < int(8); ++j) {       bool flag = false;       for (int i = 0; i < int(8); ++i)         if (a[i][j] ==  B  && !r[i]) {           flag = true;           break;         }       if (flag) ++ans;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector )   #pragma GCC optimize( unroll-loops )   using namespace std;   const int BLK = 320;   const int MXN = 1e5 + 5;   const int MOD = 998244353;   int add(int x, int y) { return (x += y) < MOD ? x : x - MOD; }   int sub(int x, int y) { return (x -= y) >= 00 ? x : x + MOD; }   int b[BLK];   int q[BLK][2 * BLK + 5];   int n, k;   int d[MXN];   int dp[MXN];   int arr[MXN];   int last1[MXN];   int last2[MXN];   void add(int pos) {     int id = (pos - 1) / BLK;     for (int i = BLK; i <= 2 * BLK; ++i) {       q[id][i] = add(q[id][i], dp[pos - 1]);     }   }   void update(int pos, int sgn) {     int id = (pos - 1) / BLK;     b[id] += sgn;     for (int i = pos; i > id * BLK; --i) {       if (sgn == +1) q[id][d[i] + BLK] = sub(q[id][d[i] + BLK], dp[i - 1]);       d[i] += sgn;       if (sgn == -2) {         q[id][d[i] + BLK] = add(q[id][d[i] + BLK], dp[i - 1]),                      q[id][d[i] + BLK + 1] =                          add(q[id][d[i] + BLK + 1], dp[i - 1]);       }     }   }   int get(int pos) {     int ret = 0;     int id = (pos - 1) / BLK;     for (int i = pos; i > id * BLK; --i) {       if (d[i] <= k) ret = add(ret, dp[i - 1]);     }     int sum = b[id];     while (--id >= 0) {       if (abs(sum - k) <= BLK) {         ret = add(ret, q[id][k - sum + BLK]);       } else if (sum < k) {         ret = add(ret, q[id][BLK + BLK]);       }       sum += b[id];     }     return ret;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0);     dp[0] = 1;     cin >> n >> k;     for (int i = 1; i <= n; ++i) {       cin >> arr[i];       add(i);       update(i, 1);       if (last1[arr[i]]) update(last1[arr[i]], -2);       if (last2[arr[i]]) update(last2[arr[i]], +1);       dp[i] = get(i);       last2[arr[i]] = last1[arr[i]];       last1[arr[i]] = i;     }     cout << dp[n] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long cdiv(long long x, long long y) { return x / y + (x % y > 0); }   long long w(long long a, long long b) {     return cdiv(a, 2) * cdiv(b, 2) + (a / 2) * (b / 2);   }   long long W(long long x1, long long y1, long long x2, long long y2) {     return w(x2, y2) - w(x2, y1 - 1) - w(x1 - 1, y2) + w(x1 - 1, y1 - 1);   }   long long B(long long x1, long long y1, long long x2, long long y2) {     return (y2 - y1 + 1) * (x2 - x1 + 1) - W(x1, y1, x2, y2);   }   int main() {     int t;     cin >> t;     while (t--) {       int x1, x2, x3, x4, y1, y2, y3, y4;       long long n, m;       cin >> n >> m;       cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;       long long white = W(1, 1, m, n);       long long black = B(1, 1, m, n);       white = white + B(x1, y1, x2, y2);       black = black - B(x1, y1, x2, y2);       white = white - W(x3, y3, x4, y4);       black = black + W(x3, y3, x4, y4);       if (max(x1, x3) <= min(x2, x4) && max(y1, y3) <= min(y2, y4)) {         white = white - B(max(x1, x3), max(y1, y3), min(x2, x4), min(y2, y4));         black = black + B(max(x1, x3), max(y1, y3), min(x2, x4), min(y2, y4));       }       cout << white <<     << black <<   n ;     }   }
/*      author : Piyush Singh   */   #include <bits/stdc++.h>   #define IOS ios::sync_with_stdio(false), cin.tie(0)   #undef _GLIBCXX_DEBUG   using namespace std;      int main(){    IOS;    int tt;    cin >> tt;    while (tt--) {     int a, b, k;     cin >> a >> b >> k;     vector<int> A(k);     for (int i = 0; i<k; i++) {      cin >> A[i];     }     vector<int> B(k);     for (int i = 0; i<k; i++) {      cin >> B[i];     }     map<int, int> ma;     map<int, int> mb;     for (int i = 0; i<k; i++) {      ma[A[i]] += 1;      mb[B[i]] += 1;     }     long long ans = 0;     for (int i = 0; i<k; i++) {      ans += (k-1) - (ma[A[i]] - 1) - (mb[B[i]] - 1);     }     cout << ans / 2 <<   n ;    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long m;   inline long long Nr(long long n) {     long long cnt = 0, k, lim, put;     for (k = 2; 1LL * k * k * k <= n; ++k) {       put = 1LL * k * k * k;       lim = n / put;       if (1LL * lim * put > n) --lim;       if (1LL * (lim + 1) * put <= n) ++lim;       cnt += lim;     }     return cnt;   }   int main() {     int i, j, x, y;     cin >> m;     long long st = 0, dr = 100000000000000000LL, mij, sol = -1;     while (st <= dr) {       mij = (st + dr) / 2;       long long x = Nr(mij);       if (x > m)         dr = mij - 1;       else if (x < m)         st = mij + 1;       else {         sol = mij;         dr = mij - 1;       }     }     cout << sol;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, K, M;   int main() {     scanf( %d%d , &N, &K);     if (K <= 1)       printf( -1 n );     else if (K >= 2 * N)       printf( 1 n );     else if (K > N)       printf( 3 n );     else if (N == K)       printf( 5 n );     else if (K == 2) {       if (N == 3)         printf( 11 n );       else         printf( -1 n );     } else if (K == 3) {       if (N == 4)         printf( 9 n );       else if (N == 5)         printf( 11 n );       else         printf( -1 n );     } else {       N -= (K - 2);       M = 4;       if (K >= 2 * N)         ++M;       else if (K > N)         M += 3;       else if (K == N)         M += 5;       else {         N -= K;         M += 2 * (N / (K / 2 - 1));         N %= (K / 2 - 1);         N += K;         if (N > K) {           N -= (K / 2 - 1);           M += 2;         }         if (K >= 2 * N)           ++M;         else if (K > N)           M += 3;         else           M += 5;       }       printf( %d n , M);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, y;     int cnt = 0;     cin >> x >> y;     if (x != y)       cout << min(x, y) <<    ;     else       cout << x <<    ;     if (x > y) {       x = x - y;       for (int i = 2; i <= x; i += 2) {         cnt++;       }       cout << cnt;     } else if (y > x) {       y = y - x;       for (int i = 2; i <= y; i += 2) {         cnt++;       }       cout << cnt;     } else       cout << 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, ans, final = 0, play = 0, study = 0, big, small, i, j;     cin >> n >> m;     int a[n + 1];     for (i = 1; i <= n; i++) {       cin >> a[i];       if (a[i] == 1) {         study++;       } else {         play++;       }     }     for (i = 1; i <= m; i++) {       j = i;       big = study;       small = play;       while (j <= n) {         if (a[j] == 1) {           big--;         } else {           small--;         }         j += m;       }       ans = abs(big - small);       if (ans > final) {         final = ans;       }     }     cout << final;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int amin = 10, bmin = 10;     char mat[8][8];     map<int, int> mapping;     for (int i = 0; i < 8; i++) {       for (int j = 0; j < 8; j++) {         cin >> mat[i][j];       }       getchar();     }     for (int i = 0; i < 8; i++) {       for (int j = 0; j < 8; j++) {         if (mat[i][j] ==  B ) mapping[j] = 1;         if (mat[i][j] ==  W  && mapping.find(j) == mapping.end()) {           if (i < amin) amin = i;           mapping[j] = 1;           break;         }       }     }     mapping.clear();     for (int i = 7; i >= 0; i--) {       for (int j = 7; j >= 0; j--) {         if (mat[i][j] ==  W ) mapping[j] = 1;         if (mat[i][j] ==  B  && mapping.find(j) == mapping.end()) {           if (7 - i < bmin) bmin = 7 - i;           mapping[j] = 1;           break;         }       }     }     if (amin <= bmin) {       cout <<  A  << endl;     } else       cout <<  B  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[1 << 20], w[25][25];   string s[25];   pair<int, int> alph[25][26];   int ma[25][26];   int cost[1 << 20];   vector<pair<int, int> > rco;   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> s[i];     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) cin >> w[i][j];     }     fill(cost, cost + (1 << 20), (int)1e9);     cost[0] = 0;     for (int i = 0; i < m; i++) {       for (int j = 0; j < n; j++) {         cost[1 << j] = min(cost[1 << j], w[j][i]);         alph[i][(s[j][i] -  a )].first |= (1 << j);         alph[i][(s[j][i] -  a )].second += w[j][i];         ma[i][s[j][i] -  a ] = max(ma[i][s[j][i] -  a ], w[j][i]);       }       for (int j = 0; j < 26; j++) {         alph[i][j].second -= ma[i][j];         cost[alph[i][j].first] = min(cost[alph[i][j].first], alph[i][j].second);       }     }     for (int i = 1; i < (1 << 20); i++) {       if (cost[i] != (int)1e9) rco.push_back(make_pair(i, cost[i]));     }     fill(dp, dp + (1 << n), (int)1e9);     dp[0] = 0;     for (int i = 0; i < rco.size(); i++) {       const int mask = rco[i].first, co = rco[i].second;       for (int j = 0; j < (1 << n); j++) {         dp[j | mask] = min(dp[j | mask], dp[j] + co);       }     }     cout << dp[(1 << n) - 1];   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b;     cin >> n >> a >> b;     if (b) b = (b / abs(b)) * (abs(b) % n);     if (!b) {       cout << a;       return 0;     }     if (b > 0) {       int i, cnt = 0;       for (i = a; cnt != b; (i != n) ? (i++) : i = 1) {         cnt++;       }       cout << i;       return 0;     }     if (b < 0) {       b = abs(b);       int i, cnt = 0;       for (i = a; cnt != b; (i != 1) ? (i--) : i = n) {         cnt++;       }       cout << i;       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int ret[1001];   int main() {     int N;     scanf( %d n , &N);     char s[1000];     scanf( %s , s);     fill(ret, ret + N, 1);     for (int i = 0; i < N; i++) {       int t = 1;       for (int j = i; j < N; j++)         if (s[j] ==  R )           break;         else if (s[j] ==  L )           t++;       ret[i] = max(ret[i], t);       t = 1;       for (int j = i - 1; j >= 0; j--)         if (s[j] ==  L )           break;         else if (s[j] ==  R )           t++;       ret[i] = max(ret[i], t);     }     printf( %d , ret[0]);     for (int i = 1; i < N; i++) printf(  %d , ret[i]);     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     {       ios_base::sync_with_stdio(false);       cin.tie(NULL);       cout.tie(NULL);     };     long long t;     cin >> t;     while (t--) {       long long a, b, n, s;       cin >> a >> b >> n >> s;       bool ans = false;       long long f = s / n;       s -= min(f, a) * n;       if (s <= b) {         cout <<  YES n ;       } else {         cout <<  NO n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int sign = 1, tmp = 0, ans = 0;     for (int i = 0; i < s.size(); i++) {       if (!(s[i] >=  0  && s[i] <=  9 )) {         ans += tmp * sign;         if (s[i] ==  - )           sign = -1;         else           sign = 1;         tmp = 0;       }       tmp = (s[i] -  0 ) + tmp * 10;     }     ans += tmp * sign;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long double pi = acos(-1);   const int MOD = 1e9 + 7;   const long long int LINF = 0x3f3f3f3f3f3f3f3f;   bitset<4096> bs[100050];   pair<int, int> carac[100005][15];   int c[15][100005];   int n, k, q;   int type[100050];   int a[100050];   int b[100050];   int qte;   int pega(int x, int y) {     int mask = 0;     for (int i = k - 1; i >= 0; i--) {       mask ^= (1 << carac[y][i].second);       if (bs[x][mask]) {         return carac[y][i].first;       }     }   }   int main() {     scanf( %d%d%d , &n, &k, &q);     for (int i = 0; i < k; i++) {       for (int j = 0; j < n; j++) {         scanf( %d , &c[i][j]);         carac[j][i] = make_pair(c[i][j], i);       }     }     for (int i = 0; i < k; i++) {       for (int j = 0; j < (1 << k); j++) {         if ((1 << i) & j) bs[i][j] = 1;       }     }     for (int i = 0; i < n; i++) {       sort(carac[i], carac[i] + k);     }     qte = k;     for (int i = 0; i < q; i++) {       int t, x, y;       cin >> t >> x >> y;       if (t == 1) {         type[qte] = 1;         x--, y--;         bs[qte] = bs[x] | bs[y];         qte++;       } else if (t == 2) {         x--, y--;         type[qte] = 2;         bs[qte] = bs[x] & bs[y];         qte++;       } else if (t == 3) {         x--;         y--;         cout << pega(x, y) <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 203;   const int MOD = 1e9 + 7;   int n, ssz;   string s;   int len[N][2];   int dp[N][N][N][2];   int calc(const string &t) {     int tsz = t.size();     for (int i = tsz; i > 0; --i) {       if (s.substr(0, i) == t.substr(tsz - i, i)) return i;     }     return 0;   }   void add(int &a, int b) {     a += b;     if (a >= MOD) a -= MOD;   }   int main() {     cin >> n >> s;     ssz = s.size();     if (s[0] ==  ( )       len[0][0] = 1;     else       len[0][1] = 1;     string pref;     for (int i = 0; i < ssz; ++i) {       pref += s[i];       pref +=  ( ;       len[i + 1][0] = calc(pref);       pref.pop_back();       pref +=  ) ;       len[i + 1][1] = calc(pref);       pref.pop_back();     }     dp[0][0][0][0] = 1;     for (int i = 0; i < 2 * n; ++i) {       for (int j = 0; j <= n; ++j) {         for (int pos = 0; pos <= ssz; ++pos) {           for (int f = 0; f < 2; ++f) {             if (dp[i][j][pos][f] == 0) continue;             if (j + 1 <= n && (2 * n - i - 1) >= (j + 1))               add(dp[i + 1][j + 1][len[pos][0]][f | (len[pos][0] == ssz)],                   dp[i][j][pos][f]);             if (j > 0)               add(dp[i + 1][j - 1][len[pos][1]][f | (len[pos][1] == ssz)],                   dp[i][j][pos][f]);           }         }       }     }     int ans = 0;     for (int i = 0; i <= ssz; ++i) add(ans, dp[2 * n][0][i][1]);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = (int)2e5 + 7;   const int mod = 998244353;   int n, m, l;   int a[maxn << 2], b[maxn << 2], rev[maxn << 2];   int num[maxn << 2];   const int pr = 3;   const int phi = mod - 1;   int qpow(int x, int y) {     int t = 1;     while (y) {       if (y & 1) t = 1ll * t * x % mod;       x = 1ll * x * x % mod;       y >>= 1;     }     return t;   }   void NTT(int *P, int n, int opt) {     for (int i = 0; i < n; i++) {       if (i < rev[i]) {         swap(P[i], P[rev[i]]);       }     }     for (int i = 1; i < n; i <<= 1) {       int W = qpow(pr, phi / (i << 1));       for (int p = i << 1, j = 0; j < n; j += p) {         int w = 1;         for (int k = 0; k < i; k++, w = 1ll * w * W % mod) {           int X = P[j + k], Y = 1ll * w * P[i + j + k] % mod;           P[j + k] = (X + Y) % mod;           P[i + j + k] = (X - Y + mod) % mod;         }       }     }     if (opt == -1) reverse(P + 1, P + n);   }   vector<int> solve(int l, int r) {     if (l == r) {       vector<int> res;       for (int i = 0; i <= num[l]; i++) {         res.push_back(1);       }       return res;     }     vector<int> v1 = solve(l, (l + r >> 1));     vector<int> v2 = solve((l + r >> 1) + 1, r);     int siz1 = v1.size(), siz2 = v2.size();     int k = 0, s = 2;     while ((1 << k) < max(siz1, siz2) + 1) k++, s <<= 1;     for (int i = 1; i < s; i++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (k));     for (int i = 0; i < s; i++) {       if (i < siz1) {         a[i] = v1[i];       }       if (i < siz2) {         b[i] = v2[i];       }     }     NTT(a, s, 1);     NTT(b, s, 1);     int inv = qpow(s, mod - 2);     for (int i = 0; i < s; i++) {       a[i] = 1ll * a[i] * b[i] % mod;     }     NTT(a, s, -1);     for (int i = 0; i < s; i++) {       a[i] = 1ll * a[i] * inv % mod;     }     vector<int> v3;     for (int i = 0, tt = siz1 + siz2 - 1; i < tt; i++) {       v3.push_back(a[i]);     }     for (int i = 0; i < s; i++) {       a[i] = b[i] = 0;     }     return v3;   }   int vis[maxn * 30];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       int t;       scanf( %d , &t);       vis[t]++;     }     int nn = 0;     for (int i = 1; i <= 3000000; i++) {       if (vis[i]) {         num[++nn] = vis[i];       }     }     vector<int> res = solve(1, nn);     int maxx = 0;     maxx = res[n / 2];     printf( %d n , maxx);     return 0;   }
#include <bits/stdc++.h>   int b[100005], a[100005], n, x, A, k;   int main() {     while (~scanf( %d %d , &n, &k)) {       memset(b, 0, sizeof(b));       scanf( %d , &a[1]);       x = 2;       for (int i = 2; i <= n; i++) {         scanf( %d , &A);         if (A != a[x - 1]) a[x++] = A;       }       for (int i = 1; i < x; i++) {         b[a[i]]++;         if (i < x - 1 && i > 0) {           if (a[i - 1] == a[i + 1]) b[a[i]]++;         }       }       int y = 1;       if (x == k + 1)         printf( 1 n );       else {         for (int i = 2; i <= k; i++) {           if (b[i] > b[y]) y = i;         }         printf( %d n , y);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = (1e9) + 7;   const long long C = (1 << (17));   vector<vector<long long> > up, sum;   vector<long long> cost, maxw, d;   long long LOG = 20;   void push(long long v, long long x) {     cost.push_back(x);     maxw.push_back(x);     d.push_back(0);     for (int i = 0; i < LOG; ++i) {       sum[i].push_back(x);       up[i].push_back(v);     }   }   void init() {     up.resize(20);     sum.resize(20);     push(0, 0);   }   void add(long long pr, long long w) {     long long v = up[0].size();     if (maxw[pr] < w) {       push(v, w);       return;     }     for (int i = LOG - 1; i >= 0; --i) {       if (cost[up[i][pr]] < w) pr = up[i][pr];     }     if (cost[pr] < w) {       pr = up[0][pr];       assert(cost[pr] >= w);     }     cost.push_back(w);     maxw.push_back(maxw[pr]);     d.push_back(d[pr] + 1);     up[0].push_back(pr);     sum[0].push_back(cost[pr]);     for (int i = 1; i < LOG; ++i) {       long long pp = up[i - 1][v];       up[i].push_back(up[i - 1][pp]);       if (pp != up[i - 1][pp]) {         sum[i].push_back(sum[i - 1][v] + sum[i - 1][pp]);       } else {         sum[i].push_back(sum[i - 1][v]);       }     }   }   long long req(long long v, long long first) {     if (cost[v] > first) return 0;     first -= cost[v];     long long ans = 1;     for (int i = LOG - 1; i >= 0; --i) {       if (sum[i][v] <= first) {         ans += d[v] - d[up[i][v]];         first -= sum[i][v];         v = up[i][v];       }     }     return ans;   }   int source() {     init();     long long Q;     cin >> Q;     long long last = 0;     for (long long q1 = 0; q1 < Q; ++q1) {       long long type, p, q;       cin >> type >> p >> q;       long long R = p ^ last;       --R;       long long W = q ^ last;       if (type == 1) {         add(R, W);       } else {         last = req(R, W);         cout << last <<   n ;       }     }     return 0;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     source();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = INT_MAX / 2;   int main() {     int n, k, q;     scanf( %d%d%d , &n, &k, &q);     vector<int> vec(n);     for (int i = 0; i < n; i++) {       scanf( %d , &vec[i]);     }     set<pair<int, int> > st;     map<int, int> mp;     for (int i = 0; i < q; i++) {       int type, id;       scanf( %d%d , &type, &id);       id--;       if (type == 1) {         if (st.size() < k) {           st.insert(make_pair(vec[id], id));           mp[id] = 1;         } else {           set<pair<int, int> >::iterator it = st.begin();           if ((*it).first < vec[id]) {             mp.erase((*it).second);             st.erase(it);             st.insert(make_pair(vec[id], id));             mp[id] = 1;           }         }       } else {         if (mp.count(id))           printf( YES n );         else           printf( NO n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n = 0, ans = 1e9 + 1;     string s;     cin >> n >> s;     vector<double> x(n);     for (int i = 0; i < n; i++) {       cin >> x[i];     }     for (int i = 0; i < n; i++) {       if (i < n + 1 && s[i] ==  R  && s[i + 1] ==  L  &&           (x[i + 1] - x[i]) / 2 < ans) {         ans = (x[i + 1] - x[i]) / 2;       }     }     if (ans == 1e9 + 1) {       cout << -1;     } else {       cout << ans;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 100009;   int n, m, k, a[MAX], b[MAX], pos[MAX];   int main() {     cin >> n >> m >> k;     for (int i = 1; i <= n; i++) {       cin >> a[i];       pos[a[i]] = i;     }     long long ans = 0;     for (int i = 1; i <= m; i++) {       cin >> b[i];       int current = pos[b[i]];       ans += (current + k - 1) / k;       if (current > 1) {         swap(pos[a[current]], pos[a[current - 1]]);         swap(a[current], a[current - 1]);       }     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200001];   bool b[200001];   int main() {     string s1, s2;     int n, i;     cin >> s1 >> s2;     n = s1.size();     for (i = 1; i <= n; i++) cin >> a[i];     int l, r, mid, pr = 0, j;     l = 0;     r = n;     while (l != r) {       mid = (l + r + 1) / 2;       for (i = 0; i <= n; i++) b[i] = 1;       for (i = 1; i <= mid; i++) b[a[i] - 1] = 0;       j = 0;       for (i = 0; i < n && j < s2.size(); i++) {         if (b[i]) {           if (s1[i] == s2[j]) j++;         }       }       if (j == s2.size())         l = mid;       else         r = mid - 1;     }     cout << l << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       k++;       vector<int> v;       for (int i = 0, x; i < n; i++) {         cin >> x;         v.push_back(x);       }       int lo = 1;       int hi = 1000000000;       while (lo < hi) {         int me = (lo + hi) / 2;         bool can = 0;         for (int i = 0; i + k - 1 < n; i++) {           if (v[i + k - 1] - v[i] <= me) can = 1;         }         if (!can)           lo = me + 1;         else           hi = me;       }       int x = -10;       for (int i = 0; i + k - 1 < n; i++) {         if (v[i + k - 1] - v[i] <= lo) x = (v[i] + v[i + k - 1]) / 2;       }       cout << x <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 12;   unsigned long long ans;   unsigned long long n;   unsigned long long data[maxn];   void init() {     scanf( %I64d , &n);     memset(data, 0, sizeof(data));     ans = 0;   }   void solve() {     for (int i = 1; i <= n; ++i) {       ++data[i % 9];       ans -= n / i;     }     for (int i = 0; i < 9; ++i)       for (int j = 0; j < 9; ++j) ans += data[i] * data[j] * data[i * j % 9];   }   void write() { printf( %I64d n , ans); }   int main() {     init();     solve();     write();     return 0;   }