malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long Pow[10005];   long long ans[10005];   int main() {     long long N, X, now = 1, i, con = 0, t;     Pow[0] = 1;     for (i = 1; i <= 40; i++) Pow[i] = Pow[i - 1] * 2;     scanf( %lld %lld , &X, &N);     for (i = 40; i >= 0; i--) {       while (X && X - (Pow[i] - 1) >= 0) {         t = i;         while (t--) ans[con++] = now;         X -= (Pow[i] - 1);         now += N;         now++;       }     }     printf( %lld n , con);     for (i = 0; i < con; i++) printf( %lld  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   const int maxn = 1000 + 10;   const int maxm = 4e5 + 10;   const int inf_max = 0x3f3f3f;   using namespace std;   int a, b, c;   int main() {     int t;     cin >> t;     while (t--) {       cin >> a >> b >> c;       string ans =   ;       if (a) ans +=  0 ;       for (int i = 1; i <= a; ++i) ans +=  0 ;       if (c) {         ans +=  1 ;         if (a) b--;       }       for (int i = 1; i <= c; ++i) ans +=  1 ;       int len = ans.size();       if (len == 0 && b) ans +=  0 ;       len = ans.size();       if (ans[len - 1] ==  0 ) {         while (b >= 2) ans +=  10 , b -= 2;         if (b) ans +=  1 ;       } else {         if (b) ans +=  0 , b--;         while (b >= 2) ans +=  10 , b -= 2;         if (b) ans +=  1 ;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   ll inf = 1e18;   using vb = vector<bool>;   using vc = vector<char>;   using vd = vector<double>;   using vi = vector<int>;   using vvi = vector<vi>;   using vll = vector<ll>;   using vvll = vector<vll>;   using pi = pair<int, int>;   using pll = pair<ll, ll>;   int a[8] = {-1, -1, -1, 0, 0, 1, 1, 1};   int b[8] = {-1, 0, 1, -1, 1, -1, 0, 1};   ll mod = 998244353;   ll ans = 0;   ll x(string s, char a) {     ll n = s.size();     if (n == 1) {       if (s[0] == a) {         return 0;       } else {         return 1;       }     }     ll d = 0;     ll e = 0;     string q, w;     for (ll i = 0; i < n / 2; i++) {       q += s[i];       if (s[i] == a) {         d++;       }     }     for (ll i = n / 2; i < n; i++) {       w += s[i];       if (s[i] == a) {         e++;       }     }     ll p = n / 2;     ll ans1 = (p - d) + x(w, a + 1);     ll ans2 = (p - e) + x(q, a + 1);     return min(ans1, ans2);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ll t;     cin >> t;     while (t--) {       ll n;       cin >> n;       string s;       cin >> s;       ll ans = x(s,  a );       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long sumfirst = 0, sumsecond = 0;     long long n;     vector<long long> first, second;     long long arr[200000];     cin >> n;     for (int i = 0; i < n; i++) {       cin >> arr[i];       if (arr[i] > 0)         sumfirst += arr[i];       else if (arr[i] < 0)         sumsecond += arr[i];       if (arr[i] > 0)         first.push_back(arr[i]);       else         second.push_back(arr[i]);     }     if (sumfirst > (sumsecond * -1)) {       cout <<  first  << endl;       return 0;     } else if (sumfirst < (sumsecond * -1)) {       cout <<  second  << endl;       return 0;     }     for (int i = 0; i < min(second.size(), first.size()); i++) {       if (first[i] > (second[i] * -1)) {         cout <<  first  << endl;         return 0;       } else if ((second[i] * -1) > first[i]) {         cout <<  second  << endl;         return 0;       }     }     if (arr[n - 1] > 0) {       cout <<  first  << endl;       return 0;     } else       cout <<  second  << endl;     return 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 220000;   const long long MOD = 1e9 + 7;   int n;   int was[MAXN * 2];   vector<int> beds[MAXN * 2];   int go[MAXN * 2];   int tm1;   long long dfs1(int v) {     was[v] = 1;     long long ans = 1;     for (int u : beds[v]) ans = (ans + dfs1(u)) % MOD;     return ans;   }   int dfs2(int v) {     was[v] = tm1;     if (was[go[v]] == tm1) {       return 1;     }     if (was[go[v]]) return 0;     return dfs2(go[v]);   }   int main() {     scanf( %d , &n);     for (int i = 0; i < 2 * n; ++i) go[i] = -1;     for (int i = 0; i < n; ++i) {       int x, y;       scanf( %d%d , &x, &y);       --x, --y;       go[x] = y;       beds[y].push_back(x);     }     long long ans = 1;     for (int i = 0; i < 2 * n; ++i) {       if (go[i] == -1)         ans = (ans * dfs1(i)) % MOD;       else if (go[i] == i) {         was[i] = 1;       }     }     tm1 = 1;     for (int i = 0; i < 2 * n; ++i) {       if (was[i]) continue;       ++tm1;       if (dfs2(i)) ans = (ans * 2) % MOD;     }     cout << ans <<   n ;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define int long long int   #define intu unsigned long long int   #define vi vector<int>   #define ii pair<int,int>   #define pb push_back   #define ff first   #define ss second   #define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);   # define PI           3.14159265358979323846    #define all(a) a.begin(),a.end()   #define for0(i, n) for (int i = 0; i < n; i++)   #define for1(i, n) for (int i = 1; i <= n; i++)   #define loop(i,a,b) for (int i = a; i < b; i++)   #define bloop(i,a,b) for (int i = a ; i>=b;i--)   #define tc(t) int t; cin >> t; while (t--)   int mod = 1000000007;   int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}   int lcm(int a, int b) {return a * b / gcd(a, b); }   int bpow(int a,int b)    {     int res = 1;     while (b > 0) {       if (b & 1)res = ((res) * (a));         a = ((a) * (a));         b >>= 1;     }     return res;   }   int fact(int n) {       if ((n==0)||(n==1))         return 1;       else         return ((n%mod) * (fact(n-1))%mod)%mod;   }   void go()   {   #ifndef ONLINE_JUDGE     freopen( input.txt , r ,stdin);     freopen( output.txt , w ,stdout);     #endif   }      map<int,int> mp;      signed main()      {          fast_io         go();            tc(t){           int n;cin>>n;           vi v(n);           bool yes=0;           for0(i,n){             cin>>v[i];                        }           for0(i,n){                          int yo=sqrt(v[i]);             if(yo*yo!=v[i]){               yes=1;               break;             }           }                if(yes)             cout <<  YES  <<   n ;           else             cout <<  NO  <<   n ;                    }       }
#include <bits/stdc++.h>   using namespace std;   long long a[2000000];   int main() {     long long n, t, i;     cin >> n;     for (i = 0; i < n; i++) {       scanf( %lld , &a[i]);     }     cin >> t;     for (i = 0; i < t; i++) {       long long x;       scanf( %lld , &x);       a[x - 1] = -a[x - 1];     }     stack<long long> st;     for (i = n - 1; i >= 0; i--) {       if (a[i] < 0) {         st.push(a[i]);       } else {         if (st.empty() || st.top() != -a[i]) {           st.push(-a[i]);           a[i] = -a[i];         } else {           st.pop();         }       }     }     if (st.empty()) {       cout <<  YES n ;       for (i = 0; i < n; i++) printf( %lld  , a[i]);     } else       cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a, b, x, y;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> a >> x >> b >> y;     while (a != x && b != y) {       ++a;       if (a == n + 1) {         a = 1;       }       --b;       if (b == 0) {         b = n;       }       if (a == b) {         return 0 * puts( YES );       }     }     return 0 * puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   struct point {     int x, y, i;     long long dx, dy;   };   vector<vector<int> > e;   vector<int> sz;   vector<int> ans;   vector<point> pt;   int dfs(int s) {     sz[s] = 1;     for (int i = 0; i < e[s].size(); i++)       if (sz[e[s][i]] == 0) sz[s] += dfs(e[s][i]);     return sz[s];   }   bool cmp(const point &p1, const point &p2) {     return (p1.dx * p2.dy - p1.dy * p2.dx) < 0;   }   void go(int begin, int end, int s) {     for (int i = begin + 1; i < end; i++)       if (make_pair(pt[i].x, pt[i].y) < make_pair(pt[begin].x, pt[begin].y))         swap(pt[begin], pt[i]);     for (int i = begin; i < end; i++) {       pt[i].dx = pt[i].x - pt[begin].x;       pt[i].dy = pt[i].y - pt[begin].y;     }     sort(pt.begin() + begin + 1, pt.begin() + end, cmp);     ans[pt[begin].i] = s + 1;     for (int i = 0, k = begin + 1; i < e[s].size(); i++) {       int v = e[s][i];       if (sz[v] < sz[s]) {         go(k, k + sz[v], v);         k += sz[v];       }     }   }   int main(int argc, char *argv[]) {     int n;     cin >> n;     e.resize(n);     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       u--, v--;       e[u].push_back(v);       e[v].push_back(u);     }     pt.resize(n);     for (int i = 0; i < n; i++) {       cin >> pt[i].x >> pt[i].y;       pt[i].i = i;     }     sz.assign(n, 0);     dfs(0);     ans.assign(n, -1);     go(0, n, 0);     for (int i = 0; i < n; i++) cout << (i ?     :   ) << ans[i];     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, s, sum = 0;     cin >> n >> s;     int arr[n];     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     sort(arr, arr + n);     for (int i = 0; i < n - 1; i++) {       sum += arr[i];     }     if (sum > s)       cout <<  NO  << endl;     else       cout <<  YES  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long x, d, count = 0;     int n;     char a;     cin >> n >> x;     while (n--) {       cin >> a >> d;       if (a ==  + ) {         x += d;       } else {         if (d <= x)           x -= d;         else           count++;       }     }     cout << x <<     << count;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1010;   int ar[MAXN][MAXN], star[MAXN][MAXN];   int main() {     int n, m, t;     char a;     cin >> n >> m >> t;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         scanf(  %c , &a);         ar[i][j] = a -  0 ;       }     for (int i = 2; i < n; i++)       for (int j = 2; j < m; j++)         if (ar[i][j] && ar[i - 1][j] && ar[i][j - 1] && ar[i + 1][j] &&             ar[i][j + 1])           star[i][j] = 1;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         star[i][j] += star[i][j - 1] + star[i - 1][j] - star[i - 1][j - 1];     long long tmp, fl, res = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         tmp = 1;         for (int k = j - 2; k >= 1; k--) {           fl = 1;           while (fl && tmp < i - 1) {             fl = 0;             if (star[i - 1][j - 1] - star[tmp][j - 1] - star[i - 1][k] +                     star[tmp][k] >=                 t)               tmp++, fl = 1;           }           res += tmp - 1;         }       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, mod;   long long fast(long long base, long long pow) {     long long res = 1;     while (pow) {       if (pow % 2) res = ((res % mod) * (base % mod)) % mod;       pow /= 2;       base = ((base % mod) * (base % mod)) % mod;       if (!base) base = mod;     }     return res;   }   int main() {     cin >> n >> mod;     long long res = ((long long)(2 * ((1 - fast(3, n)) / -2.0)) % mod);     if (res == -1)       cout << mod - 1 << endl;     else       cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int _c, n, m;   int e[70];   long long p[70][70], V, A, B, C, ans, G, F;   void dfs2(const long long b, int x) {     if (F / b < b) return;     if (x > n) {       long long c = F / b;       if (G * b + b * c + c * G < ans)         ans = G * b + b * c + c * G, A = G, B = b, C = c;       return;     }     for (int E = e[x]; E >= 0; --E) dfs2(b * p[x][E], x + 1);   }   void dfs(const long long a, int x) {     if (V / a / a < a) return;     if (x > n) {       double T = sqrt(V / a);       G = a, F = V / a;       if (T * a * 2 + V / a < ans) dfs2(1, 1);       return;     }     int E = e[x];     e[x] = 0;     for (; E >= 0; --E, ++e[x]) dfs(a * p[x][E], x + 1);     --e[x];   }   void work() {     scanf( %d , &n);     V = 1;     for (int i = 1; i <= n; ++i) {       scanf( %I64d%d , &p[i][1], &e[i]);       p[i][0] = 1;       for (int j = 2; j <= e[i]; ++j) p[i][j] = p[i][1] * p[i][j - 1];       V *= p[i][e[i]];     }     ans = V * 2 + 1;     A = V, B = C = 1;     dfs(1, 1);     printf( %I64d %I64d %I64d %I64d n , ans << 1, A, B, C);   }   int main() {     for (scanf( %d , &_c); _c--;) work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000000 + 7;   int main() {     string s;     long long n;     cin >> n;     long long a[n];     for (int i = 0; i < n; ++i) cin >> a[i];     long long x = 0, y = n - 1, z = 0;     while (x <= y) {       if (max(a[x], a[y]) < z)         break;       else {         if (a[x] < a[y] && a[x] > z) {           z = a[x];           s +=  L ;           x++;         } else if (a[y] > z) {           z = a[y];           s +=  R ;           y--;         } else {           z = a[x];           s +=  L ;           x++;         }       }     }     cout << s.size() << endl;     cout << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, s, e;   long long dp[5005][5005];   vector<int> x, a, b, c, d;   int main() {     cin >> n >> s >> e;     x.resize(n);     a.resize(n);     b.resize(n);     c.resize(n);     d.resize(n);     for (int i = 0; i < n; i++) {       cin >> x[i];     }     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < n; i++) {       cin >> b[i];     }     for (int i = 0; i < n; i++) {       cin >> c[i];     }     for (int i = 0; i < n; i++) {       cin >> d[i];     }     memset(dp, 0x3f, sizeof(dp));     dp[0][0] = 0;     bool iss = 0, ise = 0;     for (int i = 0; i < n; i++) {       if (i == s - 1) {         iss = 1;       }       if (i == e - 1) {         ise = 1;       }       if (i == n - 1) {         long long p = dp[i][0];         if (i == s - 1) {           dp[i + 1][0] = min(dp[i + 1][0], p + x[i] + c[i]);         } else if (i == e - 1) {           dp[i + 1][0] = min(dp[i + 1][0], p + x[i] + a[i]);         } else {           dp[i + 1][0] = min(dp[i + 1][0], p + 2 * x[i] + a[i] + c[i]);         }         continue;       }       for (int j = 0; j <= n - 2; j++) {         long long p = dp[i][j];         if (i == s - 1) {           dp[i + 1][j] = min(dp[i + 1][j], p - x[i] + d[i]);           if (j) dp[i + 1][j - 1] = min(dp[i + 1][j - 1], p + x[i] + c[i]);         } else if (i == e - 1) {           dp[i + 1][j] = min(dp[i + 1][j], p - x[i] + b[i]);           if (j) dp[i + 1][j - 1] = min(dp[i + 1][j - 1], p + x[i] + a[i]);         } else {           dp[i + 1][j + 1] = min(dp[i + 1][j + 1], p - 2 * x[i] + b[i] + d[i]);           if (j) {             dp[i + 1][j] = min(dp[i + 1][j], p - x[i] + b[i] + x[i] + c[i]);             dp[i + 1][j] = min(dp[i + 1][j], p + x[i] + a[i] - x[i] + d[i]);           }           if (iss) {             dp[i + 1][j] = min(dp[i + 1][j], p + x[i] + a[i] - x[i] + d[i]);           }           if (ise) {             dp[i + 1][j] = min(dp[i + 1][j], p - x[i] + b[i] + x[i] + c[i]);           }           if (j + iss + ise > 1) {             dp[i + 1][j - 1] =                 min(dp[i + 1][j - 1], p + x[i] + a[i] + x[i] + c[i]);           }         }       }     }     cout << dp[n][0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   const ll OO = 1e18;   int di[8] = {0, 0, 1, -1, -1, 1, -1, 1};   int dj[8] = {1, -1, 0, 0, 1, 1, -1, -1};   string ys =  YES , no =  NO ;   const long double dgr = acos(-1) / 180, dg = 180 / acos(-1);   const int mod = 1e9 + 9, N = 1e5 + 5, M = 2001;   ll fast_power(ll base, ll power) {     ll ans = 1;     while (power > 0) {       if (power & 1) ans = (ans * base) % mod;       base = (base * base) % mod;       power >>= 1;     }     return ans;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     ll n, m;     cin >> n >> m;     ll pw_m = fast_power(2, m);     ll ans = 1;     for (int i = 1; i <= n; i++) {       ans = ans * (pw_m - i) % mod;     }     cout << ans % mod <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int many;   int s[100010];   int a[100010];   int p[100010];   int run(int o) {     int zuo = 1;     int you = o - 1;     int re = -1;     int k;     while (zuo <= you) {       k = (zuo + you) / 2;       if (a[k] < s[o]) {         re = k;         you = k - 1;       } else         zuo = k + 1;     }     return re;   }   int main() {     cin >> many;     for (int i = 1; i <= many; i++) scanf( %d , &s[many + 1 - i]);     a[1] = s[1];     p[1] = -1;     for (int i = 2; i <= many; i++) a[i] = min(a[i - 1], s[i]);     for (int i = 2; i <= many; i++) {       if (a[i - 1] >= s[i])         p[i] = -1;       else         p[i] = i - 1 - run(i);     }     for (int i = 1; i <= many; i++) printf( %d  , p[many + 1 - i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void printVector(T begin, T end) {     for (auto i = begin; i != end; i++) {       cout << *i <<    ;     }     cout << endl;   }   long long readLL() {     long long x;     cin >> x;     return x;   }   int a[200];   int b[200];   int main() {     int n, k;     scanf( %d %d , &n, &k);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     int res = 0;     for (int i = 0; i < k; i++) {       for (int j = 0; j < n; j++) {         b[j] = a[j];       }       for (int j = i; j < n; j += k) {         b[j] = 0;       }       int q = 0, w = 0;       for (int j = 0; j < n; j++) {         if (b[j] < 0) q++;         if (b[j] > 0) w++;       }       res = max(res, abs(q - w));     }     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2710;   const double eps = 1e-9;   const double pi = 3.1415926536;   int dp[maxn][maxn];   string s;   int main(int argc, char const *argv[]) {     dp[0][0] = 1;     for (int i = 1; i <= 100; i++) {       for (int j = 0; j <= (i - 1) * 26; j++) {         for (int k = 0; k < 26; k++) {           dp[i][j + k] = (dp[i][j + k] + dp[i - 1][j]) % 1000000007;         }       }     }     int t;     std::cin >> t;     while (t--) {       std::cin >> s;       int len;       len = s.size();       int sum = 0;       for (int i = 0; i < len; i++) {         sum += s[i] -  a ;       }       std::cout << dp[len][sum] - 1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, v, cost, i;     cin >> n >> v;     if (v >= (n - 1))       cout << n - 1;     else {       cost = v;       for (i = 2; i <= n; i++) {         v--;         if ((n - i) <= v) {           cout << cost;           break;         } else {           cost += i;           v++;         }       }     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /stack:200000000 )   int t, n, m, j, ans, k, a, b, c, d, e, f, sum, i, sz, row, col, l;   string s, s2, s3, s4;   deque<pair<int, int> > v;   void brainfuck();   int main() {     ios_base::sync_with_stdio(NULL);     cin.tie(NULL);     cout.tie(NULL);     brainfuck();     return 0;   }   void brainfuck() {     cin >> n >> m >> k;     for (i = 1; i <= n; i++) {       for (j = 1; i & 1 && j <= m; j++) v.push_back({i, j});       for (j = m; i % 2 == 0 && j >= 1; j--) v.push_back({i, j});     }     for (j = 1; j <= k; j++) {       if (j != k)         a = 2;       else         a = v.size();       cout << a;       while (a--) {         cout <<     << v.front().first <<     << v.front().second;         v.pop_front();       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int s[18257 + 1];   int main() {     memset(s, 0, sizeof(s));     s[1] = 1;     for (int i = 2; i <= 18257; i++) {       s[i] = (2 * i - 3) * 6 + 6;     }     int a;     scanf( %d , &a);     if (a == 1) {       cout << s[1] << endl;     } else {       int sum = 0;       for (int i = 1; i <= a; i++) {         sum += s[i];       }       cout << sum << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 210, MAX_K = 1010, MOD = 1e9 + 7;   int N, K, arr[MAX_N], dp[MAX_N][MAX_N][MAX_K];   void add(int& a, long long b) {     b %= MOD;     a = (a + b) % MOD;   }   int solve() {     sort(arr + 1, arr + N + 1);     dp[0][0][0] = 1;     for (int i = 1; i <= N; i++) {       for (int j = 0; j <= i; j++) {         for (int k = 0; k <= K; k++) {           int v = dp[i - 1][j][k];           int nk = k + j * (arr[i] - arr[i - 1]);           if (nk > K) continue;           add(dp[i][j][nk], v);           add(dp[i][j][nk], 1LL * j * v);           add(dp[i][j + 1][nk], v);           if (j) add(dp[i][j - 1][nk], 1LL * j * v);         }       }     }     int ret = 0;     for (int k = 0; k <= K; k++) {       add(ret, dp[N][0][k]);     }     return ret;   }   void read() {     cin >> N >> K;     for (int i = 1; i <= N; i++) cin >> arr[i];   }   int main() {     read();     cout << solve() << endl;     return (0);   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int mod = 1000000007;   const int N = 5e5 + 5;   int n, m, q, ans[N];   struct node {     int cnt, id;   } c[N];   struct ask {     int id;     long long x;   } Q[N];   int st[N << 2];   void update(int o, int l, int r, int pos) {     if (l == r) {       ++st[o];       return;     }     int mid = l + r >> 1;     if (pos <= mid)       update(o << 1, l, mid, pos);     else       update(o << 1 | 1, mid + 1, r, pos);     st[o] = st[o << 1] + st[o << 1 | 1];   }   int query(int o, int l, int r, int k) {     if (l == r) return l;     int mid = l + r >> 1;     if (k <= st[o << 1])       return query(o << 1, l, mid, k);     else       return query(o << 1 | 1, mid + 1, r, k - st[o << 1]);   }   int main() {     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       ++c[x].cnt;     }     for (int i = 1; i <= m; i++) c[i].id = i;     for (int i = 1; i <= q; i++) {       long long x;       scanf( %lld , &x);       Q[i].id = i, Q[i].x = x;     }     sort(c + 1, c + 1 + m, [](const node& a, const node& b) {       return a.cnt == b.cnt ? a.id < b.id : a.cnt < b.cnt;     });     sort(Q + 1, Q + 1 + q, [](const ask& a, const ask& b) { return a.x < b.x; });     long long now = n;     int j = 1;     for (int i = 1; i <= m; i++) {       long long nxt = (i == m ? 2e18 : 1ll * (c[i + 1].cnt - c[i].cnt) * i + now);       update(1, 1, m, c[i].id);       while (j <= q && Q[j].x <= nxt) {         long long x = Q[j].x;         int tmp = (x - now) % i;         if (!tmp) tmp = i;         ans[Q[j].id] = query(1, 1, m, tmp);         ++j;       }       now = nxt;     }     for (int i = 1; i <= q; i++) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char str[1000005];   int num[1000005];   int main() {     int i, j, len, ans;     while (scanf( %s , str) != EOF) {       len = strlen(str);       for (i = 0, j = len - 1; i < j; i++, j--) {         swap(str[i], str[j]);       }       str[len] =  0 ;       memset(num, 0, sizeof(num));       ans = 0;       for (i = 0; i <= len; i++) {         if (str[i] ==  1 ) {           for (j = i + 1; j <= len; j++) {             if (str[j] ==  0 ) break;           }           if (j != i + 1) {             num[j] = 1;             num[i] = -1;             str[j] =  1 ;           } else {             num[i] = 1;           }           i = j - 1;         }       }       for (i = 0; i <= len; i++) {         if (num[i]) ans++;       }       printf( %d n , ans);       for (i = 0; i <= len; i++) {         if (num[i]) {           if (num[i] == 1) printf( + );           if (num[i] == -1) printf( - );           printf( 2^%d n , i);         }       }     }     return 0;   }