malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   map<int, int> mp[11];   const int N = 2e5 + 5;   int ws(int u) { return (int)log10(u) + 1; }   int n, k, a[N], mo[11][N];   long long ans;   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       mo[0][i] = a[i] % k;       for (int j = 1; j <= 10; j++) {         mo[j][i] = (int)(((long long)mo[j - 1][i] * 10) % k);       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= 10; j++) {         if (mo[j][i]) {           mp[j][mo[j][i]]++;         } else {           mp[j][0]++;         }       }     }     for (int i = 1; i <= n; i++) {       int w = ws(a[i]);       if (mo[0][i]) {         ans += mp[w][k - mo[0][i]];       } else {         ans += mp[w][0];       }       if ((mo[w][i] + mo[0][i]) % k == 0) {         ans--;       }     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int gl, bl, br, gr;     cin >> gl >> gr >> bl >> br;     if (br <= (gl + 1) * 2 && br >= gl - 1) {       cout <<  YES ;       return 0;     }     if (bl <= (gr + 1) * 2 && bl >= gr - 1) {       cout <<  YES ;       return 0;     }     cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   long long a[345678], b[456111], c, n, i, l, s = 0, k = 0, m, j, t, x, y;   string p, q, r, rr;   int main() {     cin >> n >> m;     for (i = 0; i < m; i++) {       a[i] = n / m;     }     for (i = 1; i <= n % m; i++) a[i]++;     for (i = 0; i < m; i++) {       for (j = 0; j < m; j++) {         if ((i * i + j * j) % m == 0) {           s += a[i] * a[j];         }       }     }     cout << s << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string str;     int flag = 1;     cin >> str;     int len = str.size();     str[len] =  1 ;     str[len + 1] =  1 ;     for (int i = 0; i < str.size();) {       string temp =   ;       if (str[i] ==  1 ) {         temp = str[i + 1];         if (temp ==  4 ) {           temp += str[i + 2];           if (temp ==  44 ) {             i += 3;           } else {             i += 2;           }         } else {           i++;         }       } else {         flag = 0;         break;       }     }     if (flag)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxm = 1e6 + 5;   double q[maxm];   int buf[maxm], len[maxm];   void run_case() {     int n;     cin >> n;     int top = 0;     for (int i = 1; i <= n; ++i) cin >> buf[i];     q[++top] = buf[1], len[1] = 1;     for (int i = 2; i <= n; ++i) {       double now = buf[i];       int nowlen = 1;       while (q[top] > now) {         now = (now * nowlen + q[top] * len[top]) / (nowlen + len[top]);         nowlen += len[top--];       }       q[++top] = now, len[top] = nowlen;     }     for (int i = 1; i <= top; ++i)       for (int j = 0; j < len[i]; ++j) cout << q[i] <<   n ;   }   int main() {     ios::sync_with_stdio(false), cin.tie(0);     cout.setf(ios_base::showpoint);     cout.precision(10);     run_case();     cout.flush();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int m = 10000000;   int n;   int a[1000005];   int p[10000005];   long long gcd(long long a, long long b) {     if (!b) return a;     return gcd(b, a % b);   }   int get(int x) { return p[x] == x ? x : p[x] = get(p[x]); }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       p[a[i]] = a[i];     }     int k = n;     int x, y;     for (long long j = 1; j <= m; j++)       for (long long i = j + 1; 2 * i * j <= m && i * i - j * j <= m; i++)         if (gcd(2 * i * j, i * i - j * j) == 1) {           x = 2 * i * j;           y = i * i - j * j;           if (p[x] != 0 && p[y] != 0) {             x = get(x);             y = get(y);             if (x != y) {               k--;               p[x] = y;             }           }           if (i * i + j * j <= m) {             x = 2 * i * j;             y = i * i + j * j;             if (p[x] != 0 && p[y] != 0) {               x = get(x);               y = get(y);               if (x != y) {                 k--;                 p[x] = y;               }             }           }           if (i * i + j * j <= m) {             x = i * i + j * j;             y = i * i - j * j;             if (p[x] != 0 && p[y] != 0) {               x = get(x);               y = get(y);               if (x != y) {                 k--;                 p[x] = y;               }             }           }         }     cout << k << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1100010;   const double pai = acos(-1.0);   char s[maxn], t[maxn];   int n, m, a[maxn], b[maxn], ans[maxn], fa[maxn][6], rev[maxn], bin[1100010];   struct node {     double a, b;     node(double t0 = 0.0, double t1 = 0.0) {       a = t0;       b = t1;     }   } A[maxn], B[maxn];   node operator+(node a, node b) {     node c;     c.a = a.a + b.a;     c.b = a.b + b.b;     return c;   }   node operator-(node a, node b) {     node c;     c.a = a.a - b.a;     c.b = a.b - b.b;     return c;   }   node operator*(node a, node b) {     node c;     c.a = a.a * b.a - a.b * b.b;     c.b = a.b * b.a + a.a * b.b;     return c;   }   void FFT(node *t, int n, int id) {     int len = bin[n];     for (int i = 0; i < n; i++)       rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (len - 1));     for (int i = 0; i < n; i++)       if (i < rev[i]) swap(t[i], t[rev[i]]);     for (int i = 1; i < n; i <<= 1) {       node Wn;       Wn.a = cos(pai / i);       Wn.b = id * sin(pai / i);       for (int j = 0; j < n; j += (i << 1)) {         node W;         W.a = 1;         W.b = 0;         for (int k = j; k < j + i; k++) {           node t1 = t[k], t2 = t[k + i] * W;           t[k] = t1 + t2;           t[k + i] = t1 - t2;           W = W * Wn;         }       }     }   }   int find(int *f, int x) {     if (f[x] == x) return x;     return f[x] = find(f, f[x]);   }   void solve(int x, int y) {     int len = 1;     while (len <= 2 * (n + m)) len <<= 1;     for (int i = 0; i < len; i++) A[i].a = A[i].b = B[i].a = B[i].b = 0;     for (int i = 0; i < n; i++)       if (s[i] -  a  == x) A[i].a = 1;     for (int i = 0; i < m; i++)       if (t[i] -  a  == y) B[i].a = 1;     reverse(B, B + m);     FFT(A, len, 1), FFT(B, len, 1);     for (int i = 0; i < len; i++) A[i] = A[i] * B[i];     FFT(A, len, -1);     for (int i = m - 1; i < n; i++) {       int temp = (int)(A[i].a / len + 0.5);       if (!temp) continue;       if (find(fa[i], x) != find(fa[i], y)) {         fa[i][fa[i][x]] = fa[i][y];         ans[i]++;       }     }   }   int main() {     for (int i = 0; i <= 20; i++) bin[1 << i] = i;     scanf( %s , s);     scanf( %s , t);     n = strlen(s);     m = strlen(t);     for (int i = 0; i < n; i++)       for (int j = 0; j < 6; j++) fa[i][j] = j;     for (int i = 0; i < 6; i++)       for (int j = 0; j < 6; j++)         if (i != j) solve(i, j);     for (int i = m - 1; i < n; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fast() {     std::ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);   }   void file() {}   int main() {     fast();     file();     int n, idx = 0;     cin >> n;     vector<vector<int>> v(n, vector<int>(n));     vector<bool> ans(n, 1);     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> v[i][j];         if (v[i][j] == 3) {           ans[i] = 0;           ans[j] = 0;         } else if (v[i][j] == 1)           ans[i] = 0;         else if (v[i][j] == 2)           ans[j] = 0;       }     }     int cnt = 0;     for (int i = 0; i < n; i++) {       if (ans[i]) cnt++;     }     cout << cnt << endl;     for (int i = 0; i < n; i++) {       if (ans[i]) cout << i + 1 <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void sc(T &x) {     char r;     bool start = false, neg = false;     T ret = 0;     while (true) {       r = getchar();       if ((r -  0  < 0 || r -  0  > 9) && r !=  -  && !start) continue;       if ((r -  0  < 0 || r -  0  > 9) && r !=  -  && start) break;       if (start) ret *= 10;       start = true;       ret += r -  0 ;     }     if (!neg)       x = ret;     else       x = -ret;   }   template <typename T>   T gcd(T a, T b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     map<int, int> m;     int i, j = 0, k = 0;     i = 6;     while (i--) {       cin >> j;       if (m.find(j) != m.end())         m[j]++;       else         m[j] = 1;     }     i = j = k = 0;     if (m.size() == 1) {       cout <<  Elephant n ;     } else if (m.size() > 3) {       cout <<  Alien n ;     } else if (m.size() == 2) {       for (map<int, int>::iterator it = m.begin(); it != m.end(); it++) {         if ((*it).second >= 4) k++;         if ((*it).second == 2) j++;       }       if (k & j) {         cout <<  Elephant n ;       } else if (k) {         cout <<  Bear n ;       } else {         cout <<  Alien n ;       }     } else if (m.size() == 3) {       for (map<int, int>::iterator it = m.begin(); it != m.end(); it++) {         if ((*it).second == 4) k++;       }       if (k) {         cout <<  Bear n ;       } else {         cout <<  Alien n ;       }     }   }
#include <bits/stdc++.h>      using namespace std;      void code()   {    int n;    cin>>n;    string s;    cin>>s;       set<char> used;    char last= - ;    bool possible=true;    for(char& c:s)    {     if(c!=last)     {      if(used.find(c)!=used.end())      {       possible=false;       break;      }     }     last=c;     used.insert(c);    }       if(possible)     cout<< YES ;    else     cout<< NO ;    cout<<  n ;   }      int main()   {    ios_base::sync_with_stdio(false);    cin.tie(nullptr);       int t=1;    cin>>t;    for(int tt=1;tt<=t;++tt)    {     code();    }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1 << 20;   int n;   int part[N][2];   bool vis[N];   vector<int> ans;   vector<pair<int, int> > G[N];   void dfs(int u) {     vis[u] = true;     for (auto v : G[u])       if (!vis[v.first]) dfs(v.first);   }   bool check(int Mask) {     for (int i = 0; i <= Mask; ++i) G[i].clear(), vis[i] = false;     for (int i = 1; i <= n; ++i) {       int u = part[i][0] & Mask;       int v = part[i][1] & Mask;       G[u].push_back({v, 2 * i - 1});       G[v].push_back({u, 2 * i - 2});     }     int comps = 0;     for (int i = 0; i <= Mask; ++i) {       if (G[i].size() & 1) return false;       if (!vis[i] && G[i].size() > 0) {         ++comps;         dfs(i);       }     }     return comps == 1;   }   void go(int u, int prv = -1) {     while (G[u].size()) {       auto e = G[u].back();       G[u].pop_back();       if (vis[e.second / 2]) continue;       vis[e.second / 2] = true;       go(e.first, e.second);     }     if (prv != -1) {       ans.push_back(prv);       ans.push_back(prv ^ 1);     }   }   void restore(int Mask) {     for (int i = 0; i <= n; ++i) vis[i] = false;     for (int i = 0; i <= Mask; ++i)       if (G[i].size()) {         go(i);         break;       }     for (int i = 0; i < n + n; ++i)       printf( %d%c , ans[i] + 1,    n [i + 1 == n + n]);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d %d , &part[i][0], &part[i][1]);     for (int i = 20; i >= 0; --i)       if (check((1 << i) - 1)) {         printf( %d n , i);         restore((1 << i) - 1);         exit(0);       }     assert(false);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1, c = getchar();     while (c < 48) c ==  -  && (f = -1), c = getchar();     while (c > 47) x = x * 10 + c -  0 , c = getchar();     return x * f;   }   const int MAXN = 100005;   struct Node {     int l, r, mx;     double p;   } q[5005];   std::vector<int> G[5005];   int lg[MAXN], fac[20], st[18][MAXN];   double f[5005][5005];   int n, m;   bool operator<(Node a, Node b) { return a.l ^ b.l ? a.l < b.l : a.r > b.r; }   inline void dfs(int x) {     double p = 1;     for (int y : G[x]) dfs(y);     for (int y : G[x]) p *= f[y][q[x].mx - q[y].mx];     f[x][0] = (1 - q[x].p) * p;     for (int i = 1; i <= m; ++i) {       double lp = 1, rp = 1;       for (int y : G[x]) {         lp *= f[y][min(q[x].mx + i - q[y].mx - 1, m)];         rp *= f[y][min(q[x].mx + i - q[y].mx, m)];       }       f[x][i] = q[x].p * lp + (1 - q[x].p) * rp;     }   }   inline int query(int l, int r) {     int k = lg[r - l + 1];     return max(st[k][l], st[k][r - fac[k] + 1]);   }   inline void buildst() {     for (int i = 1; i <= n; ++i) st[0][i] = read();     for (int i = fac[0] = 1; i < 20; ++i) fac[i] = fac[i - 1] << 1;     for (int i = 2; i <= n; ++i) lg[i] = lg[i >> 1] + 1;     for (int j = 1; j < 17; ++j)       for (int i = 1; i + fac[j] - 1 <= n; ++i)         st[j][i] = max(st[j - 1][i], st[j - 1][i + fac[j - 1]]);   }   int main(int argc, char const *argv[]) {     n = read();     m = read();     buildst();     for (int i = 1; i <= m; ++i) {       q[i].l = read();       q[i].r = read();       scanf( %lf , &q[i].p);       q[i].mx = query(q[i].l, q[i].r);     }     q[++m] = Node{1, n, query(1, n), 0};     sort(q + 1, q + m + 1);     for (int i = 2; i <= m; ++i)       for (int j = i - 1; j; --j)         if (q[j].l <= q[i].l && q[i].r <= q[j].r) {           G[j].push_back(i);           break;         }     dfs(1);     double ans = f[1][0] * q[1].mx;     for (int i = 1; i <= m; ++i) ans += (f[1][i] - f[1][i - 1]) * (q[1].mx + i);     printf( %lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> v(n);     for (int i = 0; i < n; ++i) {       cin >> v[i];     }     sort(v.begin(), v.end());     cout << min(v[n - 1] - v[1], v[n - 2] - v[0]);   }
#include <bits/stdc++.h>   using namespace std;   const int MaxN = 1e3 + 100;   const int LogN = 20;   long long Inf = 1e9 + 100;   const int dx[4] = {0, 1, 0, -1};   const int dy[4] = {1, 0, -1, 0};   const double eps = 1e-9;   int md = 2520;   struct el {     int v, u, c;   };   vector<el> Ans;   vector<int> Gr[MaxN];   int Sz[MaxN];   int Ct = -1;   int N;   int Next = 1;   int Add = 1;   int find(int v, int p = -1, int c = 0) {     int Mx = 0;     int Sum = 1;     for (int to : Gr[v]) {       if (to == p) continue;       int k = find(to, v, c + 1);       Sum += k;       if (Ct != -1) return Sum;       Sz[to] = k;       Mx = ((Mx) > (Sz[to]) ? (Mx) : (Sz[to]));     }     Mx = ((Mx) > (N - Sum) ? (Mx) : (N - Sum));     if (Mx <= N / 2 && Ct == -1) {       Ct = v;       Sz[p] = N - Sum;     }     return Sum;   }   void dfs(int v, int k, int p = -1) {     for (int to : Gr[v]) {       if (p == to) continue;       Ans.push_back({v, to, Next - k});       Next += Add;       dfs(to, Next - Add, v);     }   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cout << fixed << setprecision(5);     cin >> N;     for (int i = 0; i < N - 1; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       Gr[a].push_back(b);       Gr[b].push_back(a);     }     find(0);     vector<pair<int, int> > Mt;     for (int to : Gr[Ct]) {       Mt.push_back({Sz[to], to});     }     sort(Mt.begin(), Mt.end());     vector<pair<int, int> > At;     int k = 0;     while (k < (N - 1) / 3 + ((N - 1) % 3 != 0)) {       At.push_back(Mt.back());       Mt.pop_back();       k += At.back().first;     }     for (pair<int, int> a : At) {       Ans.push_back({Ct, a.second, Next});       Next += Add;       dfs(a.second, Next - Add, Ct);     }     Add = (k + 1);     Next = k + 1;     for (pair<int, int> a : Mt) {       Ans.push_back({Ct, a.second, Next});       Next += Add;       dfs(a.second, Next - Add, Ct);     }     for (el a : Ans) {       cout << a.v + 1 <<     << a.u + 1 <<     << a.c <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12;   int n, sum, a[maxn];   int main(void) {     cin >> n;     for (int i = 0; i < n; i++) scanf( %d , &(a[i])), sum += a[i];     sort(a, a + n);     int ans = 0;     int l = sum / n, r;     r = l + 1;     int y = n - sum + l * n;     for (int i = 0; i < n; i++) {       while (i < y) {         ans += abs(a[i] - l);         i++;       }       while (i < n) {         ans += abs(r - a[i]);         i++;       }     }     cout << ans / 2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int arr[3500];   int main(void) {     int c;     scanf( %d n , &c);     for (int t = 0; t < c; t++) {       int n, m, k;       scanf( %d %d %d n , &n, &m, &k);       for (int i = 0; i < n; i++) {         scanf( %d  , &arr[i]);       }       scanf(  n );       vector<int> v;       for (int i = 0; i < m; i++) {         v.push_back(max(arr[i], arr[i + n - m]));       }       if (k >= m) {         k = m - 1;       }       int ret = 0;       for (int i = 0; i <= k; i++) {         int mini = 2e9;         for (int j = i; j < i + m - k; j++) {           mini = min(v[j], mini);         }         ret = max(ret, mini);       }       printf( %d n , ret);     }   }
#include <bits/stdc++.h>   using namespace std;   int n, sl, fh;   struct node {     int s, m, r, t;   } a[100010];   struct seg {     vector<long long> tim, pre, suf;     vector<node> a;     int lt;     void resize(int l) {       pre.resize(l);       suf.resize(l);     }     long long getans(int T) {       if (!lt) {         long long ret = 0;         for (int i = 0; i < (int)a.size(); ++i)           ret += min(0ll + a[i].m, a[i].s + 1ll * T * a[i].r);         lt = T;         return ret;       }       int t = T - lt,           p = upper_bound(tim.begin(), tim.end(), t) - tim.begin() - 1;       long long ret = 0;       if (p >= 0) ret = pre[p];       if (p < (int)a.size() - 1) ret += t * suf[p + 1];       lt = T;       return ret;     }   } tr[100010 << 2];   int rd() {     sl = 0;     fh = 1;     char ch = getchar();     while (ch <  0  ||  9  < ch) {       if (ch ==  - ) fh = -1;       ch = getchar();     }     while ( 0  <= ch && ch <=  9 ) sl = sl * 10 + ch -  0 , ch = getchar();     return sl * fh;   }   void merge(seg &res, seg &x, seg &y) {     int sz, sx = x.a.size(), sy = y.a.size();     res.resize(sz = sx + sy);     int i = 0, j = 0;     for (; i < sx && j < sy;)       if (x.tim[i] <= y.tim[j])         res.a.push_back(x.a[i]), res.tim.push_back(x.tim[i]), ++i;       else         res.a.push_back(y.a[j]), res.tim.push_back(y.tim[j]), ++j;     for (; i < sx; ++i) res.a.push_back(x.a[i]), res.tim.push_back(x.tim[i]);     for (; j < sy; ++j) res.a.push_back(y.a[j]), res.tim.push_back(y.tim[j]);     res.pre[0] = res.a[0].m;     for (int i = 1; i < sz; ++i) res.pre[i] = res.pre[i - 1] + res.a[i].m;     res.suf[sz - 1] = res.a[sz - 1].r;     for (int i = sz - 1; i; --i) res.suf[i - 1] = res.suf[i] + res.a[i - 1].r;   }   void build(int x, int l, int r) {     if (l == r) {       tr[x].a.push_back(a[l]);       tr[x].tim.push_back(a[l].t);       tr[x].pre.push_back(a[l].m);       tr[x].suf.push_back(a[l].r);       return;     }     build(x << 1, l, ((l + r) >> 1));     build(x << 1 | 1, ((l + r) >> 1) + 1, r);     merge(tr[x], tr[x << 1], tr[x << 1 | 1]);   }   void pushdown(int x) {     if (tr[x].lt >= 0) tr[x << 1].lt = tr[x << 1 | 1].lt = tr[x].lt, tr[x].lt = 0;   }   long long query(int x, int l, int r, int L, int R, int T) {     if (L <= l && r <= R && tr[x].lt >= 0) return tr[x].getans(T);     pushdown(x);     tr[x].lt = -1;     long long ret = 0;     if (L <= ((l + r) >> 1)) ret = query(x << 1, l, ((l + r) >> 1), L, R, T);     if (R > ((l + r) >> 1))       ret += query(x << 1 | 1, ((l + r) >> 1) + 1, r, L, R, T);     if (tr[x << 1].lt == tr[x << 1 | 1].lt) tr[x].lt = tr[x << 1].lt;     return ret;   }   int main() {     n = rd();     for (int i = 1; i <= n; ++i) {       a[i].s = rd();       a[i].m = rd();       a[i].r = rd();       if (!a[i].r)         a[i].t = 1e9;       else         a[i].t = (a[i].m - 1) / a[i].r + 1;     }     build(1, 1, n);     for (int l, r, t, T = rd(); T; --T) {       t = rd();       l = rd();       r = rd();       printf( %lld n , query(1, 1, n, l, r, t));     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(3)   using namespace std;   int n, x, y, final, a[100500], dep[100500], maxn, root, f[100500];   std::vector<int> G[100500];   priority_queue<int> Que;   void DFS1(int now, int fa) {     for (int i = 0; i < (int)G[now].size(); i++) {       if (G[now][i] == fa) continue;       dep[G[now][i]] = dep[now] + 1;       DFS1(G[now][i], now);     }     if (dep[now] > maxn) {       root = now;       maxn = dep[now];     }   }   void DFS2(int now, int fa) {     f[now] = 1;     int son = 0;     for (int i = 0; i < (int)G[now].size(); i++) {       if (G[now][i] == fa) continue;       int to = G[now][i];       DFS2(to, now);       if (f[to] + 1 > f[now]) {         f[now] = f[to] + 1;         son = to;       }     }     for (int i = 0; i < (int)G[now].size(); i++)       if (G[now][i] != fa && G[now][i] != son) Que.push(f[G[now][i]]);   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       scanf( %d%d , &x, &y);       G[x].push_back(y);       G[y].push_back(x);     }     dep[1] = 1;     DFS1(1, 0);     DFS2(root, 0);     Que.push(f[root]);     printf( 1  );     for (int i = 2; i <= n; i++) {       int add = 0;       if (!Que.empty()) add = Que.top(), Que.pop();       final += add;       printf( %d  , final);     }     return 0;   }
#include <bits/stdc++.h>   int m, n = 0, num[(20)];   long long f[(20)][(20)], cnt[(20)], ans = 0;   void CountBit(int m);   long long dfs(int bit, int value, bool limit);   void solve(int p, int s, int q, long long tot);   int main() {     scanf( %d , &m);     CountBit(m);     memset(f, 0xff, sizeof(f));     for (int i = 0; i <= n; i++) cnt[i] = dfs(n, i, true);     cnt[0]--;     for (int i = 1; i <= n; i++) solve(0, 1, i, cnt[i]);     printf(          %I64d            n ,         ans);     return 0;   }   void solve(int p, int s, int q, long long tot) {     if (p >= q) return;     if (s == 7) {       if (q > p) ans += tot, ans %= (1000000007LL);       return;     }     for (int i = 0; i < q; i++) {       if (cnt[i]) {         cnt[i]--;         solve(p + i, s + 1, q, tot * (cnt[i] + 1) % (1000000007LL));         cnt[i]++;       }     }   }   long long dfs(int bit, int value, bool limit) {     long long ret = 0, &save = f[bit][value];     if (!bit) {       if (!value) return save = 1;       return 0;     }     if (!limit && (~save)) return save;     int border = limit ? num[bit] : 9;     for (int i = 0; i <= border; i++)       ret += dfs(bit - 1, value - (i == 4 || i == 7), limit && i == border);     if (!limit) save = ret;     return ret;   }   void CountBit(int m) {     while (m) num[++n] = m % 10, m /= 10;   }
#include <bits/stdc++.h>   using namespace std;   long long x, a[] = {3, 15, 81, 6723, 50625, 2562991875LL};   int sg[] = {0, 1, 2, 0, 3, 1, 2}, n, ans = 0;   int main() {     cin >> n;     while (n--) {       cin >> x;       ans ^= sg[lower_bound(a, a + 6, x) - a];     }     cout << (ans ?  Furlo  :  Rublo ) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q;     scanf( %d , &q);     map<long long, long long> road;     for (int i = 0; i < q; i++) {       int s;       scanf( %d , &s);       if (s == 1) {         long long u, v, w;         scanf( %I64d %I64d %I64d , &u, &v, &w);         while (u != v) {           if (u > v) {             road[u] += w;             u /= 2;           } else {             road[v] += w;             v /= 2;           }         }       } else if (s == 2) {         long long u, v;         scanf( %I64d %I64d , &u, &v);         long long result = 0;         while (u != v) {           if (u > v) {             result += road[u];             u /= 2;           } else {             result += road[v];             v /= 2;           }         }         printf( %I64d n , result);       }     }     return 0;   }