malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (a < 0) a = -a;     if (b < 0) b = -b;     return b == 0 ? a : gcd(b, a % b);   }   template <typename T>   void read(T &res) {     bool flag = false;     char ch;     while (!isdigit(ch = getchar())) (ch ==  - ) && (flag = true);     for (res = ch - 48; isdigit(ch = getchar());          res = (res << 1) + (res << 3) + ch - 48)       ;     flag && (res = -res);   }   long long lcm(long long a, long long b) { return a * b / gcd(a, b); }   long long qp(long long a, long long b, long long mod) {     long long ans = 1;     if (b == 0) {       return ans % mod;     }     while (b) {       if (b % 2 == 1) {         b--;         ans = ans * a % mod;       }       a = a * a % mod;       b = b / 2;     }     return ans % mod;   }   long long qpn(long long a, long long b, long long p) {     long long ans = 1;     a %= p;     while (b) {       if (b & 1) {         ans = (ans * a) % p;         --b;       }       a = (a * a) % p;       b >>= 1;     }     return ans % p;   }   char s[100006];   signed main() {     long long n, k;     read(n);     read(k);     scanf( %s , s + 1);     for (long long i = 1; i <= n - 1; i++) {       if (k == 0) {         break;       }       if (s[i] ==  4  && s[i + 1] ==  7 ) {         if (i % 2 == 1) {           s[i + 1] =  4 ;         } else {           if (s[i - 1] ==  4 ) {             if (k % 2 == 1) {               s[i] =  7 ;             } else {               s[i] =  4 ;             }             break;           } else {             s[i] =  7 ;           }         }         k--;       }     }     printf( %s , s + 1);   }
#include <bits/stdc++.h>   using namespace std;   void _read();   const int nax = 2001;   const int inf = 1e9 + 11;   void NO() {     cout <<  NO n ;     exit(0);   }   int mat[nax][nax];   using tp = tuple<int, int, int>;   struct Solution {     int n;     bool in_a[nax];     vector<vector<pair<int, int>>> adj;     void inp() {       cin >> n;       adj.resize(n + 1);       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) {           cin >> mat[i][j];           if (i == j && mat[i][j]) NO();           if (i != j && !mat[i][j]) NO();         }       }     }     void rec() {       vector<tuple<int, int, int>> vec;       for (int i = 2; i <= n; i++) {         vec.emplace_back(mat[i][1], 1, i);       }       sort((vec).begin(), (vec).end(), greater<tp>());       while (!vec.empty()) {         auto &[d, u, v] = vec.back();         adj[u].emplace_back(v, d);         adj[v].emplace_back(u, d);         vec.pop_back();         for (int i = 0; i < ((int)(vec).size()); i++) {           int a, b, c;           tie(a, b, c) = vec[i];           if (mat[v][c] < a) {             b = v;             a = mat[v][c];             vec[i] = {a, b, c};           }         }         sort((vec).begin(), (vec).end(), greater<tp>());       }     }     void bfs(int src) {       vector<int> dis(n + 1);       vector<int> q = {src};       vector<int> vis(n + 1);       vis[src] = 1;       dis[src] = 0;       for (int i = 0; i < ((int)(q).size()); i++) {         int u = q[i];         for (auto &[v, w] : adj[u]) {           if (vis[v]) continue;           vis[v] = 1;           dis[v] = dis[u] + w;           q.push_back(v);         }       }       for (int i = 1; i <= n; i++) {         if (dis[i] != mat[src][i]) NO();         if (dis[i] != mat[i][src]) NO();       }     }     void check() {       for (int i = 1; i <= n; i++) {         bfs(i);       }     }     void test() {       inp();       in_a[1] = true;       rec();       check();       cout <<  YES n ;     }   };   int main() {     _read();     Solution().test();     return 0;   };   void _read() {     ios_base ::sync_with_stdio(false);     cin.tie(NULL);   }
#include <bits/stdc++.h>   using namespace std;   string tsize[] = { S ,  M ,  L ,  XL ,  XXL };   int a[6];   int main() {     int n = 5;     for (int i = 0; i < 5; i++) {       cin >> a[i];     }     int m;     cin >> m;     for (int k = 0; k < m; k++) {       string tshirt;       cin >> tshirt;       int tcode = 0;       for (int i = 0; i < n; i++)         if (tsize[i] == tshirt) tcode = i;       for (int i = 0; i < n; i++) {         if (tcode + i < n && a[tcode + i] > 0) {           cout << tsize[tcode + i] << endl;           a[tcode + i]--;           break;         }         if (tcode - i >= 0 && a[tcode - i] > 0) {           cout << tsize[tcode - i] << endl;           a[tcode - i]--;           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300500;   int n, a[N];   vector<int> v;   int cnt[N];   vector<int> all;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       v.push_back(a[i]);     }     sort(v.begin(), v.end());     v.resize(unique(v.begin(), v.end()) - v.begin());     if (n == (int)v.size()) {       cout << -1;       return 0;     }     for (int i = 1; i <= n; ++i) {       a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;     }     vector<pair<int, int> > ans;     for (int i = 1; i <= n; ++i) {       int id = -1;       for (int j = i; j <= n; ++j) {         if (cnt[a[j]]) {           id = j;           break;         }         ++cnt[a[j]];       }       if (id == -1) {         ans[(int)ans.size() - 1].second = n;         break;       } else {         ans.push_back(make_pair(i, id));         for (int j = i; j <= id; ++j) cnt[a[j]] = 0;         i = id;       }     }     printf( %d n , (int)ans.size());     for (int i = 0; i < (int)ans.size(); ++i)       printf( %d %d n , ans[i].first, ans[i].second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int mod;   unsigned long long work(vector<int> &x) {     sort(x.begin(), x.end());     int n = x.size();     int m = x.end() - unique(x.begin(), x.end());     unsigned long long ret = 1;     for (int i = 2; i <= n; i++) {       unsigned long long tmp = i;       while (m > 0 && tmp % 2 == 0) tmp /= 2, m--;       ret = ret * tmp % mod;     }     return ret;   }   int main() {     vector<pair<int, int> > vec;     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int a;       scanf( %d , &a);       vec.push_back(pair<int, int>(a, i));     }     for (int i = 0; i < n; i++) {       int b;       scanf( %d , &b);       vec.push_back(pair<int, int>(b, i));     }     scanf( %d , &mod);     sort(vec.begin(), vec.end());     unsigned long long ans = 1;     for (int i = 0; i < n + n;) {       int nexti = i;       vector<int> tmp;       while (nexti < n + n && vec[i].first == vec[nexti].first) {         tmp.push_back(vec[nexti].second);         nexti++;       }       ans = ans * work(tmp) % mod;       i = nexti;     }     printf( %d n , (int)ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     int i, count1 = 0, count = 0;     cin >> s;     for (i = 0; i < s.length(); i++) {       if (s[i] ==  1 ) {         count++;         count1 = 0;         if (count == 7) {           cout <<  YES ;           return 0;         }       } else {         count = 0;         count1++;         if (count1 == 7) {           cout <<  YES ;           return 0;         }       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5009;   struct edge {     int to, nxt;   } e[N * 2];   int hd[N], tot;   void add(int u, int v) {     e[++tot] = (edge){v, hd[u]};     hd[u] = tot;   }   int n, leaf, lcnt[N], l[N];   void dfs1(int u, int fa) {     for (int i = hd[u], v; i; i = e[i].nxt) {       l[u]++;       if ((v = e[i].to) == fa) continue;       dfs1(v, u);     }     leaf += (l[u] == 1);   }   int f[N][N][2], g[N][2];   void dfs2(int u, int fa) {     if (l[u] == 1) {       f[u][0][0] = f[u][1][1] = 0;       lcnt[u] = 1;       return;     }     bool vst = 0;     for (int i = hd[u], v; i; i = e[i].nxt) {       if ((v = e[i].to) == fa) continue;       dfs2(v, u);       if (!vst) {         for (int k = 0; k <= lcnt[v]; k++)           f[u][k][0] = min(f[v][k][0], f[v][k][1] + 1),           f[u][k][1] = min(f[v][k][0] + 1, f[v][k][1]);       } else {         for (int j = 0; j <= min(lcnt[u], leaf / 2); j++)           for (int k = 0; k < 2; k++)             g[j][k] = f[u][j][k], f[u][j][k] = 0x3f3f3f3f;         for (int j = 0; j <= min(lcnt[u], leaf / 2); j++) {           for (int k = 0; k <= min(lcnt[v], leaf / 2 - j); k++) {             f[u][j + k][0] =                 min(f[u][j + k][0], g[j][0] + min(f[v][k][0], f[v][k][1] + 1));             f[u][j + k][1] =                 min(f[u][j + k][1], g[j][1] + min(f[v][k][1], f[v][k][0] + 1));           }         }       }       vst = 1;       lcnt[u] += lcnt[v];     }   }   int main() {     scanf( %d , &n);     if (n == 2) return puts( 2 ), 0;     for (int i = 1, u, v; i < n; i++) scanf( %d%d , &u, &v), add(u, v), add(v, u);     dfs1(1, 0);     memset(f, 0x3f, sizeof(f));     int root = 1;     while (l[root] == 1) root++;     dfs2(root, 0);     printf( %d , min(f[root][leaf / 2][0], f[root][leaf / 2][1]));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char a[60][60], b[60][60];   int dir[4][2] = {0, 1, 1, 0, -1, 0, 0, -1};   struct node {     int x, y, sum;   };   node ans[2600];   bool cmp(node a, node b) { return a.sum < b.sum; }   int bfs(int x, int y) {     queue<node> q;     node t, next;     t.x = x;     t.y = y;     q.push(t);     int cnt = 1;     a[x][y] =  * ;     while (!q.empty()) {       t = q.front();       q.pop();       for (int i = 0; i < 4; i++) {         int tx = t.x + dir[i][0];         int ty = t.y + dir[i][1];         if (tx < 0 || ty < 0 || tx >= n || ty >= m) {           cnt = -1e9;           continue;         }         if (a[tx][ty] ==  * ) continue;         a[tx][ty] =  * ;         next.x = tx;         next.y = ty;         cnt++;         q.push(next);       }     }     return cnt;   }   void bfs2(int x, int y) {     queue<node> q;     node t, next;     t.x = x;     t.y = y;     q.push(t);     b[x][y] =  * ;     while (!q.empty()) {       t = q.front();       q.pop();       for (int i = 0; i < 4; i++) {         int tx = t.x + dir[i][0];         int ty = t.y + dir[i][1];         if (b[tx][ty] ==  * ) continue;         b[tx][ty] =  * ;         next.x = tx;         next.y = ty;         q.push(next);       }     }   }   int main(void) {     int i, j, k;     while (scanf( %d%d%d , &n, &m, &k) == 3) {       for (i = 0; i < n; i++) {         scanf( %s , a[i]);         strcpy(b[i], a[i]);       }       int c = 0;       for (i = 0; i < n; i++)         for (j = 0; j < m; j++)           if (a[i][j] ==  . ) {             int t = bfs(i, j);             if (t > 0) {               ans[c].x = i;               ans[c].y = j;               ans[c].sum = t;               c++;             }           }       sort(ans, ans + c, cmp);       int sum = 0;       for (i = 0; i < c - k; i++) {         sum += ans[i].sum;         bfs2(ans[i].x, ans[i].y);       }       printf( %d n , sum);       for (i = 0; i < n; i++) printf( %s n , b[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   struct cell {     int x, y, cost;     cell(int i, int j, int k) {       x = i;       y = j;       cost = k;     }   };   int main() {     int n, m, s;     scanf( %d%d%d , &n, &m, &s);     s--;     int t1, t2, t3;     vector<vector<pair<int, int> > > g(n);     vector<int> qq(m), w(m), e(m);     for (int i = 0; i < m; ++i) {       scanf( %d%d%d , &t1, &t2, &t3);       t1--;       t2--;       qq[i] = t1;       w[i] = t2;       e[i] = t3;       g[t1].push_back(make_pair(t2, t3));       g[t2].push_back(make_pair(t1, t3));     }     int l;     scanf( %d , &l);     vector<int> d(n, 1000000000);     d[s] = 0;     queue<int> q;     q.push(s);     d[s] = 0;     while (!q.empty()) {       int v = q.front();       q.pop();       for (unsigned int i = 0; i < g[v].size(); i++) {         int to = g[v][i].first, len = g[v][i].second;         if (d[v] + len < d[to]) {           d[to] = d[v] + len;           q.push(to);         }       }     }     int ans = 0;     for (int i = 0; i < n; ++i)       if (d[i] == l) ans++;     for (int i = 0; i < m; ++i) {       int x = qq[i], y = w[i], z = e[i];       int k1 = l - d[x];       if (k1 > 0 && k1 != z) {         int res = min(d[x] + k1, z - k1 + d[y]);         if (res == l) ans++;       }       int k2 = l - d[y];       if (k2 > 0 && k2 != z - k1 && k2 != z) {         int res = min(d[y] + k2, z - k2 + d[x]);         if (res == l) ans++;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long cs = 1, t = 15, ar[100], n;     while (t--) {       long long ans = 0;       n = cs;       map<long long, long long> mp;       for (long long i = 0; i <= n; i++) {         for (long long j = 0; j <= n; j++) {           for (long long k = 0; k <= n; k++) {             for (long long l = 0; l <= n; l++) {               if (i + j + k + l == n) {                 long long val = 1 * i + 5 * j + 10 * k + 50 * l;                 if (mp[val] == 0) {                   mp[val]++;                   ans++;                   ar[n] = ans;                 }               }             }           }         }       }       cs++;     }     cin >> n;     if (n <= 14)       cout << ar[n] << endl;     else {       long long an = ar[14] + ((n - 14) * 49);       cout << an << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n;     cin >> n;     vector<string> a(n);     for (long long i = 0; i < n; ++i) {       cin >> a[i];     }     unordered_set<char> diagonal, non_diagonal;     for (long long i = 0; i < n; ++i) {       for (long long j = 0; j < n; ++j) {         if (i == j) {           diagonal.insert(a[i][j]);         } else if (j == n - i - 1) {           diagonal.insert(a[i][j]);         } else {           non_diagonal.insert(a[i][j]);         }       }     }     if (diagonal.size() == 1 && non_diagonal.size() == 1) {       for (char a : diagonal) {         for (char b : non_diagonal) {           if (a != b) {             cout <<  YES ;           } else {             cout <<  NO ;           }         }       }     } else {       cout <<  NO ;     }   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int a[n];       for (int i = 0; i < n; i++) cin >> a[i];       int dif[n];       memset(dif, 0, sizeof(dif));       int ans = 0;       for (int i = 1; i < n; i++) {         int cnt = 1;         int temp = a[i];         while (a[i - 1] > a[i]) {           dif[i]++;           a[i] = temp + cnt;           cnt *= 2;         }         if (a[i] > a[i - 1] && dif[i]) {           dif[i]--;           a[i] = a[i - 1];         }         ans = max(ans, dif[i]);       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     int ans = 0;     for (int i = 0; i < s.size(); i++) {       if (((s[i] -  0 ) % 2) == 0) {         ans = ans + i + 1;       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v[200005];   vector<int> par(200005, -1);   vector<int> ran(200005, 1);   int fi(int c) {     while (1) {       if (par[c] == -1)         return c;       else         c = par[c];     }   }   int main() {     int n, m;     cin >> n >> m;     long long int a[n];     long long int val = 10000000000000000;     int in;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (a[i] < val) {         val = a[i];         in = i;       }     }     vector<pair<long long int, pair<int, int> > > v;     for (int i = 0; i < n; i++) {       if (i != in) {         v.push_back({a[i] + val, {i, in}});       }     }     long long int sum = 0;     while (m--) {       int x, y;       cin >> x >> y;       long long int z;       cin >> z;       x--, y--;       v.push_back({z, {x, y}});     }     sort(v.begin(), v.end());     int s = v.size();     for (int i = 0; i < s; i++) {       int t1 = v[i].second.first;       int t2 = v[i].second.second;       int t3 = fi(t1);       int t4 = fi(t2);       if (t3 != t4) {         if (ran[t3] > ran[t4]) {           par[t4] = t3;           ran[t3] += ran[t4];         } else {           par[t3] = t4;           ran[t4] += ran[t3];         }         sum += v[i].first;       }     }     cout << sum;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N, n, m, min, max;     while (cin >> N) {       n = N % 7;       if (n <= 2) {         max = N / 7 * 2 + n;         min = N / 7 * 2;       } else if (n == 6) {         min = N / 7 * 2 + 1;         max = N / 7 * 2 + 2;       } else {         min = N / 7 * 2;         max = N / 7 * 2 + 2;       }       cout << min <<     << max << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, pos, kol;   long long a[1000];   int main() {     cin >> n;     for (long long i = 1; i <= 2 * n; ++i) cin >> a[i];     for (long long i = 1; i < 2 * n; ++i) {       for (long long j = i + 1; j <= 2 * n; ++j) {         if (a[i] == a[j]) {           pos = j;           break;         }       }       while (pos > i + 1) {         swap(a[pos - 1], a[pos]);         --pos;         ++kol;       }     }     cout << kol << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   const long long MAXN = 100005;   long long n, m, o, a[MAXN], b[MAXN], f[2][205][5005];   int main() {     n = read();     m = read();     memset(a, 0, sizeof(a));     memset(b, 0, sizeof(b));     for (long long i = (1); i <= (n); ++i) {       long long x = read();       while (x % 2 == 0) a[i]++, x /= 2;       while (x % 5 == 0) b[i]++, x /= 5;     }     memset(f, 0, sizeof(f));     f[0][0][0] = 1;     o = 0;     for (long long i = (1); i <= (n); ++i) {       o = 1 - o;       memset(f[o], 0, sizeof(f[o]));       for (long long j = (0); j <= (i); ++j)         for (long long k = (0); k <= (j * 25); ++k) {           f[o][j][k] = max(f[o][j][k], f[1 - o][j][k]);           if (k >= b[i] && j > 0 && f[1 - o][j - 1][k - b[i]] > 0)             f[o][j][k] = max(f[o][j][k], f[1 - o][j - 1][k - b[i]] + a[i]);         }     }     long long ans = 0;     for (long long i = (0); i <= (m * 25); ++i)       ans = max(ans, min(f[o][m][i] - 1, i));     cout << ans << endl;     return 0;   }
#include<iostream>   #include<cstring>   #include<cstdio>   #include<climits>   #include<algorithm>   #include<queue>   #include<vector>   #define int long long   #define pii pair<int,int>   #define mp make_pair   #define pb push_back   #define fi first   #define se second   using namespace std;   inline int read(){    int f=1,ans=0; char c=getchar();    while(c< 0 ||c> 9 ){if(c== - )f=-1;c=getchar();}    while(c>= 0 &&c<= 9 ){ans=ans*10+c- 0 ;c=getchar();}    return f*ans;   }   const int MAXN=15;   const int MAXM=101;   struct node{int x,y,w;}tp[MAXM]; bool cmp(node x1,node x2){return x1.w<x2.w;}   int X[MAXN],Y[MAXN],N,M,f[1<<MAXN][MAXM],INF,g[1<<MAXN][MAXM],Dis[1<<MAXN][MAXN],DIS[1<<MAXN][MAXM],Maxn;   signed main(){    //freopen( 1.in , r ,stdin);    N=read(),M=read(); for(int i=0;i<N;i++) X[i]=read(),Y[i]=read(); for(int i=1;i<=M;i++) tp[i].x=read(),tp[i].y=read(),tp[i].w=read();    sort(tp+1,tp+M+1,cmp);    memset(f,127/3,sizeof(f)); memset(g,-127/3,sizeof(g)); memset(Dis,127/3,sizeof(Dis)); memset(DIS,127/3,sizeof(DIS)); INF=f[0][0];    for(int S=1;S<(1<<N);S++) for(int u=0;u<N;u++){int Minn=INF; for(int v=0;v<N;v++) if(S&(1<<v)) Minn=min(Minn,abs(X[u]-X[v])+abs(Y[u]-Y[v])); Dis[S][u]=Minn;}    for(int S=1;S<(1<<N);S++) for(int u=1;u<=M;u++){int Minn=INF; for(int v=0;v<N;v++) if(S&(1<<v)) Minn=min(Minn,abs(X[v]-tp[u].x)+abs(Y[v]-tp[u].y)); DIS[S][u]=Minn;}    for(int i=0;i<N;i++) f[1<<i][0]=0; for(int i=1;i<=M;i++) g[0][i]=1;    for(int S=0;S<(1<<N);S++){     // f update f     for(int i=0;i<=M;i++) if(f[S][i]!=INF) for(int j=0;j<N;j++) if(!(S&(1<<j)))       f[S|(1<<j)][i]=min(f[S|(1<<j)][i],f[S][i]+Dis[S][j]);     // f update g     for(int i=0;i<=M;i++) if(f[S][i]!=INF) for(int j=1;j<=M;j++) if(f[S][i]+DIS[S][j]<=tp[j].w) g[S][j]=max(g[S][j],i+1);     //g update g     for(int i=1;i<=M;i++) if(g[S][i]>=0){      for(int j=i+1;j<=M;j++) if(tp[i].w+min(abs(tp[i].x-tp[j].x)+abs(tp[i].y-tp[j].y),DIS[S][j])<=tp[j].w)        g[S][j]=max(g[S][j],g[S][i]+1);      Maxn=max(Maxn,g[S][i]);     }     //g update f     for(int i=1;i<=M;i++) if(g[S][i]>=0) for(int j=0;j<N;j++) if(!(S&(1<<j)))       f[S|(1<<j)][g[S][i]]=min(f[S|(1<<j)][g[S][i]],tp[i].w+(min(abs(tp[i].x-X[j])+abs(tp[i].y-Y[j]),Dis[S][j])));    }    printf( %lld n ,Maxn); return 0;    }/*   3 4   1 1   2 3   5 2   2 2 12   5 1 4   6 2 11   3 5 10   */
#include <bits/stdc++.h>   using namespace std;   int a[51];   long long c[51][51];   double dp[51][51][51];   bool state[51][51][51];   double cal(int stu, int room, int mval) {     if (state[stu][room][mval]) return dp[stu][room][mval];     state[stu][room][mval] = true;     double &ret = dp[stu][room][mval];     if (!stu) return ret = mval;     if (!room) return ret = 0.0;     for (int i = 0; i <= stu; i++) {       int rval = i / a[room] + (i % a[room] != 0);       ret += 1.0 * c[i][stu] * pow(1.0 / room, i) *              pow(1.0 - 1.0 / room, stu - i) *              cal(stu - i, room - 1, max(mval, rval));     }     return ret;   }   int main() {     int n, m, i;     for (i = 1; i <= 50; i++) c[0][i] = c[i][i] = 1;     for (i = 2; i <= 50; i++)       for (n = 1; n < i; n++) c[n][i] = c[n - 1][i - 1] + c[n][i - 1];     scanf( %d %d , &n, &m);     for (i = 1; i <= m; i++) scanf( %d , a + i);     printf( %.20lf , cal(n, m, 0));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M;   pair<pair<long long, long long>, int> range[200000 - 1];   pair<long long, int> bridge[200000];   priority_queue<pair<long long, int>, vector<pair<long long, int> >,                  greater<pair<long long, int> > >       rends;   int ans[200000 - 1];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> N >> M;     long long prevL, prevR;     cin >> prevL >> prevR;     for (int i = 0; i < N - 1; i++) {       long long L, R;       cin >> L >> R;       range[i] = {{L - prevR, R - prevL}, i};       prevL = L;       prevR = R;     }     for (int i = 0; i < M; i++) {       cin >> bridge[i].first;       bridge[i].second = i;     }     sort(range, range + N - 1);     sort(bridge, bridge + M);     int ind = 0;     for (int i = 0; i < M; i++) {       while (ind < N - 1 && bridge[i].first >= range[ind].first.first) {         rends.push(make_pair(range[ind].first.second, range[ind].second));         ind++;       }       if (!rends.empty()) {         pair<long long, int> e = rends.top();         rends.pop();         if (e.first >= bridge[i].first) {           ans[e.second] = bridge[i].second + 1;         } else {           cout <<  No  << endl;           return 0;         }       }     }     if (ind < N - 1 || !rends.empty()) {       cout <<  No  << endl;       return 0;     }     cout <<  Yes  <<   n ;     cout << ans[0];     for (int i = 1; i < N - 1; i++) {       cout <<     << ans[i];     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int s;     cin >> s;     while (s) {       int n, a, b, c, d;       bool status = true;       cin >> n >> a >> b >> c >> d;       int rangem = (a - b) * n, rangeM = (a + b) * n;       if (((c + d) < rangem) || (c - d) > rangeM) status = false;       if (status)         cout <<  Yes  << endl;       else         cout <<  No  << endl;       s--;     }     return 0;   }