malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<int> a[200001];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       int x, y;       scanf( %d %d , &x, &y);       a[x].push_back(y);     }     set<pair<int, int> > S;     for (int i = 1; i <= n; i++) {       sort(a[i].begin(), a[i].end());       if (!a[i].empty()) {         S.insert(make_pair(a[i][a[i].size() - 1], i));       }     }     int q;     cin >> q;     while (q--) {       int k;       scanf( %d , &k);       vector<pair<int, int> > temp;       for (int i = 1; i <= k; i++) {         int x;         scanf( %d , &x);         if (a[x].size()) {           S.erase(make_pair(a[x][a[x].size() - 1], x));           temp.push_back(make_pair(a[x][a[x].size() - 1], x));         }       }       if (S.size() == 0) {         cout <<  0 0 n ;       } else if (S.size() == 1) {         set<pair<int, int> >::iterator it;         it = S.begin();         int x = it->second, y = it->first;         printf( %d %d n , x, a[x][0]);       } else {         set<pair<int, int> >::reverse_iterator it;         it = S.rbegin();         int u = it->second;         it++;         int x = it->second, y = it->first;         int ans = *upper_bound(a[u].begin(), a[u].end(), y);         printf( %d %d n , u, ans);       }       for (int i = 0; i < temp.size(); i++) {         S.insert(temp[i]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, int> c;   int main() {     int l1, l2, f, ans = 0;     string s1, s2;     cin >> s1 >> s2;     l1 = s1.length();     l2 = s2.length();     for (int i = 1; i <= min(l1, l2); i++)       if (l1 % i == 0 && l2 % i == 0) {         f = 0;         c.clear();         for (int j = 0; j < l1; j += i) c[s1.substr(j, i)]++;         if (c[s1.substr(0, i)] == l1 / i) f++;         c.clear();         for (int j = 0; j < l2; j += i) c[s2.substr(j, i)]++;         if (c[s1.substr(0, i)] == l2 / i) f++;         if (f == 2) ans++;       }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const MAX = 1e5 + 41;   int n;   int q;   int s[MAX];   int m[MAX];   int r[MAX];   int const BLOCK = 441;   bool sp[MAX];   int lt[MAX];   int ltb[MAX];   vector<pair<int, int> > a[MAX];   vector<long long> prefsum[MAX];   vector<long long> prefspeed[MAX];   int const INF = 2e9 + 41;   void init() {     for (int i = 0, k = 0; i < n; i += BLOCK, k++) {       for (int j = 0; j <= BLOCK - 1; j++) {         if (i + j >= n) break;         int m = ::m[i + j];         int r = ::r[i + j];         if (r != 0) {           a[k].push_back(make_pair((m + r - 1) / r, i + j));         } else {           a[k].push_back(make_pair(INF, i + j));         }       }       sort(a[k].begin(), a[k].end());       long long sm = 0;       long long sr = 0;       for (int j = 0; j <= (int)a[k].size() - 1; j++) {         int m = ::m[a[k][j].second];         int r = ::r[a[k][j].second];         sm += m;         sr += r;         prefsum[k].push_back(sm);         prefspeed[k].push_back(sr);       }     }   }   long long queryblock(int id, int t) {     long long res = 0;     int p = (int)(lower_bound(a[id].begin(), a[id].end(),                               make_pair(t - ltb[id], INF)) -                   a[id].begin());     p--;     if (p >= 0) {       res += prefsum[id][p];     }     res += prefspeed[id].back() * (t - ltb[id]);     if (p >= 0) {       res -= prefspeed[id][p] * (t - ltb[id]);     }     ltb[id] = t;     return res;   }   long long bruteblock(int id, int l, int r, int t) {     if (l > r) return 0LL;     l -= BLOCK * id;     r -= BLOCK * id;     sp[id] = false;     int sh = id * BLOCK;     for (int i = 0; i <= (int)a[id].size() - 1; i++) {       lt[sh + i] = max(lt[sh + i], ltb[id]);     }     long long res = 0;     for (int i = l; i <= r; i++) {       long long add = min((long long)m[sh + i],                           (long long)::r[sh + i] * (t - lt[sh + i]) + s[sh + i]);       res += add;       lt[sh + i] = t;       s[sh + i] = 0;     }     return res;   }   int getblockright(int x) {     int res = (x / BLOCK + 1) * BLOCK - 1;     res = min(res, n - 1);     return res;   }   int getblockleft(int x) { return x / BLOCK * BLOCK; }   void solve() {     init();     scanf( %d , &q);     for (int o = 1; o <= q; o++) {       int t, l, r;       scanf( %d %d %d , &t, &l, &r);       l--;       r--;       long long res = 0;       int rl = min(r, getblockright(l));       res += bruteblock(l / BLOCK, l, rl, t);       l = rl + 1;       int lr = max(l, getblockleft(r));       res += bruteblock(r / BLOCK, lr, r, t);       r = lr;       while (l < r) {         if (sp[l / BLOCK]) {           res += queryblock(l / BLOCK, t);         } else {           res += bruteblock(l / BLOCK, l, l + BLOCK - 1, t);           sp[l / BLOCK] = 1;           ltb[l / BLOCK] = t;         }         l += BLOCK;       }       printf( %lld n , res);     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i <= n - 1; i++) {       scanf( %d %d %d , &s[i], &m[i], &r[i]);     }     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1005;   double a[N][N], f[N];   int n, m, sx, sy;   inline void solve(int x) {     memset(a, 0, sizeof(a));     for (int i = 1; i <= m; ++i) {       if (i == 1) {         a[1][1] = 2;         a[1][2] = -1;         a[1][m + 1] = 3 + f[1];       } else if (i == m) {         a[m][m] = 2;         a[m][m - 1] = -1;         a[m][m + 1] = 3 + f[m];       } else {         a[i][i] = 3;         a[i][i - 1] = a[i][i + 1] = -1;         a[i][m + 1] = 4 + f[i];       }     }     for (int i = 1; i < m; ++i) {       double p = a[i + 1][i] / a[i][i];       a[i + 1][i] = 0;       a[i + 1][i + 1] -= a[i][i + 1] * p;       a[i + 1][m + 1] -= a[i][m + 1] * p;     }     f[m] = a[m][m + 1] / a[m][m];     for (int i = m - 1; i >= 1; --i) {       f[i] = (a[i][m + 1] + f[i + 1]) / a[i][i];     }   }   int main() {     scanf( %d%d , &n, &m);     scanf( %d%d , &sx, &sy);     if (m == 1) {       printf( %.10lf n , 2.0 * (n - sx));       return 0;     }     for (int i = n - 1; i >= sx; --i) solve(i);     printf( %.10lf n , f[sy]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T abs(T x) {     if (x < 0) return -x;     return x;   }   template <class T>   T sqr(T a) {     return a * a;   }   const double pi = acos(-1.0);   const double eps = 1e-8;   int i, n, cnt;   char s1[110], s2[110];   void fun1() {     if (s1[i + 1] ==  0 ) {       s1[i + 1] =  X ;       cnt++;     } else if (s2[i + 1] ==  0 ) {       s2[i + 1] =  X ;       cnt++;     }   }   void fun2() {     if (s1[i + 1] ==  0  && s2[i + 1] ==  0 ) {       s1[i + 1] =  X ;       s2[i + 1] =  X ;       cnt++;     }   }   int main() {     while (2 == scanf( %s%s , &s1, s2)) {       cnt = 0;       n = strlen(s1);       for (i = 0; i < n - 1; i++) {         if (s1[i] ==  0  && s2[i] ==  0 ) fun1();         if (s1[i] ==  0  || s2[i] ==  0 ) fun2();       }       printf( %d n , cnt);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int check(string s) {     int d = 0;     for (int i = 0; i < s.length(); i++)       if (s[i] ==  a  || s[i] ==  e  || s[i] ==  o  || s[i] ==  u  || s[i] ==  i )         d++;     return d;   }   int main() {     string s1, s2, s3;     getline(cin, s1);     getline(cin, s2);     getline(cin, s3);     if (check(s1) == 5 && check(s2) == 7 && check(s3) == 5)       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   const int N = 55;   string s[N];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; ++i) cin >> s[i];     int sx, sy, ex, ey;     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) {         if (s[i][j] ==  S ) sx = i, sy = j;         if (s[i][j] ==  E ) ex = i, ey = j;       }     string w;     cin >> w;     string p =  ULDR ;     sort((p).begin(), (p).end());     map<char, int> dx = {{ D , -1}, { U , +1}};     map<char, int> dy = {{ L , -1}, { R , +1}};     int ans = 0;     do {       bool ok = true;       int x = sx, y = sy;       for (int i = 0; i < w.size(); ++i) {         if (x == ex && y == ey) break;         if (x < 0 || x >= n || y < 0 || y >= m || s[x][y] ==  # ) {           ok = false;           break;         }         x += dx[p[w[i] -  0 ]];         y += dy[p[w[i] -  0 ]];       }       if (ok && x == ex && y == ey) ++ans;     } while (next_permutation((p).begin(), (p).end()));     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char str1[200002], str2[200002];   const int K = 1024;   int aw[200002];   int bw[200002];   char bit[1 << 16];   short cnt[200002 / K + 1][200002];   int main() {     gets(str1);     gets(str2);     int l1 = strlen(str1), l2 = strlen(str2);     for (int i = 0; i < l1; ++i) {       unsigned int one = 1;       for (int j = 0; j < 16 && i + j < l1; ++j) {         if (str1[i + j] ==  1 ) aw[i] |= one;         one <<= 1;       }     }     for (int i = 0; i < l2; ++i) {       unsigned int one = 1;       for (int j = 0; j < 16 && i + j < l2; ++j) {         if (str2[i + j] ==  1 ) bw[i] |= one;         one <<= 1;       }     }     bit[0] = 0;     for (int i = 1; i < (1 << 16); ++i) {       bit[i] = (i & 1) + bit[i >> 1];     }     int IT = K >> 4;     for (int i = 0; i + K <= l1; i += K) {       int ind = i / K;       for (int j = 0; j + K <= l2; ++j) {         int p1 = i, p2 = j;         for (int t = 0; t < IT; ++t) {           cnt[ind][j] += bit[aw[p1] ^ bw[p2]];           p1 += 16;           p2 += 16;         }       }     }     int q, p1, p2, len;     scanf( %d , &q);     while (q--) {       scanf( %d%d%d , &p1, &p2, &len);       int ans = 0;       int pos = (p1 / K) * K, r = p1 + len - 1;       while (pos < p1) pos += K;       for (int i = p1; i < pos && i <= r; ++i) {         ans += str1[i] != str2[p2];         ++p2;       }       if (pos <= r) {         while (pos + K - 1 <= r) {           ans += cnt[pos / K][p2];           pos += K;           p2 += K;         }         for (int i = pos; i <= r; ++i) {           ans += str1[i] != str2[p2];           ++p2;         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 10086;   struct Node {     string name;     vector<Node *> son;   };   char str[MAXN];   int ans;   void build(Node *&root, int &pos) {     if (str[pos] == 0) {       root = NULL;       return;     }     string name =   ;     for (; str[pos] !=  .  && str[pos] !=  : ;) {       name += str[pos++];     }     root = new Node();     root->name = name;     if (str[pos] ==  : ) {       do {         pos++;         Node *son;         build(son, pos);         if (son != NULL) root->son.push_back(son);       } while (str[pos] !=  . );     }     pos++;   }   void dfs(Node *root, map<string, int> &mp) {     if (root == NULL) return;     mp[root->name]++;     for (vector<Node *>::iterator it = root->son.begin(); it != root->son.end();          it++) {       map<string, int> _mp;       dfs(*it, _mp);       ans += _mp[root->name];       for (map<string, int>::iterator mit = _mp.begin(); mit != _mp.end(); mit++)         mp[mit->first] += mit->second;     }   }   int main() {     while (~scanf( %s , str)) {       Node *root;       int pos = 0;       build(root, pos);       ans = 0;       map<string, int> mp;       dfs(root, mp);       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100008;   int n, a[N];   vector<pair<int, int> > ans;   int main(void) {     int i, j, k;     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , a + i);     for (i = 1; i + 2 <= n; i++)       if (a[i]) {         k = 1;         for (j = 2; i + j <= n; j++)           if (a[i + j]) {             if (i + j + j <= n)               k = j;             else               k = 1;             break;           }         a[i] ^= 1;         a[i + k] ^= 1;         a[i + k + k] ^= 1;         ans.push_back(make_pair(i, k));       }     if (a[n - 1] == 0 && a[n] == 0)       ;     else if (a[n - 1] == 1 && a[n] == 0) {       if (n >= 8) {         ans.push_back(make_pair(n - 7, 1));         ans.push_back(make_pair(n - 7, 3));         ans.push_back(make_pair(n - 6, 1));       } else {         printf( NO );         return 0;       }     } else if (a[n - 1] == 0 && a[n] == 1) {       if (n >= 7) {         ans.push_back(make_pair(n - 6, 1));         ans.push_back(make_pair(n - 6, 3));         ans.push_back(make_pair(n - 5, 1));       } else {         printf( NO );         return 0;       }     } else {       if (n >= 8) {         ans.push_back(make_pair(n - 7, 1));         ans.push_back(make_pair(n - 7, 3));         ans.push_back(make_pair(n - 6, 1));         ans.push_back(make_pair(n - 6, 1));         ans.push_back(make_pair(n - 6, 3));         ans.push_back(make_pair(n - 5, 1));       } else {         printf( NO );         return 0;       }     }     printf( YES n%d n , (int)ans.size());     for (auto p : ans)       printf( %d %d %d n , p.first, p.first + p.second,              p.first + p.second + p.second);     return 0;   }
#include<bits/stdc++.h>   typedef long long ll;   using namespace std;   const int MAXN = 5005;   int tag[MAXN],s[MAXN];   ll dp[MAXN];   int main(){       ios::sync_with_stdio(false);       int t;cin>>t;       while(t--){           int n;cin>>n;           for(int i=1;i<=n;i++){               cin>>tag[i];           }           for(int i=1;i<=n;i++){               cin>>s[i];               dp[i]=0;           }           for(int i=2;i<=n;i++){               for(int j=i-1;j>=1;j--){                   if(tag[i]==tag[j]) continue;                   ll di=dp[i],dj=dp[j],add=abs(s[i]-s[j]);                   dp[i]=max(dp[i],dj+add);                   dp[j]=max(dp[j],di+add);               }           }           ll ans=0;           for(int i=1;i<=n;i++){               ans=max(ans,dp[i]);           }           cout<<ans<<  n ;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   template <typename T>   inline T Bigmod(T base, T power, T MOD) {     T ret = 1;     while (power) {       if (power & 1) ret = (ret * base) % MOD;       base = (base * base) % MOD;       power >>= 1;     }     return ret;   }   bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {     return (a.first > b.first);   }   int main() {     ios::sync_with_stdio(false);     int n, m;     while (cin >> n >> m) {       int a[n];       int b[m];       int max_a = 0, min_a = 110, min_b = 110;       for (int i = 0; i < n; i++) {         cin >> a[i];         max_a = max(max_a, a[i]);         min_a = min(min_a, a[i]);       }       for (int i = 0; i < m; i++) {         cin >> b[i];         min_b = min(min_b, b[i]);       }       if (max(2 * min_a, max_a) < min_b)         cout << max(2 * min_a, max_a) << endl;       else         cout <<  -1 n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   const long long int P = 1000000007;   const double eps = 1e-6;   int val[N];   int deg[N];   vector<int> gr[N];   vector<long long int> mx(N);   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     long long int ans = 0;     for (int i = 0; i < n; i++) {       cin >> val[i];       ans += val[i];     }     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       u--;       v--;       gr[u].push_back(v);       gr[v].push_back(u);       deg[u]++, deg[v]++;     }     int start;     cin >> start;     start--;     stack<int> st;     for (int i = 0; i < n; i++)       if (deg[i] == 1 && i != start) st.push(i);     long long int maxall = 0;     while (!st.empty()) {       int now = st.top();       st.pop();       deg[now]--;       ans -= val[now];       for (auto i : gr[now]) {         if (deg[i]) {           deg[i]--;           if (deg[i] == 1 && i != start) st.push(i);           mx[i] = max((long long int)mx[i],                       (long long int)mx[now] + (long long int)val[now]);           maxall = max(maxall, mx[i]);         }       }     }     cout << ans + maxall;     cerr <<   nTime elapsed :   << 1000 * clock() / CLOCKS_PER_SEC <<   ms n ;     return 0;   }
#include <bits/stdc++.h>   int main() {     char A[100];     int M, N = 0, i = 0;     scanf( %d , &M);     scanf( %s , A);     for (i = 0; i < M; i++) {       if (A[i] ==  x  && A[i + 1] ==  x  && A[i + 2] ==  x ) {         N++;       }     }     printf( %d n , N);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int i, j, k;     long long int n, m, t;     long long int a, b;     scanf( %I64d%I64d%I64d , &n, &a, &b);     t = n / a + 1;     for (i = 0; i <= t; i++) {       m = i * a;       if ((n - m) % b == 0 && n - m >= 0) {         printf( YES n%I64d %I64d , i, (n - m) / b);         return 0;       }     }     printf( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 9;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     long long n, m;     cin >> n >> m;     vector<vector<long long>> v(n);     vector<vector<long long>> vr(n);     long long a, b;     for (int i = 0; i < m; ++i) {       cin >> a >> b;       a--;       b--;       v[a].push_back(b);       vr[b].push_back(a);     }     vector<long long> mr(n, 0);     long long ps;     cin >> ps;     vector<long long> p(ps);     for (int i = 0; i < ps; ++i) {       cin >> p[i];       p[i]--;     }     mr[p[ps - 1]] = 0;     queue<int> q;     q.push(p[ps - 1]);     vector<bool> used(n);     used[p[ps - 1]] = true;     while (!q.empty()) {       long long cur = q.front();       q.pop();       for (auto i : vr[cur]) {         if (!used[i]) {           used[i] = true;           mr[i] = mr[cur] + 1;           q.push(i);         }       }     }     long long mn = 0, mx = 0;     for (int i = 0; i < ps - 1; ++i) {       long long lg = 1000000000000;       set<long long> s;       for (auto j : v[p[i]]) {         if (mr[j] < lg) {           s.clear();           s.insert(j);           lg = mr[j];         } else if (mr[j] == lg) {           s.insert(j);         }       }       if (s.find(p[i + 1]) == s.end()) {         mn++;         mx++;       } else {         if (s.size() > 1) {           mx++;         }       }     }     cout << mn <<     << mx;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const int N = 2e5 + 4;   int main() {     int n;     scanf( %d , &n);     long long b[n], c[n], sum = 0;     for (int i = 0; i < n; i++) scanf( %lld , &b[i]), sum += b[i];     for (int i = 0; i < n; i++) scanf( %lld , &c[i]), sum += c[i];     if (sum % 2 * n != 0) {       printf( %d , -1);       return 0;     }     sum /= 2 * n;     long long a[n];     for (int i = 0; i < n; i++) {       long long here = b[i] + c[i] - sum;       if (here >= 0 and here % n != 0) {         printf( %d , -1);         return 0;       }       a[i] = here / n;     }     vector<int> fa(31, 0);     for (int bit = 0; bit < 31; bit++) {       for (int i = 0; i < n; i++)         if (a[i] & (1LL << bit)) fa[bit]++;     }     for (int i = 0; i < n; i++) {       for (int bit = 0; bit < 31; bit++)         if (a[i] & (1LL << bit)) b[i] -= (1LL << bit) * fa[bit];       if (b[i] != 0) {         printf( %d , -1);         return 0;       }     }     for (int i = 0; i < n; i++) printf( %lld  , a[i]);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(         Ofast,unroll-loops,no-stack-protector,unsafe-math-optimizations )   #pragma GCC target( avx )   inline int read_char() {     static char buf[1 << 16], *ptr = buf, *end_ptr = buf;     if (ptr == end_ptr) {       int len = fread(buf, 1, sizeof(buf), stdin);       if (len <= 0) return EOF;       ptr = buf;       end_ptr = buf + len;     }     return *ptr++;   }   inline int read_int() {     int ch;     bool sg = 0;     do {       ch = read_char();       if (ch ==  - ) sg = 1;     } while (ch <  0  || ch >  9 );     int x = ch -  0 ;     while (true) {       ch = read_char();       if (ch <  0  || ch >  9 ) break;       x = x * 10 + ch -  0 ;     }     return (sg ? -x : x);   }   float __attribute__((aligned(64))) a[100005];   int n, m, ans, t, l, r;   float x;   int main() {     n = read_int();     m = read_int();     for (int i = 1; i <= n; i++) a[i] = read_int();     for (int i = 1; i <= m; i++) {       t = read_int();       l = read_int();       r = read_int();       x = read_int();       if (t == 1) {         for (int j = l; j <= r; j++)           if (a[j] > x) a[j] -= x;       } else {         ans = 0;         for (int j = l; j <= r; j++) ans += (a[j] == x);         printf( %d n , ans);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 10;   unsigned long long x[N], y[N], f[N];   int a[N], cnt[N];   queue<int> g[N];   mt19937_64 rng(time(0));   char buf[1 << 23], *p1 = buf, *p2 = buf, obuf[1 << 23], *O = obuf;   inline int rd() {     int x = 0, f = 1;     char ch =         (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)              ? EOF              : *p1++);     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch =           (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)                ? EOF                : *p1++);     }     while (isdigit(ch))       x = x * 10 + (ch ^ 48),       ch =           (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)                ? EOF                : *p1++);     return x * f;   }   namespace Hash {   const int hashmod = 999983;   int v[hashmod];   bool vis[hashmod];   unsigned long long h[hashmod];   int &get(unsigned long long S) {     int i = S % hashmod;     for (; vis[i] && h[i] != S; i = (i + 1) % hashmod)       ;     if (!vis[i]) vis[i] = 1, h[i] = S;     return v[i];   }   }  // namespace Hash   int main() {     int n = rd();     for (int i = 1; i <= n; ++i) {       a[i] = rd();       x[i] = rng();       y[i] = rng();     }     unsigned long long now = 0, ans = 0;     ++Hash::get(now);     int p = 0;     for (int i = 1; i <= n; ++i) {       if (g[a[i]].size() == 3) {         int t = g[a[i]].front();         g[a[i]].pop();         while (p < t) --Hash::get(f[p++]);       }       g[a[i]].push(i);       switch (++cnt[a[i]] % 3) {         case 1:           f[i] = now ^= x[a[i]];           break;         case 2:           f[i] = now ^= y[a[i]];           break;         case 0:           f[i] = now ^= x[a[i]] ^ y[a[i]];           break;       }       ans += Hash::get(now)++;     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   void bubbleSort(long long int arr[], int n) {     for (int i = 0; i < n - 1; i++) {       for (int j = 0; j < n - i - 1; j++) {         if (arr[j] > arr[j + 1]) {           int swap = arr[j];           arr[j] = arr[j + 1];           arr[j + 1] = swap;         }       }     }   }   int main() {     int n, k, ans;     scanf( %d %d , &n, &k);     long long int arr[n];     for (int i = 0; i < n; i++) {       scanf( %lld , &arr[i]);       bubbleSort(arr, i + 1);       int j = i;       long long int sum = 0;       while (j > -1) {         sum += arr[j];         j -= 2;       }       if (sum <= k) {         ans = i + 1;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 1000 * 1000;   const int mod = 1000 * 1000 + 3;   string com =  ><+-.,[] ;   int main() {     string s;     cin >> s;     int res = 0;     for (int i = 0; i < s.size(); i++)       res = (res << 4) % mod, res = (res + 8 + com.find(s[i])) % mod;     cout << res << endl;     return 0;   }