malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const unsigned long long x = 31;   unsigned long long X[60000];   int Ql[20], Qr[20];   char str[60000], s[60000];   int N;   map<unsigned long long, int> T[20];   map<unsigned long long, bool> A;   void add(int index, unsigned long long H) { T[index][H] = T[index][H] + 1; }   void CalcHashes(char s[], int index) {     unsigned long long H;     int i, j, L = strlen(s);     for (i = 1; i <= L; i++) {       H = 0;       for (j = 0; j < i; j++) H += X[i - j - 1] * (s[j] -  a  + 1);       add(index, H);       for (j = i; j < L; j++) {         H = (H - X[i - 1] * (s[j - i] -  a  + 1)) * x + (s[j] -  a  + 1);         add(index, H);       }     }   }   int answer;   void check(unsigned long long H) {     if (A[H]) return;     A[H] = true;     int i, t;     bool v = true;     for (i = 0; i < N && v; i++) {       t = T[i][H];       if (t < Ql[i] || Qr[i] < t) v = false;     }     if (v) answer++;   }   int main() {     unsigned long long H;     int i, j, L;     for (X[0] = 1, i = 1; i <= 60000; i++) X[i] = X[i - 1] * x;     scanf( %s , str);     scanf( %d , &N);     for (i = 0; i < N; i++) {       scanf( %s%d%d , &s, &Ql[i], &Qr[i]);       CalcHashes(s, i);     }     L = strlen(str);     for (i = 1; i <= L; i++) {       H = 0;       for (j = 0; j < i; j++) H += X[i - j - 1] * (str[j] -  a  + 1);       check(H);       for (j = i; j < L; j++) {         H = (H - X[i - 1] * (str[j - i] -  a  + 1)) * x + (str[j] -  a  + 1);         check(H);       }     }     printf( %d , answer);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i;     scanf( %d , &n);     for (i = 1; i <= (n / 2); i++) {       if (i & 1)         cout <<  ab ;       else         cout <<  ba ;     }     int k = n / 2;     if (n & 1) {       if ((k) % 2 == 0)         printf( a );       else         printf( b );     }   }
#include<bits/stdc++.h>   using namespace std;      int main(){    int t,n,x;    set<int> notes;    cin>>t;    while(t--){     cin>>n;     notes.clear();     for(int i=0;i<n;i++){      cin>>x;      if(notes.find(x)==notes.end()){       notes.insert(x);      }else{       notes.insert(x+1);      }     }     cout<<notes.size()<<endl;    }   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e6 + 7;   struct node {     long long l, r, i;   };   bool cmp(node &a, node &b) { return a.l < b.l; }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t;     t = 1;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long x, y;       bool flag = 0;       vector<long long> ans(n);       vector<node> a;       for (long long i = 0; i < n; i++) {         cin >> x >> y;         a.push_back({x, y, i});       }       sort((a).begin(), (a).end(), cmp);       long long p = -1;       x = a[0].r;       for (long long i = 1; i < n; i++) {         if (x < a[i].l) {           p = i;           break;         }         x = max(x, a[i].r);       }       if (p == -1)         cout << -1 <<   n ;       else {         for (long long i = 0; i < p; i++) ans[a[i].i] = 1;         for (long long i = p; i < n; i++) ans[a[i].i] = 2;         for (auto i : ans) cout << i <<    ;         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   const double eps = 1e-9;   const int inf = 1e9;   int deg[N];   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n, x;       scanf( %d%d , &n, &x);       for (int i = 0; i < n + 10; i++) deg[i] = 0;       for (int i = 1; i < n; i++) {         int u, v;         scanf( %d%d , &u, &v);         deg[u]++;         deg[v]++;       }       if (deg[x] < 2)         printf( Ayush n );       else {         if (n & 1)           printf( Ashish n );         else           printf( Ayush n );       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     cout <<  YES n ;     for (int i = 1; i <= n; i++) {       int x1, x2, y1, y2;       cin >> x1 >> y1 >> x2 >> y2;       cout << (2 * ((x1 % 2 + 2) % 2) + (y1 % 2 + 2) % 2) + 1 <<   n ;     }   }
#include <bits/stdc++.h>   int sm(int a, int b) {     if (a % b == 0)       return b;     else       return a % b;   }   int main() {     int n, m, s;     scanf( %d%d%d , &n, &m, &s);     printf( %I64d , (long long)sm(n, s) * sm(m, s) * ((n - 1) / s + 1) *                         ((m - 1) / s + 1));   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e17 + 9;   long long n, m;   vector<int> num;   long long dp[100009][2];   void solve(int tp) {     multiset<int> s;     multiset<int>::iterator it;     if (tp == 0) {       for (long long i = 1; i < (m + 1); ++i) {         s.insert(num[i]);         it = s.upper_bound(num[i]);         if (it != s.end()) s.erase(it);         dp[i][tp] = (long long)(s).size();       }     } else {       for (long long i = m + 1 - 1; i >= 1; i--) {         s.insert(num[i]);         it = s.upper_bound(num[i]);         if (it != s.end()) s.erase(it);         dp[i][tp] = (long long)(s).size();       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m;     long long acum[100009];     memset(acum, 0, sizeof acum);     for (long long i = 0; i < (n); ++i) {       long long a, b;       cin >> a >> b;       acum[a]++;       acum[b + 1]--;     }     for (long long i = 1; i < (m + 2); ++i) {       acum[i] += acum[i - 1];     }     for (long long i = 0; i < (m + 1); ++i) {       num.push_back(acum[i]);     }     solve(0);     solve(1);     long long ans = 0;     for (long long i = 1; i < (m + 1); ++i) {       ans = max({dp[i][0] + dp[i][1] - 1, ans});     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i;     cin >> n;     pair<int, int> a[n];     for (i = 0; i < n; i++) {       cin >> a[i].first;       a[i].second = i + 1;     }     sort(a, a + n);     int ans = a[0].first / max(a[0].second - 1, n - a[0].second);     for (i = 1; i < n - 1; i++)       ans = min(ans, a[i].first / max(a[i].second - 1, n - a[i].second));     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class substr {    public:     string str;     int id;     bool operator<(const substr &a) const { return str > a.str; }   };   priority_queue<substr> Q;   int main() {     string s;     int k, n;     cin >> s >> k;     n = s.length();     for (int i = 0; i < n; i++) {       substr a;       a.str = s[i];       a.id = i;       Q.push(a);     }     while (!Q.empty()) {       substr p;       p = Q.top();       Q.pop();       k--;       if (!k) {         cout << p.str << endl;         return 0;       }       if (p.id != n - 1) {         p.str = p.str + s[p.id + 1];         p.id = p.id + 1;         Q.push(p);       }     }     cout <<  No such line.  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dp[1 << 20][20], p[20][20];   bool mark[1 << 20][20];   int n;   double mem(int mask, int winner) {     if (!mask) return (winner == 1);     if (mark[mask][winner]) return dp[mask][winner];     mark[mask][winner] = true;     double &ret = dp[mask][winner];     for (int i = 1; i < n; i++)       if (mask & (1 << i)) {         double tmp = 0;         tmp += p[i][winner] * mem(mask ^ (1 << i), i);         tmp += p[winner][i] * mem(mask ^ (1 << i), winner);         ret = max(ret, tmp);       }     return ret;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     for (int i = 1; i <= n; i++) {       p[i][0] = 1;       for (int j = 1; j <= n; j++) cin >> p[i][j];     }     n++;     cout << setprecision(10) << fixed << mem((1 << n) - 2, 0) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = int(1e9) + 7;   int main() {     ios::sync_with_stdio(false);     ios_base::sync_with_stdio(false);     long long n, m;     cin >> n >> m;     vector<long long> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     if (n >= 1001) {       cout << 0;       return 0;     }     long long res = 1;     for (int i = 0; i < n; ++i)       for (int j = i + 1; j < n; ++j) res = (res * (abs(a[i] - a[j]))) % m;     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int dp[100005];     vector<int> t;     vector<pair<int, int> > p;     int r, n;     cin >> r >> n;     t.push_back(0);     p.push_back(make_pair(1, 1));     for (int i = 0; i < n; i++) {       dp[i] = 0;       int x, y;       cin >> x;       t.push_back(x);       cin >> x >> y;       p.push_back(make_pair(x, y));     }     int maxi = 0, ans = 0;     dp[n] = 0;     for (int i = n; i >= 0; i--) {       for (int j = i - 1; j >= max(0, i - 2000); j--) {         int dif = abs(p[i].first - p[j].first) + abs(p[i].second - p[j].second);         if (dif <= abs(t[i] - t[j])) {           dp[j] = max(dp[j], dp[i] + 1);         }       }     }     cout << dp[0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 10005;   void solve() {     string s;     cin >> s;     int n = s.size();     s =  a  + s;     set<int> one, zero;     vector<int> ans[n];     for (int i = 0; i < n; i++) zero.insert(i);     for (int i = 1; i <= n; i++) {       if (s[i] ==  0 ) {         if (zero.size() == 0) {           cout << -1;           return;         } else {           auto it = zero.begin();           int val = *it;           ans[val].push_back(i);           zero.erase(it);           one.insert(val);         }       } else {         if (one.size() == 0) {           cout << -1;           return;         } else {           auto it = one.begin();           int val = *it;           ans[val].push_back(i);           one.erase(it);           zero.insert(val);         }       }     }     int cnt = 0;     for (int i = 0; i < n; i++) {       if (ans[i].size() == 0) break;       if (s[ans[i][ans[i].size() - 1]] ==  1 ) {         cout <<  -1 ;         return;       }       cnt++;     }     cout << cnt <<   n ;     for (int i = 0; i < cnt; i++) {       cout << ans[i].size() <<    ;       for (auto X : ans[i]) cout << X <<    ;       cout <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     srand(time(NULL));     ;     int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int a[3010], id[3010], num[3010];   vector<int> ans;   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     int m;     scanf( %d , &m);     int need = n - m;     while (true) {       int tot = 0;       memset(id, -1, sizeof(id));       memset(num, 0, sizeof(num));       for (int i = 1; i <= n; i++) {         if (id[i] == -1) {           id[i] = tot;           int now = a[i];           while (now != i) {             id[now] = tot;             now = a[now];           }           tot++;         }       }       for (int i = 1; i <= n; i++) {         num[id[i]]++;       }       if (tot == need) break;       if (tot > need) {         for (int i = 2; i <= n; i++) {           if (id[i] != id[1]) {             ans.push_back(1);             ans.push_back(i);             swap(a[1], a[i]);             break;           }         }       } else {         for (int i = 1; i <= n; i++) {           if (num[id[i]] == 1) continue;           for (int j = i + 1; j <= n; j++) {             if (id[i] == id[j]) {               ans.push_back(i);               ans.push_back(j);               swap(a[i], a[j]);               break;             }           }           break;         }       }     }     printf( %d n , ans.size() / 2);     for (int i = 0; i < ans.size(); i++) {       if (i) printf(   );       printf( %d , ans[i]);     }     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     int fl = 1;     cin >> s;     for (int i = 0; i < s.size(); ++i) {       if (s[i] ==  1  || s[i] ==  2 )         fl = 0;       else if (s[i] ==  3  && s[s.size() - i - 1] !=  3 )         fl = 0;       else if (s[i] ==  7  && s[s.size() - i - 1] !=  7 )         fl = 0;       else if (s[i] ==  4  && s[s.size() - i - 1] !=  6 )         fl = 0;       else if (s[i] ==  6  && s[s.size() - i - 1] !=  4 )         fl = 0;       else if (s[i] ==  5  && s[s.size() - i - 1] !=  9 )         fl = 0;       else if (s[i] ==  9  && s[s.size() - i - 1] !=  5 )         fl = 0;       else if (s[i] ==  8  && s[s.size() - i - 1] !=  0 )         fl = 0;       else if (s[i] ==  0  && s[s.size() - i - 1] !=  8 )         fl = 0;     }     if (fl == 1)       cout <<  Yes ;     else       cout <<  No ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool debug;   const int inf = 1e9 + 5;   const int nax = 205;   int k;   namespace MinCost {   struct Edge {     int w, c, v, rev;     Edge(int _w, int _c, int _v, int _rev) : w(_w), c(_c), v(_v), rev(_rev) {}   };   int odl[nax], pot[nax], pop[nax], pop_kraw[nax];   vector<Edge> v[nax];   bool bylo[nax];   void init(int n) {     for (int i = 0; i <= n; ++i) v[i].clear();   }   void AddEdge(int a, int b, int cap, int cost) {     v[a].push_back(Edge(b, cap, cost, int(v[b].size()) + (a == b)));     v[b].push_back(Edge(a, 0, -cost, int(v[a].size() - 1)));   }   pair<int, int> MinCostMaxFlow(int s, int t, int n) {     int flow = 0, cost = 0;     for (int i = 0; i <= n; ++i) pot[i] = 0;     while (true) {       for (int i = 0; i <= n; ++i) {         odl[i] = inf;         bylo[i] = false;       }       odl[s] = 0;       for (int k = 0; k <= (n)-1; ++k) {         int x = 0;         int najm = inf;         for (int i = 0; i <= n; ++i)           if (!bylo[i] && najm > odl[i]) {             x = i;             najm = odl[i];           }         bylo[x] = true;         int dl = v[x].size();         for (int i = 0; i <= (dl)-1; ++i)           if (v[x][i].c > 0 &&               odl[v[x][i].w] > odl[x] + pot[x] - pot[v[x][i].w] + v[x][i].v) {             odl[v[x][i].w] = odl[x] + pot[x] - pot[v[x][i].w] + v[x][i].v;             pop[v[x][i].w] = x;             pop_kraw[v[x][i].w] = i;           }       }       if (odl[t] == inf) break;       for (int i = 0; i <= n; ++i) pot[i] += odl[i];       int x = t;       int cap = inf;       while (x != s) {         cap = min(cap, v[pop[x]][pop_kraw[x]].c);         x = pop[x];       }       x = t;       int one_path_cost = 0;       while (x != s) {         one_path_cost += v[pop[x]][pop_kraw[x]].v;         v[pop[x]][pop_kraw[x]].c -= cap;         v[x][v[pop[x]][pop_kraw[x]].rev].c += cap;         x = pop[x];       }       int ile_zmiesci = one_path_cost ? (k - cost) / one_path_cost : inf;       cost += min(cap, ile_zmiesci) * one_path_cost;       flow += min(cap, ile_zmiesci);       if (ile_zmiesci < cap) break;     }     return make_pair(flow, cost);   }   };  // namespace MinCost   using namespace MinCost;   int n, a;   int main(int argc, char* argv[]) {     scanf( %d%d , &n, &k);     init(n - 1);     for (int i = 0; i <= (n)-1; ++i)       for (int j = 0; j <= (n)-1; ++j) {         scanf( %d , &a);         if (a > 0) {           AddEdge(i, j, a, 0);           AddEdge(i, j, k, 1);         }       }     printf( %d n , MinCostMaxFlow(0, n - 1, n - 1).first);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int num[10];   int main(void) {     int T, n;     scanf( %d , &T);     while (T--) {       memset(num, 0, sizeof(num));       scanf( %d , &n);       num[1] = n / 2;       if (n & 01) {         printf( 7 );         for (int i = 1; i < num[1]; ++i) printf( 1 );       } else         for (int i = 0; i < num[1]; ++i) printf( 1 );       if (T) printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   int tree[2000005] = {0}, num[500005] = {0}, dp[500005] = {1};   void modify(int index, int l, int r, int ql, int qr, int v) {     if (ql <= l && qr >= r) {       tree[index] = v;       return;     }     int mid = (l + r) >> 1;     if (ql <= mid && qr >= l) modify(index << 1, l, mid, ql, qr, v);     if (ql <= r && qr >= mid + 1) modify(index << 1 | 1, mid + 1, r, ql, qr, v);     tree[index] = max(tree[index << 1], tree[index << 1 | 1]);   }   int query(int index, int l, int r, int ql, int qr) {     if (ql <= l && qr >= r) return tree[index];     int mid = (l + r) >> 1, ans = 0;     if (ql <= mid && qr >= l) ans = max(ans, query(index << 1, l, mid, ql, qr));     if (ql <= r && qr >= mid + 1)       ans = max(ans, query(index << 1 | 1, mid + 1, r, ql, qr));     return ans;   }   int main() {     int i, n, k, d, index = 0;     scanf( %d%d%d , &n, &k, &d);     for (i = 1; i <= n; i++) scanf( %d , &num[i]);     sort(num + 1, num + n + 1);     modify(1, 0, n, 0, 0, 1);     for (i = 1; i <= n; i++) {       while (num[i] > num[index] + d) index++;       if (i - k >= index - 1)         dp[i] = query(1, 0, n, index - 1, i - k);       else         dp[i] = 0;       modify(1, 0, n, i, i, dp[i]);     }     if (dp[n])       puts( YES );     else       puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, k;     long long res = 0;     cin >> n >> m >> k;     map<int, long long> dp;     bool arr[n + 1], s[m + 1];     for (int i = 0; i < n; i++) cin >> arr[i];     arr[n] = 0;     for (int i = 0; i < m; i++) cin >> s[i];     s[m] = 0;     int ones = 0;     for (int i = 0; i < n + 1; i++) {       if (arr[i])         ones++;       else if (ones) {         if (dp.find(ones) != dp.end()) {           res += dp[ones];           ones = 0;           continue;         }         int tones = 0;         long long dpres = 0;         long long prev = 0;         for (int j = 0; j < m + 1; j++) {           if (s[j]) {             tones++;             dpres += prev;             if (k % tones == 0 && tones * ones >= k) {               dpres += ones - (k / tones) + 1;               prev += ones - (k / tones) + 1;             }           } else {             tones = 0;             prev = 0;           }         }         dp[ones] = dpres;         res += dpres;         ones = 0;       }     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int n;   signed main() {     ios_base ::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> s;     vector<pair<int, int>> a;     vector<int> p(n, 0), nxt(n, 0);     stack<pair<int, int>> S;     S.push({0, -1});     for (int i = 0; i < n; ++i) {       if (s[i] ==  ( ) {         p[i] = S.top().second;         a.push_back({S.top().first + 1, i});         S.push({a.back().first, i});       } else {         nxt[S.top().second] = i;         S.pop();       }     }     sort(a.rbegin(), a.rend());     string k(n,  x );     for (int i = 0; i < int(a.size()); ++i) {       int y = a[i].second;       if (k[y] !=  x ) {         k[nxt[y]] = k[y];         continue;       }       int c = -1, cnt = 0;       for (y = a[i].second; y != -1 && k[y] ==  x ; y = p[y]) cnt ^= 1;       if (y != -1) c = k[y] -  0 ;       int t = 1;       if (c != -1) t = c ^ cnt;       for (y = a[i].second; y != -1 && k[y] ==  x ; t ^= 1, y = p[y])         k[y] = t +  0 ;       k[nxt[a[i].second]] = k[a[i].second];     }     cout << k <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<int> S;   void dfs(int Cur, int dgt, int x, int y) {     if (dgt == 11) return;     if (Cur > 0) S.insert(Cur);     dfs(Cur * 10 + x, dgt + 1, x, y);     dfs(Cur * 10 + y, dgt + 1, x, y);     return;   }   int main() {     int n, Ans = 0;     cin >> n;     S.insert(1e9);     for (int i = 0; i < 10; i++) {       for (int j = 0; j < 10; j++) {         dfs(0, 1, i, j);       }     }     for (auto x : S) {       if (x > n)         break;       else         Ans++;     }     cout << Ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     while (scanf( %d , &n) != EOF) {       for (int i = 0; i <= n; i++) {         int space = (n - i) * 2;         for (int j = 0; j < space; j++) printf(   );         if (!i)           printf( %d n , 0);         else {           for (int j = 0; j <= i; j++) printf( %d  , j);           for (int j = i - 1; j > 0; j--) printf( %d  , j);           printf( %d n , 0);         }       }       for (int i = n - 1; i >= 0; i--) {         int space = (n - i) * 2;         for (int j = 0; j < space; j++) printf(   );         if (!i)           printf( %d n , 0);         else {           for (int j = 0; j <= i; j++) printf( %d  , j);           for (int j = i - 1; j > 0; j--) printf( %d  , j);           printf( %d n , 0);         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, l, r, x, y, o, e, w, z, b[50000], aa, bb, ans;   vector<int> vec;   map<int, int> ma;   int main() {     ios_base ::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> l >> r >> x >> y;     if (y % x != 0) {       cout << 0 << endl;       return 0;     } else       y /= x;     for (int i = 2; i * i <= y; i++)       if (y % i == 0) {         vec.push_back(i);         while (y % i == 0) {           y /= i;           ma[i]++;         }       }     if (y > 1) {       vec.push_back(y);       ma[y]++;     }     z = vec.size();     for (int i = 0; i < (1 << z); i++) {       w = i;       for (int j = 0; j < z; j++) b[j] = 0;       o = 0;       while (w) {         b[o] = w & 1;         w >>= 1;         o++;       }       aa = bb = 1;       for (int j = 0; j < z; j++)         if (b[j] == 1) {           e = ma[vec[j]];           for (int h = 1; h <= e; h++) aa *= vec[j];         } else {           e = ma[vec[j]];           for (int h = 1; h <= e; h++) bb *= vec[j];         }       if (l <= aa * x && aa * x <= r && l <= bb * x && bb * x <= r) ans++;     }     cout << ans << endl;     return 0;   }
#include<bits/stdc++.h>    using namespace std;    #define ll long long   int main() {    ll k,l,r,t,x,y;    cin>>k>>l>>r>>t>>x>>y;    if(k<l || k>r) {        cout<< No <<endl; return 0;    }    if(x>y) {        if(k+y>r) k-=x; t--;        if(k<l) return cout<< No <<endl,0;        if((k-l)/(x-y) < t ) {            cout<< No <<endl; return 0;        }        cout<< Yes <<endl; return 0;    }    else {        vector<bool> was(x,false);        while(t>0) {            if(was[k%x]) return cout<< Yes <<endl,0;            was[k%x]=true;            ll remd=min(t,(k-l)/x);            k-=remd*x;            t-=remd;            if(t==0) return cout<< Yes <<endl,0;            t--;            if(k+y<=r) k+=y;            k=k-x;            if(k<l || k>r) return cout<< No <<endl,0;        }        cout<< Yes <<endl;    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)3e5 + 99;   const long long INF = (long long)1e18 + 100;   int a[N];   int b[N];   long long dp[N][3];   int n;   long long calc(long long add, long long pos) {     long long &res = dp[pos][add];     if (res != -1) return res;     res = INF;     if (pos == n) return res = 0;     for (long long x = 0; x <= 2; x++) {       if (pos == 0 || a[pos] + x != a[pos - 1] + add)         res = min(res, calc(x, pos + 1) + x * (b[pos]));     }     return res;   }   void Solve() {     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i] >> b[i];     for (int i = 0; i <= n; i++) dp[i][0] = dp[i][1] = dp[i][2] = -1;     cout << calc(0, 0) <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     cin >> t;     while (t--) {       Solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     int cnt = 0;     for (int i = 0; i < n; i++) {       if (s[i] ==  + ) {         cnt++;       } else if (s[i] ==  -  && cnt) {         cnt--;       }     }     cout << cnt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool judge(int key) {     for (int i = 2; i * i <= key; i++) {       if (key % i == 0) return false;     }     return true;   }   int main() {     int n;     scanf( %d , &n);     if (n & 1 || n == 2) {       if (judge(n))         printf( 1 n );       else if (judge(n - 2))         printf( 2 n );       else         printf( 3 n );     } else       printf( 2 n );     return 0;   }