malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   double Fib(double x, double z);   string BinDec(unsigned long long x);   string StringInt(long long x);   unsigned long long StringInt(string x);   unsigned long long BinDec(string x);   unsigned long long POWMOD(unsigned long long x, unsigned long long y,                             unsigned long long mod);   unsigned long long POWE(long long, long long);   long long fast_pow(long long a, long long b, long long mod) {     if (b == 0) return 1ll;     long long ans = 1;     if (b % 2) return ans = (fast_pow(a, b - 1, mod) * a) % mod;     ans = (fast_pow(a, b / 2, mod) % mod);     return ((ans * ans) % mod);   }   int arr[10][10] = {};   vector<vector<pair<int, int> > > vec, vec2;   void rec(int i, int j, vector<pair<int, int> > v) {     if (v.size() == 8) {       vec.push_back(v);     }     if (i == 9) return;     if (arr[i][j] == 0) {       for (int k = 1; k <= 8; k++) arr[k][j]++;       for (int l = 1; l <= 8; l++) arr[i][l]++;       arr[i][j]--;       for (int k = 1; k <= 8; k++) {         if (i + k <= 8 && j + k <= 8) arr[i + k][k + j]++;         if (i - k >= 1 && j - k >= 1) arr[i - k][j - k]++;         if (i + k <= 8 && j - k >= 1) arr[i + k][j - k]++;         if (i - k >= 1 && j + k <= 8) arr[i - k][j + k]++;       }       v.push_back({i, j});       if (j == 8)         rec(i + 1, 1, v);       else         rec(i, j + 1, v);       v.pop_back();       for (int k = 1; k <= 8; k++) arr[k][j]--;       for (int l = 1; l <= 8; l++) arr[i][l]--;       arr[i][j]++;       for (int k = 1; k <= 8; k++) {         if (i + k <= 8 && j + k <= 8) arr[i + k][k + j]--;         if (i - k >= 1 && j - k >= 1) arr[i - k][j - k]--;         if (i + k <= 8 && j - k >= 1) arr[i + k][j - k]--;         if (i - k >= 1 && j + k <= 8) arr[i - k][j + k]--;       }     }     if (j == 8)       rec(i + 1, 1, v);     else       rec(i, j + 1, v);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long x, y, a, b, c, d, s;     cin >> x >> y >> a >> b;     if (a == b || y == 1)       s = 1;     else if (b % y == 0 && b - a < y)       s = 1;     else if (b % y > a % y && b - a < y && a % y)       s = 1;     else if (a % y == 1 && b % y == 0)       s = 1;     else if (b == x && a % y == 1)       s = 1;     else if (b == x)       s = 2;     else if (b % y == 0 || a % y == 1)       s = 2;     else if (b % y == ((a - 1) % y))       s = 2;     else if (b - a < y)       s = 2;     else if (b - a < y * 2 && ((b % y == 0 || b % y > y / 2) ||                                ((y - (a % y)) > y / 2 && a % y != 0)))       s = 2;     else       s = 3;     cout << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m, k;     cin >> n >> m >> k;     if (n + m - 2 < k) {       cout <<  -1 n ;       return 0;     }     long long ans = max(n * (m / (k + 1)), m * (n / (k + 1)));     if ((k - m + 2) > 0) ans = max(ans, n / (k - m + 2));     if ((k - n + 2) > 0) ans = max(ans, m / (k - n + 2));     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:667772160 )   template <class T1>   void deb(T1 e1) {     cout << e1 << endl;   }   template <class T1, class T2>   void deb(T1 e1, T2 e2) {     cout << e1 <<     << e2 << endl;   }   template <class T1, class T2, class T3>   void deb(T1 e1, T2 e2, T3 e3) {     cout << e1 <<     << e2 <<     << e3 << endl;   }   template <class T1, class T2, class T3, class T4>   void deb(T1 e1, T2 e2, T3 e3, T4 e4) {     cout << e1 <<     << e2 <<     << e3 <<     << e4 << endl;   }   template <class T1, class T2, class T3, class T4, class T5>   void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {     cout << e1 <<     << e2 <<     << e3 <<     << e4 <<     << e5 << endl;   }   template <class T1, class T2, class T3, class T4, class T5, class T6>   void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {     cout << e1 <<     << e2 <<     << e3 <<     << e4 <<     << e5 <<     << e6          << endl;   }   int value[10000000 + 7][3], level[100000 + 7], arr[100000 + 7];   long long odd;   vector<int> graph[100000 + 7];   void dfs(int u) {     level[u] = 1;     int v;     for (int i = 0; i < graph[u].size(); i++) {       v = graph[u][i];       dfs(v);       level[u] = level[v] ^ 1;     }     odd += level[u];   }   int main() {     int mx = 0, n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &arr[i]);     int p;     for (int i = 2; i <= n; i++) {       scanf( %d , &p);       graph[p].push_back(i);     }     dfs(1);     int xr = 0;     for (int i = 1; i <= n; i++) {       value[arr[i]][level[i]]++;       if (level[i]) xr = xr ^ arr[i];     }     long long ans = 0;     if (xr == 0) {       ans += (odd * (odd - 1)) / 2LL;       odd = n - odd;       ans += (odd * (odd - 1)) / 2LL;     }     for (int i = 1; i <= n; i++) {       if (level[i] && (arr[i] ^ xr) <= 10000000) ans += value[arr[i] ^ xr][0];     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int NN = 1000007;   vector<int> adj[NN];   int vst[NN], ans[NN];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       int u, v;       scanf( %d%d , &u, &v);       adj[u].push_back(v);     }     for (int i = 1; i <= n; i++)       if (!vst[i]) {         vst[i] = 1;         for (int v : adj[i])           if (!vst[v]) vst[v] = 2;       }     int cnt = 0;     for (int i = n; i; i--)       if (vst[i] == 1) {         ans[++cnt] = i;         for (int v : adj[i]) vst[v] = 2;       }     cout << cnt << endl;     for (int i = 1; i <= cnt; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int q;   long long L, R;   vector<long long> vec, vec2;   long long solve(long long x);   set<int> st;   void precalc() {     for (long long i = 2; i <= 1e6; i++) {       for (long long j = i * i * i; j <= 1e18; j *= i) {         vec.push_back(j);         if (j > (1e18) / i) break;       }     }     sort(vec.begin(), vec.end());     vec.erase(unique(vec.begin(), vec.end()), vec.end());     for (long long i = 0; i < (long long)vec.size(); i++) {       long long tmp = solve(vec[i]);       if (tmp * tmp == vec[i]) continue;       vec2.push_back(vec[i]);     }     sort(vec2.begin(), vec2.end());   }   long long solve(long long x) {     long long l = 0, r = 1e9 + 1;     while (r - l > 1) {       long long k = (l + r) / 2;       if (k * k > x)         r = k;       else         l = k;     }     return l;   }   int main() {     cin >> q;     precalc();     while (q--) {       scanf( %I64d , &R);       printf( %I64d n , R - (upper_bound(vec2.begin(), vec2.end(), R) -                              vec2.begin() + solve(R)));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = (1e18);   const int N = (2 * (1e5));   int n;   string s;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     pair<int, int> p[n];     for (int i = 0; i < n; i++) {       cin >> p[i].first;       p[i].second = i;     }     sort(p, p + n);     int ans = 0;     int a[n];     for (int i = n - 1; i >= 0; i--) {       int x = n - 1 - i;       ans += p[i].first * x + 1;       a[x] = p[i].second + 1;     }     cout << ans << endl;     for (int i = 0; i < n; i++) cout << a[i] <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = -0x3ffffff;   const int maxn = 5e6 + 5;   int fa[maxn];   int fin(int x) {     if (x == fa[x]) return x;     return fa[x] = fin(fa[x]);   }   long long n, m;   long long vis[maxn];   const long long mod = 1e9 + 7;   long long get(long long x, long long y) {     long long ans = 1;     long long h = x;     while (y) {       if (y % 2) ans = ans * x % mod;       y /= 2;       x = x * x % mod;     }     return (ans - h + mod) % mod;   }   int main() {     cin >> n >> m;     for (long long i = 1; i <= n + 5; i++) fa[i] = i;     for (int i = 0; i < n - 1; i++) {       long long l, r, t;       cin >> l >> r >> t;       if (!t) {         int x = fin(l), y = fin(r);         fa[x] = y;       }     }     for (int i = 1; i <= n; i++) {       vis[fin(i)]++;     }     long long ans = 0;     long long res = get(n, m);     for (int i = 1; i <= n; i++) {       if (fin(i) == i) {         res -= get(vis[i], m);         res = (res + mod) % mod;       }     }     cout << (res + mod) % mod;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Dbg {     template <typename T>     Dbg& operator,(const T& v) {       cerr << v <<  ,  ;       return *this;     }   } Dbg;   template <typename T>   ostream& operator<<(ostream& _o_, const vector<T>& _v_) {     if (!_v_.empty()) {       _o_ <<  [ ;       copy(_v_.begin(), _v_.end(), ostream_iterator<T>(_o_,  ,  ));       _o_ <<   b b] ;     }     return _o_;   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   vector<long long> num;   long long dp[30][3][15][15];   long long sz;   long long solve(long long pos, bool f, long long first, long long last) {     if (pos == sz) {       if (first == last) {         return 1;       }       return 0;     }     if (dp[pos][f][first][last] != -1) return dp[pos][f][first][last];     long long ans = 0;     long long mx = 0;     if (sz < num.size()) {       mx = 9;     } else {       if (f == 0) {         mx = num[pos];       } else {         mx = 9;       }     }     for (long long digit = 0; digit <= mx; digit++) {       bool tmpf = f;       long long tmpfirst = first;       if (pos == 0 && digit == 0 && sz > 1) continue;       if (pos == 0) tmpfirst = digit;       if (digit < mx) tmpf = 1;       ans += solve(pos + 1, tmpf, tmpfirst, digit);     }     return dp[pos][f][first][last] = ans;   }   long long solve(long long b) {     if (b == 0) {       return 1;     }     num.clear();     while (b > 0) {       num.push_back(b % 10);       b /= 10;     }     reverse(num.begin(), num.end());     long long ans = 0;     for (long long q = 1; q <= num.size(); q++) {       sz = q;       for (long long i = 0; i <= 19; i++) {         for (long long j = 0; j < 2; j++) {           for (long long k = 0; k < 10; k++) {             for (long long l = 0; l < 10; l++) {               dp[i][j][k][l] = -1;             }           }         }       }       ans += solve(0, 0, 0, 0);     }     return ans;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long l, r;     cin >> l >> r;     cout << solve(r) - solve(l - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> adj[300005];   int indeg[300005];   queue<int> q;   int dp[300005][26], ma = 1;   string s;   int n, m, x, y, cnt = 0;   bool co = 1;   int main() {     cin >> n >> m;     cin >> s;     for (int i = 0; i < m; i++) {       cin >> x >> y;       x--;       y--;       indeg[y]++;       adj[x].push_back(y);     }     for (int i = 0; i < n; i++) {       if (indeg[i] == 0) {         q.push(i);         dp[i][s[i] -  a ]++;       }     }     while (!q.empty()) {       int u = q.front();       q.pop();       for (int v : adj[u]) {         for (int j = 0; j < 26; j++) {           dp[v][j] = max(dp[v][j], dp[u][j] + (s[v] -  a  == j));         }         indeg[v]--;         if (indeg[v] == 0) q.push(v);       }       cnt++;     }     if (cnt < n) {       cout <<  -1 n ;     } else {       for (int i = 0; i < n; i++) {         for (int j = 0; j < 26; j++) {           if (dp[i][j] > ma) ma = dp[i][j];         }       }       cout << ma <<   n ;     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( sse4 )   using namespace std;   const int mxN = 2e5 + 5;   const long long inf = 1e18;   template <class T>   T gcd(T a, T b) {     return ((b == 0) ? a : gcd(b, a % b));   }   pair<int, long long> dp[2][4];   long long mn[mxN], mx[mxN];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, m, k, q;     cin >> n >> m >> k >> q;     vector<pair<long long, long long>> p(k);     for (int i = 0; i < (int)(mxN); i++) mn[i] = inf, mx[i] = -inf;     long long h = 0;     for (int i = 0; i < (int)(k); i++) {       cin >> p[i].first >> p[i].second;       mn[p[i].first] = min(mn[p[i].first], p[i].second);       mx[p[i].first] = max(mx[p[i].first], p[i].second);       h = max(h, p[i].first);     }     vector<int> b(q);     for (int i = 0; i < (int)(q); i++) cin >> b[i];     sort(b.begin(), b.end());     for (int i = 0; i < (int)(2); i++)       for (int j = 0; j < (int)(4); j++) dp[i][j] = make_pair(0, inf);     long long ans = 1e18;     if (mn[1] == inf) {       int pos = 1;       auto it = lower_bound(b.begin(), b.end(), pos);       if (it != b.end()) dp[0][1] = make_pair(*it, (*it - pos));       if (it != b.begin()) {         it--;         dp[0][0] = make_pair(*it, (pos - *it));       }       ans = 0;     } else {       int pos = mx[1];       auto it = lower_bound(b.begin(), b.end(), pos);       if (it != b.end()) dp[0][3] = make_pair(*it, (*it - pos) + (pos - 1));       if (it != b.begin()) {         it--;         dp[0][2] = make_pair(*it, (pos - *it) + (pos - 1));       }       ans = pos - 1;     }     int cnt = 1;     for (int i = (int)(2); i < (int)(mxN); i++)       if (mn[i] != inf) {         int cr = cnt & 1, pr = 1 - cr;         long long A = 1e18, B = 1e18;         for (int j = 0; j < (int)(4); j++)           if (dp[pr][j].second != inf) {             A = min(A, dp[pr][j].second + abs(mx[i] - dp[pr][j].first) +                            (mx[i] - mn[i]));           }         for (int j = 0; j < (int)(4); j++)           if (dp[pr][j].second != inf) {             B = min(B, dp[pr][j].second + abs(mn[i] - dp[pr][j].first) +                            (mx[i] - mn[i]));           }         int pos = mn[i];         auto it = lower_bound(b.begin(), b.end(), pos);         if (it != b.end()) dp[cr][1] = make_pair(*it, A + (*it - pos));         if (it != b.begin()) {           it--;           dp[cr][0] = make_pair(*it, A + (pos - *it));         }         pos = mx[i];         it = lower_bound(b.begin(), b.end(), pos);         if (it != b.end()) dp[cr][3] = make_pair(*it, B + (*it - pos));         if (it != b.begin()) {           it--;           dp[cr][2] = make_pair(*it, B + (pos - *it));         }         ans = min(A, B);         for (int j = 0; j < (int)(4); j++) dp[pr][j] = make_pair(0, inf);         cnt++;       }     cout << ans + h - 1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   #define pb push_back   #define pf push_front   #define fi first   #define se second      using namespace std;   typedef long long ll;      int main()   {    ios::sync_with_stdio(0);    cin.tie(0);    ll t, n, k;    cin >> t;    while(t--)       {           cin >> n >> k;           for(ll i=1; i<2*k-n; i++)           {               cout << i <<    ;           }           for(ll i=k; i>=2*k-n; i--)           {               cout << i <<    ;           }           cout <<   n ;       }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200 * 1000 + 13;   int n;   int a[N];   void get(long long T, long long& pr, long long& cnt) {     pr = 0, cnt = 0;     for (int i = 0; i < int(n); i++) {       if (T >= a[i]) {         T -= a[i];         pr += a[i];         ++cnt;       }     }   }   int main() {     long long T;     scanf( %d%lld , &n, &T);     for (int i = 0; i < int(n); i++) scanf( %d , &a[i]);     int mn = *min_element(a, a + n);     long long ans = 0;     while (T >= mn) {       long long pr, cnt;       get(T, pr, cnt);       ans += cnt * (T / pr);       T %= pr;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = 0x3f3f3f3f;   const long long OO = 1LL << 61;   const int MOD = 1000000007;   long long dp[1005][20005];   int a[1005];   int main() {     int n;     while (scanf( %d , &n) != EOF) {       for (int i = 1; i <= n; i++) scanf( %d , &a[i]);       memset(dp, 0, sizeof dp);       for (int i = 0; i <= n; i++) dp[i][10000] = 1;       for (int i = 1; i <= n; i++) {         for (int j = 0; j <= 20000; j++) {           if (j + a[i] <= 20000)             dp[i][j + a[i]] = (dp[i][j + a[i]] + dp[i - 1][j] + MOD) % MOD;           if (j - a[i] >= 0)             dp[i][j - a[i]] = (dp[i][j - a[i]] + dp[i - 1][j] + MOD) % MOD;         }       }       long long ans = 0;       for (int i = 1; i <= n; i++) ans = (ans + dp[i][10000] - 1 + MOD) % MOD;       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long x, y, p, q;   int main() {     int t;     scanf( %d , &t);     int x, y, p, q;     while (t--) {       scanf( %d %d %d %d , &x, &y, &p, &q);       if (p == q) {         printf( %d n , x == y ? 0 : -1);         continue;       }       if (p == 0) {         printf( %d n , x == 0 ? 0 : -1);         continue;       }       long long s, d;       s = x % p == 0 ? (x / p) : (x / p + 1);       d = (y - x) % (q - p) == 0 ? ((y - x) / (q - p)) : ((y - x) / (q - p) + 1);       printf( %lld n , (max(s, d)) * q - y);     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int Maxn = (1 << 23) + 5;   const int N = 50;   const int M = 24;   int read() {     int s = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       s = s * 10 + c -  0 ;       c = getchar();     }     return s * f;   }   char s[N][N];   unsigned int f[Maxn], g[Maxn];   int h[Maxn], num[Maxn];   int lowbit(int x) { return x & (-x); }   int n, m, tot, Sta, a[N][N], id[N], fa[N], sum[N];   int Find(int x) { return x == fa[x] ? x : fa[x] = Find(fa[x]); }   void Union(int x, int y) {     x = Find(x);     y = Find(y);     if (x != y) {       fa[x] = y;       sum[y] += sum[x];     }   }   int main() {     n = read();     for (int i = 1; i <= n; i++) scanf( %s , s[i] + 1);     for (int i = 1; i <= n; i++) {       fa[i] = i;       sum[i] = 1;     }     for (int i = 1; i <= n; i++)       for (int j = 1; j < i; j++)         if (s[i][j] ==  A ) Union(i, j);     for (int i = 1; i <= n; i++)       for (int j = 1; j < i; j++)         if (s[i][j] ==  X  && Find(i) == Find(j)) {           puts( -1 );           return 0;         }     for (int i = 1; i <= n; i++)       if (!id[Find(i)] && sum[Find(i)] >= 2) id[Find(i)] = ++tot;     if (!tot) {       printf( %d n , n - 1);       return 0;     }     Sta = (1 << tot) - 1;     for (int i = 1; i <= n; i++)       for (int j = 1; j < i; j++)         if (s[i][j] ==  X ) {           int x = id[Find(i)], y = id[Find(j)];           a[x][y] = a[y][x] = 1;         }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (a[i][j]) h[1 << (i - 1)] |= (1 << (j - 1));     f[0] = 1;     for (int S = 1; S <= Sta; S++) {       g[S] = 1;       num[S] = num[S >> 1] + (S & 1);       f[S] = f[S ^ lowbit(S)] + f[(S ^ lowbit(S)) ^ (S & h[lowbit(S)])];     }     for (int S = 1; S <= Sta; S++) f[S]--;     for (int k = 1; k <= tot; k++) {       unsigned int ans = 0;       for (int S = 1; S <= Sta; S++) {         g[S] *= f[S];         ans += (num[Sta ^ S] & 1 ? -1 : 1) * g[S];       }       if (ans) {         printf( %d , n + k - 1);         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void printvector(vector<long long> v) {     for (int i = 0; i < v.size(); i++) {       cout << v[i] <<    ;     }     cout << endl;   }   map<long long, long long> mp;   long long a[100005][3] = {0};   int main() {     long long m, n, i, j, k, l;     cin >> m;     for (i = 0; i < m; i++) {       cin >> a[i][0];       if (a[i][0] == 1)         cin >> a[i][1];       else         cin >> a[i][1] >> a[i][2];     }     vector<long long> v;     v.push_back(0);     for (i = 0; i < m; i++) {       if (a[i][0] == 1) {         v.push_back(1 + v[i]);         mp[1 + v[i]] = a[i][1];       } else         v.push_back(v[i] + a[i][1] * a[i][2]);     }     long long t, x;     cin >> t;     while (t--) {       cin >> x;       while (mp[x] == 0) {         long long idx = lower_bound(v.begin(), v.end(), x) - v.begin();         long long tmp = x - v[idx - 1];         x = (tmp - 1) % (a[idx - 1][1]) + 1;       }       cout << mp[x] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long pwr(long long base, long long p, long long mod = (1000000007LL)) {     long long ans = 1;     while (p) {       if (p & 1) ans = (ans * base) % mod;       base = (base * base) % mod;       p /= 2;     }     return ans;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long nCr(long long n, long long r) {     long long C[r + 1];     memset(C, 0, sizeof(C));     C[0] = 1;     for (long long i = 1; i <= n; i++)       for (long long j = min(i, r); j > 0; j--) C[j] = C[j] + C[j - 1];     return C[r];   }   bool isPrime(long long n) {     if (n <= 1) return false;     if (n == 2) return true;     if (n % 2 == 0) return false;     long long m = sqrt(n);     for (long long i = 3; i <= m; i += 2)       if (n % i == 0) return false;     return true;   }   long long M(long long a) { return (a % (1000000007LL)); }   bool isPowerOfTwo(long long x) { return x && (!(x & (x - 1))); }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(0);     int n, k;     cin >> n >> k;     vector<bool> same_name(n - k + 1);     int index = 0;     string s;     while (index < n - k + 1) {       cin >> s;       if (s ==  YES ) same_name[index] = true;       index++;     }     vector<int> ans(n);     vector<string> strings(51,   );     for (long long i = 0; i < (long long)(51); ++i) {       if (i < 26) {         strings[i] += (char)(i +  A );       } else {         strings[i] += (char)(i - 26 +  A );         strings[i] += (char)(i - 26 +  a );       }     }     int counter = k;     if (same_name[0])       for (long long i = 0; i < (long long)(k); ++i) ans[i] = i;     else {       for (long long i = 0; i < (long long)(k - 1); ++i) ans[i] = i;       ans[k - 1] = ans[0];       counter--;     }     for (int i = 1; i < n - k + 1; i++) {       if (same_name[i])         ans[k + i - 1] = counter++;       else         ans[k + i - 1] = ans[i];     }     for (long long i = 0; i < (long long)(n); ++i) cout << strings[ans[i]] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long I1 = 1e9;   const long long I2 = 1e18;   const int32_t M1 = 1e9 + 7;   const int32_t M2 = 998244353;   template <typename T, typename T1>   T maxn(T &a, T1 b) {     if (b > a) a = b;     return a;   }   template <typename T, typename T1>   T minn(T &a, T1 b) {     if (b < a) a = b;     return a;   }   void solve() {     long long int n;     cin >> n;     if (n == 1) {       cout <<  0             <<   n ;       return;     }     long long int l = 1, r = n - 1, m1, m2, ans = 0;     while (l <= r) {       m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;       long long int c1, c2;       c1 = min(2 * m1, m1 + ((n - m1) * (n - m1 - 1)) / 2);       c2 = min(2 * m2, m2 + ((n - m2) * (n - m2 - 1)) / 2);       ans = max({ans, c1, c2});       if (c1 > c2)         r = m2 - 1;       else if (c2 > c1)         l = m1 + 1;       else {         l = m1 + 1, r = m2 - 1;       }     }     cout << ans <<   n ;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int testcase = 1;     cin >> testcase;     while (testcase--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int x, y, n;       cin >> x >> y >> n;       int d = n % x;       if (d < y)         cout << n - d - (x - y) << endl;       else if (d > y)         cout << n - (d - y) << endl;       else         cout << n << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, a, b, t, u;     cin >> n >> m >> a >> b;     if (a <= (float(b) / float(m))) {       cout << n * a;     } else {       t = ceil(float(n) / float(m)) * b;       u = n / m * b + n % m * a;       cout << min(t, u);     }   }