malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     int n, l, r, m, ans = 1e9;     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> l >> r;       ans = min(ans, r - l + 1);     }     cout << ans <<   n ;     for (int i = 0; i < n; i++) cout << i % ans <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     string buf;     while (getline(cin, buf)) s += buf;     vector<int> a;     string hoge;     vector<int> cnt;     for (int i = 0; i < s.length(); ++i) {       if (s[i] ==  < ) {         hoge =   ;       } else if (s[i] ==  > ) {         if (hoge ==  table ) {           cnt.push_back(0);         }         if (hoge ==  /table ) {           a.push_back(cnt.back());           cnt.pop_back();         }         if (hoge ==  td ) ++cnt.back();       } else {         hoge += s[i];       }     }     sort(a.begin(), a.end());     for (int i = 0; i < a.size(); ++i) {       if (i) cout <<    ;       cout << a[i];     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int mod = 1e9 + 7;   long long powmod(long long a, long long b) {     long long res = 1;     if (a >= mod) a %= mod;     for (; b; b >>= 1) {       if (b & 1) res = res * a;       if (res >= mod) res %= mod;       a = a * a;       if (a >= mod) a %= mod;     }     return res;   }   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long a, b, c, d, num0, num1;     cin >> a >> b >> c >> d;     int flag = 0;     long long i, j;     for (i = 1; i <= 1000000; i++) {       long long temp = (i * (i - 1)) / 2;       if (temp > a) {         flag = 1;         break;       }       if (temp == a) {         num0 = i;         break;       }     }     for (i = 1; i <= 1000000; i++) {       long long temp = (i * (i - 1)) / 2;       if (temp > d) {         flag = 1;         break;       }       if (temp == d) {         num1 = i;         break;       }     }     if (flag == 1) {       cout <<  Impossible ;       return 0;     } else if (a + b + c + d == 0) {       cout <<  0 ;     } else if (a == 0 && b == 0 && c == 0) {       for (i = 0; i < num1; i++) cout <<  1 ;     } else if (b == 0 && c == 0 && d == 0) {       for (i = 0; i < num0; i++) cout <<  0 ;     } else {       long long num0110 = num0 * num1;       if (b + c != num0110) {         cout <<  Impossible ;         return 0;       }       long long end = c / num0;       long long rem = c % num0;       long long last = num1 - end - 1;       if (rem == 0) last++;       for (i = 0; i < end; i++) cout <<  1 ;       for (i = 0; i < num0 - rem; i++) cout <<  0 ;       if (rem != 0) cout <<  1 ;       for (i = num0 - rem; i < num0; i++) cout <<  0 ;       for (i = 0; i < last; i++) cout <<  1 ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long INF = 1e6;   long long M = 1e9 + 7;   void solve() {     long long n;     cin >> n;     vector<int> a(n), b(n - 1), c(n - 2);     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n - 1; i++) cin >> b[i];     for (int i = 0; i < n - 2; i++) cin >> c[i];     sort((a).begin(), (a).end());     sort((b).begin(), (b).end());     sort((c).begin(), (c).end());     long long x, y;     bool f1 = true, f2 = true;     for (int i = 0; i < n - 1; i++) {       if (i < n - 2 && f2) {         if (b[i] != c[i]) {           y = b[i];           f2 = false;         }       }       if (a[i] != b[i] && f1) {         x = a[i];         f1 = false;       }     }     if (f1) x = a[n - 1];     if (f2) y = b[n - 2];     cout << x <<   n  << y <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 7;   int lz[N << 2][10];   long long sum[N << 2][10], tmp[10];   void push_up(int rt) {     for (int i = 0; i < 10; ++i) sum[rt][i] = 0;     for (int i = 0; i < 10; ++i) sum[rt][lz[(rt << 1)][i]] += sum[(rt << 1)][i];     for (int i = 0; i < 10; ++i)       sum[rt][lz[(rt << 1 | 1)][i]] += sum[(rt << 1 | 1)][i];   }   void build(int rt, int l, int r) {     for (int i = 0; i < 10; ++i) lz[rt][i] = i, sum[rt][i] = 0;     if (l == r) {       int t, tmp = 1;       scanf( %d , &t);       while (t) sum[rt][t % 10] += tmp, tmp *= 10, t /= 10;       return;     }     int m = (l + r) >> 1;     build((rt << 1), l, m);     build((rt << 1 | 1), m + 1, r);     push_up(rt);   }   void push_down(int rt) {     for (int i = 0; i < 10; ++i) lz[(rt << 1)][i] = lz[rt][lz[(rt << 1)][i]];     for (int i = 0; i < 10; ++i)       lz[(rt << 1 | 1)][i] = lz[rt][lz[(rt << 1 | 1)][i]];     memset(tmp, 0, sizeof(tmp));     for (int i = 0; i < 10; ++i) tmp[lz[rt][i]] += sum[rt][i];     for (int i = 0; i < 10; ++i) sum[rt][i] = tmp[i];     for (int i = 0; i < 10; ++i) lz[rt][i] = i;   }   void update(int rt, int l, int r, int ql, int qr, int x, int y) {     if (ql <= l && qr >= r) {       for (int i = 0; i < 10; ++i)         if (lz[rt][i] == x) lz[rt][i] = y;       return;     }     push_down(rt);     int m = (l + r) >> 1;     if (ql <= m) update((rt << 1), l, m, ql, qr, x, y);     if (qr > m) update((rt << 1 | 1), m + 1, r, ql, qr, x, y);     push_up(rt);   }   long long query(int rt, int l, int r, int ql, int qr) {     long long res = 0;     if (ql <= l && qr >= r) {       for (int i = 0; i < 10; ++i) res += sum[rt][i] * lz[rt][i];       return res;     }     push_down(rt);     int m = (l + r) >> 1;     if (ql <= m) res += query((rt << 1), l, m, ql, qr);     if (qr > m) res += query((rt << 1 | 1), m + 1, r, ql, qr);     return res;   }   int main() {     int n, q;     scanf( %d%d , &n, &q);     build(1, 1, n);     while (q--) {       int op, l, r, x, y;       scanf( %d%d%d , &op, &l, &r);       if (op == 1) {         scanf( %d%d , &x, &y);         update(1, 1, n, l, r, x, y);       } else         printf( %I64d n , query(1, 1, n, l, r));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e6 + 5;   int cnt[MAXN * 2];   struct state {     int len, link, first_pos;     bool isClone;     map<char, int> next;   };   state st[MAXN * 2];   int sz, last;   void sa_init() {     for (int i = 0; i < sz; i++) st[i].next.clear();     st[0].len = 0;     st[0].link = -1;     sz = last = 0;     ++sz;   }   void sa_extend(char c) {     int cur = sz++;     st[cur].len = st[last].len + 1;     st[cur].first_pos = st[cur].len - 1;     st[cur].isClone = false;     int p = last;     while (p != -1 && !st[p].next.count(c)) {       st[p].next[c] = cur;       p = st[p].link;     }     if (p == -1) {       st[cur].link = 0;     } else {       int q = st[p].next[c];       if (st[p].len + 1 == st[q].len) {         st[cur].link = q;       } else {         int clone = sz++;         st[clone].len = st[p].len + 1;         st[clone].next = st[q].next;         st[clone].link = st[q].link;         st[clone].first_pos = st[q].first_pos;         st[clone].isClone = true;         while (p != -1 && st[p].next[c] == q) {           st[p].next[c] = clone;           p = st[p].link;         }         st[q].link = st[cur].link = clone;       }     }     last = cur;   }   bool cmp(int i, int j) { return st[i].len > st[j].len; }   int b[MAXN];   int pow_cad(string &P) {     int i = 0, j = -1;     b[0] = -1;     while (i < (P).size()) {       while (j >= 0 && P[i] != P[j]) j = b[j];       i++, j++, b[i] = j;     }     int n = (P).size();     int k = n - b[n];     if (n % k == 0) return k;     return n;   }   void match(string &t, int k) {     int v = 0, l = 0, ans = 0;     for (int i = 0; i < (t).size(); i++) {       while (v && !st[v].next.count(t[i])) {         v = st[v].link;         l = st[v].len;       }       if (st[v].next.count(t[i])) {         v = st[v].next[t[i]];         l++;         if (l >= k) {           if (st[st[v].link].len >= k) {             v = st[v].link;             l = st[v].len;           }           ans += cnt[v];         }       }     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     string s;     cin >> s;     sa_init();     for (auto c : s) {       sa_extend(c);     }     for (int i = 1; i < sz; i++) {       if (!st[i].isClone) cnt[i] = 1;     }     vector<int> node(sz);     iota((node).begin(), (node).end(), 0);     sort((node).begin(), (node).end(), cmp);     for (int u : node) {       if (~st[u].link) cnt[st[u].link] += cnt[u];     }     int n;     string pat;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> pat;       int k = (pat).size();       int rep = pow_cad(pat);       pat += pat.substr(0, rep - 1);       cerr <<  pat             <<  _=_  << pat <<   n ;       match(pat, k);     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:256000000 )   using namespace std;   const double infd = 2e+9;   const int infi = 1ll << 30;   const long long infl = 1ll << 60;   const int mod = 1e+9 + 7;   template <class T>   inline T sqr(T x) {     return x * x;   }   int main() {     string a, b;     int k;     cin >> a >> b >> k;     int n = a.length();     vector<int> p(k + 1);     p[0] = 1;     for (int i = 1; i <= k - 1; i++) p[i] = p[i - 1] * 1ll * (n - 1) % mod;     vector<int> d[2];     d[0].resize(k + 1);     d[1].resize(k + 1);     d[0][0] = 1;     d[1][0] = 0;     for (int i = 1; i <= k; i++) {       for (int m = 0; m < 2; m++) d[m][i] = (p[i - 1] - d[m][i - 1] + mod) % mod;     }     int result = 0;     for (int i = 0; i < n; i++) {       bool compactible = true;       for (int j = 0; j < n; j++) {         if (b[(i + j) % n] != a[j]) {           compactible = false;           break;         }       }       if (compactible) {         if (i == 0)           result += d[0][k];         else           result += d[1][k];         result %= mod;       }     }     cout << result;     return 0;   }
#include <bits/stdc++.h>   #define ll long long   #define ull unsigned long long   #define vll vector<ll>   using namespace std;   inline void sol() {     ll n, m;     cin >> n >> m;     vll a(n);     for(ll i=0;i<n;i++){       cin >> a[i];     }     vector<pair<int,double>> b(m);     for(int i=0;i<m;i++){       int r; double p;       cin >> r >> p;       b[i] = {r, p};     }     int rm;     for(rm = n-1; rm >= 0 and a[rm] == rm + 1; rm--);     if(rm == -1){       cout <<  1 n ;       return;     }     double ans = 1;     for(int i=0;i<m;i++){       if(b[i].first - 1 >= rm)         ans *= (1 - b[i].second);     }     // cout << 1 - ans << endl;     printf( %0.6lf n , 1 - ans);   }   int main() {     // cin.tie(0);     // ios_base::sync_with_stdio(false);        int t;     cin >> t;     while(t--)       sol();        return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, ans, u, v, start;   string opz;   int vis[2][200005];   vector<int> grafo[2][200005];   void dfs(int nodo, int mode) {     vis[mode][nodo] = 1;     for (auto i : grafo[mode][nodo]) {       if (vis[mode][i] == 1) {         cout <<  -1 n ;         exit(0);       }       if (vis[mode][i] == 0) {         dfs(i, mode);       }     }     vis[mode][nodo] = 2;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m;     opz.resize(n);     for (int i = 0; i < m; i++) {       cin >> u >> v;       grafo[0][u].push_back(v);       grafo[1][v].push_back(u);     }     for (int i = 1; i <= n; i++) {       if (vis[0][i] == 0 && vis[1][i] == 0) {         opz[i - 1] =  A ;         ans++;       } else {         opz[i - 1] =  E ;       }       if (vis[0][i] == false) dfs(i, 0);       if (vis[1][i] == false) dfs(i, 1);     }     cout << ans <<   n  << opz <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void handle_io() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   void solve() {     int P;     cin >> P;     if (P == 5)       cout << 2 <<     << 4 << endl;     else       cout << 2 <<     << P / 2 << endl;   }   int main() {     handle_io();     int t;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e6 + 7, Inf = 1e9 + 7;   int n, m, k = Inf, x, l, r, f, a[inf], b[inf], c[inf], d[inf];   map<int, int> p[inf];   vector<int> v;   string s;   int main() {     cin >> n >> s;     for (int i = 0; i < n; ++i) cin >> a[i];     for (int i = 1; i < n; ++i)       if (s[i] ==  L  && s[i - 1] ==  R ) k = min(k, (a[i] - a[i - 1]) / 2);     if (k == Inf)       cout << -1;     else       cout << k;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> all;   void backtrack(long long x, int cnt4, int cnt7) {     if (x > 1e10) return;     if (cnt4 == cnt7) all.push_back(x);     long long nxt = x * 10 + 4;     backtrack(nxt, cnt4 + 1, cnt7);     nxt = x * 10 + 7;     backtrack(nxt, cnt4, cnt7 + 1);   }   int main() {     std::ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     int n;     cin >> n;     backtrack(0, 0, 0);     sort(all.begin(), all.end());     cout << *lower_bound(all.begin(), all.end(), n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 7;   const long long mod = 1e9 + 7;   int n;   int a;   int b;   string s;   int main() {     cin >> n >> a >> b;     cin >> s;     if (s[b - 1] == s[a - 1]) {       cout << 0;       return 0;     }     int x = 1e7, y = 1e7;     for (int i = b - 1; i < n; i++) {       if (s[i] == s[b - 1]) {         x = i;         break;       }     }     for (int i = b - 1; i >= 0; i--) {       if (s[i] == s[b - 1]) {         y = i;         break;       }     }     if (b - x < 0) {       cout << b - x;     }     if (b - y < 0) {       cout << b - y;     }     cout << min(b - x, b - y);   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int X = 0, w = 1;     char ch = 0;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) w = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       X = (X << 3) + (X << 1) + ch -  0 , ch = getchar();     return X * w;   }   int n, tot, a[300007], val[300007 * 30], trie[300007 * 30][2],       cnt[300007 * 30][2];   void add(int x) {     int cur = 0;     for (int i = 29; i >= 0; i--) {       int y = (x >> i) & 1;       if (!trie[cur][y]) {         trie[cur][y] = ++tot;       }       cnt[cur][y]++;       cur = trie[cur][y];     }     val[cur] = x;   }   int ask(int x) {     int cur = 0;     for (int i = 29; i >= 0; i--) {       int y = (x >> i) & 1;       if (cnt[cur][y]) {         cnt[cur][y]--;         cur = trie[cur][y];       } else {         cnt[cur][y ^ 1]--;         cur = trie[cur][y ^ 1];       }     }     return val[cur];   }   int main() {     n = read();     for (int i = 1; i <= n; i++) {       a[i] = read();     }     for (int i = 1; i <= n; i++) {       int x = read();       add(x);     }     for (int i = 1; i <= n; i++) {       printf( %d  , a[i] ^ ask(a[i]));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)2e3 + 113;   long long n, k, cnt = 0;   int main() {     cin >> k >> n;     while (n > k) {       if (n % k != 0) {         cout <<  NO ;         return 0;       }       n /= k;       cnt++;     }     if (n == k) {       cout <<  YES  << endl << cnt;       return 0;     }     cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010;   const int inf = 0x3f3f3f3f;   const int modu = 1e9 + 7;   int t, n, m, k, p, q, cnta, cntb;   double sum, res, ans;   struct pen {     int money;     int num;     int pp;   } a[maxn];   vector<int> ve[110];   bool cmp(const pen a, const pen b) {     return a.pp == b.pp ? a.money > b.money : a.pp < b.pp;   }   int main() {     cnta = inf;     sum = 0;     res = 0;     sum = 0;     memset(a, 0, sizeof(a));     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> p >> q;       cnta = min(cnta, p);       a[i].money = p;       a[i].pp = q;       a[i].num = i + 1;     }     sort(a, a + n, cmp);     int j;     for (j = 0; j < k - 1 && a[j].pp == 1; j++) {       sum += a[j].money * 0.5;     }     if (a[k - 1].pp == 1) sum -= cnta * 0.5;     for (j; j < n; j++) {       sum += a[j].money;     }     printf( %.1f n , sum);     for (int i = 0; i < k - 1; ++i) {       printf( 1 %d n , a[i].num);     }     cout << n - k + 1;     for (int i = k - 1; i < n; ++i) {       printf(  %d , a[i].num);     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int T;     cin >> T;     for (int t = 1; t <= T; ++t) {       int64_t n;       cin >> n;       if (n == 1) {         cout << 0 <<   n ;         continue;       }       int count = 0;       int first = 1;       int64_t res = INT_MAX;       for (int i = 1; i <= 63500; ++i) {         first += 1;         count += 1;         int64_t sum = first;         res = min(res, (((n - sum) + (first - 1)) / first) + count);       }       cout << res <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   int main() {     ios::sync_with_stdio(0), cin.tie(0);     int tt;     cin >> tt;     while (tt--) {       int n, k;       cin >> n >> k;       int ans = 0;       int count = 0;       char x;       int lwb = 0;       bool f = false;       for (int i = 0; i < n; i++) {         cin >> x;         if (x ==  1 ) {           if (!f) {             lwb = count;           } else {             ans += count / (k + 1);             if (count / (k + 1) > 0 && count % (k + 1) != k) {               ans--;             }           }           count = 0;           f = true;         } else {           count++;         }       }       ans += lwb / (k + 1);       ans += count / (k + 1);       if (count == n && n % (k + 1) > 0) {         ans++;       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> vec[200010];   int a[200010], b[200010], color[200010];   bool flag = false;   void dfs(int now, int pre, int col) {     color[now] = col;     for (int i = 0; i < vec[now].size(); i++) {       int v = vec[now][i];       if (v == pre) continue;       if (color[v] == -1)         dfs(v, now, 1 - col);       else if (color[v] == color[now])         flag = true;     }   }   int main() {     int n, m;     cin >> n >> m;     memset(color, -1, sizeof(color));     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       a[i] = u;       b[i] = v;       vec[u].push_back(v);       vec[v].push_back(u);     }     dfs(1, -1, 0);     if (flag) {       cout <<  NO  << endl;       return 0;     }     cout <<  YES  << endl;     for (int i = 0; i < m; i++) {       if (color[a[i]])         cout <<  0 ;       else         cout <<  1 ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     vector<vector<int>> a(n, vector<int>(m)), n_s(1001, vector<int>(1001)),         n_c(1001, vector<int>(1001));     vector<int> m_s(1001), m_c(1001);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) cin >> a[i][j];     for (int i = 0; i < n; i++) {       vector<pair<int, int>> num;       for (int j = 0; j < m; j++) num.push_back(make_pair(a[i][j], j));       sort(num.begin(), num.end());       int h = 0;       for (int k = 0; k < num.size(); k++) {         if (k && num[k].first != num[k - 1].first) h++;         n_s[i][num[k].second] = h;       }       m_s[i] = h;     }     for (int i = 0; i < m; i++) {       vector<pair<int, int>> num;       for (int j = 0; j < n; j++) num.push_back(make_pair(a[j][i], j));       sort(num.begin(), num.end());       int h = 0;       for (int k = 0; k < num.size(); k++) {         if (k && num[k].first != num[k - 1].first) h++;         n_c[i][num[k].second] = h;       }       m_c[i] = h;     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         int l_s = n_s[i][j];         int l_c = n_c[j][i];         int g_s = m_s[i] - l_s;         int g_c = m_c[j] - l_c;         cout << max(l_s, l_c) + 1 + max(g_s, g_c) <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mxn = 2e5;   const long long INF = 2e18;   const int32_t M = 1000000007;   const long double pie = acos(-1);   template <typename Arg1>   void __f(const char *name, Arg1 &&arg1) {     cerr << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char *names, Arg1 &&arg1, Args &&...args) {     const char *comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   void solve() {     long long n, m;     cin >> n >> m;     vector<long long> gr[n + 1];     vector<long long> ingr[n + 1];     for (long long i = 1; i <= m; i++) {       long long u, v;       cin >> u >> v;       gr[u].push_back(v);       ingr[v].push_back(u);     }     long long k;     cin >> k;     vector<long long> p(k + 1);     for (long long i = 1; i <= k; i++) {       cin >> p[i];     }     long long s = p[1], t = p[k];     vector<long long> d(n + 1, INF);     d[t] = 0;     queue<long long> q;     vector<bool> vis(n + 1, false);     q.push(t);     vis[t] = true;     while (!q.empty()) {       long long v = q.front();       q.pop();       for (long long u : ingr[v]) {         if (!vis[u]) {           q.push(u);           vis[u] = true;         }         d[u] = min(d[u], d[v] + 1);       }     }     long long mn = 0, mx = 0;     for (long long i = 1; i <= k - 1; i++) {       long long curmn = INF;       for (long long v : gr[p[i]]) {         curmn = min(curmn, d[v]);       }       long long cntmn = 0;       for (long long v : gr[p[i]]) {         if (d[v] == curmn) cntmn++;         if (cntmn == 2) break;       }       if (d[p[i + 1]] == curmn) {         if (cntmn == 2) mx++;       } else {         mx++;         mn++;       }     }     cout << mn <<     << mx;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long _t = 1;     for (long long i = 1; i <= _t; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int max2(int a, int b) { return ((a > b) ? a : b); }   inline int min2(int a, int b) { return a < b ? a : b; }   inline int max3(int a, int b, int c) { return max2(a, max2(b, c)); }   long long int gcd(long long int a, long long int b) {     while (b) {       long long int temp = a;       a = b;       b = temp % b;     }     return a;   }   int main() {     int n, w, k;     scanf( %d , &k);     scanf( %d , &n);     scanf( %d , &w);     int total = w * (w + 1);     total = total / 2;     total = total * k;     int diff = total - n;     if (diff > 0)       printf( %d n , diff);     else       printf( %d n , 0);     return 0;   }