malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     string s;     cin >> s;     vector<int> stars, pacmans;     for (int i = 0; i < n; i++) {       if (s[i] ==  * )         stars.push_back(i);       else if (s[i] ==  P )         pacmans.push_back(i);     }     stars.push_back(1e9);     int l = 1, r = 2 * n, ok = 1;     while (l <= r) {       int mid = (l + r) / 2;       int start = stars[0];       int curr = 0;       bool f = true;       for (int x : pacmans) {         if (start < x - mid)           f = false;         else if (start < x) {           curr = max(x + mid - (x - start) * 2, x + (mid - x + start) / 2);         } else {           curr = x + mid;         }         start = *upper_bound(stars.begin(), stars.end(), curr);       }       if (!f or start != 1e9) {         l = mid + 1;       } else {         ok = mid;         r = mid - 1;       }     }     cout << ok << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool used[10000001];   int n, m, second = 0, ds[1000001], ans[1000001], str[1000001], sv[1000001];   struct o {     int x, i, j;   };   o d[1000001];   vector<vector<int> > a;   bool comp(o a, o b) {     if (a.x == b.x) return a.i < b.i;     return a.x < b.x;   }   bool fcomp(o a, o b) {     if (a.x == b.x) return a.j < b.j;     return a.x < b.x;   }   int FS(int v) {     if (ds[v] == v) return v;     return ds[v] = FS(ds[v]);   }   void US(int a, int b) {     a = FS(a);     b = FS(b);     ds[a] = ds[b];     return;   }   vector<pair<int, int> > tt[1000001];   pair<int, int> dd(int v) {     int i = (v - 1) / m;     ++i;     int j = v % m;     if (j == 0) j = m;     return {i, j};   }   int main() {     cin >> n >> m;     a.resize(n + 1);     for (int k = 1; k <= n; ++k) {       a[k].resize(m + 1);     }     for (int k = 1; k <= n; ++k)       for (int i = 1; i <= m; ++i) {         cin >> a[k][i];         ds[(k - 1) * m + i] = (k - 1) * m + i;         o w;         w.x = a[k][i];         w.i = k;         w.j = i;         d[++second] = w;       }     sort(d + 1, d + second + 1, comp);     for (int k = 1; k < second; ++k)       if (d[k].x == d[k + 1].x) {         if (d[k].i == d[k + 1].i)           US((d[k].i - 1) * m + d[k].j, (d[k + 1].i - 1) * m + d[k + 1].j);       }     sort(d + 1, d + second + 1, fcomp);     for (int k = 1; k < second; ++k)       if (d[k].x == d[k + 1].x) {         if (d[k].j == d[k + 1].j) {           US((d[k].i - 1) * m + d[k].j, (d[k + 1].i - 1) * m + d[k + 1].j);         }       }     for (int k = 1; k <= n * m; ++k) tt[FS(ds[k])].push_back(dd(k));     for (int k = 1; k <= second; ++k) {       int i = d[k].i;       int j = d[k].j;       if (used[(i * m - m) + j]) continue;       int cm = FS(ds[(i * m - m) + j]);       int cnt = 0;       for (int i = 0; i < tt[cm].size(); ++i) {         int ii = tt[cm][i].first;         int jj = tt[cm][i].second;         used[ii * (m)-m + jj] = 1;         cnt = max(str[ii], cnt);         cnt = max(sv[jj], cnt);       }       for (int i = 0; i < tt[cm].size(); ++i) {         int ii = tt[cm][i].first;         int jj = tt[cm][i].second;         ans[ii * (m)-m + jj] = cnt + 1;         sv[jj] = max(cnt + 1, sv[jj]);         str[ii] = max(cnt + 1, str[ii]);       }     }     for (int k = 1; k <= n; ++k) {       for (int i = 1; i <= m; ++i) cout << ans[(k - 1) * m + i] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ans, C1[4000 + 1], C2[4000 + 1];   void Init(long long *C, int m) {     C[0] = C[1] = 1;     for (int i = 2; i < m; i++) {       C[i] = 1;       for (int j = i - 1; j > 0; j--) C[j] = (C[j - 1] + C[j]) % 1000000009;     }   }   int main() {     int n, w, b;     scanf( %d%d%d , &n, &w, &b);     Init(C1, b);     Init(C2, w);     int bin = max(1, n - w);     int end = min(n - 2, b);     for (int i = bin; i <= end; i++) {       int k = n - i;       ans = (ans + C1[i - 1] * C2[k - 1] % 1000000009 * (k - 1) % 1000000009) %             1000000009;     }     int i;     for (i = 1; i <= b && i <= w; i++)       ans = ans * i % 1000000009 * i % 1000000009;     while (i <= b) ans = ans * (i++) % 1000000009;     while (i <= w) ans = ans * (i++) % 1000000009;     printf( %lld n , ans);   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   int n, m, t, k;   int d[((int)1e5 + 5)];   int countt[105];   int l = 1;   int r = 100;   void lbulma() {     while (countt[l] == 0) l++;     return;   }   void rbulma() {     while (countt[r] == 0) r--;     return;   }   int asal[4] = {2, 3, 5, 7};   int main() {     long long int sum = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> d[i];       sum += d[i];       countt[d[i]]++;     }     lbulma();     rbulma();     long long minn = INT_MAX;     for (int j = 100; j >= l; --j) {       if (countt[j])         for (int i = 10; i >= 2; --i) {           if (j % i == 0 && (j / i) + (l * i) < j + l) {             long long int tmp = sum - ((j + l) - ((j / i) + (l * i)));             minn = min(minn, tmp);           }         }     }     cout << min(minn, sum) << endl;   }
#include <bits/stdc++.h>   using namespace std;   long double PI = acosl(-1);   bool compare_int(int a, int b) { return (a > b); }   bool compare_string(string a, string b) { return a.size() < b.size(); }   bool compare_pair(const pair<int, int> &a, const pair<int, int> &b) {     if (a.second == b.second)       return a.first > b.first;     else       return (a.second > b.second);   }   long long int fact(long long int n) {     if (n == 0 || n == 1)       return 1;     else       return n * fact(n - 1);   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     string s, st;     long long int x = 0, temp = 0, ans = 0;     cin >> s;     if (s.size() == 1) {       cout << s << endl;       return 0;     }     for (int i = 1; i < s.size(); i++) st +=  9 ;     stringstream ss(s);     ss >> x;     stringstream sm(st);     sm >> temp;     long long int te = x - temp;     while (te) {       ans += (te % 10);       te /= 10;     }     cout << ans + (s.size() - 1) * 9 << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long num(string str) {     long long out = 0;     for (int i = 0; i < str.length(); i++) {       out *= 26;       out += str.at(i) -  A  + 1;     }     return out;   }   string pb26(long long n) {     string reverse =   ;     while (n > 0) {       int d = (n - 1) % 26 + 1;       char c = d +  A  - 1;       reverse.push_back(c);       n -= d;       n /= 26;     }     string out =   ;     for (int i = reverse.length() - 1; i > -1; i--) out.push_back(reverse.at(i));     return out;   }   int main() {     long long N;     cin >> N;     for (int t = 0; t < N; t++) {       string S;       cin >> S;       bool rc = S.at(0) ==  R ;       if (rc) {         int i = 0;         while (i < S.length() && S.at(i) !=  C ) i++;         rc = i < S.length() && i > 1;         if (rc) {           for (int j = 1; j < i && rc; j++) {             char c = S.at(j);             if (c <  0  || c >  9 ) rc = false;           }           if (rc) {             long long row = stoll(S.substr(1, i - 1)),                       col = stoll(S.substr(i + 1));             cout << pb26(col) << row <<   n ;           }         }       }       if (!rc) {         int i = 0;         while (true) {           char c = S.at(i);           if (c >=  0  && c <=  9 ) break;           i++;         }         string col = S.substr(0, i);         long long row = stoll(S.substr(i));         cout <<  R  << row <<  C  << num(col) <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   bool comp(pair<double, int> &a, pair<double, int> &b) {     if (a.first != b.first) return a.first > b.first;     return a.second < b.second;   }   void solve() {     int n;     double t1, t2, k;     cin >> n >> t1 >> t2 >> k;     vector<pair<double, int>> p(n);     for (int i = 0; i < (n); i++) {       double a, b;       cin >> a >> b;       p[i].second = i + 1;       p[i].first = max(a * t1 - (a * t1 * k) / 100 + b * t2,                        b * t1 - (b * t1 * k) / 100 + a * t2);     }     sort(p.begin(), p.end(), comp);     for (auto x : p)       cout << x.second <<     << setprecision(2) << fixed << x.first <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   long long n, x;   map<long long, long long> mp;   map<long long, long long> nums;   long long grund(long long x) {     if (x <= 1) return 0;     if (mp[x]) return mp[x];     for (long long i = 31; i >= 0; i--) {       if ((x & (1 << i))) {         set<long long> second;         second.clear();         for (long long j = i; j >= 1; j--) {           long long y = x % (1 << j);           for (long long k = j; k <= i; k++) {             if (x & (1 << k)) y |= (1 << (k - j));           }           second.insert(grund(y));         }         for (long long j = 0; j <= 31; j++)           if (second.find(j) == second.end()) return mp[x] = j;       }     }   }   signed main() {     ios_base::sync_with_stdio(0);     cin >> n;     for (long long i = 1; i <= n; i++) {       cin >> x;       long long y = x;       for (long long j = 2; j <= sqrt(x); j++) {         if (!(y % j)) {           long long cnt = 0;           while (!(y % j)) {             cnt++;             y /= j;           }           nums[j] |= (1 << cnt);         }       }       if (y > 1) nums[y] |= 2;     }     if (!nums.size()) {       cout <<  Arpa ;       return 0;     }     long long g = 0;     for (map<long long, long long>::iterator it = nums.begin(); it != nums.end();          it++) {       g ^= grund(it->second);     }     if (!g)       cout <<  Arpa ;     else       cout <<  Mojtaba ;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   void c_p_c() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   bool is_pallindrome(string str, long long int left, long long int right) {     if (left > right) return true;     return (str[left] == str[right] && is_pallindrome(str, left + 1, right - 1));   }   long long int convertToInt(string str) {     long long int sum = 0;     long long int power = 1;     for (long long int i = str.length() - 1; i >= 0; i--) {       long long int val = str[i] -  0 ;       long long int prod =           ((val % 1000000007) * (power % 1000000007)) % 1000000007;       sum = ((sum % 1000000007) + prod % 1000000007) % 1000000007;       power *= 10;     }     return sum;   }   bool compare(pair<long long int, long long int> a,                pair<long long int, long long int> b) {     if (a.first != b.first) return a.first < b.first;     return a.second < b.second;   }   int32_t main() {     c_p_c();     long long int t;     cin >> t;     while (t--) {       long long int a, b;       cin >> a >> b;       if (b % 2 == 0) {         cout << a * (b / 2);       } else {         long long int ans = b / 2 * a;         if (a % 2 == 0)           ans += a / 2;         else           ans += (a / 2) + 1;         cout << ans;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const unsigned long long l = 1000000007;   const int MAX_ = 2000;   int T;   void solve(int t) {     long long n;     cin >> n;     vector<int> p[n];     for (int i = 0; i < n; i++) {       int k;       cin >> k;       p[i] = vector<int>(k);       for (int j = 0; j < k; j++) {         cin >> p[i][j];       }     }     set<int> s;     for (int i = 1; i <= n; i++) {       s.insert(i);     }     int pos = -1;     for (int i = 0; i < n; i++) {       bool f = 0;       for (int j = 0; j < p[i].size(); j++) {         int x = p[i][j];         if (s.find(x) != s.end()) {           f = 1;           s.erase(x);           break;         }       }       if (pos < 0 && f == 0) {         pos = i + 1;       }     }     if (pos > 0) {       cout <<  IMPROVE  << endl;       cout << pos <<     << *s.begin() << endl;       return;     }     cout <<  OPTIMAL  << endl;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t, testCases;     testCases = 1;     while (testCases--) {       t = 1;       cin >> t;       T = t;       while (t--) {         solve(t);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e9 + 7;   vector<string> vec;   long long int sd(long long int n) {     long long int sum = 0;     while (n != 0) {       sum += n % 10;       n = n / 10;     }     return sum;   }   long long int nd(long long int n) {     long long int ans = 0;     while (n > 0) {       n = n / 10;       ans++;     }     return ans;   }   long long int power(long long int a, long long int b) {     long long int ans = 1ll;     while (b) {       if (b & 1) ans = (ans * a) % 1000000007;       a = (a * a) % 1000000007;       b = b / 2;     }     return ans;   }   int main() {     long long int n, a, b, r, c, d, i, k, j, temp, sum, ct = 0, flag = -1e13,                                                         start = 0, next = 1;     string st, ans;     long long int ar[1005] = {0};     vector<long long int> v;     vector<pair<long long int, long long int> > v2;     cin >> n >> k;     for (i = 0; i < n; i++) {       cin >> temp;       v.push_back(temp);     }     if (k > n) {       sort(v.begin(), v.end(), greater<long long int>());       cout << v[0];       return 0;     }     for (i = 0; i < n; i++) {       start = (i + 1) % n;       ct = 0;       if (i != 0)         if (v[start] > v[i - 1]) {           ct += 1;         }       while (ct < k) {         if (v[start] > v[i]) break;         ct++;         start++;         if (start == n) start = 0;       }       if (ct == k) {         cout << v[i];         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100000 + 7;   const int M = 100000 + 7;   const int inf = 1000000000 + 7;   const long long linf = 1ll * inf * (inf - 1);   const double pi = acos(-1);   const double eps = 1e-9;   const bool multipleTest = 0;   const int mod[2] = {(rand() % (inf - 1000) + 1000),                       (rand() % (inf - 1000) + 1000)};   int lt[2][N];   struct Hash {     string s;     long long val[2][N];     int n;     void init(string& s_) {       s = s_;       n = s.size();       val[0][0] = val[1][0] = 0;       for (int i = 1; i <= n; ++i) {         for (int j = 0; j < 2; ++j)           val[j][i] = (1ll * val[j][i - 1] * mod[j] + s[i - 1]) % inf;       }     }     long long get(int j, int u, int v) {       long long res = val[j][v] - val[j][u - 1] * lt[j][v - u + 1];       res %= inf;       if (res < 0) res += inf;       return res;     }     pair<int, int> get(int u, int v) {       return make_pair(get(0, u, v), get(1, u, v));     }   };   Hash a, b;   int n, m;   string s, t;   int k;   int dp[N][31];   int getLCP(int u, int v) {     int lo = 1, hi = min(n - u, m - v), res = 0;     while (lo <= hi) {       int g = (lo + hi) >> 1;       if (a.get(u + 1, u + g) == b.get(v + 1, v + g)) {         res = g;         lo = g + 1;       } else         hi = g - 1;     }     return res;   }   void solve() {     cin >> n >> s >> m >> t >> k;     lt[0][0] = lt[1][0] = 1;     for (int i = 1; i < N; ++i) {       lt[0][i] = (1ll * mod[0] * lt[0][i - 1]) % inf;       lt[1][i] = (1ll * mod[1] * lt[1][i - 1]) % inf;     }     a.init(s);     b.init(t);     dp[0][0] = 0;     for (int i = 0; i < n; ++i) {       dp[i][0] = 0;       int old = -1, oldRes = 0;       for (int j = 0; j <= k; ++j) {         if (j) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);         if (j < k) {           int res = 0;           if (dp[i][j] == old) {             res = oldRes;           } else {             res = oldRes = getLCP(i, dp[i][j]);             old = dp[i][j];           }           if (res > 0)             dp[i + res][j + 1] = max(dp[i + res][j + 1], dp[i][j] + res);         }       }     }     if (dp[n][k] == m)       puts( YES );     else       puts( NO );   }   int main() {     int Test = 1;     if (multipleTest) {       cin >> Test;     }     for (int i = 0; i < Test; ++i) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     int a[3];     while (t--) {       memset(a, 0, sizeof(a));       int n;       cin >> n;       for (int i = 0; i < n; i++) {         int in;         cin >> in;         a[in % 3]++;       }       if (a[2] >= a[1]) {         cout << a[0] + a[1] + ((a[2] - a[1]) / 3) << endl;       } else {         cout << a[0] + a[2] + ((a[1] - a[2]) / 3) << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1234567;   int n, a, b, T, used, ans;   int lft[N], rgt[N];   char s[N];   void fill_array(int v[]) {     for (int i = 1; i < n; i++) {       v[i] = v[i - 1] + a + 1 + ((s[i] ==  w ) ? b : 0);     }   }   void solve(int lft[], int rgt[]) {     for (int i = 1; i < n; i++) {       int need = used + lft[i];       if (need <= T) {         ans = max(ans, i + 1);       }       need += (i * a);       if (need > T) {         continue;       }       if (rgt[n - i - 1] + need <= T) {         ans = n;         break;       }       int pos = upper_bound(rgt, rgt + n, T - need) - rgt;       ans = max(ans, i + 1 + pos - 1);     }   }   int main() {     scanf( %d %d %d %d , &n, &a, &b, &T);     scanf( %s , s);     fill_array(lft);     reverse(s + 1, s + n);     fill_array(rgt);     reverse(s + 1, s + n);     used = 1;     if (s[0] ==  w ) {       used += b;     }     if (used > T) {       puts( 0 );       return 0;     }     ans = 1;     solve(lft, rgt);     solve(rgt, lft);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 1;   long double pi = 3.141592653589793238;   int main() {     long long t;     cin >> t;     while (t--) {       long long x;       cin >> x;       long double ans;       long double n = 2.0000000000000 * (long double)x;       long double angle =           (180.000000000000000 - 360.00000000000000 / n) / 2.00000000000000;       angle = angle * pi / 180.000000000000;       long double side = (long double)0.500000000000 / (long double)cosl(angle);       if (x % 2 != 0) {         ans = (long double)2.000000000 * side;       } else {         side = side * (long double)sinl(angle);         ans = (long double)2.000000000 * side;       }       cout << to_string(ans) <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 5000 + 9;   int t[MX];   int n;   int counts[MX] = {0};   int ans[MX];   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> t[i];       t[i]--;     }     for (int start = 0; start < n; start++) {       memset(counts, 0, n * sizeof(int));       int best = 0;       for (int finish = start; finish < n; finish++) {         int who = t[finish];         counts[who]++;         if (counts[who] > counts[best] ||             (counts[who] == counts[best] && who < best))           best = who;         ans[best]++;       }     }     for (int i = 0; i < n; i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<int> v;     long long int n, s, x, countt = 0;     cin >> n >> s;     for (int i = 0; i < n; i++) {       cin >> x;       v.push_back(x);     }     sort(v.begin(), v.end());     int mid = n / 2;     int m = v[mid];     if (m <= s) {       for (int i = mid; i < v.size(); i++) {         if (v[i] <= s) {           countt += abs(v[i] - s);         } else {           break;         }       }     } else if (s <= m) {       for (int i = mid; i >= 0; i--) {         if (v[i] >= s) {           countt += abs(v[i] - s);         } else {           break;         }       }     }     cout << countt << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300010, LOG = 64;   int n, arr[N], nxt[N][LOG], mx, sum[N];   long long p, ans = 0;   vector<int> seg[2][4 * N];   bool b;   void build(int s, int e, int idx) {     if (s == e) {       if (sum[s] % 2 == b) seg[b][idx].push_back(sum[s]);       return;     }     build(s, (s + e) / 2, idx * 2);     build((s + e) / 2 + 1, e, idx * 2 + 1);     for (int i = 0; i < (int)seg[b][idx * 2].size(); i++)       seg[b][idx].push_back(seg[b][idx * 2][i]);     for (int i = 0; i < (int)seg[b][idx * 2 + 1].size(); i++)       seg[b][idx].push_back(seg[b][idx * 2 + 1][i]);     sort(seg[b][idx].begin(), seg[b][idx].end());   }   int l, r, val;   int get(int s, int e, int idx) {     if (s > r || e < l) return 0;     if (s >= l && e <= r)       return seg[b][idx].end() -              lower_bound(seg[b][idx].begin(), seg[b][idx].end(), val);     return get(s, (s + e) / 2, idx * 2) + get((s + e) / 2 + 1, e, idx * 2 + 1);   }   int main() {     scanf( %d , &n);     for (int i = 0; i < LOG; i++) nxt[n][i] = n;     for (int i = 0; i < n; i++) {       scanf( %lld , &p);       arr[i] = 0;       for (int j = 62; j >= 0; j--) {         if (((p >> j) & 1) == 1) {           arr[i]++;         }       }       sum[i] = arr[i];       if (i) sum[i] += sum[i - 1];     }     b = 0;     build(0, n - 1, 1);     b = 1;     build(0, n - 1, 1);     for (int i = n - 1; i >= 0; i--) {       for (int j = 0; j < LOG; j++) {         if (arr[i] == j)           nxt[i][j] = i;         else           nxt[i][j] = nxt[i + 1][j];       }       mx = n;       b = (i == 0 ? 0 : sum[i - 1] % 2);       for (int j = LOG - 1; j >= 0; j--) {         if (nxt[i][j] >= mx) continue;         l = nxt[i][j];         r = mx - 1;         val = 2 * j + (i == 0 ? 0 : sum[i - 1]);         ans += get(0, n - 1, 1);         mx = nxt[i][j];       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   bool f(int x, int n, int *pre, int p) {     for (int j = 0; j < n; ++j) {       if ((pre[j + x] - j) % p == 0) return false;     }     return true;   }   using namespace std;   int main(int argc, char **argv) {     vector<int> ans;     int t, n, p, a[2000], pre[5001] = {0};     cin >> n >> p;     for (int i = 0; i < n; ++i) cin >> a[i];     sort(a, a + n);     int mn = a[0], mx = a[n - 1];     t = 0;     for (int i = 1; i <= 5000; ++i) {       pre[i] = pre[i - 1];       while (t < n && a[t] <= i) ++t, ++pre[i];     }     for (int i = mn; i <= 2000; ++i) {       if (f(i, n, pre, p)) ans.push_back(i);     }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); ++i) {       cout << ans[i] << (i == ans.size() - 1 ?   n  :    );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> avengers;   long long n, k, A, B;   long long rec(long long l, long long r) {     long long i =         lower_bound(avengers.begin(), avengers.end(), l) - avengers.begin();     long long j =         upper_bound(avengers.begin(), avengers.end(), r) - avengers.begin();     j--;     long long x = j - i + 1;     long long power_consumed;     if (x == 0)       power_consumed = A;     else {       power_consumed = B * x * (r - l + 1);     }     if (l == r || x == 0) return power_consumed;     long long mid = (l + r) / 2;     long long minPower = min(power_consumed, rec(l, mid) + rec(mid + 1, r));     return minPower;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> k >> A >> B;     int i;     for (i = 0; i < k; i++) {       int val;       cin >> val;       avengers.push_back(val);     }     sort(avengers.begin(), avengers.end());     long long x = (long long)1 << n;     cout << rec(1, x) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     unsigned long long x, y, z, res1 = 0, res2 = 0;     cin >> x >> y >> z;     unsigned long long a = x % z;     unsigned long long b = y % z;     res1 = (x + y) / z;     if (a == 0 || b == 0)       res2 = 0;     else {       if (a > b) {         if ((z - a) <= b) res2 = z - a;       } else {         if ((z - b) <= a) res2 = z - b;       }     }     cout << res1 <<     << res2;     return 0;   }