malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   pair<long long, long long> a[300001];   long long n, k, s, m;   bool b[300001];   inline long long read() {     long long sum = 0, x = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) x = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       sum = sum * 10 + ch -  0 ;       ch = getchar();     }     return sum * x;   }   inline void write(long long x) {     if (x < 0) {       putchar( - );       x = -x;     }     if (x > 9) write(x / 10);     putchar(x % 10 +  0 );     return;   }   inline bool cmp(pair<long long, long long> a, pair<long long, long long> b) {     return a.first > b.first;   }   signed main() {     n = read();     k = read();     for (register long long i = 1; i <= n; ++i) a[i].second = i;     for (m = 1; m <= n; ++m) {       for (register long long j = m * 2; j <= n; j += m) ++a[j].first;       s += a[m].first;       if (s >= k) break;     }     if (s < k) {       puts( No );       return 0;     }     sort(a + 1, a + m, cmp);     long long t = m;     for (register long long i = 1; i <= m; ++i) {       if (a[i].second > m / 2 && s - a[i].first >= k) {         s -= a[i].first;         b[a[i].second] = true;         t--;       }       if (s == k) break;     }     puts( Yes );     write(t);     putchar(  n );     for (register long long i = 1; i <= m; ++i)       if (!b[i]) {         write(i);         putchar(   );       }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int te;     cin >> te;     while (te--) {       int n, m, x, ji = 0, ou = 0;       cin >> n >> m;       for (int i = 0; i < n; ++i) {         cin >> x;         if (x & 1)           ji++;         else           ou++;       }       if (ji == 0) {         puts( No );         continue;       }       ji--;       m--;       int q = min(m / 2 * 2, ji / 2 * 2);       m -= q;       ou -= m;       if (ou < 0)         puts( No );       else         puts( Yes );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, q[1000010], a[1000010], del[1000010], sz[1000010], p[1000010];   stack<int> res;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) scanf( %d , &a[i]);     if (a[m] <= n) a[m + 1] = n + 1;     for (int i = 1; i <= m; i++)       for (int j = a[i]; j < a[i + 1]; j++) p[j] = i;     for (int i = 1; i <= n; i++) scanf( %d , &q[i]);     for (int i = 0; i < a[1]; i++) del[i] = n;     for (int i = 1; i <= m; i++) {       del[a[i]] = 1;       for (int j = a[i] + 1; j < a[i + 1]; j++) del[j] = del[j - i] + 1;     }     for (int i = 1; i <= n; i++) {       if (q[i] == 1 || q[i] == 0)         sz[i] = sz[i - 1] + 1;       else         sz[i] = sz[i - 1] - p[sz[i - 1]];     }     if (!sz[n]) {       puts( Poor stack! );       return 0;     }     int k = 0;     for (int i = n; i >= 1; i--) {       if (q[i] == -1)         k++;       else if (del[sz[i]] > k)         res.push(q[i]);     }     while (!res.empty()) {       printf( %d , res.top());       res.pop();     }   }
#include <bits/stdc++.h>   using namespace std;   int s0, t0, t1, n, m, Next[500000 + 5];   char s[500000 + 5], t[500000 + 5];   void GetNext() {     Next[0] = -1;     int j = 0, k = -1;     while (j < m) {       if (!~k || t[j] == t[k])         Next[++j] = ++k;       else         k = Next[k];     }   }   int main() {     scanf( %s%s , s, t);     n = strlen(s), m = strlen(t);     GetNext();     for (int i = 0; s[i]; i++) s0 += s[i] ==  0 ;     for (int i = 0; t[i]; i++) t0 += t[i] ==  0 ;     for (int i = Next[m]; t[i]; i++) t1 += t[i] ==  0 ;     int A = t0, B = m - t0, l = m - Next[m], step = 0;     while (A + t1 <= s0 && B + l - t1 <= n - s0) A += t1, B += l - t1, step++;     if (t0 <= s0 && m - t0 <= n - s0) {       printf( %s , t);       for (int i = 0; i < step; i++) printf( %s , t + Next[m]);       for (int i = s0 - A; i; i--) putchar( 0 );       for (int i = n - s0 - B; i; i--) putchar( 1 );       puts(  );     } else       printf( %s n , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 * 100 + 10;   vector<int> g[maxn];   int a[maxn], b[maxn];   bool p[maxn];   int n, m;   void input() {     cin >> n >> m;     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       u--, v--;       g[u].push_back(v);       g[v].push_back(u);     }     for (int i = 0; i < n; i++) cin >> a[i];   }   void bfs(int v) {     queue<int> q;     q.push(v);     while (!q.empty()) {       p[q.front()] = true;       int u = q.front();       b[u]++;       for (int i = 0; i < g[u].size(); i++) {         b[g[u][i]]++;         if (b[g[u][i]] == a[g[u][i]]) q.push(g[u][i]);       }       q.pop();     }   }   int main() {     input();     for (int i = 0; i < n; i++)       if (b[i] == a[i]) bfs(i);     int ans = 0;     for (int i = 0; i < n; i++) ans += p[i];     cout << ans << endl;     ;     for (int i = 0; i < n; i++)       if (p[i]) cout << i + 1 <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007;   int main() {     string s;     cin >> s;     int k;     cin >> k;     unordered_set<string> st;     for (int i = 0; i < k; i++) {       string temp;       cin >> temp;       st.insert(temp);       string temp2 =   ;       temp2 = temp2 + temp[1];       temp2 = temp2 + temp[0];       st.insert(temp2);     }     vector<pair<char, int> > arr;     for (int i = 0; i < s.size(); i++) {       int count = 1;       int j = i + 1;       while (j < s.size() && s[j] == s[i]) {         count++;         j++;       }       arr.push_back(make_pair(s[i], count));       i = j - 1;     }     int ans = 0;     for (int i = 0; i < arr.size() - 1; i++) {       string temp =   ;       temp = temp + arr[i].first;       temp = temp + arr[i + 1].first;       if (st.find(temp) != st.end()) {         int c1 = arr[i].second, c2 = arr[i + 1].second;         int j = i + 2;         while (j < s.size()) {           if (arr[j].first == arr[i].first)             c1 += arr[j].second;           else if (arr[j].first == arr[i + 1].first)             c2 += arr[j].second;           else             break;           j++;         }         ans += min(c1, c2);         i = j - 1;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, x, y;   long long dp[10000005];   int main(void) {     scanf( %lld%lld%lld , &n, &x, &y);     dp[1] = x;     for (int i = 2; i <= n; ++i) {       if (i & 1) {         dp[i] = min(dp[i - 1] + x, dp[(i + 1) >> 1] + x + y);       } else         dp[i] = min(dp[i - 1] + x, dp[i >> 1] + y);     }     printf( %lld n , dp[n]);   }
#include <bits/stdc++.h>   using namespace std;   int n, nn, sum;   vector<double> q;   double x, ans, anss;   int main() {     scanf( %d , &n);     sum = 0;     for (int i = 1; i <= 2 * n; i++) {       scanf( %lf , &x);       ans += (x - floor(x));       if (floor(x) == ceil(x)) sum++;     }     if (sum > n) n = n * 2 - sum;     sum = min(sum, n);     anss = 10000000;     for (int i = n - sum; i <= n; i++) anss = min(anss, fabs(ans - i));     printf( %.3lf , anss);   }
#include <bits/stdc++.h>   using namespace std;   struct TnT {     int k, f;   } T[111];   bool cmp(TnT a, TnT b) {     if (a.f == b.f) return a.k < b.k;     return a.f < b.f;   }   map<int, int> t;   int main() {     ios::sync_with_stdio(false);     int n, m, ans = -1;     cin >> n >> m;     for (int i = 0; i < m; i++) cin >> T[i].k >> T[i].f;     sort(T, T + m, cmp);     for (int k = 1; k <= 100; k++) {       int cnt = 1;       for (int i = 1; i <= 110; i += k) {         for (int j = i; j <= i + k - 1; j++) t[j] = cnt;         cnt++;       }       int flag = 1;       for (int i = 0; i < m; i++) {         if (t[T[i].k] != T[i].f) flag = 0;       }       if (flag) {         if (ans == -1)           ans = t[n];         else if (ans != t[n]) {           cout << -1 << endl;           return 0;         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool distinct(int n) {     set<int> a;     int i, c = 0;     while (n > 0) {       int d = n % 10;       a.insert(d);       n /= 10;     }     int l = a.size();     for (int i = 0; i <= l - 1; i++) {       c++;     }     if (c == 4) {       return true;     } else {       return false;     }   }   int main() {     int y;     cin >> y;     for (int i = y; i <= 10000; i++) {       if (i > y) {         if (distinct(i)) {           cout << i;           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, n;     cin >> t;     while (t--) {       cin >> n;       int a[n], sum = n - 1;       for (int i = 0; i < n; i++) {         cin >> a[i];         sum += a[i];       }       cout << sum / n << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char A[2005][2005], B[2005][2005];   int last_valid;   pair<int, int> lb[26], ub[26];   bool ans;   void _clear(int n, int m) {     for (int i = 0; i < 26; ++i) {       lb[i] = make_pair(INT_MAX, INT_MAX);       ub[i] = make_pair(INT_MIN, INT_MIN);     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         B[i][j] =  . ;       }     }     ans = true;     last_valid = -1;   }   void _populate(int n, int m) {     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (A[i][j] ==  . ) continue;         char c = A[i][j] -  a ;         lb[c].first = min(lb[c].first, i);         lb[c].second = min(lb[c].second, j);         ub[c].first = max(ub[c].first, i);         ub[c].second = max(ub[c].second, j);       }     }   }   void _regenerate() {     for (int i = 0; i < 26; ++i) {       if (lb[i].first != INT_MAX) {         last_valid = i;         if (lb[i].first == ub[i].first) {           int x = lb[i].first;           for (int j = lb[i].second; j <= ub[i].second; ++j) B[x][j] = i +  a ;         } else if (lb[i].second == ub[i].second) {           int x = lb[i].second;           for (int j = lb[i].first; j <= ub[i].first; ++j) B[j][x] = i +  a ;         } else           ans = false;       }     }   }   void _compare(int n, int m) {     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (A[i][j] != B[i][j]) ans = false;       }     }   }   void _print() {     if (!ans) {       cout <<  NO  << endl;       return;     }     cout <<  YES  << endl;     cout << last_valid + 1 << endl;     for (int i = 0; i <= last_valid; ++i) {       if (lb[i].first != INT_MAX) {         cout << lb[i].first + 1 <<     << lb[i].second + 1 <<                  << ub[i].first + 1 <<     << ub[i].second + 1 << endl;       } else {         int x = last_valid;         cout << lb[x].first + 1 <<     << lb[x].second + 1 <<                  << ub[x].first + 1 <<     << ub[x].second + 1 << endl;       }     }   }   void _debug(int n, int m) {     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) cout << A[i][j] <<    ;       cout << endl;     }     cout << endl;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) cout << B[i][j] <<    ;       cout << endl;     }     cout << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cout.tie(0);     cin.tie(0);     int t, n, m, i, j, k, x, y, z, a, b, c;     cin >> t;     while (t--) {       cin >> n >> m;       for (i = 0; i < n; ++i) cin >> A[i];       _clear(n, m);       _populate(n, m);       _regenerate();       _compare(n, m);       _print();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   string s;   long long dp[200011];   const long long Mod = 1e9 + 7;   long long f[200011][3];   long long power(long long x, long long n) {     if (n < 0) return 0;     if (n == 0) return 1;     if (n % 2 == 0) return power(x * x % Mod, n / 2);     return x * power(x * x % Mod, n / 2) % Mod;   }   int main() {     cin >> n;     cin >> s;     s =  .  + s;     int c = 0;     for (int i = n; i >= 1; i--) {       if (s[i] ==  ? ) c++;     }     long long cnt1 = 0;     long long cnt2 = 0;     for (int i = 1; i <= n; i++) {       if (s[i] ==  b ) {         f[i][0] += cnt1;         f[i][1] += cnt2;       }       if (s[i] ==  ? ) {         f[i][1] += cnt1;         f[i][2] += cnt2;       }       if (s[i] ==  a ) {         cnt1++;       }       if (s[i] ==  ? ) cnt2++;     }     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= 2; j++) (f[i][j] += f[i - 1][j]) %= Mod;     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       if (s[i] ==  c ) {         ans += f[i - 1][0] * power(3, c);         ans %= Mod;         ans += f[i - 1][1] * power(3, c - 1);         ans %= Mod;         ans += f[i - 1][2] * power(3, c - 2);         ans %= Mod;       }       if (s[i] ==  ? ) {         ans += f[i - 1][0] * power(3, c - 1);         ans %= Mod;         ans += f[i - 1][1] * power(3, c - 2);         ans %= Mod;         ans += f[i - 1][2] * power(3, c - 3);         ans %= Mod;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> vec[100010];   long long a[100010];   long long s;   int n;   long long dfs(int f, int u, long long val) {     int sz = vec[u].size(), v;     long long ret = 0, mv = ((long long)1e18), tmp;     if (sz == 1 && vec[u][0] == f)       return (a[u] = ((val) < (a[u]) ? (val) : (a[u])));     if (u != 1)       val = val / (sz - 1) * (sz - 1) / (sz - 1);     else       val = val / sz * sz / sz;     for (int i = 0; i < sz; i++) {       v = vec[u][i];       if (v == f) continue;       tmp = dfs(u, v, val);       mv = ((mv) < (tmp) ? (mv) : (tmp));     }     while (true) {       tmp = mv;       for (int i = 0; i < sz; i++) {         v = vec[u][i];         if (v == f) continue;         if (a[v] > tmp) tmp = ((dfs(u, v, mv)) < (tmp) ? (dfs(u, v, mv)) : (tmp));       }       if (tmp == mv)         break;       else         mv = tmp;     }     for (int i = 0; i < sz; i++)       if (vec[u][i] != f) ret += a[vec[u][i]];     return a[u] = ret;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %I64d , a + i), s += a[i];     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d%d , &u, &v);       vec[u].push_back(v);       vec[v].push_back(u);     }     long long ret = dfs(0, 1, ((long long)1e18));     cout << s - ret << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {0, 0, 1, -1};   int dy[] = {1, -1, 0, 0};   template <class T>   inline void smin(T &a, T b) {     if (a > b) a = b;   }   template <class T>   inline void smax(T &a, T b) {     if (a < b) a = b;   }   int qf, qb, q[11111111];   long long res[555], a[555][555], dst[555][555];   int r[555], first[555];   int main() {     int N, ii, i, j, nn, u, st;     scanf( %d , &N);     for (i = 0; i < N; i++)       for (j = 0; j < N; j++) scanf( %I64d , &dst[i][j]);     for (i = 0; i < N; i++) {       scanf( %d , r + i);       r[i]--;     }     nn = 0;     for (ii = N - 1; ii >= 0; ii--) {       st = r[ii];       for (i = 0; i < nn; i++) {         for (j = 0; j < nn; j++) {           smin(dst[st][first[j]], dst[st][first[i]] + dst[first[i]][first[j]]);           smin(dst[first[j]][st], dst[first[j]][first[i]] + dst[first[i]][st]);         }       }       for (i = 0; i < nn; i++)         for (j = 0; j < nn; j++)           smin(dst[first[i]][first[j]], dst[first[i]][st] + dst[st][first[j]]);       first[nn++] = st;       res[ii] = 0;       for (i = 0; i < nn; i++)         for (j = 0; j < nn; j++) res[ii] += dst[first[i]][first[j]];     }     for (i = 0; i < N; i++) {       if (i) printf(   );       printf( %I64d , res[i]);     }     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int BIG = 1000000;     int n, k;     cin >> n >> k;     string s;     int a[2][n + 2 * k];     int x[2][n + 2 * k];     for (int i = 0; i < 2; i++) {       cin >> s;       for (int j = k; j < n + k; j++) {         if (s[j - k] ==  - )           a[i][j] = 0;         else           a[i][j] = 1;       }     }     for (int i = 0; i < 2; i++)       for (int j = 0; j < k; j++) {         a[i][j] = 1;       }     for (int i = 0; i < 2; i++)       for (int j = n + k; j < n + 2 * k; j++) {         a[i][j] = 0;       }     for (int i = 0; i < 2; i++) {       for (int j = 0; j < n + 2 * k; j++) {         x[i][j] = BIG;       }     }     x[0][k] = 0;     vector<int> v[2][n + 1];     v[0][0].push_back(k);     for (int T = 1; T <= n; T++) {       for (int i = 0; i < 2; i++) {         for (int J = 0; J < v[(i) % 2][T - 1].size(); J++) {           int j = v[(i) % 2][T - 1][J];           if (x[i][j - 1] == BIG && (j - 1 - k) >= T) {             x[i][j - 1] = (a[i][j - 1] == 1) ? BIG : T;             if (!(a[i][j - 1] == 1)) v[(i) % 2][T].push_back(j - 1);           }           if (x[i][j + 1] == BIG) {             x[i][j + 1] = (a[i][j + 1] == 1) ? BIG : T;             if (!(a[i][j + 1] == 1)) v[(i) % 2][T].push_back(j + 1);           }           if (x[(i + 1) % 2][j + k] == BIG) {             x[(i + 1) % 2][j + k] = (a[(i + 1) % 2][j + k] == 1) ? BIG : T;             if (!(a[(i + 1) % 2][j + k] == 1)) v[(i + 1) % 2][T].push_back(j + k);           }         }       }     }     for (int i = 0; i < 2; i++)       for (int j = n + k; j < n + 2 * k; j++) {         if (x[i][j] <= n) {           cout <<  YES ;           return 0;         }       }     cout <<  NO ;   }
#include<bits/stdc++.h>   #define pairs pair<int,int>   #define loop(i,a,n) for(int i=a;i<n;i++)   #define m_p make_pair   #define fi first   #define se second   #define pb push_back   #define ll long long   #define all(v) v.begin(),v.end()   using namespace std;   //vector<ll> siz;   /*ll indes(ll i,ll right){       ll val=siz[i];       ll left=0;       ll ans=-1;       while(left<=right){           ll mid=(left+right)/2;           if(2*siz[mid]<=val){               ans=mid;               left=mid+1;           }           else           {               right=mid-1;           }                  }       return ans;    }*/   map<pairs,bool> mp;      void solve(){   ll n,k;   cin>>n>>k;   vector<ll> vec(n);   vector<pairs> range(n);   loop(i,0,n){       cin>>vec[i];   }   range[0].fi=vec[0];   range[0].se=vec[0];   range[n-1].fi=vec[n-1];   range[n-1].se=vec[n-1];   for(ll i=1;i<n-1;i++){     ll a=range[i-1].fi;     ll b=range[i-1].se;     ll c= b+k-1;     ll d=a-(k-1);     range[i].fi=max(d,vec[i]);     range[i].se=min(c,vec[i]+(k-1));   }      loop(i,1,n){     ll a=range[i-1].fi;     ll b=range[i-1].se;     ll c=range[i].fi;     ll d=range[i].se;        if(a-k>=d||b+k<=c){         cout<< NO ;         return;     }          }   cout<< YES ;   return;   }   int main(){       int test=1;       cin>>test;       while(test--){           solve();           cout<<endl;       }   }
#include <bits/stdc++.h>   using namespace std;   const int Mod = 1e9 + 7;   int main() {     long long N, M, ans = 0, Last = 0;     scanf( %I64d%I64d , &N, &M);     long long Min = min(N, M);     for (long long i = 1, j; i <= Min; i = j + 1) {       j = min(N / (N / i), M);       long long tmp;       if (j & 1LL)         tmp = ((j + 1) / 2 % Mod) * (j % Mod) % Mod;       else         tmp = (j / 2 % Mod) * ((j + 1) % Mod) % Mod;       ans =           (ans + (N / i) % Mod * (((tmp - Last) % Mod + Mod) % Mod) % Mod) % Mod;       Last = tmp;     }     ans = (((N % Mod) * (M % Mod) - ans) % Mod + Mod) % Mod;     printf( %I64d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2E5 + 10, mod = 1E9 + 7, M = 1E6 + 10, lim = 1E6;   int n, m, a[N], s[N], ans[N];   struct node {     int l, r, num;   } p[N];   vector<int> f[M];   int pos[M];   inline int cmp(node x, node y) { return x.r < y.r; }   struct sgtree {     int l, r, sum;   } t[N << 2];   inline int ksm(int x, int y) {     return y == 1                ? x                : 1ll * ksm(1ll * x * x % mod, y >> 1) * ((y & 1) ? x : 1) % mod;   }   inline void pl(int l = 1, int r = n, int x = 1) {     t[x] = (sgtree){l, r, 1};     if (l == r) return;     int mid = l + r >> 1;     pl(l, mid, x << 1);     pl(mid + 1, r, x << 1 | 1);   }   inline void modify(int l, int r, int v, int x = 1) {     if (l == t[x].l && r == t[x].r) {       t[x].sum = 1ll * t[x].sum * v % mod;       return;     }     int mid = t[x].l + t[x].r >> 1;     if (r <= mid)       modify(l, r, v, x << 1);     else if (l > mid)       modify(l, r, v, x << 1 | 1);     else       modify(l, mid, v, x << 1), modify(mid + 1, r, v, x << 1 | 1);   }   inline void insert(int v, int x) {     for (int i = 0; i < f[v].size(); i++) {       modify(pos[f[v][i]] + 1, x,              1ll * ksm(f[v][i], mod - 2) * (f[v][i] - 1) % mod);       pos[f[v][i]] = x;     }   }   inline int query(int l, int x = 1) {     if (t[x].l == t[x].r) return t[x].sum;     int mid = t[x].l + t[x].r >> 1;     return 1ll * t[x].sum * (l <= mid ? query(l, x << 1) : query(l, x << 1 | 1)) %            mod;   }   inline int sol(int l, int r) {     return 1ll * s[r] * ksm(s[l - 1], mod - 2) % mod * query(l) % mod;   }   int main() {     scanf( %d , &n);     s[0] = 1;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       s[i] = 1ll * s[i - 1] * a[i] % mod;     }     scanf( %d , &m);     pl();     for (int i = 1; i <= m; i++) {       scanf( %d%d , &p[i].l, &p[i].r);       p[i].num = i;     }     sort(p + 1, p + 1 + m, cmp);     int now = 1;     for (int i = 2; i <= lim; i++)       if (!f[i].size())         for (int j = 1; i * j <= lim; j++) f[i * j].push_back(i);     for (int i = 1; i <= n; i++) {       insert(a[i], i);       while (now <= m && p[now].r == i) {         ans[p[now].num] = sol(p[now].l, p[now].r);         now++;       }     }     for (int i = 1; i <= m; i++) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long fact[1000010];   long long m = 1e9 + 7;   long long me(long long a, long long b, long long m) {     long long ans = 1;     while (b > 0) {       if (b % 2 == 1) {         ans = (ans % m * a % m) % m;       }       a = (a * a) % m;       b /= 2;     }     return ans % m;   }   bool check(long long x, long long a, long long b) {     while (x > 0) {       int dg = x % 10;       if (dg != a && dg != b) return false;       x /= 10;     }     return true;   }   long long ncr(long long n, long long r) {     long long fn = fact[n];     long long tf = fact[r] * fact[n - r];     tf = tf % m;     tf = me(tf, m - 2, m);     fn = (tf % m * fn % m) % m;     return fn % m;   }   int main() {     fact[0] = 1;     for (long long i = 1; i <= 1000001; i++) {       fact[i] = (fact[i - 1] * i) % m;     }     int n, a, b;     cin >> a >> b >> n;     if (a == b) {       if (check(n * a, a, b)) {         cout <<  1 n ;       } else         cout <<  0 n ;       return 0;     }     long long ans = 0;     for (long long i = 0; i <= n; i++) {       long long tmp = i * a + (n - i) * b;       if (check(tmp, a, b)) {         ans += ncr(n, i);         ans %= m;       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     while (cin >> n) {       string s;       cin >> s;       string res =   ;       for (int i = 0; i < n; i++) {         if (s[i] <=  1 )           continue;         else {           if (s[i] ==  4 )             res +=  3 , res +=  2 , res +=  2 ;           else {             if (s[i] ==  6 )               res +=  5 , res +=  3 ;             else {               if (s[i] ==  8 )                 res +=  7 , res +=  2 , res +=  2 , res +=  2 ;               else {                 if (s[i] ==  9 )                   res +=  3 , res +=  3 , res +=  2 , res +=  7 ;                 else                   res += s[i];               }             }           }         }       }       sort(res.begin(), res.end());       reverse(res.begin(), res.end());       cout << res << endl;     }   }