malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   int64_t k;   int a, b;   int result[9];   int ascore[9] = {0, 0, 1, 1, 0, 0, 0, 1, 0};   int bscore[9] = {0, 1, 0, 0, 0, 1, 1, 0, 0};   int stack[10];   int64_t atotalscore, btotalscore;   int cyclestart, cycleend, cyclelength;   int acyclescore, bcyclescore;   int64_t cycletime, cycleremain;   int main() {     int i, j, t;     scanf( %I64d%d%d , &k, &a, &b);     stack[0] = 3 * (a - 1) + (b - 1);     for (i = 0; i < 9; i++) {       scanf( %d , &t);       result[i] = 3 * (t - 1);     }     for (i = 0; i < 9; i++) {       scanf( %d , &t);       result[i] += (t - 1);     }     for (i = 1; i < k; i++) {       stack[i] = result[stack[i - 1]];       for (j = 0; j < i; j++) {         if (stack[i] == stack[j]) {           cyclestart = j;           cycleend = i - 1;           cyclelength = i - j;           break;         }       }       if (cyclelength != 0) break;     }     if (cyclelength == 0) {       for (i = 0; i < k; i++) {         atotalscore += ascore[stack[i]];         btotalscore += bscore[stack[i]];       }       printf( %I64d %I64d n , atotalscore, btotalscore);       return 0;     }     for (i = 0; i < cyclestart; i++) {       atotalscore += ascore[stack[i]];       btotalscore += bscore[stack[i]];     }     for (i = cyclestart; i <= cycleend; i++) {       acyclescore += ascore[stack[i]];       bcyclescore += bscore[stack[i]];     }     cycletime = (k - cyclestart) / cyclelength;     cycleremain = (k - cyclestart) % cyclelength;     atotalscore += acyclescore * cycletime;     btotalscore += bcyclescore * cycletime;     for (i = cyclestart; i < cyclestart + cycleremain; i++) {       atotalscore += ascore[stack[i]];       btotalscore += bscore[stack[i]];     }     printf( %I64d %I64d n , atotalscore, btotalscore);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x[100005], y[100005];   bool sign(int t) { return (t > 0); }   bool check(long double r) {     vector<pair<long double, long double> > v;     for (int i = 0; i < n; i++) {       long double t = (2.0 * r - y[i]) * y[i];       if (t < 0) return 0;       long double l = sqrt(t);       v.push_back({-l + x[i], l + x[i]});     }     long double mn = 1e18, mx = -1e18;     for (auto p : v) {       mn = min(mn, p.second);       mx = max(mx, p.first);     }     return (mx <= mn);   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d%d , &x[i], &y[i]);       if (sign(y[i]) != sign(y[0])) {         printf( -1 );         return 0;       }     }     for (int i = 0; i < n; i++) y[i] = abs(y[i]);     long double st = 0.0, en = 1e14;     for (int _ = 0; _ < 100; _++) {       long double mid = (st + en) / 2;       if (check(mid))         en = mid;       else         st = mid;     }     printf( %.9Lf , st);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5005;   const int M = 1005;   const int K = 15;   int n, m;   char name[N][K], oper[N][K], val[N][M];   bool isV[N];   int idx1[N], idx2[N];   map<string, int> mp;   char ansmx[M], ansmn[M];   int res[N];   int work(int a, int b, char op[]) {     if (op[0] ==  A ) return a & b;     if (op[0] ==  O ) return a | b;     return a ^ b;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %s , name[i]);       mp[name[i]] = i;       char buf[M];       scanf( %s , buf);       scanf( %s , buf);       if (buf[0] >=  0  && buf[0] <=  9 ) {         memcpy(val[i], buf, sizeof(buf));         isV[i] = 0;       } else {         isV[i] = 1;         idx1[i] = buf[0] ==  ?  ? -1 : mp[buf];         scanf( %s , oper[i]);         scanf( %s , buf);         idx2[i] = buf[0] ==  ?  ? -1 : mp[buf];       }     }     for (int i = 0; i < m; i++) {       int ans[2] = {0, 0};       for (int j = 0; j < 2; j++) {         for (int k = 0; k < n; k++) {           if (!isV[k])             res[k] = (val[k][i] -  0 );           else {             int op1 = idx1[k] == -1 ? j : res[idx1[k]];             int op2 = idx2[k] == -1 ? j : res[idx2[k]];             res[k] = work(op1, op2, oper[k]);           }           ans[j] += res[k];         }       }       if (ans[0] == ans[1])         ansmx[i] = ansmn[i] =  0 ;       else {         ansmx[i] = ans[0] > ans[1] ?  0  :  1 ;         ansmn[i] = ans[0] < ans[1] ?  0  :  1 ;       }     }     printf( %s n%s n , ansmn, ansmx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int64_t INF = 1e18 + 10;   const int N = 2e7 + 10;   int MOD = 1000000007;   int g[26], in[26], used[26];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     for (int i = 0; i < 26; i++) g[i] = -1;     int n;     cin >> n;     vector<string> a(n,   );     bool arr = 1;     for (int i = 0; i < n; i++) {       string s;       cin >> s;       for (auto j : s) used[j -  a ] = 1;       for (int j = 1; j < s.size(); j++) {         int u = s[j - 1] -  a ;         if (g[u] != -1 && g[u] != s[j] -  a  || s[j] == s[j - 1]) arr = 0;         g[s[j - 1] -  a ] = s[j] -  a ;         in[s[j] -  a ]++;       }     }     if (!arr) {       cout <<  NO ;       return 0;     }     string ans =   ;     for (int i = 0; i < 26; i++) {       if (in[i] == 0 && used[i]) {         int x = i;         while (x != -1) {           used[x]--;           if (used[x] < 0) break;           ans +=  a  + x;           x = g[x];         }       }     }     for (int i = 0; i < 26; i++) {       if (used[i] != 0) arr = 0;     }     if (arr)       cout << ans;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   using vl = vector<long long>;   using vpl = vector<pair<long long, long long>>;   using vs = vector<string>;   using pl = pair<long long, long long>;   using ll = long long int;   using vb = vector<bool>;   void printcase(ll x) { cout <<  Case #  << x <<  :  ; }   void read(vector<ll> &v, ll &n) {     for (ll i = 0; i < n; ++i) cin >> v[i];   }   void read(ll a[], ll &n) {     for (ll i = 0; i < n; ++i) cin >> a[i];   }   void print() { cout << endl; }   void write(vector<ll> &v, ll &n) {     for (ll i = 0; i < n; ++i) cout << v[i] <<    ;     cout << endl;   }   void write(vector<ll> &v) {     ll n = v.size();     for (ll i = 0; i < n; ++i) cout << v[i] <<    ;     cout << endl;   }   void write(ll a[], ll &n) {     for (ll i = 0; i < n; ++i) cout << a[i] <<    ;     cout << endl;   }   bool sorted(vl &v) {     ll n = v.size();     for (int i = 0; i < n - 1; i++) {       if (v[i] > v[i + 1]) return 0;     }     return 1;   }   bool solve() {     ll n;     cin >> n;     vl v(n);     read(v, n);     if (n <= 2) return 1;     vl suff(n), suffind(n), preind(n);     suff[n - 1] = v[n - 1];     suffind[n - 1] = n - 1;     preind[0] = 0;     for (int i = 1; i < n; i++) {       if (v[i] == v[i - 1])         preind[i] = preind[i - 1];       else         preind[i] = i;     }     for (int i = n - 2; i >= 0; i--) {       if (v[i] < suff[i + 1])         suffind[i] = i;       else         suffind[i] = suffind[i + 1];       suff[i] = min(v[i], suff[i + 1]);     }     for (int i = 0; i < n - 1; i++) {       if (v[i] > v[i + 1]) {         swap(v[preind[i]], v[suffind[i + 1]]);         if (sorted(v))           return 1;         else           return 0;       }     }     return 1;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     if (solve())       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = INT32_MAX;   const int NMAX = 10007;   int main() {     cin.tie(0);     cin.sync_with_stdio(0);     cout.precision(30);     string z[2];     cin >> z[0] >> z[1];     int n;     cin >> n;     cout << z[1] <<     << z[0] << endl;     for (int i = 0; i < n; i++) {       string k, next;       cin >> k >> next;       if (k == z[1])         z[1] = next;       else         z[0] = next;       cout << z[1] <<     << z[0] << endl;     }     return 0;   };
#include <bits/stdc++.h>   using namespace std;   pair<int, int> arr[200000];   int ans[200000], tree[500000], lazy[500000];   set<int> s;   int n;   set<int>::iterator it;   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> arr[i].first;       arr[i].second = i;     }     sort(arr, arr + n);     int l, r, mn = arr[0].second, len;     for (int i = 0; i < n; i++) {       ans[i] = arr[0].first;     }     s.insert(arr[0].second);     for (int i = 1; i < n; i++) {       it = s.lower_bound(arr[i].second);       r = *it;       if (it == s.end()) {         r = n;       }       if (*it == mn) {         l = -1;       } else {         it--;         l = *it;       }       mn = min(mn, arr[i].second);       s.insert(arr[i].second);       len = r - l - 1;       ans[len - 1] = max(arr[i].first, ans[len - 1]);     }     for (int i = n - 2; i >= 0; i--) {       ans[i] = max(ans[i], ans[i + 1]);     }     for (int i = 0; i < n; i++) {       cout << ans[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 7;   int arr[200005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     if (n % 2 == 0) {       cout <<  NO n ;       return 0;     }     int flag = 1, ct = 1;     for (int i = 1; i <= n; i++) {       if (flag) {         arr[i] = ct;         arr[n + i] = ct + 1;         flag = 0;       } else {         arr[i] = ct + 1;         arr[n + i] = ct;         flag = 1;       }       ct += 2;     }     cout <<  YES n ;     for (int i = 1; i <= 2 * n; i++) {       cout << arr[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   void out(vector<int>& v) {     for (int i = 0; i < v.size(); ++i) cout << v[i] <<    ;     cout << endl;   }   int main() {     int n;     cin >> n;     vector<int> p(n + 1);     p.back() = 1;     vector<int> c(n);     c[0] = 1;     if (n == 2) {       p[1] = 1;     }     if (n == 3) {       p[1] = 1;     }     if (n == 4) {       p[1] = 1;     }     if (n == 5) {       p[2] = 1;     }     if (n == 6) {       p[1] = 1;     }     if (n == 7) {       p[3] = 1;     }     if (n == 8) {       p[2] = 1;       p[3] = 1;       p[4] = 1;     }     if (n == 9) {       p[4] = 1;     }     if (n == 10) {       p[3] = 1;     }     if (n == 11) {       p[2] = 1;     }     if (n == 12) {       p[6] = 1;       p[4] = 1;       p[1] = 1;     }     if (n == 13) {       p[4] = 1;       p[3] = 1;       p[1] = 1;     }     if (n == 14) {       p[6] = 1;       p[1] = 1;       p[10] = 1;     }     if (n == 15) {       p[1] = 1;     }     if (n == 16) {       p[1] = 1;       p[3] = 1;       p[12] = 1;     }     if (n == 17) {       p[3] = 1;     }     if (n == 18) {       p[7] = 1;     }     if (n == 19) {       p[1] = 1;       p[2] = 1;       p[5] = 1;     }     if (n == 20) {       p[3] = 1;     }     if (n == 21) {       p[2] = 1;     }     if (n == 22) {       p[1] = 1;     }     if (n == 23) {       p[5] = 1;     }     if (n == 24) {       p[1] = 1;       p[2] = 1;       p[7] = 1;     }     if (n == 25) {       p[3] = 1;     }     if (n == 26) {       p[1] = 1;       p[2] = 1;       p[6] = 1;     }     if (n == 27) {       p[1] = 1;       p[2] = 1;       p[5] = 1;     }     if (n == 28) {       p[3] = 1;     }     if (n == 29) {       p[2] = 1;     }     if (n == 30) {       p[1] = 1;       p[2] = 1;       p[23] = 1;     }     if (n == 31) {       p[3] = 1;     }     if (n == 32) {       p[1] = 1;       p[2] = 1;       p[22] = 1;     }     if (n == 33) {       p[13] = 1;     }     if (n == 34) {       p[3] = 1;       p[4] = 1;       p[8] = 1;     }     if (n == 35) {       p[2] = 1;     }     if (n == 36) {       p[11] = 1;     }     if (n == 37) {       p[1] = 1;       p[4] = 1;       p[6] = 1;     }     if (n == 38) {       p[1] = 1;       p[5] = 1;       p[6] = 1;     }     if (n == 39) {       p[4] = 1;     }     if (n == 40) {       p[3] = 1;       p[4] = 1;       p[5] = 1;     }     if (n == 41) {       p[3] = 1;     }     if (n == 42) {       p[3] = 1;       p[4] = 1;       p[7] = 1;     }     if (n == 43) {       p[3] = 1;       p[4] = 1;       p[6] = 1;     }     if (n == 44) {       p[2] = 1;       p[5] = 1;       p[6] = 1;     }     if (n == 45) {       p[1] = 1;       p[3] = 1;       p[4] = 1;     }     if (n == 46) {       p[6] = 1;       p[7] = 1;       p[8] = 1;     }     if (n == 47) {       p[5] = 1;     }     if (n == 48) {       p[4] = 1;       p[7] = 1;       p[9] = 1;     }     if (n == 49) {       p[9] = 1;     }     if (n == 50) {       p[2] = 1;       p[3] = 1;       p[4] = 1;     }     for (int i = 1; i < p.size(); ++i) cout << p[i] <<    ;     cout << endl;     out(c);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, p, i, j, k, result;     cin >> n >> p;     int a[n + 1], b[n + 1];     for (i = 1; i <= n; i = i + 1) cin >> a[i];     i = 0;     j = p - 1;     result = p - 1;     do {       int m = (i + j) / 2;       bool check = true;       b[0] = 0;       for (int k = 1; k <= n; k = k + 1) b[k] = 1000000000;       for (int k = 1; k <= n; k = k + 1) {         if (((a[k] + m) % p >= b[k - 1]) && (a[k] + m >= p)) b[k] = b[k - 1];         if ((b[k - 1] - a[k] >= 0) && (b[k - 1] - a[k] <= m))           b[k] = min(b[k], b[k - 1]);         if (a[k] >= b[k - 1]) b[k] = min(b[k], a[k]);         if (b[k] == 1000000000) {           check = false;           break;         };       }       if (check == true) {         j = m - 1;         result = min(result, m);       } else         i = m + 1;     } while (i <= j);     cout << result;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     vector<int> a;     scanf( %d%d , &n, &m);     int min = n + 2;     for (int i = 0; i < m; i++) {       int t;       scanf( %d , &t);       if (t < min) {         a.push_back(t);         min = t;       }       if (t == 1) break;     }     sort(a.begin(), a.end());     for (int i = 0; i < a.size() - 1; i++)       for (int j = 0; j < a[i + 1] - a[i]; j++) printf( %d  , a[i]);     for (int i = 0; i < n - a.back(); i++) printf( %d  , a.back());     printf( %d n , a.back());   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int t = 1;     while (t--) {       map<char, long long int> a, b;       long long int n;       cin >> n;       string s, t;       cin >> s >> t;       for (long long int i = 0; i < n; i++) a[s[i]]++, b[t[i]]++;       vector<long long int> ans;       if (a != b)         cout << -1;       else {         if (s == t)           cout << 0;         else {           std::vector<int> move;           for (int i = n - 1; i >= 0; --i) {             if (s[i] != t[i]) {               int j = i - 1;               for (j = i - 1; j >= 0; --j) {                 if (s[j] == t[i]) break;               }               while (j < i) {                 move.push_back(j + 1);                 swap(s[j], s[j + 1]);                 ++j;               }             }           }           cout << move.size() <<   n ;           for (int x : move) cout << x <<    ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f;   vector<string> cur;   void upd(string s, int x, int y, int o) {     int dx = 0, dy = 1;     if (o) swap(dx, dy);     for (int i = 0; i < s.size(); i++) {       int xx = x + dx * i;       int yy = y + dy * i;       if (cur[xx][yy] ==  .  || cur[xx][yy] == s[i]) {         cur[xx][yy] = s[i];       } else {         f = 0;       }     }   }   int main() {     vector<string> a(6);     for (auto &x : a) {       cin >> x;     }     sort((a).begin(), (a).end());     vector<string> ans = { Z };     ans[0][0]++;     vector<string> ans0 = ans;     do {       f = 1;       vector<int> b;       vector<int> c;       for (int t = 0; t < 6; t += 3) {         int mx = 0;         int s = 0;         for (int i = t; i < t + 3; i++) {           s += a[i].size();           mx = max(mx, (int)a[i].size());         }         for (int i = t; i < t + 3; i++) {           if (a[i].size() == mx) {             b.push_back(i);             break;           }         }         if (s - 2 * mx != 1) {           f = 0;         }       }       for (int i = 0; i < 6; i++) {         if (i != b[0] && i != b[1]) {           c.push_back(i);         }       }       if (f) {         vector<int> bb, cc;         for (auto x : b) bb.push_back(a[x].size());         for (auto x : c) cc.push_back(a[x].size());         string t;         for (int i = 0; i < bb[1]; i++) {           t.push_back( . );         }         cur = vector<string>(bb[0], t);         upd(a[c[0]], 0, 0, 1);         upd(a[c[2]], 0, 0, 0);         upd(a[b[0]], 0, cc[2] - 1, 1);         upd(a[b[1]], cc[0] - 1, 0, 0);         upd(a[c[1]], cc[0] - 1, bb[1] - 1, 1);         upd(a[c[3]], bb[0] - 1, cc[2] - 1, 0);       }       if (f) {         if (cur < ans) ans = cur;       }     } while (next_permutation((a).begin(), (a).end()));     if (ans == ans0) {       cout <<  Impossible  << endl;       return 0;     }     for (auto s : ans) {       cout << s << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod(long long a, long long b) {     if (a % b < 0) {       return a % b + b;     }     return a % b;   }   long long mod_exp(long long a, long long b, long long c) {     long long res = 1;     a = a % c;     while (b > 0) {       if (b % 2 == 1) {         res = (res * a) % c;       }       b /= 2;       a = (a * a) % c;     }     return res;   }   long long gcd(long long a, long long b) {     if (b == 0) {       return a;     }     return gcd(b, a % b);   }   bool prime[3001];   void SieveOfEratosthenes() {     memset(prime, true, sizeof(prime));     prime[1] = false;     for (int p = 2; p * p <= 3000; p++) {       if (prime[p] == true) {         for (int i = p * p; i <= 3000; i += p) prime[i] = false;       }     }   }   long long powe[20];   void power() {     powe[0] = 1;     for (long long i = 1; i < 20; i++) {       powe[i] = (powe[i - 1] * 10) % 1000000007;       if (powe[i] < 0) powe[i] += 1000000007;     }   }   long long func(long long A[], long long n) {     long long lis[n];     lis[0] = 1;     for (long long i = 0; i < n; i++) {       lis[i] = 1;     }     return lis[0];   }   void solve() {     long long a, b, c;     cin >> a >> b >> c;     if ((c >= b && b >= a) || (a >= b && b >= c)) {       if (a >= b && b >= c) {         swap(a, c);       }       while (b > (a + c) / 2) {         b--;         a++;       }       while (b < (a + c) / 2) {         b++;         c--;       }       cout << ((((a > b) ? a : b) > c) ? ((a > b) ? a : b) : c) <<   n ;       return;     }   }   int main() {     long long n, a, b, c;     cin >> n;     cout <<   n? 1 2 n ;     fflush(stdout);     cin >> a;     cout <<  ? 2 3 n ;     fflush(stdout);     cin >> b;     cout <<  ? 1 3 n ;     fflush(stdout);     cin >> c;     long long A[n];     A[0] = (a + c - b) / 2;     A[1] = a - A[0];     A[2] = c - A[0];     for (long long i = 3; i < n; i++) {       cout <<  ? 1   << i + 1 <<   n ;       fflush(stdout);       cin >> a;       A[i] = a - A[0];     }     cout <<  !  ;     for (long long i = 0; i < n; i++) {       cout << A[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 5;   struct ACA {     int pool[N], ptp;     int stk[30], sz[N], rt[N], rtid, tp;     int nxt[N][26], tran[N][26], fail[N], end[N], num[N], tot;     inline int newnode() { return ++tot; }     int merge(int x, int y) {       if (!x || !y) return x | y;       for (int i = 0; i < 26; i++) nxt[x][i] = merge(nxt[x][i], nxt[y][i]);       end[x] += end[y];       pool[++ptp] = y;       return x;     }     void build(int p) {       queue<int> q;       for (int i = 0; i < 26; i++)         if (nxt[p][i])           fail[tran[p][i] = nxt[p][i]] = p, q.push(nxt[p][i]);         else           tran[p][i] = p;       while (!q.empty()) {         int k = q.front();         q.pop();         num[k] = end[k] + num[fail[k]];         for (int i = 0; i < 26; i++) {           if (nxt[k][i]) {             fail[tran[k][i] = nxt[k][i]] = tran[fail[k]][i];             q.push(tran[k][i]);           } else             tran[k][i] = tran[fail[k]][i];         }       }     }     void ins(char *s, int n, int v) {       rt[++rtid] = newnode();       sz[rtid] = 1;       int p = rt[rtid];       for (int i = 0; i < n; i++) {         int k = s[i] -  a ;         if (!nxt[p][k]) nxt[p][k] = newnode();         p = nxt[p][k];       }       end[p] += v;       while (tp && sz[stk[tp]] < 2 * sz[rtid])         rt[rtid] = merge(rt[rtid], rt[stk[tp]]), sz[rtid] += sz[stk[tp]], --tp;       build(rt[rtid]);       stk[++tp] = rtid;     }     int qry(char *s, int n) {       int ans = 0;       for (int i = 1; i <= tp; i++) {         int p = rt[stk[i]];         for (int i = 0; i < n; i++) {           p = tran[p][s[i] -  a ];           ans += num[p];         }       }       return ans;     }   } ac;   int main() {     int m;     scanf( %d , &m);     for (int i = 1; i <= m; i++) {       static char s[N];       int op;       scanf( %d%s , &op, s);       if (op == 1)         ac.ins(s, strlen(s), 1);       else if (op == 2)         ac.ins(s, strlen(s), -1);       else         printf( %d n , ac.qry(s, strlen(s))), fflush(stdout);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 1, logN = 21 + 1, mod = 1e9 + 7;   int fl(int n) {     int ans = 0;     while (n /= 2) ++ans;     return ans;   }   int ord2(int n) {     int ans = 0;     while (n % 2 == 0) {       n >>= 1;       ++ans;     }     return ans;   }   long long binpow(long long a, long long s) {     long long ans = 1;     while (s) {       if (s & 1) ans = ans * a % mod;       a = a * a % mod;       s >>= 1;     }     return ans;   }   long long inv(long long a) { return binpow(a, mod - 2); }   long long f[N], finv[N];   void init() {     f[0] = 1;     finv[0] = 1;     for (long long i = 1; i < N; ++i) {       f[i] = f[i - 1] * i % mod;       finv[i] = inv(f[i]);     }   }   int n, logn;   int cnt[logN];   long long solve(int k) {     for (int i = 0; i < logn; ++i) cnt[i] = 0;     for (int i = 1; i <= n; ++i) {       int ord = ord2(i);       if (ord < k)         ++cnt[ord];       else if (ord >= k) {         if (i % 3)           ++cnt[k];         else           ++cnt[ord + 1];       }     }     long long ans = 1;     for (int i = 0; i < logn; ++i) ans = ans * cnt[i] % mod;     ans = ans * f[cnt[0] - 1] % mod;     int sum = cnt[0] - 1;     for (int i = 1; i < logn; ++i) {       ans = ans * (f[sum + cnt[i]] * finv[sum + 1] % mod) % mod;       sum += cnt[i];     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cout.tie(0);     cin.tie(0);     init();     cin >> n;     logn = fl(n) + 1;     long long ans = 0;     for (int i = 0; i < logn; ++i) ans = (ans + solve(i)) % mod;     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, t, a[110];   int main() {     scanf( %d%d , &n, &t);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     for (int i = 1; i <= n; i++) {       t = t - 86400 + a[i];       if (t <= 0) {         printf( %d , i);         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int a[100005];     int b[100005];     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &a[i], &b[i]);     }     int flag = 1;     if (n % 2 == 0)       for (int i = 1; i < n / 2; i++) {         if (a[i] + a[i + n / 2] != a[i + 1] + a[i + 1 + n / 2] ||             b[i] + b[i + n / 2] != b[i + 1] + b[i + 1 + n / 2]) {           flag = 0;           break;         }       }     else       flag = 0;     if (flag)       printf( YES n );     else       printf( NO n );   }