malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   long long n, k;   long long POW(long long a, long long n) {     if (!n) return 1;     long long ans = 1;     while (n) {       if (n & 1) ans = ans * a % mod;       n >>= 1;       a = a * a % mod;     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n >> k;     if (!n) return cout << 0, 0;     n %= mod;     cout << (POW(2, k + 1) * n % mod - POW(2, k) % mod + 1 + mod * mod) % mod;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long check, tn, tm, maxn;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long exgcd(long long a, long long b, long long &x, long long &y) {     if (b == 0) {       x = 1, y = 0;       return a;     }     long long d = exgcd(b, a % b, x, y);     long long z = x;     x = y;     y = z - y * (a / b);     return d;   }   long long solve(long long x, long long y) {     long long c = x + y, dx, dy;     long long d = exgcd(tn, tm, dx, dy);     if (c % d) return maxn + 1;     long long mod = tm / d;     dx *= c / d;     if (mod < 0) mod = -mod;     dx = (dx % mod + mod) % mod;     long long ans = tn * dx - x;     if (ans < 0 || ans > maxn) return maxn + 1;     return ans;   }   int main() {     long long n, m, k, x, y;     cin >> n >> m >> k;     maxn = n * m / gcd(n, m);     tn = n << 1, tm = -(m << 1);     for (int i = 1; i <= k; ++i) {       cin >> x >> y;       long long ans = maxn + 1;       ans = min(ans, solve(x, y));       ans = min(ans, solve(x, -y));       ans = min(ans, solve(-x, y));       ans = min(ans, solve(-x, -y));       if (ans == maxn + 1)         cout << -1 << endl;       else         cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2 * 1e5 + 10;   inline long long po(long long a, long long p, long long mod) {     long long r = 1;     for (; p; p >>= 1, a = a * a % mod)       if (p & 1) r = r * a % mod;     return r;   }   const long long mod1 = 1e9 + 7;   const long long mod2 = 1e9 + 9;   const long long bas = 1e9 + 3;   int n;   int m;   long long a[N];   long long b[N];   long long pa1;   long long pa2;   long long sa1;   long long sa2;   long long pb1;   long long pb2;   long long sb1;   long long sb2;   long long mi1[N];   long long mi2[N];   long long imi1[N];   long long imi2[N];   long long ans[N];   int tp;   long long inv1;   long long inv2;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);     sort(a + 1, a + n + 1);     for (int i = 1, j = n; i <= n; i++, j--) b[j] = a[i];     mi1[0] = 1;     for (int i = 1; i <= n; i++) (mi1[i] = mi1[i - 1] * bas) %= mod1;     mi2[0] = 1;     for (int i = 1; i <= n; i++) (mi2[i] = mi2[i - 1] * bas) %= mod2;     for (int i = n; i >= 1; i--)       pa1 = (pa1 * bas + a[i]) % mod1, pa2 = (pa2 * bas + a[i]) % mod2,       pb1 = (pb1 * bas + b[i]) % mod1, pb2 = (pb2 * bas + b[i]) % mod2;     inv1 = po(po(bas, n, mod1) + mod1 - 1, mod1 - 2, mod1);     inv2 = po(po(bas, n, mod2) + mod2 - 1, mod2 - 2, mod2);     for (int i = n; i >= 0; i--) {       long long t1 = ((pa1 + pb1) + (sa1 + mod1 - sb1)) % mod1;       long long x1 = (bas - 1) * t1 % mod1 * inv1 % mod1;       long long t2 = ((pa2 + pb2) + (sa2 + mod2 - sb2)) % mod2;       long long x2 = (bas - 1) * t2 % mod2 * inv2 % mod2;       if (x1 == x2 && x1 < m) ans[++tp] = x1;       pa1 = (pa1 + mod1 - a[i] * mi1[i - 1] % mod1) % mod1;       pa2 = (pa2 + mod2 - a[i] * mi2[i - 1] % mod2) % mod2;       sa1 = (sa1 + a[i] * mi1[i - 1]) % mod1;       sa2 = (sa2 + a[i] * mi2[i - 1]) % mod2;       pb1 = (pb1 + mod1 - a[i]) * 750000005 % mod1;       pb2 = (pb2 + mod2 - a[i]) * 166666668 % mod2;       sb1 = (sb1 * 750000005 + mi1[n - 1] * (m - a[i])) % mod1;       sb2 = (sb2 * 166666668 + mi2[n - 1] * (m - a[i])) % mod2;     }     printf( %d n , tp);     sort(ans + 1, ans + tp + 1);     for (int i = 1; i <= tp; i++) printf( %lld  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 0x3f3f3f3f3f3f3f3f;   long long dx[] = {0, 1, 1, 1, 0, -1, -1, -1};   long long dy[] = {1, 1, 0, -1, -1, -1, 0, 1};   struct BipartiteMatcher {     vector<vector<long long>> G;     vector<long long> L, R, Viz;     BipartiteMatcher(long long n, long long m)         : G(n), L(n, -1), R(m, -1), Viz(n) {}     void AddEdge(long long a, long long b) { G[a].push_back(b); }     bool Match(long long node) {       if (Viz[node]) return false;       Viz[node] = true;       for (auto vec : G[node]) {         if (R[vec] == -1) {           L[node] = vec;           R[vec] = node;           return true;         }       }       for (auto vec : G[node]) {         if (Match(R[vec])) {           L[node] = vec;           R[vec] = node;           return true;         }       }       return false;     }     long long Solve() {       long long ok = true;       while (ok--) {         fill(Viz.begin(), Viz.end(), 0);         for (long long i = 0; i < (long long)L.size(); ++i)           if (L[i] == -1) ok |= Match(i);       }       long long ret = 0;       for (long long i = 0; i < L.size(); ++i) ret += (L[i] != -1);       return ret;     }   };   bool comp(const pair<long long, pair<long long, long long>> &a,             const pair<long long, pair<long long, long long>> &b) {     return a.second.second < b.second.second;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long t = 1;     while (t--) {       long long n, m;       cin >> n >> m;       vector<pair<long long, pair<long long, long long>>> roads;       for (long long i = 0; i < m; ++i) {         long long u, v, w;         cin >> u >> v >> w;         --u;         --v;         roads.push_back({u, {v, w}});       }       sort(roads.begin(), roads.end(), comp);       long long lo = 0, hi = 1e9 + 1;       while (lo < hi) {         long long md = (lo + hi) >> 1;         BipartiteMatcher graph(n, n);         for (auto it : roads) {           if (it.second.second <= md)             graph.AddEdge(it.first, it.second.first);           else             break;         }         long long cnt = graph.Solve();         if (cnt < n) {           lo = md + 1;         } else           hi = md;       }       if (hi == (1e9 + 1))         cout << -1;       else         cout << hi;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define fi first   #define se second   #define fill0(a) memset(a,0,sizeof(a))   #define fill1(a) memset(a,-1,sizeof(a))   #define fillbig(a) memset(a,63,sizeof(a))   #define pb push_back   #define ppb pop_back   #define mp make_pair   #define mt make_tuple   #define eprintf(...) fprintf(stderr,__VA_ARGS__)   template<typename T1,typename T2> void chkmin(T1 &x,T2 y){if(x>y) x=y;}   template<typename T1,typename T2> void chkmax(T1 &x,T2 y){if(x<y) x=y;}   typedef pair<int,int> pii;   typedef long long ll;   typedef unsigned int u32;   typedef unsigned long long u64;   typedef long double ld;   namespace fastio{    #define FILE_SIZE 1<<23    char rbuf[FILE_SIZE],*p1=rbuf,*p2=rbuf,wbuf[FILE_SIZE],*p3=wbuf;    inline char getc(){return p1==p2&&(p2=(p1=rbuf)+fread(rbuf,1,FILE_SIZE,stdin),p1==p2)?-1:*p1++;}    inline void putc(char x){(*p3++=x);}    template<typename T> void read(T &x){     x=0;char c=getchar();T neg=0;     while(!isdigit(c)) neg|=!(c^ - ),c=getchar();     while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();     if(neg) x=(~x)+1;    }    template<typename T> void recursive_print(T x){return (!x)?void():(recursive_print(x/10),putc(x%10^48),void());}    template<typename T> void print(T x){(!x)&&(putc( 0 ),0);(x<0)&&(putc( - ),x=~x+1);recursive_print(x);}    template<typename T> void print(T x,char c){print(x);putc(c);}    void print_final(){fwrite(wbuf,1,p3-wbuf,stdout);}   }   const int MAXN=2e5;   const int MAXV=1e6;   int n,qu,s,d,a[MAXN+5],f[MAXN+5],pos[MAXV+5];   set<int> cmp[MAXN+5];int cmp_cnt=0;   int find(int x){return (!f[x])?x:f[x]=find(f[x]);}   bool merge(int x,int y){    x=find(x);y=find(y);if(x==y) return 0;    if(cmp[x].size()<cmp[y].size()) swap(x,y);    for(int v:cmp[y]) cmp[x].insert(v);    cmp[y].clear();f[y]=x;cmp_cnt--;return 1;   }   set<int> st;   int hd[MAXN+5],to[MAXN*2+5],nxt[MAXN*2+5],val[MAXN*2+5],ec=0;   void adde(int u,int v,int w){/*printf( %d %d %d n ,u,v,w);*/to[++ec]=v;val[ec]=w;nxt[ec]=hd[u];hd[u]=ec;}   int mx[MAXN+5];   void dfs(int x,int f){    for(int e=hd[x];e;e=nxt[e]){     int y=to[e],z=val[e];if(y==f) continue;     mx[y]=max(mx[x],z);dfs(y,x);    }   }   int main(){    scanf( %d%d%d%d ,&n,&qu,&s,&d);cmp_cnt=n;    for(int i=1;i<=n;i++){     scanf( %d ,&a[i]);st.insert(a[i]);     pos[a[i]]=i;cmp[i].insert(i);    }    while(cmp_cnt>1){     vector<pair<int,pii> > ed;     for(int i=1;i<=n;i++) if(!cmp[i].empty()){      for(int x:cmp[i]) st.erase(st.find(a[x]));      for(int x:cmp[i]){       for(int j=-1,v=-d;j<=1;j++,v=j*d) if(j!=0){        auto it=st.lower_bound(a[x]+v);        if(it!=st.end()) ed.pb(mp(abs(abs(a[x]-(*it))-d),mp(x,pos[*it])));        if(it!=st.begin()){--it;ed.pb(mp(abs(abs(a[x]-(*it))-d),mp(x,pos[*it])));}       }      }      for(int x:cmp[i]) st.insert(a[x]);     } sort(ed.begin(),ed.end());     for(int i=0;i<ed.size();i++){      int w=ed[i].fi,x=ed[i].se.fi,y=ed[i].se.se;      if(merge(x,y)) adde(x,y,w),adde(y,x,w);     }    } dfs(s,0);    while(qu--){     int x,k;scanf( %d%d ,&x,&k);     printf( %s n ,(mx[x]<=k)? Yes : No );    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[105][2005];   int main() {     memset(dp, -1, sizeof(dp));     int v1, v2, t, d;     cin >> v1 >> v2 >> t >> d;     dp[1][v1] = v1;     for (int i = 1; i < t; i++)       for (int j = 0; j < 2005; j++)         if (dp[i][j] != -1)           for (int k = -d; k <= d; k++)             if (j + k >= 0)               dp[i + 1][j + k] = max(dp[i + 1][j + k], dp[i][j] + j + k);     if (dp[t][v2] == -1)       cout <<  0 n ;     else       cout << dp[t][v2] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 9223372036854775807ll;   const long long dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, inf = 2147483647,                   nmax = 300005;   struct trip {     long long a, b, c;   };   long long n, m, s[nmax];   vector<pair<long long, long long> > neg, poz;   vector<trip> sol;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> m;     for (long long i = 1; i <= m; ++i) {       long long x, y, w;       cin >> x >> y >> w;       s[x] -= w;       s[y] += w;     }     for (long long i = 1; i <= n; ++i) {       if (s[i] > 0) poz.push_back({i, s[i]});       if (s[i] < 0) neg.push_back({i, -s[i]});     }     while (poz.size() && neg.size()) {       long long x = min(poz.back().second, neg.back().second);       long long a = neg.back().first, b = poz.back().first;       sol.push_back({a, b, x});       poz.back().second -= x;       neg.back().second -= x;       if (poz.back().second == 0) poz.pop_back();       if (neg.back().second == 0) neg.pop_back();     }     cout << sol.size() <<   n ;     for (auto x : sol) cout << x.a <<     << x.b <<     << x.c <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using vll = vector<ll>;   using vii = vector<int>;   using pii = pair<int, int>;   template <typename T = vii>   using vec = vector<T>;   const ll INF = 1e18, MOD = 998244353;   const int MAX = 1e6;   ll ft[MAX + 1];   void cf() {     ft[0] = 1;     for (int i = 1; i <= MAX; i++) {       ft[i] = (i * ft[i - 1]) % MOD;     }   }   int main() {     cin.tie(NULL);     ios_base::sync_with_stdio(false);     cf();     int n;     cin >> n;     unordered_map<int, int> cnt;     for (int i = 1; i < n; i++) {       int u, v;       cin >> u >> v;       u--, v--;       cnt[u]++;       cnt[v]++;     }     ll res = 1;     for (auto p : cnt) {       (res *= ft[p.second]) %= MOD;     }     cout << (n * res) % MOD <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long T, n, tempur;   int t[105], l[105], h[105];   int main() {     cin >> T;     while (T--) {       memset(t, 0, sizeof t);       memset(h, 0, sizeof h);       memset(l, 0, sizeof l);       cin >> n >> tempur;       int maxn = tempur, minn = tempur;       for (int i = 1; i <= n; i++) {         cin >> t[i] >> l[i] >> h[i];       }       int f = 0;       for (int i = 1; i <= n; i++) {         maxn += t[i] - t[i - 1];         minn -= t[i] - t[i - 1];         if ((h[i] >= minn && l[i] <= maxn) || (h[i] <= maxn && l[i] >= minn)) {           maxn = min(maxn, h[i]);           minn = max(minn, l[i]);         } else {           f = 1;           break;         }       }       if (!f)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     long long N, B;     cin >> N >> B;     vector<long long> res(N, -1);     queue<pair<long long, long long> > Q;     long long endTime = -1;     for (long long i = 0; i < N; i++) {       long long t, d;       cin >> t >> d;       while (endTime <= t) {         if (Q.size()) {           res[Q.front().second] = endTime = endTime + Q.front().first;           Q.pop();         } else {           endTime = t;           break;         }       }       if (Q.size() < B) {         Q.push({d, i});       }     }     while (Q.size()) {       res[Q.front().second] = endTime = endTime + Q.front().first;       Q.pop();     }     for (long long i = 0; i < N; i++) cout << res[i] <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int N;   int A[100005];   int psm[100005];   int DP[100005][20];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> N;     for (int i = 1; i <= N; i++) {       cin >> A[i];       psm[i] = (psm[i - 1] + A[i]) % 10;     }     for (int d = 1; d <= 17; d++) {       if ((1 << d) > N) break;       int l = (1 << d);       for (int i = 1; i <= N; i++) {         if (i + l - 1 > N) break;         int m = i + l / 2 - 1;         int r = i + l - 1;         DP[i][d] =             DP[i][d - 1] + DP[m + 1][d - 1] +             ((psm[m] - psm[i - 1] + 10) % 10 + (psm[r] - psm[m] + 10) % 10 >= 10);       }     }     int Q;     int l, r;     cin >> Q;     while (Q--) {       cin >> l >> r;       int ln = (r - l + 1), d = 0;       while (ln > 1) {         d++, ln /= 2;       }       cout << DP[l][d] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using ll = long long;   using ld = long double;   using ull = unsigned long long;   using namespace std;   const int N = 2002, NN = 502, mod = 1e9 + 7, mod1 = 1e9 + 9, Base = 317,             Base1 = 371;   int n, K, pw[NN], pw1[NN], lcp[N], mn[N][11], id[N];   string s[N];   struct Hash {     vector<pair<int, int> > hs;     Hash() {}     Hash(const string &s) : hs(((int)(s).size()) + 1, {0, 0}) {       for (int i = (1); i <= (((int)(s).size())); ++i)         hs[i] = {(hs[i - 1].first * 1LL * Base + s[i - 1]) % mod,                  (hs[i - 1].second * 1LL * Base1 + s[i - 1]) % mod1};     }     pair<int, int> query(int l, int r) {       pair<int, int> h = {           hs[r].first - hs[l - 1].first * 1LL * pw[r - l + 1] % mod,           hs[r].second - hs[l - 1].second * 1LL * pw1[r - l + 1] % mod1};       if (h.first < 0) h.first += mod;       if (h.second < 0) h.second += mod;       return h;     }   } hs[N];   int getLcp(const int &A, const int &B) {     int l = 1, r = min(((int)(s[A]).size()), ((int)(s[B]).size()));     while (l <= r) {       int m = (l + r) >> 1;       if (hs[A].query(1, m) == hs[B].query(1, m))         l = m + 1;       else         r = m - 1;     }     return r;   }   bool cmp(const int &A, const int &B) {     int r = getLcp(A, B);     if (r == ((int)(s[B]).size())) return 0;     if (r == ((int)(s[A]).size())) return 1;     return s[A][r] < s[B][r];   }   int queryLcp(int l, int r) {     int k = 31 - __builtin_clz(r - l + 1);     return min(mn[l][k], mn[r - (1 << k) + 1][k]);   }   vector<int> solve(int l, int r) {     if (l == r) return vector<int>(2, 0);     vector<int> dp(r - l + 2, 0);     int mid = l + 1;     for (int i = (l + 2); i <= (r); ++i)       if (lcp[i] < lcp[mid]) mid = i;     vector<int> dpLeft = solve(l, mid - 1), dpRight = solve(mid, r);     for (int i = (0); i <= (mid - l); ++i)       for (int j = (0); j <= (r - mid + 1); ++j)         dp[i + j] = max(dp[i + j], dpLeft[i] + dpRight[j] + i * j * lcp[mid]);     return dp;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n >> K;     for (int i = (1); i <= (n); ++i) cin >> s[i], id[i] = i, hs[i] = Hash(s[i]);     sort(id + 1, id + 1 + n, cmp);     for (int i = (2); i <= (n); ++i) lcp[i] = getLcp(id[i - 1], id[i]);     cout << solve(1, n)[K];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int k;   int main() {     cin >> n >> k;     int l = (n - 1) / k * 2 + ((n - 1) % k != 0) + ((n - 1) % k >= 2);     cout << l << endl;     for (int i = 1; i < n; i++) {       if (i <= k)         cout << i + 1 <<     << 1 << endl;       else         cout << i + 1 <<     << i + 1 - k << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e6 + 5, mod = 1e9 + 7, inf = 1e18;   long long n, q, a[maxn], mx[2ll][maxn];   pair<long long, long long> dp[2ll][maxn];   void cal_mx0(long long x) {     long long l = n - 1ll, sum = a[n];     for (long long i = n; i > 0; i--) {       if (l == 0) {         mx[0][i] = 1;         sum -= a[i];         continue;       }       while ((l > 0) && (sum + a[l] <= x)) {         sum += a[l];         l--;       }       mx[0][i] = l + 1ll;       sum -= a[i];     }   }   void cal_mx1(long long x) {     long long r = 2ll, sum = a[1];     for (long long i = 1; i <= n; i++) {       if (r == n + 1ll) {         mx[1][i] = n;         sum -= a[i];         continue;       }       while ((r <= n) && (sum + a[r] <= x)) {         sum += a[r];         r++;       }       mx[1][i] = r - 1ll;       sum -= a[i];     }   }   void cal_dp0() {     long long sum = 0;     for (long long i = 1; i <= n; i++) {       sum += a[i];       if (mx[0][i] == 1) {         dp[0][i] = {1, sum};         continue;       }       dp[0][i].first = dp[0][mx[0][i] - 1ll].first + 1ll;       dp[0][i].second = dp[0][mx[0][i] - 1ll].second;     }   }   void cal_dp1() {     long long sum = 0;     for (long long i = n; i > 0; i--) {       sum += a[i];       if (mx[1][i] == n) {         dp[1][i] = {1, sum};         continue;       }       dp[1][i].first = dp[1][mx[1][i] + 1ll].first + 1ll;       dp[1][i].second = dp[1][mx[1][i] + 1ll].second;     }   }   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n >> q;     long long second = 0;     for (long long i = 1; i <= n; i++) {       cin >> a[i];       second += a[i];     }     a[n + 1ll] = inf;     a[0] = inf;     while (q--) {       long long x;       cin >> x;       if (x >= second) {         cout << 1 <<   n ;         continue;       }       cal_mx0(x);       cal_mx1(x);       cal_dp0();       cal_dp1();       long long ans = min(dp[0][n].first, dp[1][1].first);       for (long long i = 1; i < n; i++) {         long long z = 0;         if ((dp[0][i].second + dp[1][i + 1ll].second) <= x) z = 1ll;         ans = min(ans, dp[0][i].first + dp[1ll][i + 1ll].first - z);       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     char a[2 * n - 1][2 * n - 1];     int v = 0, k = n;     for (int i = 0; i < n; i++, k--, v++) {       for (int j = 0; j < k; j++) printf(    );       for (int j = 0; j < v; j++) printf( %d  , j);       printf( %d , v);       for (int j = v - 1; j >= 0; j--) printf(  %d , j);       printf(  n );     }     for (int i = 0; i < n; i++) printf( %d  , i);     printf( %d , n);     for (int i = n - 1; i >= 0; i--) printf(  %d , i);     for (int i = 0, k = 1, v = n - 1; i < n; i++, k++, v--) {       printf(  n );       for (int j = 0; j < k; j++) printf(    );       for (int j = 0; j < v; j++) printf( %d  , j);       printf( %d , v);       for (int j = v - 1; j >= 0; j--) printf(  %d , j);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     int n, m, k, ans = 0;     cin >> n >> m >> k;     vector<int> a(n + 1), b(n + 1), c(k + 1);     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) cin >> b[i];     for (int i = 1; i <= k; i++) cin >> c[i];     for (int i = 1; i <= k; i++) {       int curp = a[c[i]], curid = b[c[i]];       for (int j = 1; j <= n; j++) {         if (b[j] == curid && curp < a[j]) {           ans++;           a[c[i]] = 0;           b[c[i]] = 0;           break;         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   uint64_t mat[5][5] = {{0, 0, 1, 0, 0},                         {1, 0, 1, 0, 0},                         {0, 1, 1, 0, 0},                         {0, 0, 1, 1, 0},                         {0, 0, 0, 1, 1}};   uint64_t ex[5][5] = {{0, 0, 0, 0, 0},                        {0, 0, 0, 0, 0},                        {0, 0, 0, 0, 0},                        {0, 0, 0, 0, 0},                        {0, 0, 0, 0, 0}};   static const uint64_t mod = 1000000000 + 6;   static const uint64_t mod2 = 1000000000 + 7;   void mult(int i) {     uint64_t tmp[5][5];     uint64_t tmp2[5][5];     if (i == 1) {       for (int c = 0; c < 5; c++) {         for (int d = 0; d < 5; d++) {           tmp[c][d] = ex[c][d];         }       }     } else {       for (int c = 0; c < 5; c++) {         for (int d = 0; d < 5; d++) {           tmp[c][d] = mat[c][d];         }       }     }     for (int c = 0; c < 5; c++) {       for (int d = 0; d < 5; d++) {         tmp2[c][d] = ex[c][d];       }     }     for (int c = 0; c < 5; c++) {       for (int d = 0; d < 5; d++) {         ex[c][d] = 0;         for (int k = 0; k < 5; k++) {           ex[c][d] += (tmp2[c][k] * tmp[k][d]) % mod;           ex[c][d] %= mod;         }       }     }   }   void expo(uint64_t n) {     if (n == 1) {       for (int c = 0; c < 5; c++) {         for (int d = 0; d < 5; d++) {           ex[c][d] = mat[c][d];         }       }       return;     }     if (n % 2 == 0) {       expo(n / 2);       mult(1);     } else {       expo(n - 1);       mult(0);     }   }   static inline uint64_t calcCoeff(uint64_t a[5]) {     uint64_t ans = 0;     for (int c = 0; c < 5; c++) {       ans += (a[c] * ex[c][2]) % mod;       ans %= mod;     }     return ans;   }   uint64_t sexp(uint64_t a, uint64_t n) {     if (n == 0) {       return 1;     }     if (n % 2 == 0) {       uint64_t ans = sexp(a, n / 2);       return (ans * ans) % mod2;     } else {       return (a * sexp(a, n - 1)) % mod2;     }   }   int main(void) {     uint64_t n, f1, f2, f3, mc;     cin >> n >> f1 >> f2 >> f3 >> mc;     expo(n - 3);     uint64_t nf1, nf2, nf3;     uint64_t nc;     uint64_t a, b, c;     {       uint64_t init[5] = {1, 0, 0, 0, 0};       nf1 = calcCoeff(init);     }     {       uint64_t init[5] = {0, 1, 0, 0, 0};       nf2 = calcCoeff(init);     }     {       uint64_t init[5] = {0, 0, 1, 0, 0};       nf3 = calcCoeff(init);     }     {       uint64_t init[5] = {0, 0, 0, 2, 2};       nc = calcCoeff(init);     }     uint64_t ans = (((sexp(f1, nf1) * sexp(f2, nf2)) % mod2 * sexp(f3, nf3)) %                     mod2 * sexp(mc, nc)) %                    mod2;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int low(int a) {     if (a == 1) {       return 0;     }     return 1;   }   int main() {     int t;     cin >> t;     string s;     cin >> s;     stack<char> st;     st.push(s[0]);     int c = 0;     for (int i = 1; i < t; i++) {       if (st.top() == s[i]) {         c++;       } else {         st.push(s[i]);       }     }     cout << c;   }