malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T sqr(T t) {     return t * t;   }   inline void files() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int n, a[100100];   int main() {     files();     int l = 0, r = 0;     int ans = 0;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 3; i <= n; i++) {       if (a[i] == a[i - 1] + a[i - 2]) {         if (l == 0) l = max(1, i - 2);         r = i;         ans = max(ans, r - l + 1);       } else {         l = 0;         r = 0;       }     }     ans = max(ans, min(n, 2));     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k;   void nhap() { cin >> n >> m >> k; }   long long tinh(long long x) {     if (x > k) return -1e19 + 10;     long long r = n / (x + 1);     long long h = k - x;     long long d = m / (h + 1);     return r * d;   }   void xuli() {     if (n - 1 + m - 1 < k) {       cout << -1;       return;     }     long long kq = -1e19 + 10;     for (int i = 1; i <= sqrt(n); i++) {       if (n % i == 0) {         kq = max(kq, tinh(1ll * i - 1));         kq = max(kq, tinh(n / i - 1));       }     }     swap(n, m);     for (int i = 1; i <= sqrt(n); i++) {       if (n % i == 0) {         kq = max(kq, tinh(1ll * i - 1));         kq = max(kq, tinh(n / i - 1));       }     }     cout << kq;   }   int main() {     nhap();     xuli();   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 5;   long long n, k, sum, l, x, m, i, a, b[N];   vector<long long> ans;   int main() {     cin >> n;     if (n == 1) {       cin >> a;       cout << a;       return 0;     }     for (long long i = 0; i < n; i++) {       cin >> a;       b[i] = a + i;     }     sort(b, b + n);     for (long long i = 0; i < n; i++) {       ans.push_back(b[i] - i);       if (b[i] == b[i + 1]) return cout <<  :(  << endl, 0;     }     for (long long i = 0; i < n; i++) {       cout << ans[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char str[200005];     gets(str);     vector<char> v;     if (strlen(str) > 1) {       v.push_back(str[0]);       v.push_back(str[1]);     } else {       cout << str;       return 0;     }     int l = strlen(str);     int len;     for (int i = 2; i < l; i++) {       len = v.size();       if (str[i] == v[len - 1] && str[i] == v[len - 2]) continue;       if (v[len - 3] == v[len - 2] && str[i] == v[len - 1])         continue;       else         v.push_back(str[i]);     }     len = v.size();     for (int i = 0; i < len; i++) printf( %c , v[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100500];   int v[100500];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     v[0] = -1;     int ans = 0;     for (int i = 0; i < n; i++) {       int l = 0, r = ans + 1;       while (r - l > 1) {         int j = (l + r) / 2;         if (v[j] < a[i])           l = j;         else           r = j;       }       v[l + 1] = a[i];       if (l + 1 > ans) ans = l + 1;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1500004];   int main() {     int t, c;     string s;     cin >> t;     for (int l = 0; l < t; l++) {       cin >> s;       c = 0;       for (int i = 0; i < s.size(); i++) {         if (s[i] ==  o  && s[i + 1] ==  n  && s[i + 2] ==  e  ||             s[i - 1] ==  t  && s[i] ==  w  && s[i + 1] ==  o  &&                 s[i + 2] ==  n  && s[i + 3] ==  e  ||             s[i] ==  t  && s[i + 1] ==  w  && s[i + 2] ==  o  &&                 s[i + 3] !=  n  ||             s[i] ==  t  && s[i + 1] ==  w  && s[i + 2] ==  o  &&                 s[i + 4] !=  e ) {           s[i + 1] =  1 ;           a[c] = i + 2;           c++;         }       }       cout << c <<   n ;       for (int i = 0; i < c; i++) cout << a[i] <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T sq(T n) {     return n * n;   }   template <class T>   T gcd(T a, T b) {     return (b != 0 ? gcd<T>(b, a % b) : a);   }   template <class T>   T lcm(T a, T b) {     return (a / gcd<T>(a, b) * b);   }   template <class T>   T power(T N, T P) {     return (P == 0) ? 1 : N * power(N, P - 1);   }   int A[5000001], len;   long long dp[5000001];   int convert(char c) {     if (c >=  a  && c <=  z )       return (int)(c - 87);     else if (c >=  0  && c <=  9 )       return (int)(c - 48);     else       return (int)(c - 29);   }   int main(int argc, char *argv[]) {     string S;     int i;     long long k1, k2, v = 1, res = 1;     cin >> S;     len = S.length();     for (i = 0; i <= len - 1; i++) A[i] = convert(S[i]);     dp[0] = 1;     k1 = A[0];     k2 = A[0];     for (i = 1; i <= len - 1; i++) {       v *= 5;       k1 += (v * A[i]);       k2 = 5 * k2 + A[i];       if (k1 == k2) dp[i] = dp[(i + 1) / 2 - 1] + 1;       res += dp[i];     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m;   long long a[10001], f[10001];   int main() {     int d, x, y;     scanf( %I64d %I64d , &n, &m);     f[0] = f[1] = 1;     for (int i = 2; i <= n; i++) f[i] = f[i - 1] + f[i - 2], f[i] %= 1000000000LL;     for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]);     for (int i = 1; i <= m; i++) {       scanf( %I64d , &d);       if (d == 1) {         scanf( %I64d %I64d , &x, &y);         a[x] = y;       } else {         long long ans = 0;         scanf( %I64d %I64d , &x, &y);         for (int i = x; i <= y; i++) ans += f[i - x] * a[i], ans %= 1000000000LL;         printf( %I64d n , ans);       }     }     return 0;   }
#include <bits/stdc++.h>   FILE *in = stdin, *out = stdout;   using namespace std;   int n;   vector<int> son[5005];   int tot;   vector<int> edge[5005];   int dy[5005][2][5005];   int leaf[5005];   int visit[5005];   void input() {     fscanf(in,  %d , &n);     for (int i = (1); i <= (n - 1); i++) {       int x, y;       fscanf(in,  %d , &x), fscanf(in,  %d , &y);       edge[x].push_back(y);       edge[y].push_back(x);     }   }   int temp[2][5005];   void go(int x) {     visit[x] = 1;     int flag = 0;     for (auto &i : edge[x]) {       if (visit[i]) continue;       go(i);       if (flag == 0) dy[x][0][0] = dy[x][1][0] = 0;       flag = 1;       for (int j = (0); j <= (leaf[x] + leaf[i]); j++)         temp[0][j] = temp[1][j] = 0x7fffffff;       for (int p1 = (0); p1 <= (1); p1++)         for (int p2 = (0); p2 <= (1); p2++)           for (int j = (0); j <= (leaf[x]); j++)             for (int k = (0); k <= (leaf[i]); k++)               if (dy[x][p1][j] != 0x7fffffff && dy[i][p2][k] != 0x7fffffff)                 temp[p1][j + k] =                     min(temp[p1][j + k],                         dy[x][p1][j] + dy[i][p2][k] + (p1 == p2 ? 0 : 1));       for (int j = (0); j <= (leaf[x] + leaf[i]); j++)         for (int k = (0); k <= (1); k++) dy[x][k][j] = temp[k][j];       leaf[x] += leaf[i];     }     if (flag == 0) {       leaf[x] = 1;       dy[x][0][0] = 0;       dy[x][1][1] = 0;       tot++;     }   }   void pro() {     for (int i = (0); i <= (n); i++)       for (int j = (0); j <= (n); j++) dy[i][0][j] = dy[i][1][j] = 0x7fffffff;     for (int i = (1); i <= (n); i++)       if (edge[i].size() > 1) {         go(i);         fprintf(out,  %d , dy[i][1][tot / 2]);         return;       }   }   int main() {     input();     if (n == 2)       fprintf(out,  1 );     else       pro();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma warning(disable : 4996)   const int maxn = 2e5 + 5;   struct node {     int idx, p;     bool operator<(const node &b) const { return p < b.p; }   } ver[100005], hor[100005];   int vcnt, hcnt;   vector<node> V1[maxn], V2[maxn];   int tempx[100005], tempy[100005];   int ansx[100005], ansy[100005];   int main() {     int n, w, h;     cin >> n >> w >> h;     int g, p, t;     for (int i = 1; i <= n; i++) {       scanf( %d , &g);       if (g == 1) {         vcnt++;         scanf( %d%d , &p, &t);         V1[p - t + 100000].push_back({i, p});       } else {         hcnt++;         scanf( %d%d , &p, &t);         V2[p - t + 100000].push_back({i, p});       }     }     for (int i = 0; i < maxn; i++) {       sort(V1[i].begin(), V1[i].end());       sort(V2[i].begin(), V2[i].end());     }     for (int i = 0; i < maxn; i++) {       int cnt = 0;       for (int j = 0; j < V1[i].size(); j++) {         tempx[cnt] = V1[i][j].p;         tempy[cnt] = h;         cnt++;       }       for (int j = V2[i].size() - 1; j >= 0; j--) {         tempx[cnt] = w;         tempy[cnt] = V2[i][j].p;         cnt++;       }       cnt = 0;       for (int j = V2[i].size() - 1; j >= 0; j--) {         ansx[V2[i][j].idx] = tempx[cnt];         ansy[V2[i][j].idx] = tempy[cnt];         cnt++;       }       for (int j = 0; j < V1[i].size(); j++) {         ansx[V1[i][j].idx] = tempx[cnt];         ansy[V1[i][j].idx] = tempy[cnt];         cnt++;       }     }     for (int i = 1; i <= n; i++) {       printf( %d %d n , ansx[i], ansy[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[105][105], n, m, k;   int res, c;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> k;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) cin >> a[i][j];     for (int j = 1; j <= m; ++j) {       int cnt = 0;       int maxx = 0;       int now = 0;       for (int i = 1; i <= n; ++i)         if (a[i][j] == 1) {           int tmp = 0;           cnt++;           for (int h = i; h <= i + min(k, n - i + 1) - 1; ++h)             if (a[h][j] == 1) ++tmp;           if (tmp > maxx) {             maxx = tmp;             now = cnt;           }         }       res += maxx;       c += max(0, now - 1);     }     cout << res <<     << c;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long x, long long y, long long z) {     long long ret = 1;     while (y > 0) {       if (y & 1) ret = (ret * x) % z;       x = (x * x) % z;       y >>= 1;     }     return ret;   }   long long q;   map<long long, long long> getFactors(long long num) {     long long i;     map<long long, long long> answer;     for (i = 2; i * i <= num; i++) {       while (num > 1 && num % i == 0) {         answer[i]++;         num /= i;       }     }     if (num > 1) answer[num]++;     return answer;   }   int main() {     long long i, j, t;     scanf( %lld , &q);     ;     map<long long, long long> factors = getFactors(q);     long long sum = 0, xorVal = 0, flag = 0, ting;     for (auto it = factors.begin(); it != factors.end(); it++) {       long long temp = it->second;       sum += temp;     }     xorVal = factors.size();     cerr <<  sum           <<   ::   << sum <<   t           <<  flag           <<   ::   << flag <<   t           <<  xorVal           <<   ::   << xorVal <<   n ;     ;     if (sum == 2) {       cout <<  2  << endl;       return 0;     }     if (sum <= 1)       cout <<  1  << endl <<  0  << endl;     else {       long long answer = 1, cutter = 0;       for (auto it = factors.begin(); it != factors.end(); it++) {         long long siz = it->second;         for (j = 0; j < siz; j++) {           if (cutter >= 2) {             cout <<  1  << endl << answer << endl;             return 0;           }           answer = answer * (it->first);           cutter++;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n, k;       cin >> n >> k;       long long int arr[n];       long long int i;       for (i = 0; i <= n - 1; i++) {         cin >> arr[i];       }       long long int temp = k;       vector<long long int> v;       long long int sum = 0;       for (i = 0; i <= n - 1; i++) {         sum = sum + arr[i];         if (sum % 2 != 0 && temp > 1) {           v.push_back(i);           sum = 0;           temp--;         }       }       if (sum % 2 == 0) {         cout <<  NO               <<   n ;       } else {         v.push_back(n - 1);         cout <<  YES               <<   n ;         for (i = 0; i < v.size(); i++) {           cout << v[i] + 1 <<    ;         }         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 111111;   const int INF = 1000000000, mod = 1000000007;   const long long LLINF = 1000000000000000000ll;   pair<string, string> a[N];   int p[N];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;     for (int i = 0; i < n; ++i) {       cin >> p[i];       --p[i];     }     string mx =   ;     for (int j = 0; j < n; ++j) {       int i = p[j];       if (j == 0) {         mx = min(a[i].first, a[i].second);         continue;       }       if (a[i].first > a[i].second) swap(a[i].first, a[i].second);       if (a[i].first < mx) {         if (a[i].second < mx) {           puts( NO );           return 0;         }         mx = a[i].second;       } else         mx = a[i].first;     }     puts( YES );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010;   int n, d, m, cnta = 0, cntb = 0;   long long a[MAXN], b[MAXN];   inline bool cmp(long long x, long long y) { return x > y; }   int main() {     scanf( %d%d%d , &n, &d, &m);     for (int i = 1; i <= n; i++) {       long long x;       scanf( %lld , &x);       if (x > m)         a[++cnta] = x;       else         b[++cntb] = x;     }     sort(a + 1, a + cnta + 1, cmp);     sort(b + 1, b + cntb + 1, cmp);     for (int i = 1; i <= cnta; i++) a[i] += a[i - 1];     for (int i = 1; i <= cntb; i++) b[i] += b[i - 1];     long long ans = b[cntb];     for (int i = 1; i <= cnta; i++) {       if ((i - 1) * (d + 1) + 1 > n) break;       int ind = min(n - (i - 1) * (d + 1) - 1, cntb);       ans = max(ans, a[i] + b[ind]);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5, MOD = 1e9 + 7;   int main() {     vector<int> a(27, -1), b(27, -1), c(27, -1);     string str;     cin >> str;     for (int i = 0; i < (int)str.size(); i++) {       if (a[str[i] -  a ] == -1) {         a[str[i] -  a ] = i;         c[str[i] -  a ] = i;       } else {         b[str[i] -  a ] = max(i - a[str[i] -  a ], b[str[i] -  a ]);         a[str[i] -  a ] = i;       }     }     int x = (int)str.size() - 1;     int ans = (int)str.size() / 2 + 1;     for (int i = 0; i < 27; i++) {       if (b[i] != -1) {         b[i] = max({b[i], x - a[i] + 1, c[i] + 1});         ans = min(b[i], ans);       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T, class U>   void ckmin(T &a, U b) {     if (a > b) a = b;   }   template <class T, class U>   void ckmax(T &a, U b) {     if (a < b) a = b;   }   int N, K;   pair<int, int> arr[213];   vector<pair<int, int> > blocks;   int dp[100013][2];   int tmp[100013][2];   int ans;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout << fixed << setprecision(12);     cerr << fixed << setprecision(4);     cin >> N >> K;     for (auto i = (0); i < (K); i++) {       cin >> arr[i].first >> arr[i].second;       if (i == 0 && arr[i].first > 0) {         blocks.push_back({arr[i].first, 0});       }       if (i > 0) {         blocks.push_back({arr[i].first - arr[i - 1].second, 0});       }       blocks.push_back({arr[i].second - arr[i].first, 1});     }     if (arr[K - 1].second != 2 * N) {       blocks.push_back({2 * N - arr[K - 1].second, 0});     }     for (auto i = (0); i < (N + 1); i++) {       dp[i][0] = 1000000007;       dp[i][1] = 1000000007;     }     dp[0][0] = 0;     dp[0][1] = 0;     for (pair<int, int> p : blocks) {       int sz = p.first;       if (!p.second) {         for (auto i = (N + 1) - 1; i >= (sz); i--) {           dp[i][0] = dp[i - sz][0];         }         for (auto i = (sz)-1; i >= (0); i--) {           dp[i][0] = 1000000007;         }       } else {         for (auto i = (0); i < (N + 1); i++) {           tmp[i][0] = 1000000007;           tmp[i][1] = 1000000007;         }         multiset<int> dp0, dp1;         for (auto i = (0); i < (N + 1); i++) {           dp0.insert(dp[i][0]);           dp1.insert(dp[i][1]);           ckmin(tmp[i][0], *dp0.begin() + 2);           ckmin(tmp[i][1], *dp1.begin() + 2);           ckmin(tmp[i][1], *dp0.begin() + 1);           ckmin(tmp[i][0], *dp1.begin() + 1);           if (i >= sz) {             dp0.erase(dp0.find(dp[i - sz][0]));             dp1.erase(dp1.find(dp[i - sz][1]));           }         }         for (auto i = (0); i < (N + 1); i++) {           ckmin(tmp[i][1], dp[i][1]);         }         for (auto i = (0); i < (N + 1 - sz); i++) {           ckmin(tmp[i + sz][0], dp[i][0]);         }         for (auto i = (0); i < (N + 1); i++) {           dp[i][0] = tmp[i][0];           dp[i][1] = tmp[i][1];         }       }     }     ans = min(dp[N][0], dp[N][1]);     if (ans >= 1000000007) {       cout <<  Hungry n ;       return 0;     }     cout <<  Full n  << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T bigmod(T p, T e, T M) {     long long int ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p) % M;       p = (p * p) % M;     }     return (T)ret;   }   template <class T>   inline T modinverse(T a, T M) {     return bigmod(a, M - 2, M);   }   template <class T>   inline T gcd(T a, T b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int arr[105], cnt;   int moveee(int n) {     for (int i = 3, j = 1; i <= 99; i += 2, j++)       if (n == i) return j;     return -1;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     ;     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> arr[i];     int mov = moveee(n);     if (mov == -1) return cout << -1 << endl, 0;     for (int i = mov; i >= 1; i--) {       int a = i, b = i << 1, c = b + 1;       int maxi = max(arr[b], arr[c]);       arr[a] = max(0, arr[a] - maxi);       arr[b] = max(0, arr[b] - maxi);       arr[c] = max(0, arr[c] - maxi);       cnt += maxi;     }     if (arr[1] > 0) cnt += arr[1];     cout << cnt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1);   const int maxn = 1e6 + 10;   const int mod = 1e9 + 7;   typedef struct p {     long long x, y;   };   p a[maxn];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %lld %lld , &a[i].x, &a[i].y);     }     int isok = 1;     if (n % 2) {       printf( NO n );       return 0;     }     for (int i = 0; i < n / 2; i++) {       int a1 = i, b1 = i + 1, a2 = (i + n / 2 + n) % n,           b2 = (i + n / 2 + n + 1) % n;       if (abs(a[a1].x - a[b1].x) != abs(a[a2].x - a[b2].x) ||           abs(a[a1].y - a[b1].y) != abs(a[a2].y - a[b2].y)) {         isok = 0;         break;       }     }     if (isok)       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int r, c, n, k;     cin >> r >> c >> n >> k;     int x[n], y[n], res = 0, xi, yi;     for (int i = 0; i < n; i++) {       cin >> xi >> yi;       x[i] = xi - 1;       y[i] = yi - 1;     }     for (int i = 0; i < r; i++) {       for (int j = 0; j < c; j++) {         for (int i2 = i; i2 < r; i2++) {           for (int j2 = j; j2 < c; j2++) {             int violasenimg = 0;             for (int v = 0; v < n; v++) {               if (i <= x[v] && x[v] <= i2 && j <= y[v] && y[v] <= j2)                 violasenimg++;             }             if (violasenimg >= k) res++;           }         }       }     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e6 + 5;   long long v[MAX];   long long GCD(long long a, long long b) {     if (!b) return a;     if (!a) return b;     return GCD(b, a % b);   }   int main() {     long long mx = 0;     long long n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> v[i];       mx = max(v[i], mx);     }     long long G = 0;     for (int i = 1; i <= n; i++) {       G = GCD(mx - v[i], G);     }     long long ans1 = 0;     for (int i = 1; i <= n; i++) {       ans1 += (mx - v[i]) / G;     }     cout << ans1 <<     << G <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e5 + 11;   long long cs[4][N], n, dp[N][4][4];   vector<int> g[N], ord;   bool u[N];   void dfs(int v) {     u[v] = 1;     ord.push_back(v);     for (int i = 0; i < g[v].size(); i++) {       int to = g[v][i];       if (!u[to]) dfs(to);     }   }   pair<long long, vector<int> > f(int x, int y) {     long long res = 0;     vector<int> g(n + 1);     g[ord[0]] = x;     g[ord[1]] = y;     res += cs[x][ord[0]] + cs[y][ord[1]];     for (int i = 2; i < n; i++) {       int cur = ord[i];       int col = 6 - x - y;       res += cs[col][cur];       g[cur] = col;       x = y;       y = col;     }     return make_pair(res, g);   }   void solve() {     cin >> n;     for (int i = 1; i <= 3; i++)       for (int j = 1; j <= n; j++) cin >> cs[i][j];     for (int i = 1; i < n; i++) {       int x, y;       cin >> x >> y;       g[x].push_back(y);       g[y].push_back(x);     }     int cnt = 0;     for (int i = 1; i <= n; i++)       if (g[i].size() > 2) {         cout << -1;         return;       } else if (g[i].size() == 1)         cnt++;     if (cnt != 2) {       cout << -1;       return;     }     int st = 0;     for (int i = 1; i <= n; i++)       if (g[i].size() == 1) st = i;     dfs(st);     pair<long long, vector<int> > ans = min(         min(f(1, 2), f(1, 3)), min(min(f(2, 1), f(2, 3)), min(f(3, 1), f(3, 2))));     cout << ans.first <<   n ;     for (int i = 1; i <= n; i++) cout << ans.second[i] <<    ;   }   int main() {     ;     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int tt = 1;     for (int i = 1; i <= tt; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int sum = 0;     for (int i = 0; i < n; ++i) {       int l, r;       cin >> l >> r;       sum += r - l + 1;     }     int ct = 0;     while (sum % k != 0) {       ct++;       sum++;     }     cout << ct << endl;   }
#include <bits/stdc++.h>   using namespace std;   char buff[100010];   int calc() {     scanf( %s , buff);     int mask = 0;     int len = strlen(buff);     for (int i = 0; i < len; ++i) mask |= 1 << (buff[i] -  a );     return mask;   }   int main() {     int n;     scanf( %d , &n);     int mask = (1 << 26) - 1;     bool flag = false;     int cnt = 0;     for (int i = 0; i < n; ++i) {       scanf( %s , buff);       char op = buff[0];       if (!flag) {         if (op ==  ! ) {           mask &= calc();         } else if (op ==  . ) {           mask &= ~calc();         } else {           mask &= ~calc();         }         if (mask == (mask & -mask)) flag = true;       } else {         if (op ==  ! ) {           if (mask & calc()) cnt++;         } else if (op ==  . ) {           calc();         } else {           if (calc() != mask) cnt++;         }       }     }     printf( %d n , cnt);     return 0;   }
#include <bits/stdc++.h>   const int N = 1e5 + 5;   char str[N];   int n, s[N];   long long f[N][11], ans;   inline int nex(int i, int j) { return (9 + i * (i - 1) / 2 + j + 1) % 11; }   int main() {     scanf( %s , str + 1);     n = strlen(str + 1);     for (int i = 1; i <= n; ++i) s[i] = str[i] -  0 ;     for (int i = 1; i <= n; ++i)       if (s[i]) ++f[i][s[i]];     for (int i = 1; i <= n; ++i)       for (int j = 0; j <= 10; ++j) {         if (s[i] < j) f[i][nex(j, s[i])] += f[i - 1][j];       }     for (int i = 1; i <= n; ++i)       for (int j = 0; j <= 10; ++j) ans += f[i][j];     printf( %I64d n , ans);     return 0;   }