malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9;   const int MOD = 1e9 + 7;   vector<string> vec_splitter(string s) {     s +=  , ;     vector<string> res;     while (!s.empty()) {       res.push_back(s.substr(0, s.find( , )));       s = s.substr(s.find( , ) + 1);     }     return res;   }   void debug_out(vector<string> __attribute__((unused)) args,                  __attribute__((unused)) int idx,                  __attribute__((unused)) int LINE_NUM) {     cerr <<   n ;   }   template <typename Head, typename... Tail>   void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {     if (idx > 0)       cerr <<  ,  ;     else       cerr <<  Line(  << LINE_NUM <<  )  ;     stringstream ss;     ss << H;     cerr << args[idx] <<   =   << ss.str();     debug_out(args, idx + 1, LINE_NUM, T...);   }   void run() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   long long gcd(long long n1, long long n2) {     if (n2 != 0)       return gcd(n2, n1 % n2);     else       return n1;   }   bool checkPalindrome(string s) {     int n = s.size();     for (int i = 0; i < n / 2; i++) {       if (s[i] != s[n - i - 1]) return false;     }     return true;   }   long long digSum(long long n) {     long long sum = 0;     while (n > 0) {       sum += n % 10;       n /= 10;     }     return sum;   }   bool compare(pair<int, int> a, pair<int, int> b) {     if (a.first == a.second)       return true;     else if (b.first == b.second)       return false;     else {       int adiff = a.second - a.first;       int bdiff = b.second - b.first;       if (adiff > bdiff)         return false;       else         return true;     }   }   int main() {     run();     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       vector<int> v(n + 1);       for (int i = 1; i <= n; i++) {         cin >> v[i];       }       sort(v.begin(), v.end());       long long ans = 0;       int ind = n - 2 * k;       int half = ind + k;       for (int i = 1; i <= ind; i++) {         ans += v[i];       }       for (int i = ind + 1; i <= half; i++) {         ans = ans + (v[i] / v[i + k]);       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k;   const long long pri = 1e9 + 7;   long long myPow(long long a, long long b) {     long long ret = 1;     while (b != 0) {       if (b % 2 != 0) {         ret = (ret * a) % pri;       }       a = (a * a) % pri;       b /= 2;     }     return ret;   }   int main() {     ios_base::sync_with_stdio(false);     long long precision = numeric_limits<double>::digits10;     cin >> n >> m >> k;     if (k == -1 && (n + m) % 2 != 0)       cout << 0 <<   n ;     else {       long long ans = myPow(2, m - 1);       ans = myPow(ans, n - 1);       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   int main() {     int x, y;     scanf( %d%d , &x, &y);     int r2 = x * x + y * y;     int r = floor(sqrt(static_cast<double>(r2)));     if (r * r < r2 && (r + 1) * (r + 1) > r2 &&         (r % 2 == 1 && x * y > 0 || r % 2 == 0 && x * y < 0)) {       printf( white n );     } else {       printf( black n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int maxn = 250005;   vector<int> g[maxn];   int pa[maxn];   int v[maxn];   int dep[maxn];   vector<int> leaf;   int n, m, k;   void build(int now) {     int x = 0, y = 0;     for (auto &i : g[now]) {       if (i == pa[now]) {         continue;       } else if (x == 0) {         x = i;       } else {         y = i;       }     }     vector<int> ans;     if ((dep[now] - dep[x] + 1) % 3) {       ans.push_back(now);       while (ans.back() != x) {         ans.push_back(pa[ans.back()]);       }     } else if ((dep[now] - dep[y] + 1) % 3) {       ans.push_back(now);       while (ans.back() != y) {         ans.push_back(pa[ans.back()]);       }     } else {       if (dep[x] < dep[y]) {         swap(x, y);       }       ans.push_back(now);       ans.push_back(x);       while (ans.back() != y) {         ans.push_back(pa[ans.back()]);       }     }     cout << ans.size() <<   n ;     for (auto &i : ans) {       cout << i <<    ;     }     cout <<   n ;   }   void dfs(int now) {     v[now] = 1;     int f = 0;     if (dep[now] * k >= n) {       cout <<  PATH n ;       vector<int> ans{now};       while (ans.back() != 1) {         ans.push_back(pa[ans.back()]);       }       cout << ans.size() <<   n ;       for (auto &i : ans) {         cout << i <<    ;       }       cout <<   n ;       exit(0);     }     for (auto &i : g[now]) {       if (v[i]) {         continue;       }       dep[i] = dep[now] + 1;       pa[i] = now;       dfs(i);       f = 1;     }     if (!f) {       leaf.push_back(now);     }   }   void go() {     cin >> n >> m >> k;     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       g[x].push_back(y);       g[y].push_back(x);     }     dep[1] = 1;     dfs(1);     cout <<  CYCLES n ;     for (int i = 0; i < k; i++) {       build(leaf[i]);     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int c = 0;     int t;     if (!c) {       t = 1;     } else {       cin >> t;     }     while (t--) {       go();     }   }
#include <bits/stdc++.h>   using namespace std;   const int KMAX = 8;   const int NMAX = 2505;   char mat[NMAX][NMAX];   int psm[NMAX][NMAX], pt1[KMAX], pt2[KMAX];   inline int sum(int x1, int y1, int x2, int y2) {     return psm[x2][y2] - psm[x2][y1 - 1] - psm[x1 - 1][y2] + psm[x1 - 1][y1 - 1];   }   long long solve(int x1, int y1, int x2, int y2, int k) {     if (x1 == x2 and y1 == y2) return sum(x1, y1, x2, y2) == k;     long long ans;     if (x2 - x1 <= y2 - y1) {       int ym = (y1 + y2) / 2;       ans = solve(x1, y1, x2, ym, k) + solve(x1, ym + 1, x2, y2, k);       for (int i = x1; i <= x2; ++i) {         for (int k1 = 0; k1 <= k; ++k1) pt1[k1] = y1, pt2[k1] = y2;         for (int j = i; j <= x2; ++j) {           for (int k1 = 0; k1 <= k; ++k1) {             while (pt1[k1] <= ym and sum(i, pt1[k1], j, ym) > k1) ++pt1[k1];             while (pt2[k1] > ym and sum(i, ym + 1, j, pt2[k1]) > k1) --pt2[k1];           }           for (int k1 = 0; k1 <= k; ++k1)             ans += 1LL * (((k1 > 0) ? pt1[k1 - 1] : (ym + 1)) - pt1[k1]) *                    (pt2[k - k1] - ((k - k1 > 0) ? pt2[k - k1 - 1] : ym));         }       }     } else {       int xm = (x1 + x2) / 2;       ans = solve(x1, y1, xm, y2, k) + solve(xm + 1, y1, x2, y2, k);       for (int i = y1; i <= y2; ++i) {         for (int k1 = 0; k1 <= k; ++k1) pt1[k1] = x1, pt2[k1] = x2;         for (int j = i; j <= y2; ++j) {           for (int k1 = 0; k1 <= k; ++k1) {             while (pt1[k1] <= xm and sum(pt1[k1], i, xm, j) > k1) ++pt1[k1];             while (pt2[k1] > xm and sum(xm + 1, i, pt2[k1], j) > k1) --pt2[k1];           }           for (int k1 = 0; k1 <= k; ++k1)             ans += 1LL * (((k1 > 0) ? pt1[k1 - 1] : (xm + 1)) - pt1[k1]) *                    (pt2[k - k1] - ((k - k1 > 0) ? pt2[k - k1 - 1] : xm));         }       }     }     return ans;   }   int main(void) {     int n, m, k;     scanf( %d %d %d , &n, &m, &k);     for (int i = 1; i <= n; ++i) {       scanf( %s , mat[i] + 1);       for (int j = 1; j <= m; ++j)         psm[i][j] =             psm[i - 1][j] + psm[i][j - 1] - psm[i - 1][j - 1] + (mat[i][j] -  0 );     }     printf( %I64d n , solve(1, 1, n, m, k));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[2001][2001];   int f(int i, int j) {     if (j < 0 || i < 0 || j > i) return 0;     if (dp[i][j] != -1) return dp[i][j];     if (j == i)       dp[i][j] =           (((long long)i - 1) * (f(i - 1, i - 1) + (long long)f(i - 2, i - 2))) %           1000000007;     else       dp[i][j] =           (f(i - 1, j - 1) * ((long long)j) + ((long long)i - j) * f(i - 1, j)) %           1000000007;     return dp[i][j];   }   int used[2001] = {};   int a[2001];   int main() {     int x, n, bound = 0, total = 0, i, j;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d , &a[i]);       if (a[i] == -1)         total++;       else         used[a[i]] = 1;     }     for (i = 0; i < n; i++) {       if (used[i + 1] == 0 && a[i] == -1) bound++;     }     memset(dp, -1, sizeof(dp));     dp[0][0] = 1;     dp[1][0] = 1;     dp[1][1] = 0;     printf( %d n , f(total, bound));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e8;   long long inf = 1e15;   long long n, m, k, ans, x;   long long t[2003], c[2003];   long long dp[2003][4003];   long long f(long long x, long long y) {     long long &ret = dp[x][y];     if (ret != -1) return ret;     if (x == n + 1 && y < 2000) return inf;     if (x == n + 1) return 0;     long long yy = y + t[x];     yy = min(yy, 4000LL);     ret = c[x] + f(x + 1, yy);     ret = min(ret, f(x + 1, y - 1));     return ret;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     memset(dp, -1, sizeof dp);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> t[i] >> c[i];     }     cout << f(1, 2000);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T, class L>   bool smax(T &x, L y) {     return x < y ? (x = y, 1) : 0;   }   template <class T, class L>   bool smin(T &x, L y) {     return x > y ? (x = y, 1) : 0;   }   const int maxn = 15e3 + 17, maxk = 1e3 + 17, mod = 1e9 + 7, base = 1e7 + 19,             lg = 17, maxq = 3e4 + 17;   vector<int> iman[maxq << 2];   int n, k, nq, q, dp[lg][maxk], w[maxn], v[maxn], ans[maxq], po[maxk];   void majid(int st, int en, int idx, int l = 0, int r = q, int id = 1) {     if (st <= l && r <= en) {       iman[id].push_back(idx);       return;     }     if (en <= l || r <= st) return;     int mid = l + r >> 1;     majid(st, en, idx, l, mid, id << 1), majid(st, en, idx, mid, r, id << 1 | 1);   }   void hamid(int l = 0, int r = q, int id = 1, int h = 1) {     memcpy(dp[h], dp[h - 1], sizeof dp[h]);     for (auto idx : iman[id])       for (int wi = k - w[idx]; wi >= 0; wi--)         smax(dp[h][wi + w[idx]], dp[h][wi] + v[idx]);     partial_sum(dp[h], dp[h] + k + 1, dp[h],                 [](int &x, int &y) { return max(x, y); });     if (r - l < 2) {       for (int i = 1; i <= k; i++)         ans[l] = (ans[l] + (long long)po[i - 1] * dp[h][i]) % mod;       return;     }     int mid = l + r >> 1;     hamid(l, mid, id << 1, h + 1), hamid(mid, r, id << 1 | 1, h + 1);   }   int st[maxn], en[maxn];   int main() {     ios::sync_with_stdio(0), cin.tie(0);     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> v[i] >> w[i];     po[0] = 1;     for (int i = 1; i <= k; i++) po[i] = (long long)po[i - 1] * base % mod;     memset(en, 63, sizeof en);     cin >> nq;     for (int t, x; nq--;) {       cin >> t;       if (t == 1)         cin >> v[n] >> w[n], st[n++] = q;       else if (t == 2)         cin >> x, en[x - 1] = q;       else         q++;     }     for (int i = 0; i < n; i++) majid(st[i], min(q, en[i]), i);     hamid();     for (int i = 0; i < q; i++) cout << ans[i] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int need[105];   int main() {     int n;     cin >> n;     int i;     for (i = 1; i <= n - 1; i++) {       cin >> need[i];     }     int a, b;     cin >> a >> b;     int ans = 0;     for (i = a; i <= b - 1; i++) {       ans += need[i];     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     string s;     cin >> s;     int n = s.size();     if (s[0] ==  b  && s[n - 1] ==  a ) {       s[0] =  a ;     } else if (s[0] ==  a  && s[n - 1] ==  b ) {       s[n - 1] =  a ;     }     cout << s <<   n ;   }   int main() {     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     int n;     cin >> n;     vector<char> c(n);     vector<int> id(n);     map<int, bool> state, exist;     for (int i = 0; i < n; i++) cin >> c[i] >> id[i];     for (int i = 0; i < n; i++) {       if (c[i] ==  + )         exist[id[i]] = true;       else {         if (exist[id[i]])           exist[id[i]] = false;         else           state[id[i]] = true;       }     }     int ans = state.size();     for (int i = 0; i < n; i++) {       if (c[i] ==  + )         state[id[i]] = true;       else {         state.erase(id[i]);       }       ans = max(ans, int(state.size()));     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long i, j, k, l, m, n, s, t, p, q, a, b, aa, bb, d;   char c[2222222];   int main() {     t = 1;     while (gets(c) != 0) {       for (i = 0; c[i] != 0; i++)         if (c[i] !=    ) break;       if (c[i] ==  # ) {         if (t == 0) puts(  );         puts(c);         t = 1;       } else {         for (i = 0; c[i] != 0; i++)           if (c[i] !=    ) cout << c[i];         t = 0;       }     }     if (t == 0) puts(  );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m;     long long inf = 1000000005;     cin >> n >> m;     long long i, j, k;     bool a[n + 1][n + 1];     long long deg[n + 1];     for (i = 0; i < n + 1; i++) {       deg[i] = 0;       for (j = 0; j < n + 1; j++) a[i][j] = false;     }     long long res = inf;     for (i = 0; i < m; i++) {       cin >> j >> k;       a[j][k] = true;       a[k][j] = true;       deg[j]++;       deg[k]++;     }     for (i = 1; i < n; i++) {       for (j = i + 1; j <= n; j++) {         if (a[i][j]) {           for (k = j + 1; k <= n; k++) {             if (a[i][k] && a[j][k]) res = min(res, deg[i] + deg[j] + deg[k]);           }         }       }     }     if (res == inf)       cout << -1 << endl;     else       cout << res - 6 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int t;     cin >> t;     for (int i = 0; i < n; ++i) {       int a, b;       cin >> a >> b;       int d[7] = {0};       d[a] = 1;       d[7 - a] = 1, d[b] = 1, d[7 - b] = 1;       d[t] = 1;       int cn = 0;       for (int j = 1; j < 7; ++j) {         if (d[j] == 0) {           t = 7 - j;           cn++;         }       }       if (cn == 2) return (cout <<  NO , 0);     }     cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 100;   int a[N];   int main() {     std::ios::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 0; i < n; ++i) cin >> a[i];     vector<int> nrs;     for (int i = 0; i < n; ++i) nrs.push_back(a[i]);     for (int i = 1; i < 32; ++i) {       vector<int> counts(32, 0);       vector<int> cur;       for (int j = 0; j < n; ++j) {         if (not(a[j] & (1 << i))) continue;         cur.push_back(a[j]);         for (int k = 0; k < 32; ++k) {           if (a[j] & (1 << k)) ++counts[k];         }       }       if (cur.empty()) continue;       bool ok = true;       for (int j = 0; j < i; ++j) {         ok &= counts[j] < counts[i];       }       if (ok) nrs = cur;     }     cout << nrs.size() <<   n ;     for (int i = 0; i < (int)nrs.size(); ++i) {       if (i > 0) cout <<    ;       cout << nrs[i];     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     scanf( %d , &(n)), scanf( %d , &(m));     int a[(100000 + 10)][2];     for (int i(0), _n(n); i < _n; ++i) {       scanf( %d , &a[i][1]);       if (a[i][1] > 0)         a[i][0] =  + ;       else         a[i][0] =  - , a[i][1] = -a[i][1];     }     int yes[(100000 + 10)], no[(100000 + 10)];     memset((yes), 0, sizeof(yes));     memset((no), 0, sizeof(no));     for (int i(0), _n(n); i < _n; ++i) {       if (a[i][0] ==  + )         yes[a[i][1]]++;       else         no[a[i][1]]++;     }     int sno = 0;     for (int i(1), _h(n); i <= _h; ++i) sno += no[i];     bool may[(100000 + 10)];     memset((may), false, sizeof(may));     int cnt = 0;     for (int i(1), _h(n); i <= _h; ++i)       if (yes[i] + sno - no[i] == m) {         may[i] = true;         cnt++;       }     for (int i(0), _n(n); i < _n; ++i) {       if (a[i][0] ==  + ) {         if (may[a[i][1]] && cnt == 1)           puts( Truth );         else if (may[a[i][1]])           puts( Not defined );         else           puts( Lie );       } else {         if (may[a[i][1]] && cnt == 1)           puts( Lie );         else if (may[a[i][1]])           puts( Not defined );         else           puts( Truth );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200010], b[200010], n, m, q;   vector<pair<int, int> > e[200010];   long long T[800010], d[800010];   long long f[200010];   void push(int id) {     T[id << 1] += d[id];     T[id << 1 | 1] += d[id];     d[id << 1] += d[id];     d[id << 1 | 1] += d[id];     d[id] = 0;     return;   }   void upd(int x, int y, long long dx, int id = 1, int l = 0, int r = n) {     if (x >= r || l >= y) return;     if (x <= l && r <= y) {       T[id] += dx;       d[id] += dx;       return;     }     push(id);     upd(x, y, dx, id << 1, l, l + r >> 1);     upd(x, y, dx, id << 1 | 1, l + r >> 1, r);     T[id] = min(T[id << 1], T[id << 1 | 1]);     return;   }   void build() {     for (int i = 0; i < n; i++) upd(i, i + 1, b[i]);     for (int i = 0; i < n; i++) {       for (auto p : e[i]) {         int to, cost;         tie(to, cost) = p;         upd(0, to + 1, cost);       }       f[i] = T[1];     }     memset(T, 0, sizeof(T));     memset(d, 0, sizeof(d));     for (int i = 0; i < n; i++) upd(i, i + 1, a[i] + f[i]);     return;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m >> q;     for (int i = 0; i < n - 1; i++) cin >> a[i] >> b[i + 1];     for (int i = 0, u, v, w; i < m; i++) {       cin >> u >> v >> w;       e[--u].push_back((make_pair((--v), (w))));     }     build();     cout << T[1] << endl;     while (q--) {       int x, w;       cin >> x >> w;       upd(x - 1, x, w - a[x - 1]);       a[x - 1] = w;       cout << T[1] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, t, lim = 16;   int w[4], g[1005];   char ch[4][1005];   int num[4][4];   int s[4][4][4];   int dp[1005][16][16][16][16];   int main() {     scanf( %d , &n);     for (int i = 0; i < 4; i++) scanf( %d , &w[i]);     for (int i = 0; i < 4; i++) scanf( %s , ch[i]);     memset(dp, 0x3f, sizeof(dp));     for (int i = 0; i < n; i++) {       t = 0;       for (int j = 0; j < 4; j++) t <<= 1, t += (ch[j][i] ==  . );       g[i] = t;     }     for (int i = n; i < n + 5; i++) g[i] = lim - 1;     dp[0][g[0]][g[1]][g[2]][g[3]] = 0;     for (int i = 0; i < 4; i++)       for (int j = 0; j < 4 - i; j++) {         for (int k = 0; k < 4; k++)           for (int p = 0; p < 4; p++) num[k][p] = 0;         for (int k = 0; k <= i; k++)           for (int p = j; p <= j + i; p++) num[k][p] = 1;         for (int k = 0; k < 4; k++) {           t = 0;           for (int p = 0; p < 4; p++) t <<= 1, t += num[k][p];           s[i][j][k] = t;         }       }     for (int i = 0; i < n; i++)       for (int a = 0; a < lim; a++)         for (int b = 0; b < lim; b++)           for (int c = 0; c < lim; c++)             for (int d = 0; d < lim; d++) {               if (dp[i][a][b][c][d] >= 0x3f3f3f3f) continue;               if (a == lim - 1)                 dp[i + 1][b][c][d][g[i + 4]] =                     min(dp[i + 1][b][c][d][g[i + 4]], dp[i][a][b][c][d]);               for (int j = 0; j < 4; j++)                 for (int k = 0; k < 4 - j; k++)                   dp[i][a | s[j][k][0]][b | s[j][k][1]][c | s[j][k][2]]                     [d | s[j][k][3]] = min(dp[i][a | s[j][k][0]][b | s[j][k][1]]                                              [c | s[j][k][2]][d | s[j][k][3]],                                            dp[i][a][b][c][d] + w[j]);             }     printf( %d , dp[n - 1][lim - 1][lim - 1][lim - 1][lim - 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int N = 2e5 + 7;   int n, m, i, j, a, b;   int check(int x, int y) {     int dis1 = abs(x - i);     int dis2 = abs(y - j);     if (dis1 % a == 0 && dis2 % b == 0) {       int p = dis1 / a;       int q = dis2 / b;       if (p == q) return q;       if ((p + q) & 1) return inf;       if (p < q) {         if (i + a > n && i - a < 1) return inf;       } else {         if (j + b > m && j - b < 1) return inf;       }       return max(p, q);     } else       return inf;   }   int main() {     scanf( %d , &n);     scanf( %d , &m);     scanf( %d , &i);     scanf( %d , &j);     scanf( %d , &a);     scanf( %d , &b);     int ans = inf;     ans = min(ans, check(1, 1));     ans = min(ans, check(n, 1));     ans = min(ans, check(1, m));     ans = min(ans, check(n, m));     if (ans == inf)       puts( Poor Inna and pony! );     else       printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( sse4 )   using namespace std;   const long long INF = 1e18;   const long long MOD = 1e9 + 7;   const long long N = 2e6 + 10;   const long long dx[8] = {1, 0, -1, 0, 1, 1, -1, -1},                   dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};   bool TC = 0;   long long binpow(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = res * 1LL * a;       a = a * 1LL * a;       b >>= 1;     }     return res;   }   long long s(long long n) {     long long res = 0;     while (n) {       res += n % 10;       n /= 10;     }     return res;   }   void test_case() {     long long a, b, c;     cin >> a >> b >> c;     vector<long long> v;     for (long long i = 1; i <= 81; i++) {       long long var = b * ((long long)binpow(i, a)) + c;       if (s(var) == i && var < 1e9) v.push_back(var);     }     cout << (long long)((v).size()) <<   n ;     for (long long i = 0; i < (long long)((v).size()); i++) {       cout << v[i] <<    ;     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     if (TC) {       long long T;       cin >> T;       while (T--) test_case();     } else       test_case();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   long long pow_[20];   long long binpow(long long a, long long n) {     long long res = 1;     while (n) {       if (n % 2 == 1) {         res = (a * res) % mod;       }       a = (a * a) % mod;       n /= 2;     }     return res;   }   long long C(long long n, long long k) {     long long res = 1;     n = n % mod;     for (long long i = n; i >= n - k + 1; i--) {       res = (res * i) % mod;     }     for (long long i = 1; i <= k; i++) {       res = (res * pow_[i]) % mod;     }     return res;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie();     cout.tie();     for (long long i = 1; i <= 19; i++) {       pow_[i] = binpow(i, mod - 2);     }     long long n, s;     cin >> n >> s;     vector<long long> f(n);     for (long long i = 0; i < n; i++) cin >> f[i];     long long res = 0;     for (long long mask = 0; mask < (1 << n); mask++) {       long long t = 0;       for (long long i = 0; i < n; i++) {         if (mask & (1 << i)) t++;       }       long long cur;       if (t % 2 == 0)         cur = 1;       else         cur = -1;       long long sum = 0;       for (long long i = 0; i < n; i++) {         if (mask & (1 << i)) sum += (f[i] + 1);       }       if (s - sum + n - 1 < n - 1) continue;       cur = (cur * C(s - sum + n - 1, n - 1) + mod) % mod;       res = (res + cur) % mod;     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long int k;   long long int a[100001];   int main() {     cin >> n >> k;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     sort(a + 1, a + n + 1);     for (int i = 1; i <= n / 2; i++) {       long long int c = (a[i + 1] - a[i] + a[n - i + 1] - a[n - i]) * i;       if (c <= k)         k -= c;       else {         cout << a[n - i + 1] - a[i] - k / i;         return 0;       }     }     cout << 0;     return 0;   }