malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma )   #pragma GCC optimize( unroll-loops )   using namespace std;   double eps = 1e-12;   template <class T>   void swp(T& a, T& b) {     T temp = a;     a = b;     b = temp;   }   long long ceil_div(long long a, long long b) {     return a % b == 0 ? a / b : a / b + 1;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long modex(long long x, unsigned int y, long long p) {     long long res = 1;     x = x % p;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   int binarySearch(int arr[], int l, int r, int x) {     if (r >= l) {       int mid = l + (r - l) / 2;       if (arr[mid] == x) return mid;       if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x);       return binarySearch(arr, mid + 1, r, x);     }     return -1;   }   const long long MOD = 998244353;   const long long mod = 1e9 + 7;   void solve() {}   int main() {     long long n, m;     cin >> n >> m;     vector<long long> v(n + 2);     v[n] = 1ll;     for (long long i = n - 1; i > 0ll; --i) {       v[i] = v[i + 1];       for (long long j = 2ll; j < n + 1ll; j++) {         if (j * i > n) break;         v[i] = (v[i] + (v[j * i] - v[min(n, j * (i + 1ll) - 1ll) + 1ll])) % m;       }       v[i] = (v[i] + v[i + 1ll]) % m;     }     if (v[1] >= v[2]) {       cout << v[1] - v[2];     } else {       cout << (m + v[1] - v[2]) % m;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void ins(long long int a[], long long int n, long long int i = 0) {     for (long long int i = 0; i < n; i++) a[i] = i;   }   template <typename t>   void ins(t a[], long long int n, t b = 0) {     for (long long int i = 0; i < n; i++) a[i] = b;   }   void print(long long int a[], long long int n) {     for (long long int i = 0; i < n; i++) cout << a[i] <<    ;     ;     cout << endl;   }   template <typename t>   void print(t a[], long long int n) {     for (long long int i = 0; i < n; i++) cout << a[i] <<    ;     ;     cout << endl;   }   void po(long long int a[], long long int n) {     for (long long int i = 0; i < n; i++) {       cin >> a[i];     }   }   template <typename t>   void po(t a[], long long int n) {     for (long long int i = 0; i < n; i++) {       cin >> a[i];     }   }   long long int visited[100009];   vector<long long int> a[100009];   long long int n;   long long int b[100009];   long long int c[100001];   void start() {     cin >> n;     for (long long int i = 0; i < n - 1; i++) {       cin >> b[i + 1];       a[i + 2].push_back(b[i + 1]);       a[b[i + 1]].push_back(i + 2);     }     for (long long int i = 0; i < n + 3; i++) {       visited[i] = 0;       c[i] = 0;     }   }   void dfs(long long int s, long long int t) {     visited[s] = 1;     if (s != 1)       c[t + 1] += a[s].size() - 1;     else       c[t + 1] += a[s].size();     for (long long int i = 0; i < a[s].size(); i++) {       if (!visited[a[s][i]]) dfs(a[s][i], t + 1);     }   }   int main() {     start();     long long int count = 0;     dfs(1, 0);     for (long long int i = 0; i < n + 3; i++) {       if (c[i] % 2 == 1) {         count++;       }     }     cout << count + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, mi, mx;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     long long a[n];     for (int i = 0; i < n && cin >> a[i]; i++)       ;     cout << abs(a[0] - a[1]) <<     << abs(a[0] - a[n - 1]) << endl;     for (int i = 1; i < n - 1; i++) {       cout << min(abs((a[i]) - (a[i - 1])), abs((a[i]) - (a[i + 1]))) <<                << max(abs((a[i]) - (a[n - 1])), abs((a[i]) - (a[0]))) << endl;     }     cout << abs((a[n - 1]) - (a[n - 2])) <<     << abs(a[n - 1] - a[0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s, t, ts, ans;   int pos[10000005], len[10000005], tot;   inline string reverse(string s) {     string t;     t.resize(s.size());     int n = s.size();     for (int i = 0; i < n; i++) t[n - i - 1] = s[i];     return t;   }   void Duval(const string& s) {     int n = s.size();     for (int i = 0; i < n;) {       int j = i, k = i + 1;       while (s[j] <= s[k]) {         if (s[j] == s[k])           ++j;         else           j = i;         ++k;       }       len[++tot] = k - j;       while (i <= j) {         pos[tot] = i + k - j - 1;         i += k - j;       }     }   }   int p[10000005];   void Exkmp(const string& s) {     int n = s.size();     int mid = 0, mx = 0;     p[0] = n;     for (int i = 1; i < n; i++) {       if (i <= mx) p[i] = min(p[i - mid], mx - i + 1);       while (s[i + p[i]] == s[p[i]]) ++p[i];       if (i + p[i] - 1 > mx) mid = i, mx = i + p[i] - 1;     }   }   int main() {     ios::sync_with_stdio(false);     cin >> s;     t = reverse(s);     int k;     cin >> k;     if (k == 1) return cout << min(s, t), 0;     Duval(t);     pos[0] = -1;     while (k > 2 && tot) {       if (len[tot] == 1) {         while (tot && len[tot] == 1)           ans += t.substr(pos[tot - 1] + 1, pos[tot] - pos[tot - 1]), --tot;         --k;       } else         ans += t.substr(pos[tot - 1] + 1, pos[tot] - pos[tot - 1]), --k, --tot;     }     if (tot == 0) return cout << ans, 0;     if (tot == 1) {       string tmp = t.substr(0, pos[1] + 1);       tmp = min(tmp, reverse(tmp));       cout << ans + tmp;       return 0;     }     s = reverse(t = t.substr(0, pos[tot] + 1));     ts = t +  #  + s;     Exkmp(ts);     string tmp = min(s, t);     int cut = 0, n = s.size();     for (int i = 1; i < n; i++) {       int cl = min(i - cut, p[n + 1 + cut]);       if (cut + cl == i) cl += p[cl];       cl = min(cl, n - cut);       if ((cl < i - cut ? s[cut + cl] : t[cut + cl - i]) < t[cl]) cut = i;     }     tmp = min(tmp, s.substr(0, cut) + t.substr(0, n - cut));     string las = t.substr(pos[tot - 1] + 1, len[tot]);     string lass = t.substr(pos[tot - 2] + 1, len[tot]);     int st = pos[tot - 1] + 1;     string tt = t.substr(st, n - st);     string res = t.substr(0, n - tt.size());     tt += min(res, reverse(res));     tmp = min(tmp, tt);     if (las == lass) {       st = pos[tot - 2] + 1;       tt = t.substr(st, n - st);       res = t.substr(0, n - tt.size());       tt = tt + min(res, reverse(res));       tmp = min(tmp, tt);     }     cout << ans + tmp;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T1, class T2>   int upmin(T1 &x, T2 v) {     if (x > v) {       x = v;       return 1;     }     return 0;   }   template <class T1, class T2>   int upmax(T1 &x, T2 v) {     if (x < v) {       x = v;       return 1;     }     return 0;   }   const int INF = 0x3f3f3f3f;   vector<string> dict;   void init() {     for (string s; getline(cin, s);) {       dict.emplace_back(s);     }   }   int maxlen;   void preprocess() {     for (int i = 0; i < dict.size(); ++i) {       upmax(maxlen, dict[i].size());     }     for (int i = 0; i < maxlen + 2; ++i) {       cout <<  * ;       if (i + 1 == maxlen + 2) {         cout << endl;       }     }     for (int i = 0, t = 0; i < dict.size(); ++i) {       cout <<  * ;       int splen = maxlen - dict[i].size();       int ls, rs;       if (~splen & 1) {         ls = rs = splen / 2;       } else {         if (t == 0) {           ls = (splen - 1) / 2;           rs = splen - ls;         } else {           rs = (splen - 1) / 2;           ls = splen - rs;         }         t ^= 1;       }       for (int j = 0; j < ls; ++j) {         cout <<    ;       }       cout << dict[i];       for (int j = 0; j < rs; ++j) {         cout <<    ;       }       cout <<  *  << endl;     }     for (int i = 0; i < maxlen + 2; ++i) {       cout <<  * ;       if (i + 1 == maxlen + 2) {         cout << endl;       }     }   }   void solve() {}   signed main() {     ios::sync_with_stdio(0);     init();     preprocess();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long c, hr, hb, wr, wb;     cin >> c >> hr >> hb >> wr >> wb;     long long res = 0;     for (long long w = 0; w < 2; ++w) {       for (long long i = 0; i * wr <= c && i <= 10000000; ++i) {         res = max(res, i * hr + hb * ((c - i * wr) / wb));       }       swap(hb, hr);       swap(wb, wr);     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cerr <<  Time :   << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC          <<  ms n ;     string s;     cin >> s;     int l = 0, r = s.length() - 1;     int cnt = 0;     set<int> s1;     while (l < r) {       if (s[l] ==  ( ) {         while (l < r && s[r] ==  ( ) {           r--;         }         if (s[r] ==  ) ) {           cnt = 1;           s1.insert(l + 1);           s1.insert(r + 1);         }       } else if (s[r] ==  ) ) {         while (l < r && s[l] ==  ) ) {           l++;         }         if (s[l] ==  ( ) {           cnt = 1;           s1.insert(l + 1);           s1.insert(r + 1);         }       }       l++;       r--;     }     cout << cnt <<   n ;     if (cnt) {       cout << s1.size() <<   n ;       for (auto it = s1.begin(); it != s1.end(); it++) {         cout << *it <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[500007];   int l[500007];   int r[500007];   long long ans = 0;   pair<int, int> p[500007];   void input() {     scanf( %d , &n);     int i;     for (i = 0; i < n; i++) {       scanf( %d , &a[i]);       p[i].first = a[i];       p[i].second = i;     }     sort(p, p + n);   }   void solve() {     if (n < 3) {       printf( 0 n );       return;     }     int i;     for (i = 0; i < n; i++) {       l[i] = i - 1;       r[i] = i + 1;     }     int ind;     int x, y;     int lo = 0;     int hi = n - 1;     for (i = 0; i < n - 2; i++) {       ind = p[i].second;       if (ind == lo) {         ans += p[i].first;         lo = r[ind];         continue;       }       if (ind == hi) {         ans += p[i].first;         hi = l[ind];         continue;       }       x = l[ind];       y = r[ind];       ans += min(a[x], a[y]);       r[x] = y;       l[y] = x;     }     printf( %I64d n , ans);   }   int main() {     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   void add(int &x, int y) { x = (x + y) % mod; }   int mul(int x, int y) { return (long long)x * y % mod; }   int pw(int x, int p) {     int r = 1;     while (p) {       if (p & 1) r = mul(r, x);       x = mul(x, x);       p >>= 1;     }     return r;   }   int fac[3602];   int rev[3602];   int nCr(int n, int r) {     if (n < r || r < 0) return 0;     return mul(fac[n], mul(rev[r], rev[n - r]));   }   int h, w, n;   int chR[3602], chC[3602];   int dpR[3602], dpC[3602];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.precision(30);     cout << fixed;     fac[0] = 1;     for (int i = 1; i <= 3601; ++i) fac[i] = mul(fac[i - 1], i);     rev[3601] = pw(fac[3601], mod - 2);     for (int i = 3601; i--;) rev[i] = mul(rev[i + 1], i + 1);     cin >> h >> w >> n;     for (int i = 0; i < n + n; ++i) {       int r, c;       cin >> r >> c;       chR[r] = 1;       chC[c] = 1;     }     chR[h + 1] = chC[w + 1] = 1;     vector<int> R, C;     int Rcnt = 0, Ccnt = 0;     for (int i = 1, p = 0; i <= h + 1; ++i) {       if (chR[i]) {         if (p) R.push_back(p);         p = 0;       } else {         ++p;         ++Rcnt;       }     }     for (int i = 1, p = 0; i <= w + 1; ++i) {       if (chC[i]) {         if (p) C.push_back(p);         p = 0;       } else {         ++p;         ++Ccnt;       }     }     dpR[0] = 1;     for (int x : R) {       for (int i = 3602; i--;) {         if (dpR[i] == 0) continue;         for (int j = 1; j + j <= x; ++j) {           ;           add(dpR[i + j], mul(dpR[i], nCr(x - j, j)));         }       }     }     dpC[0] = 1;     for (int x : C) {       for (int i = 3602; i--;) {         if (dpC[i] == 0) continue;         for (int j = 1; j + j <= x; ++j) {           add(dpC[i + j], mul(dpC[i], nCr(x - j, j)));         }       }     }     for (int i = 0; i <= 3600; ++i) {       if (dpR[i] != 0)         ;     }     for (int i = 0; i <= 3600; ++i) {       if (dpC[i] != 0)         ;     }     int ans = 0;     for (int i = 0; i <= 3600; ++i) {       for (int j = 0; j <= 3600; ++j) {         if (i + i + j > Rcnt) continue;         if (i + j + j > Ccnt) continue;         int val = mul(dpR[i], dpC[j]);         val = mul(val, nCr(Rcnt - i - i, j));         val = mul(val, nCr(Ccnt - j - j, i));         add(ans, mul(val, mul(fac[i], fac[j])));       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   char s[200001];   char pick(char a, char b) {     char c;     for (c =  a ; c == a || c == b; c++)       ;     return c;   }   char *handle(char *s) {     char *ps = s;     for (s += 1; *s; s++) {       if (*s == *(s - 1)) *s = pick(*(s - 1), *(s + 1));     }     return ps;   }   int main() {     scanf( %s , s);     printf( %s n , handle(s));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   long long c[N], d[N];   int main() {     long long sum = 0, ans = 0;     int n, k;     scanf( %d %d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %lld , &c[i]);       sum += c[i];     }     for (int i = 1; i <= k; i++) {       scanf( %lld , &d[i]);       sum -= c[d[i]];       ans += sum * c[d[i]];       c[d[i]] = 0;     }     for (int i = 2; i <= n; i++) {       ans += c[i] * c[i - 1];     }     ans += c[1] * c[n];     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, s;     cin >> n >> s;     int a[n + 1];     int cnt = 0;     for (int i = 1; i < n; ++i) {       a[i] = 1;       cnt++;     }     a[n] = s - cnt;     s -= cnt;     if (s - cnt < 2) {       cout <<  NO  << endl;     } else {       cout <<  YES  << endl;       for (int i = 1; i <= n; ++i) cout << a[i] <<    ;       cout << endl;       cout << (cnt + 1) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int val_of_op[200];   int n;   struct T {     string Name, Expr;     bool danger;     int num[5];     int sum(int a0 = 0, int a1 = 0, int a2 = 0, int a3 = 0) {       return num[a0] + num[a1] + num[a2] + num[a3];     }   } macro[1000];   void Eliminate_Space(string &s) {     int p;     while ((p = s.find(   )) != string::npos) s.erase(s.begin() + p);   }   bool isDigit(char c) { return c >=  0  && c <=  9 ; }   bool isLetter(char c) { return c >=  a  && c <=  z  || c >=  A  && c <=  Z ; }   stack<int> Ope, Num;   void Pop(int n) {     int y = Num.top();     Num.pop();     int x = Num.top();     Num.pop();     int z = Ope.top();     Ope.pop();     if (x != -1 && macro[x].danger || y != -1 && macro[y].danger)       macro[n].danger = 1;     if (z == 2 && y != -1 && macro[y].sum(1, 2)) macro[n].danger = 1;     if (z == 3)       if (y != -1 && macro[y].sum(1, 2) || x != -1 && macro[x].sum(1, 2))         macro[n].danger = 1;     if (z == 4)       if (x != -1 && macro[x].sum(1, 2) || y != -1 && macro[y].sum(1, 2, 3, 4))         macro[n].danger = 1;     Num.push(x);   }   void doit(int n, string &s) {     while (!Ope.empty()) Ope.pop();     while (!Num.empty()) Num.pop();     int p = 0;     while (p < ((int)(s).size())) {       if (s[p] ==  ( ) {         Ope.push(-1);         p++;         continue;       }       if (s[p] ==  ) ) {         while (Ope.top() != -1) Pop(n + 1);         Ope.pop();         if (Num.top() != -1 && macro[Num.top()].danger) macro[n + 1].danger = 1;         Num.top() = -1;         p++;         continue;       }       if (val_of_op[s[p]]) {         while (!Ope.empty() && val_of_op[s[p]] <= 2 && Ope.top() >= 3) Pop(n + 1);         Ope.push(val_of_op[s[p]]);         p++;         continue;       }       string a;       while (p < ((int)(s).size()) && (isDigit(s[p]) || isLetter(s[p])))         a.push_back(s[p++]);       int i = -1;       for (int j = (1); j <= (n); j++)         if (macro[j].Name == a) i = j;       Num.push(i);     }     while (!Ope.empty()) macro[n + 1].num[Ope.top()]++, Pop(n + 1);     if (Num.top() != -1 && macro[Num.top()].danger) macro[n + 1].danger = 1;   }   int main() {     val_of_op[ + ] = 1, val_of_op[ - ] = 2, val_of_op[ * ] = 3,     val_of_op[ / ] = 4;     cin >> n;     getline(cin, macro[1].Name);     for (int i = (1); i <= (n); i++) {       getline(cin, macro[i].Name,  e );       getline(cin, macro[i].Name,  e );       cin >> macro[i].Name;       getline(cin, macro[i].Expr);       Eliminate_Space(macro[i].Expr);       doit(i - 1, macro[i].Expr);     }     string Expr;     getline(cin, Expr);     Eliminate_Space(Expr);     doit(n, Expr);     if (macro[n + 1].danger)       puts( Suspicious );     else       puts( OK );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 9;   int n, sq, a[MAX], group[MAX];   struct Bucket {     Bucket() : l(1), r(0) {}     int l, r, freq[MAX], cnt;   } buckets[320];   void add(int idx, int k) {     for (int i = buckets[idx].r + 1; i <= n; ++i) {       if (!buckets[idx].freq[a[i]]) {         if (buckets[idx].cnt == k) {           return;         } else {           ++buckets[idx].cnt;         }       }       ++buckets[idx].freq[a[i]];       buckets[idx].r = i;     }   }   void del(int idx, int lst) {     for (int i = buckets[idx].l; i <= min(buckets[idx].r, lst); ++i) {       --buckets[idx].freq[a[i]];       if (!buckets[idx].freq[a[i]]) {         --buckets[idx].cnt;       }     }     buckets[idx].l = lst + 1;     buckets[idx].r = max(buckets[idx].r, lst);   }   int naive(int k) {     for (int i = 1; i <= n; ++i) {       group[i] = 0;     }     int cnt = 0, curGroup = 1;     for (int i = 1; i <= n; ++i) {       if (group[a[i]] != curGroup && cnt == k) {         ++curGroup;         cnt = 0;       }       if (group[a[i]] != curGroup) {         ++cnt;         group[a[i]] = curGroup;       }     }     return curGroup;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     sq = (int)sqrt(n + .0);     for (int i = 1; i <= n; ++i) {       cin >> a[i];     }     for (int k = 1; k <= sq; ++k) {       cout << naive(k) <<    ;     }     for (int k = sq + 1; k <= n; ++k) {       add(1, k);       int lst = buckets[1].r, curBucket = 1;       while (lst < n) {         ++curBucket;         del(curBucket, lst);         add(curBucket, k);         lst = buckets[curBucket].r;       }       cout << curBucket <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010, MAXC = 500;   int can[MAXC], c = 0;   int n, m, a[MAXN], b[MAXN];   int t[MAXN][MAXC];   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> a[i];     memcpy(b, a, sizeof(b));     sort(b, b + n);     for (int i = 0; i < n; i++) {       int end = i;       while (b[end] == b[i]) end++;       if (end - i >= b[i]) can[c++] = b[i];       i = end - 1;     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < c; j++) {         t[i + 1][j] = t[i][j];         if (a[i] == can[j]) t[i + 1][j]++;       }     }     int l, r;     for (int i = 0; i < m; i++) {       cin >> l >> r;       int ans = 0;       for (int j = 0; j < c; j++)         if (t[r][j] - t[l - 1][j] == can[j]) ans++;       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct exam {     long long a;     long long b;   };   exam a[200000];   long long n, r, avg;   bool comp(exam a, exam b) { return a.b < b.b; }   int main() {     cin >> n >> r >> avg;     for (int i = 0; i < n; i++) cin >> a[i].a >> a[i].b;     sort(a, a + n, comp);     long long needed = n * avg;     long long owned = 0;     for (int i = 0; i < n; i++) {       owned += a[i].a;     }     needed -= owned;     long long answer = 0;     int i = 0;     while (needed > 0 && i < n) {       if (r - a[i].a < needed) {         answer += (r - a[i].a) * a[i].b;         needed -= (r - a[i].a);       } else {         answer += (needed)*a[i].b;         needed = 0;       }       i++;     }     cout << answer << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n;   map<int, int> num;   int main() {     cin >> n;     int minNum = 1000 * 1000 * 1000 + 1;     for (int i = 0; i < n; i++) {       int tmp;       cin >> tmp;       num[tmp]++;       minNum = min(minNum, tmp);     }     for (int i = minNum; n > 0; i++) {       if (num[i] == 0 || num[i] > num[i + 1]) {         cout <<  NO  << endl;         return 0;       }       num[i + 1] -= num[i];       n -= 2 * num[i];     }     cout <<  YES  << endl;     return 0;   }
#include <bits/stdc++.h>   int max(int a, int b) {     if (a > b)       return a;     else       return b;   }   int main() {     int t, j;     scanf( %d , &t);     for (j = 0; j < t; j++) {       int n, i, first = 0, last = 0, flagf = 0, count = 0;       scanf( %d , &n);       char arr[n];       scanf( %s , arr);       for (i = 0; i < n; i++) {         if (arr[i] ==  1 ) {           count++;           last = i;           if (!flagf) {             first = i;             flagf = 1;           }         }       }       if (arr[0] ==  1  || arr[n - 1] ==  1 )         printf( %d , 2 * n);       else {         if (!first && !last)           printf( %d , 2 * count + (n - count));         else {           int k = 2 * (n - first);           int l = 2 * (last + 1);           int f = max(k, l);           printf( %d , f);         }       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ans, l, r, j, cn, ii, ix, p, N = 4e3;   vector<long long> A;   long long pww(long long a, long long b) {     long long r = 1;     for (long long i = 1; i <= b; i++) r *= a;     return r;   }   void gen(long long i, long long p) {     long long r = 0;     for (long long k = 0; k < p; k++) {       if (i & (1 << k))         r += pww(10, k) * 7;       else         r += pww(10, k) * 4;     }     A.push_back(r);   }   int main() {     cin >> l >> r;     while (cn < N) {       ii += 1;       long long pw = pow(2, ii);       for (long long a = 0; a < pw; a++) {         gen(a, ii);       }       cn += pw;     }     p = l;     while (A[j] < l) j++;     ix = j;     for (ix = j; A[ix] <= r; ix++) {       ans += A[ix] * (A[ix] - p + (ix == j ? 1 : 0));       p = A[ix];     }     ans += A[ix] * (r - p + (ix == j ? 1 : 0));     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int itr = 0; itr < t; itr++) {       int n;       vector<int> s;       cin >> n;       for (int i = 1; i <= n; i++) {         int tmp;         cin >> tmp;         s.push_back(tmp);       }       int token = 0;       for (int i = 0; i < s.size(); i++) {         int flag = 0;         for (int j = 2; j <= 2 + i; j++) {           if (s[i] % j != 0) {             flag = 1;             break;           }         }         if (flag == 0) {           token = 1;           break;         }       }       if (token == 1)         cout <<  NO n ;       else         cout <<  YES n ;     }   }
#include <bits/stdc++.h>   using namespace std;   map<char, int> freq;   vector<int> vec;   vector<char> vec2;   int main() {     int n, k;     cin >> n >> k;     string s, ans, update, alpha =  abcdefghijklmnopqrstuvwxyz ;     cin >> s;     int size = s.size();     for (int i = 0; i < 26; i++) {       for (int j = 0; j < size; j++) {         if (k > 0) {           if (s[j] == alpha[i]) {             k--;             s[j] =  0 ;           }         }       }     }     for (int i = 0; i < size; i++) {       if (s[i] !=  0 ) {         ans += s[i];       }     }     cout << ans << endl;     return 0;   }