malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 305, MOD = 1e4 + 7;   char s[N];   int n, m, ndc, f[N][N][N];   int getf(int cnt, int l, int r) {     if (cnt < 0) return 0;     if (~f[cnt][l][r]) return f[cnt][l][r];     if (l == 1 && r == m) return f[cnt][l][r] = !cnt;     int ret = 0;     if (l > 1 && r < m && s[l - 1] == s[r + 1])       ret = (ret + getf(cnt, l - 1, r + 1)) % MOD;     if (l > 1 && s[l - 1] != s[r]) ret = (ret + getf(cnt - 1, l - 1, r)) % MOD;     if (r < m && s[l] != s[r + 1]) ret = (ret + getf(cnt - 1, l, r + 1)) % MOD;     return f[cnt][l][r] = ret;   }   struct matrix {     int sq[N][N];     matrix() { memset(sq, 0, sizeof(sq)); }     matrix operator*(const matrix &a) const {       matrix ret;       for (int i = 1; i <= ndc; i++)         for (int j = i; j <= ndc; j++)           for (int k = i; k <= j; k++)             ret.sq[i][j] = (ret.sq[i][j] + 1ll * sq[i][k] * a.sq[k][j]) % MOD;       return ret;     }   } trs, one;   inline matrix qpow(matrix x, int y) {     matrix ret = one;     while (y) {       if (y & 1) ret = ret * x;       x = x * x;       y >>= 1;     }     return ret;   }   int idr[N], idg[N], cntc[N];   int main() {     int i, j, k, ans = 0;     scanf( %s%d , s + 1, &n);     m = strlen(s + 1);     idr[0] = ++ndc;     for (i = 1; i < m; i++) {       int rem = (m - i + 1) / 2;       if ((m - i + 1) / 2 != (m - i) / 2 + 1) idg[(m - i) / 2 + 1] = ++ndc;       idr[i] = ++ndc;     }     if (!idg[1]) idg[1] = ++ndc;     idg[0] = ++ndc;     for (i = 0; i < m; i++) {       if (i) trs.sq[idr[i]][idr[i]] = 24;       if (i < m - 1) trs.sq[idr[i]][idr[i + 1]] = 1;     }     for (i = (m + 1) / 2; i > 0; i--) {       trs.sq[idg[i]][idg[i]] = 25;       trs.sq[idg[i]][idg[i - 1]] = 1;     }     for (i = 1; i <= ndc; i++) one.sq[i][i] = 1;     memset(f, -1, sizeof(f));     for (i = 0; i < m; i++) {       for (j = 1; j <= m; j++) {         cntc[i] = (cntc[i] + getf(i, j, j)) % MOD;         if (j < m && s[j] == s[j + 1])           cntc[i] = (cntc[i] + getf(i, j, j + 1)) % MOD;       }     }     for (i = 0; i < m; i++) trs.sq[idr[i]][idg[(m - i + 1) / 2]] = cntc[i];     trs.sq[ndc][ndc] = 26;     ans = (qpow(trs, (n + m + 1) / 2 + 1)).sq[1][ndc];     if (!((n + m) & 1)) {       printf( %d , ans);       return 0;     }     memset(f, -1, sizeof(f));     memset(cntc, 0, sizeof(cntc));     for (i = 0; i < m; i++)       for (j = 1; j < m; j++)         if (s[j] == s[j + 1]) cntc[i] = (cntc[i] + getf(i, j, j + 1)) % MOD;     for (i = 0; i < m; i++) trs.sq[idr[i]][idg[(m - i + 1) / 2]] = cntc[i];     trs.sq[ndc][ndc] = 0;     ans = (ans - (qpow(trs, (n + m + 1) / 2 + 1)).sq[1][ndc] + MOD) % MOD;     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       char ch;       string str;       cin >> str;       int n1 = 0, n2 = 0;       int ct = 0;       for (int i = 0; i < n; i++) {         if (str[i] ==  ( ) {           if (n2 > 0) {             if (n2 > n1) {               n2 = 0;               n1 = 0;             } else {               n1 -= n2;               n2 = 0;             }           }           n1++;         } else {           n2++;           if (n2 > n1) ct++;         }       }       cout << ct << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:256000000 )   using namespace std;   double E = 2.71828182846;   double PI = 3.1415926535897932384626433832795;   double EPS = 1e-9;   const int ROOT = 444;   const int MAXN = 300100;   const int ROOTN = 555;   int n;   int gcd(int a, int b) {     while (b) {       a %= b;       swap(a, b);     }     return a;   }   void solve() {     cin >> n;     for (int i = 0; i <= n; i += 1234567) {       for (int j = i; j <= n; j += 123456) {         if ((n - j) % 1234 == 0) {           cout <<  YES ;           return;         }       }     }     cout <<  NO ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     srand(1313);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int X = 0, w = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) w = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) X = X * 10 + c -  0 , c = getchar();     return X * w;   }   const int N = 100 + 10;   inline int id(int x, int y) {     if (x & 1)       return (x - 1) * 10 + y;     else       return (x - 1) * 10 + 11 - y;   }   int to[N];   double dp[N];   int main() {     for (register int i = 1; i <= 10; ++i)       for (register int j = 1; j <= 10; ++j) to[id(i, j)] = id(i - read(), j);     for (register int i = 2; i <= 6; ++i) {       for (register int j = 1; j < i; ++j) dp[i] += dp[j] / 6;       dp[i] = (dp[i] + 1) / (i - 1) * 6;     }     for (register int i = 7; i <= 100; ++i) {       for (register int j = 1; j <= 6; ++j)         dp[i] += min(dp[i - j], dp[to[i - j]]);       dp[i] = dp[i] / 6 + 1;     }     printf( %.10lf n , dp[100]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 200005;   int ans, cnt0, cnt1, lth, pos1[MX], pos0[MX], pre[MX], nxt[MX];   char s[MX];   bool vis[MX];   int main() {     scanf( %s , s + 1);     lth = strlen(s + 1);     for (int i = 1; i <= lth; i++) {       if (s[i] ==  0 )         pos0[++cnt0] = i;       else         pos1[++cnt1] = i;       if (cnt1 > cnt0) return puts( -1 ), 0;     }     cnt0 = cnt1 = 0;     for (int i = lth; i; i--) {       if (s[i] ==  0 )         cnt0++;       else         cnt1++;       if (cnt1 > cnt0) return puts( -1 ), 0;     }     printf( %d n , cnt0 - cnt1);     for (int i = 1; i <= cnt1; i++)       pre[pos1[i]] = pos0[i], nxt[pos0[i]] = pos1[i];     for (int i = cnt1, j = cnt0; i; i--, j--)       nxt[pos1[i]] = pos0[j], pre[pos0[j]] = pos1[i];     for (int i = 1; i <= lth; i++)       if (!vis[i]) {         int cnt = 0;         for (int j = i; j; j = nxt[j]) cnt++, vis[j] = 1;         printf( %d  , cnt);         for (int j = i; j; j = nxt[j]) printf( %d  , j);         putchar(  n );       }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 2e5 + 5;   void solve() {     long long int n, m;     cin >> n >> m;     vector<long long int> v(m);     for (auto &it : v) cin >> it;     ;     vector<long long int> suf(m);     long long int s = 0;     for (long long int i = m - 1; i >= 0; i--) {       if (i + v[i] - 1 > n - 1) {         cout << -1 <<   n ;         return;       }       s += v[i];       suf[i] = s;     }     if (s < n) {       cout << -1 <<   n ;       return;     }     long long int j = 0;     long long int start = 0, prev = -1;     vector<long long int> ans;     for (long long int i = 0; i < m; i++) {       cout << max(n - suf[i] + 1, i + 1) <<    ;     }     cout <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int t = 1;     while (t--) solve();     return 0;   }
#include<fstream>   #include<iostream>   #include<sstream>   #include<iomanip>   #include<string>   #include<vector>   #include<list>   #include<set>   #include<map>   #include<queue>   #include<algorithm>   #include<functional>   #include<numeric>   #include<bitset>   #include<cassert>   #include<array>   #include  string.h    #include  math.h    using namespace std;   typedef long long ll;   typedef unsigned long long ull;   typedef pair<int, int> pii;   typedef pair<ll, ll> pll;   #define mp make_pair      #ifndef BLAH   #define fin cin   #define fout cout   #endif      namespace   {      }      int main()   {    ios::sync_with_stdio(0);   #ifdef BLAH    ifstream fin( test.in );    ofstream fout( test.out );   #endif       int zzz; fin >> zzz;    for (int zz = 1; zz <= zzz; ++zz)    {     int n, m; fin >> n >> m;     string s, ss;     fin >> s;     s =  0  + s +  0 ;        for (int t = 0; t < m; ++t)     {      ss = s;      for (int i = 1; i <= n; ++i)      {       if (s[i - 1] != s[i + 1])        ss[i] =  1 ;      }      if (s == ss) break;      swap(s, ss);     }        fout << s.substr(1, n) << endl;    }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long modExponentiate(unsigned long long a, unsigned long long b) {     if (b == 0) return 1;     unsigned long long ans = a;     unsigned long long t = 1;     while (b > 1) {       if (b % 2 == 0) {         ans = (ans * ans) % (1000000007);         a = (a * a) % 1000000007;         b = b / 2;       } else {         t = (t * a) % 1000000007;         b = b - 1;       }     }     return (t * ans) % 1000000007;   }   int noofz(int a) {     int no = 0;     while (a > 0) {       if ((a % 2) == 1) no++;       a = a / 2;     }     return (6 - no);   }   int main() {     map<char, int> m;     for (int i = 0; i < 10; i++) m[(char)( 0  + i)] = noofz(i);     for (int i = 10; i < 36; i++) m[(char)( A  + i - 10)] = noofz(i);     for (int i = 36; i < 62; i++) m[(char)( a  + i - 36)] = noofz(i);     m[ - ] = noofz(62);     m[ _ ] = noofz(63);     char str[100001];     cin >> str;     long long ans = 1LL;     long long anslog = 0LL;     for (int i = 0; i < strlen(str); i++) {       anslog = anslog + m[str[i]];     }     ans = modExponentiate(3, anslog);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     int steps, count, i, n;     char str[500];     char pc;     scanf( %s , str);     steps = count = 0;     n = strlen(str);     if (n == 0) {       printf( 0 n );       return 0;     }     pc = str[0];     count = 1;     for (i = 1; i < n; i++) {       if (count == 5) {         count = 1;         steps++;         pc = str[i];         continue;       }       if (pc == str[i])         count++;       else {         count = 1;         steps++;         pc = str[i];       }     }     if (count > 0) steps++;     printf( %d n , steps);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int x, y, z, t1, t2, t3;     cin >> x >> y >> z >> t1 >> t2 >> t3;     long long int lift = abs(x - z) * t2 + 3 * t3 + abs(x - y) * t2,                   walk = abs(x - y) * t1;     if (lift <= walk)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int T;   char s[2000];   int main() {     scanf( %d , &T);     while (T--) {       scanf( %s , s + 1);       int l = strlen(s + 1);       if (s[l] ==  o  && s[l - 1] ==  p )         printf( FILIPINO n );       else if (s[l] ==  u  && s[l - 1] ==  s  && s[l - 2] ==  e  &&                    s[l - 3] ==  d  ||                s[l] ==  u  && s[l - 1] ==  s  && s[l - 2] ==  a  &&                    s[l - 3] ==  m )         printf( JAPANESE n );       else         printf( KOREAN n );     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       int a[n][m];       int f = 0;       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           cin >> a[i][j];           if ((i == 0 || i == n - 1) && (j == 0 || j == m - 1)) {             if (a[i][j] > 2) {               f = 1;             } else {               a[i][j] = 2;             }           } else if (i == 0 || i == n - 1 || j == 0 || j == m - 1) {             if (a[i][j] > 3) {               f = 1;             } else {               a[i][j] = 3;             }           } else {             if (a[i][j] > 4) {               f = 1;             } else {               a[i][j] = 4;             }           }         }       }       if (f == 1) {         cout <<  NO  << endl;       } else {         cout <<  YES  << endl;         for (int i = 0; i < n; i++) {           for (int j = 0; j < m; j++) {             cout << a[i][j] <<    ;           }           cout << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   int a[maxn], b[maxn];   int n, m;   int main() {     while (~scanf( %d%d , &n, &m)) {       for (int i = 0; i < n; i++) scanf( %d , a + i);       for (int i = 0; i < m; i++) scanf( %d , b + i);       int dis, ans = 0;       for (int i = 0; i < n; i++) {         int tmp = lower_bound(b, b + m, a[i]) - b;         if (tmp == 0)           dis = b[0] - a[i];         else if (tmp == m)           dis = a[i] - b[m - 1];         else           dis = min(b[tmp] - a[i], a[i] - b[tmp - 1]);         ans = max(ans, dis);       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200010;   const int mod = 1e9 + 7;   inline int cal(int x, int y) {     int l = 0, r = 1e9;     while (l < r) {       int mid = l + r + 1 >> 1;       if (3ll * mid + y <= x)         l = mid;       else         r = mid - 1;     }     if (y > x) return 0;     return l + 1;   }   int main() {     int n, l, r;     while (~scanf( %d%d%d , &n, &l, &r)) {       int cnt[5] = {0}, dp[2][5] = {0}, t = 0;       for (int i = 0; i < 3; i++) {         cnt[i] = cal(r, i) - cal(l - 1, i);       }       dp[0][0] = 1;       for (int i = 1; i <= n; i++) {         t ^= 1;         for (int j = 0; j < 3; j++) {           dp[t][j] = 0;           for (int k = 0; k < 3; k++) {             dp[t][j] += 1ll * cnt[k] * dp[t ^ 1][(j - k + 3) % 3] % mod;             if (dp[t][j] >= mod) dp[t][j] -= mod;           }         }       }       printf( %d n , dp[t][0]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s, h;     cin >> s;     h = s;     sort(h.begin(), h.end());     if (s != h) {       cout <<  NO ;       return 0;     }     int a = 0, b = 0, c = 0;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  a ) {         a++;       } else if (s[i] ==  b ) {         b++;       } else {         c++;       }     }     if (a != 0 && b != 0 && (a == c || b == c)) {       cout <<  YES ;     } else {       cout <<  NO ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_INT = 1000 * 1000 * 1000;   int n, m;   vector<int> ver;   vector<int> hor;   int main() {     cin >> n >> m;     ver.reserve(n + 1);     ver.resize(n);     for (int i = 0; i < n; ++i) cin >> ver.at(i), ver.at(i) += 1;     ver.push_back(MAX_INT + 1);     sort(ver.begin(), ver.end());     for (int i = 0; i < m; ++i) {       int x1, x2, y;       cin >> x1 >> x2 >> y;       if (x1 == 1) hor.push_back(x2 + 1);     }     sort(hor.begin(), hor.end());     int bestAns = n + m;     for (int i = 0; i < ver.size(); ++i) {       auto it = lower_bound(hor.begin(), hor.end(), ver.at(i));       int mustBreak = distance(it, hor.end());       bestAns = min(bestAns, i + mustBreak);     }     cout << bestAns << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     string s;     cin >> s;     string a(s);     int n;     cin >> n;     for (int i = 0; i < int(s.size()); ++i) {       if (isupper(s[i])) {         s[i] -=  A ;         s[i] +=  a ;       }       if (s[i] <  a  + n) {         a[i] = s[i] -  a  +  A ;       } else         a[i] = s[i];     }     cout << a;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void timer() { return; }   const int mod = 1e9 + 7;   int dx[] = {0, 0, 1, -1};   int dy[] = {1, -1, 0, 0};   string ds =  RLDU ;   const int mx = 5e4 + 10;   long long sum[mx];   void solve() {     int n, t;     cin >> n >> t;     for (int i = (1); i < (n + 1); ++i) {       for (int j = (0); j < (n - i); ++j) {         cout << 0 <<    ;       }       cout << t <<    ;       for (int j = (n - i + 1); j < (n); ++j) cout << 0 <<    ;       cout << endl;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     timer();     int t = 1;     for (int i = (1); i < (t + 1); ++i) {       solve();     }     timer();   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }   enum dir {     DOWN = 0,     UP,     RIGHT,     LEFT,     DOWN_RIGHT,     DOWN_LEFT,     UP_RIGHT,     UP_LEFT   };   int dir_r[] = {1, -1, 0, 0, 1, 1, -1, -1};   int dir_c[] = {0, 0, 1, -1, 1, -1, 1, -1};   bool p(long long s) {     if (s == 1 || (s % 2 == 0 && s != 2)) return 0;     for (int i = 2; i <= sqrt(s); i++) {       if (s % i == 0) return 0;     }     return 1;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     if (p(n)) return cout << 1, 0;     long long ans = 1e12;     for (long long i = 1; i <= sqrt(n); i++) {       if (n % i == 0) {         if (p(i)) {           ans = min(ans, i);         }         if (p(n / i)) ans = min(ans, i);       }     }     if (ans == 1e12)       cout << 0;     else {       n -= ans;       cout << n / 2 + 1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   long long a[200000], b[200000];   bool ok(long long x) {     int p(1);     long long q(0);     for (int i = 1; i <= (m); ++i)       if (b[i] > q) {         while (p <= n && a[p] + x < b[i]) ++p;         if (a[p] - x > b[i] || p > n) return false;         if (a[p] <= b[i])           q = a[p] + x;         else           q = max(b[i] + x - (a[p] - b[i]), a[p] + (x - (a[p] - b[i])) / 2);         ++p;       }     return true;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= (n); ++i) scanf( %I64d , &a[i]);     for (int i = 1; i <= (m); ++i) scanf( %I64d , &b[i]);     long long L = -1, R = 1LL << 40;     while (L + 1 < R) (ok(L + R >> 1) ? R : L) = L + R >> 1;     printf( %I64d n , R);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int x;     cin >> x;     vector<long long> result;     for (long long i = 1; i <= x; i++) {       long long n;       cin >> n;       vector<long long> v(n);       for (long long h = 0; h <= n - 1; h++) cin >> v[h];       sort(v.begin(), v.end());       if (v[n - 1] == 1 || v[n - 2] == 1)         result.push_back(0);       else if ((n - 2) < v[n - 2])         result.push_back(n - 2);       else if ((n - 2) >= v[n - 2])         result.push_back(v[n - 2] - 1);     }     for (long long i = 0; i <= x - 1; i++) cout << result[i] << endl;   }
#include <bits/stdc++.h>   using namespace std;   void solve(int test_number);   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.setf(ios::fixed);     cout.precision(9);     cerr.setf(ios::fixed);     cerr.precision(3);     int n = 1;     for (int i = 0; i < n; i++) {       solve(i);     }   }   const int MAX_N = 300005;   int n, n_edge, deg[MAX_N];   int point[MAX_N], head[MAX_N], next_edge[MAX_N];   bool line[MAX_N];   void add_edge(int u, int v) {     point[n_edge] = v, next_edge[n_edge] = head[u], head[u] = n_edge++;     point[n_edge] = u, next_edge[n_edge] = head[v], head[v] = n_edge++;   }   bool is_line(int u, int p) {     int cnt = 0;     for (int i = head[u]; i >= 0; i = next_edge[i]) {       int v = point[i];       if (v == p) {         continue;       }       if (!line[v]) {         return false;       }       cnt++;       if (cnt > 2) {         return false;       }     }     return true;   }   bool good(int u, int p, int lim) {     int cnt = 0, all = 0;     for (int i = head[u]; i >= 0; i = next_edge[i]) {       int v = point[i];       if (v == p) {         continue;       }       if (is_line(v, u)) {         cnt++;       } else if (!good(v, u, 1)) {         return false;       }       all++;     }     if (all - cnt <= lim) {       return true;     }     return false;   }   void dfs_line(int u, int p) {     int cnt = 0, lst = -1;     for (int i = head[u]; i >= 0; i = next_edge[i]) {       int v = point[i];       if (v == p) {         continue;       }       cnt++;       lst = v;       dfs_line(v, u);     }     if (cnt == 0 || (cnt == 1 && line[lst])) {       line[u] = true;     }   }   void solve(int test_number) {     cin >> n;     memset(head, -1, sizeof(head));     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       --u, --v;       add_edge(u, v);       deg[u]++;       deg[v]++;     }     for (int root = 0; root < min(n, 50); root++) {       memset(line, false, sizeof(line));       dfs_line(root, -1);       if (good(root, -1, 2) || is_line(root, -1)) {         cout <<  Yes  << endl;         return;       }     }     cout <<  No  << endl;   }
#include <bits/stdc++.h>   long long int n, m;   long long int pow(long long int k) {     long long int a = 1, t = 3;     for (; k; k /= 2) {       if (k & 1) a = (a * t) % m;       t = t * t % m;     }     return a;   }   void suru() { scanf( %I64d %I64d , &n, &m); }   void truli() {}   void sutru() { printf( %I64d n , (pow(n) - 1 + m) % m); }   int main() {     suru();     truli();     sutru();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     string s;     cin >> s;     int n = s.length();     int r = 0;     vector<int> fin(3, -1);     fin[0] = 0;     vector<int> z(n + 1);     for (int i = 1; i <= n; i++) {       r = (r + s[i - 1] -  0 ) % 3;       z[i] = z[i - 1];       if (fin[r] != -1) z[i] = max(z[i], z[fin[r]] + 1);       fin[r] = i;     }     cout << z[n] << endl;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int tst = 1;     while (tst--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[100005];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int Count = 1;     if (n == 1) {       cout << 1 << endl;     } else {       for (int i = 0; i < n - 1; i++) {         if (a[i] == a[i + 1]) {           continue;         } else {           Count++;         }       }       cout << Count << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int maxn = 1005;   int p[maxn], d[maxn], l[maxn][2], nl, ti;   int main() {     int n, h, r, c;     scanf( %d%d%d , &n, &h, &r);     for (int i = 0; i != n; ++i) scanf( %d%d , p + i, d + i);     c = h;     while (true) {       c += r;       if (c > h) c = h;       if (c <= 0) break;       int t = 0, pos = -1;       for (int i = 0; i != n; ++i)         if (c * 100 <= h * p[i] && t < d[i]) t = d[i], pos = i + 1;       if (~pos) {         r -= t;         l[nl][0] = ti;         l[nl++][1] = pos;         d[pos - 1] = -1;       } else if (r >= 0) {         puts( NO );         return 0;       }       ti++;     }     puts( YES );     printf( %d %d n , ti, nl);     for (int i = 0; i != nl; ++i) printf( %d %d n , l[i][0], l[i][1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string p, z;     cin >> p;     cin >> z;     for (int i = 0; i < p.length(); i++) {       if (p[i] >=  A  && p[i] <=  Z ) p[i] = tolower(p[i]);     }     for (int i = 0; i < z.length(); i++) {       if (z[i] >=  A  && z[i] <=  Z ) z[i] = tolower(z[i]);     }     cout << p.compare(z);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Edge {     int src, dst;     int weight;     Edge(int src, int dst, int weight) : src(src), dst(dst), weight(weight) {}   };   bool operator<(const Edge &e, const Edge &f) {     return e.weight != f.weight ? e.weight > f.weight            : e.src != f.src     ? e.src < f.src                                 : e.dst < f.dst;   }   const int MAXN = 100000;   int main() {     int n;     cin >> n;     if (n % 2 == 0) {       cout << -1 << endl;     } else {       for (int i = 0; i < (int)n - 1; ++i) cout << i <<    ;       cout << n - 1 << endl;       for (int i = 0; i < (int)n - 1; ++i) cout << i + 1 <<    ;       cout << 0 << endl;       for (int i = 0; i < (int)n - 1; ++i) cout << (i + i + 1) % n <<    ;       cout << n - 1 << endl;     }     return 0;   }