malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <class T1>   void debug(T1 e) {     cout << e << endl;   }   template <class T1, class T2>   void debug(T1 e1, T2 e2) {     cout << e1 <<   t  << e2 << endl;   }   template <class T1, class T2, class T3>   void debug(T1 e1, T2 e2, T3 e3) {     cout << e1 <<   t  << e2 <<   t  << e3 << endl;   }   template <class T1, class T2, class T3, class T4>   void debug(T1 e1, T2 e2, T3 e3, T4 e4) {     cout << e1 <<   t  << e2 <<   t  << e3 <<   t  << e4 << endl;   }   template <class T1, class T2, class T3, class T4, class T5>   void debug(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {     cout << e1 <<   t  << e2 <<   t  << e3 <<   t  << e4 <<   t  << e5 << endl;   }   template <class T1, class T2, class T3, class T4, class T5, class T6>   void debug(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {     cout << e1 <<   t  << e2 <<   t  << e3 <<   t  << e4 <<   t  << e5 <<   t           << e6 << endl;   }   template <class T>   void debug(vector<vector<T> > e, int row, int col) {     int i, j;     for (i = 0; i < row; i++) {       for (j = 0; j < col; j++) cout << e[i][j] <<    ;       cout << endl;     }     cout << endl;   }   template <class T>   void debug(vector<basic_string<T> > e, int row, int col) {     int i, j;     for (i = 0; i < row; i++) {       for (j = 0; j < col; j++) cout << e[i][j];       cout << endl;     }     cout << endl;   }   template <class T>   void debug(T e[110][110], int row, int col) {     int i, j;     for (i = 0; i < row; i++) {       for (j = 0; j < col; j++) cout << e[i][j] <<    ;       cout << endl;     }   }   template <class T>   string toString(T n) {     ostringstream oss;     oss << n;     oss.flush();     return oss.str();   }   int toInt(string s) {     int r = 0;     istringstream sin(s);     sin >> r;     return r;   }   bool isVowel(char ch) {     ch = tolower(ch);     if (ch ==  a  || ch ==  e  || ch ==  i  || ch ==  o  || ch ==  u )       return true;     return false;   }   bool isUpper(char c) { return c >=  A  && c <=  Z ; }   bool isLower(char c) { return c >=  a  && c <=  z ; }   int n;   int arr[2000];   int main() {     int n;     while (cin >> n) {       int i;       for (i = 1; i <= n; i++) cin >> arr[i];       if (n % 2 == 0 || n == 1) {         cout <<  -1  << endl;         continue;       }       int ans = 0;       for (i = n - 1; i > 1; i -= 2) {         int ma = max(arr[i], arr[i + 1]);         arr[i] = 0;         arr[i + 1] = 0;         arr[i / 2] -= ma;         arr[i / 2] = max(0, arr[i / 2]);         ans += ma;       }       ans += arr[1];       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     char c = getchar();     int d = 0, f = 1;     for (; c <  0  || c >  9 ; c = getchar())       if (c ==  - ) f = -1;     for (; c >=  0  && c <=  9 ; d = d * 10 + c - 48, c = getchar())       ;     return d * f;   }   int r, d, n;   const int N = 100001;   struct xint {     int x, y, r;   } a[N];   int main() {     r = read(), d = read(), n = read();     int ans = 0;     for (int i = 1; i <= n; ++i) {       a[i].x = read(), a[i].y = read(), a[i].r = read();       int dis = a[i].x * a[i].x + a[i].y * a[i].y;       if (dis >= (r - d + a[i].r) * (r - d + a[i].r) && r >= a[i].r &&           dis <= (r - a[i].r) * (r - a[i].r))         ans++;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const double PI = acos(-1.0);   const double E = exp(1);   const double EPS = 1e-5;   const int maxn = 2000 + 5;   int n, m;   char mp[maxn][maxn] = {0};   int dx[] = {1, 0, 0, -1};   int dy[] = {0, 1, -1, 0};   int cnt = 0;   bool check(int x, int y) {     if (x < 0 || x >= m || y < 0 || y >= n || mp[x][y] !=  . ) return false;     return true;   }   void dfs(int x, int y) {     if (!check(x, y)) return;     int num = 0;     int dir;     for (int i = 0; i < (4); i++) {       int xx = x + dx[i];       int yy = y + dy[i];       if (check(xx, yy)) {         dir = i;         num++;       }     }     if (num == 1) {       if (dir == 0) {         mp[x][y] =  ^ ;         mp[x + dx[dir]][y + dy[dir]] =  v ;       } else if (dir == 1) {         mp[x][y] =  < ;         mp[x + dx[dir]][y + dy[dir]] =  > ;       } else if (dir == 2) {         mp[x][y] =  > ;         mp[x + dx[dir]][y + dy[dir]] =  < ;       } else if (dir == 3) {         mp[x][y] =  v ;         mp[x + dx[dir]][y + dy[dir]] =  ^ ;       }       cnt += 2;       for (int i = 0; i < (4); i++) dfs(x + dx[i] + dx[dir], y + dy[i] + dy[dir]);     }   }   int main(void) {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> m >> n;     for (int i = 0; i < (m); i++) cin >> mp[i];     for (int i = 0; i < (m); i++)       for (int j = 0; j < (n); j++) {         if (mp[i][j] ==  * ) cnt++;         dfs(i, j);       }     if (cnt != m * n)       puts( Not unique );     else       for (int i = 0; i < (m); i++) cout << mp[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   using pss = pair<string, string>;   using pis = pair<int, string>;   const int maxn = 300300;   int n;   LL val[maxn], mask[maxn], sum;   signed main() {     while (cin >> n) {       sum = 0;       for (int i = 1; i <= n; i++) {         cin >> val[i] >> mask[i];         sum += val[i];       }       for (int i = 1; i <= n; i++) {         if (sum < 0) {           val[i] = -val[i];         }       }       LL ret = 0;       for (int k = 0; k < 62; k++) {         LL tot = 0;         for (int i = 1; i <= n; i++) {           if (mask[i] == (1LL << k)) {             tot += val[i];           }         }         if (tot > 0) ret |= (1LL << k);         for (int i = 1; i <= n; i++) {           if ((1LL << k) & mask[i]) {             mask[i] ^= (1LL << k);             if (tot > 0) {               val[i] = -val[i];             }           }         }       }       cout << ret << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   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...);   }   bool isprime(int n) {     for (int i = 2; i * i <= n; i++)       if (n % i == 0) return false;     return true;   }   int main() {     int n;     scanf( %d , &n);     int ans = 0;     if (n <= 3)       ans = 1;     else if (n % 2 == 0)       ans = 2;     else if (isprime(n))       ans = 1;     else if (isprime(n - 2))       ans = 2;     else       ans = 3;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x[500005];   char c[500005];   int a[20];   int q, w, e;   int main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < 10; i++) a[i] = 2;     for (int i = 0; i < n; i++) {       cin >> c[i] >> x[i];     }     for (int i = 0; i < 10; i++) {       int k = (1 << i);       for (int j = 0; j < n; j++) {         if (c[j] ==  | ) {           if (x[j] & k) {             a[i] = 1;           }         } else if (c[j] ==  & ) {           if (!(x[j] & k)) {             a[i] = 0;           }         } else {           if (x[j] & k) {             if (a[i] == 0)               a[i] = 1;             else if (a[i] == 1)               a[i] = 0;             else if (a[i] == 2)               a[i] = 3;             else               a[i] = 2;           }         }       }     }     for (int i = 0; i < 10; i++) {       if (a[i] != 0) q += (1 << i);       if (a[i] == 3) w += (1 << i);       if (a[i] == 1) e += (1 << i);     }     cout <<  3 n ;     cout <<  &   << q <<   n ;     cout <<  ^   << w <<   n ;     cout <<  |   << e <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool prime[100001];   bool ispoweroftwo(long long int x) { return x && !(x & (x - 1)); }   long long int xorcal(long long int n) {     if (n % 4 == 0) return n;     if (n % 4 == 1) return 1;     if (n % 4 == 2) return n + 1;     if (n % 4 == 3) return 0;   }   void sieve(long long int n) {     memset(prime, true, sizeof(prime));     prime[0] = false;     prime[1] = false;     for (long long int i = 2; i * i <= n; i++) {       if (prime[i] == true) {         for (long long int j = i * i; j <= n; j += i) {           prime[j] = false;         }       }     }   }   bool isprime(long long int n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 or n % 3 == 0) return false;     for (long long int i = 5; i * i <= n; i += 6) {       if (n % i == 0 or n % (i + 2) == 0) return false;     }     return true;   }   long long int modinverse(long long int a, long long int m) {     long long int m0 = m;     long long int y = 0, x = 1;     if (m == 1) return 0;     while (a > 1) {       long long int q = a / m;       long long int t = m;       m = a % m;       a = t;       t = y;       y = x - q * y;       x = t;     }     if (x < 0) x += m0;     return x;   }   long long int gcd(long long int a, long long int b) {     if (a == 0) {       return b;     }     return (b % a, a);   }   long long int power(long long int A, long long int B) {     if (A == 0) return 0;     if (B == 0) return 1;     long long int y;     if (B % 2 == 0) {       y = power(A, B / 2);       y = (y * y) % 1000000007;     } else {       y = A % 1000000007;       y = (y * power(A, B - 1) % 1000000007) % 1000000007;     }     return (long long int)((y + 1000000007) % 1000000007);   }   int main() {     ios_base::sync_with_stdio(false);     long long int n;     cin >> n;     string s;     cin >> s;     char f[10];     for (long long int i = 1; i < 10; i++) {       cin >> f[i];     }     long long int fl = 0;     for (long long int i = 0; i < n; i++) {       if (s[i] < f[s[i] -  0 ]) {         s[i] = f[s[i] -  0 ];         fl = 1;       } else if (fl == 1 and s[i] > f[s[i] -  0 ]) {         break;       }     }     cout << s <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   int n, m, pnt[N], vis[N];   long long vsum[N], esum[N], vcnt[N];   pair<pair<int, int>, pair<int, int> > edge[N];   vector<int> edge2[N];   int find(int x) {     if (x != pnt[x]) pnt[x] = find(pnt[x]);     return pnt[x];   }   void dfs(int u, int root) {     vis[u] = root;     vsum[u] = vcnt[u];     for (int i = 0; i < (int)(edge2[u]).size(); ++i) {       int v = edge2[u][i];       if (vis[v]) continue;       dfs(v, root);       vsum[u] += vsum[v];     }   }   void solve() {     int u, v, w;     m = n - 1;     memset(esum, 0, sizeof(esum));     for (int i = 0; i < n; ++i) {       vcnt[i] = 1;       pnt[i] = i;     }     for (int i = 0; i < m; ++i) {       scanf( %d%d%d , &u, &v, &w);       edge[i] = make_pair(make_pair(w, i), make_pair(u - 1, v - 1));     }     sort(edge, edge + m);     for (int i = 0; i < m; ++i) {       int j = i + 1;       for (; j < m; ++j)         if (edge[i].first.first != edge[j].first.first) break;       set<int> s;       for (int k = i; k < j; ++k) {         s.insert(find(edge[k].second.first));         s.insert(find(edge[k].second.second));       }       vector<int> vt((s).begin(), (s).end());       for (int k = 0; k < (int)(vt).size(); ++k) {         vsum[vt[k]] = vis[vt[k]] = 0;         edge2[vt[k]] = vector<int>();       }       for (int k = i; k < j; ++k) {         int p = find(edge[k].second.first);         int q = find(edge[k].second.second);         edge2[p].push_back(q);         edge2[q].push_back(p);       }       for (int k = 0; k < (int)(vt).size(); ++k) {         if (vis[vt[k]]) continue;         dfs(vt[k], vt[k] + 1);       }       for (int k = i; k < j; ++k) {         int p = find(edge[k].second.first);         int q = find(edge[k].second.second);         long long c = min(vsum[p], vsum[q]);         esum[edge[k].first.second] = 2 * c * (vsum[vis[p] - 1] - c);       }       for (int k = i; k < j; ++k) {         int p = find(edge[k].second.first);         int q = find(edge[k].second.second);         pnt[p] = q;         vcnt[q] += vcnt[p];       }       i = j - 1;     }     long long ans = 0;     int ct = 0;     for (int i = 0; i < m; ++i) {       if (ans < esum[i]) {         ans = esum[i];         ct = 1;       } else if (ans == esum[i]) {         ct++;       }     }     printf(          %I64d            %d n ,         ans, ct);     bool first = true;     for (int i = 0; i < m; ++i) {       if (esum[i] != ans) continue;       if (!first)         printf(   );       else         first = false;       printf( %d , i + 1);     }     puts(  );   }   int main() {     while (scanf( %d , &n) != EOF) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     bool v[60], h[60];     int a, b, n;     while (cin >> n) {       memset(v, false, sizeof(v));       memset(h, false, sizeof(h));       for (int i = 1; i <= n * n; i++) {         cin >> a >> b;         if (i == 1) {           cout << 1;           h[a] = true;           v[b] = true;         } else if (h[a] == false && v[b] == false) {           h[a] = true;           v[b] = true;           cout <<     << i;         }       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename S, typename T>   ostream &operator<<(ostream &os, pair<S, T> &m) {     os <<  [  << m.first <<     << m.second <<  ] ;     return os;   }   int n;   vector<int> v;   bool func(int k) {     int x = k - 1, y = n - 1;     for (int i = x; i >= 0; --i) {       if (2 * v[x] > v[y]) return false;       x--, y--;     }     return true;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     cin >> n;     v.resize(n);     for (int i = 0; i < n; ++i) cin >> v[i];     sort(begin(v), end(v));     int lo = 0, hi = n / 2, ans = 0;     while (lo <= hi) {       int mid = (lo + hi) / 2;       if (func(mid)) {         ans = mid;         lo = mid + 1;       } else         hi = mid - 1;     }     cout << n - ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   vector<int> v[1000010];   vector<int> vv;   bool visit[1000010] = {0};   int t, tt;   int res = 0;   void dfs(int x) {     visit[x] = 1;     t++;     for (int i = 0; i < v[x].size(); i++) {       int xi = v[x][i];       if (!visit[xi]) dfs(xi);     }   }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 0; i < m; i++) {       int x, y;       scanf( %d%d , &x, &y);       x--, y--;       v[x].push_back(y);       v[y].push_back(x);     }     for (int i = 0; i < n; i++) {       if (!visit[i]) {         t = 0;         dfs(i);         vv.push_back(min(t, k));       }     }     if (k == 1) {       cout << max(0, (int)(vv.size() - 2));       return 0;     }     sort(vv.begin(), vv.end());     reverse(vv.begin(), vv.end());     tt = vv[0];     for (int i = 1; i < vv.size(); i++) {       if (tt)         tt += vv[i] - 2;       else {         tt++;         res++;       }     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 4000 + 1;   const int sq = 100;   const long long int mod = 1e9 + 7;   const long long int inf = 4000 + 1;   unordered_map<long long int, int> dp;   int ps[N], n;   inline int get(int l, int r) { return ps[r] - ps[l]; }   int solve(int l, int r, int k, bool bol) {     if (r - l < k || l >= r || r > n || l < 0) return 0;     if (r - l == k && bol) return get(l, r);     if (r - l == k) return -get(l, r);     long long int key = l * N * sq * 2 + r * sq * 2 + k * 2 + bol;     if (dp.count(key)) return dp[key];     int ans, x, y;     if (bol) {       x = solve(l + k, r, k, 0) + get(l, l + k);       y = solve(l + k + 1, r, k + 1, 0) + get(l, l + k + 1);       ans = max(x, y);     } else {       x = solve(l, r - k, k, 1) - get(r - k, r);       y = solve(l, r - k - 1, k + 1, 1) - get(r - k - 1, r);       ans = min(x, y);     }     return dp[key] = ans;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     dp.rehash(16e6);     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int x;       scanf( %d , &x);       ps[i + 1] = ps[i] + x;     }     printf( %d  n , solve(0, n, 1, 1));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void init() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);   }   void skipInputLine() { cin.ignore(numeric_limits<streamsize>::max(),   n ); }   template <typename TYPE>   TYPE readNum() {     TYPE item;     cin >> item;     return item;   }   template <typename COLLECTION>   COLLECTION readNums(size_t count) {     COLLECTION collection;     typename COLLECTION::value_type item;     for (size_t i = 0; i < count; i++) {       cin >> item;       collection.insert(item);     }     return collection;   }   template <typename COLLECTION>   void writeNums(const COLLECTION &collection) {     for (auto item : collection) {       cout << item <<    ;     }     cout << endl;   }   struct Datum {     Datum() {}     Datum(uint32_t _x, uint32_t _count) : x(_x), count(_count) {}     uint32_t x;     uint32_t count;   };   void pass(const vector<Datum> &data, uint32_t k, vector<Datum> &ranges) {     uint32_t idx_left = 0, idx_right = 0;     uint32_t left_value = 0;     while (idx_left < data.size() && idx_right < data.size()) {       while (idx_right < data.size()) {         if (idx_right + 1 < data.size() &&             data[idx_right + 1].x <= data[idx_left].x + k) {           idx_right++;         } else {           break;         }       }       ranges.push_back(           Datum(data[idx_left].x, data[idx_right].count - left_value));       left_value = data[idx_left].count;       idx_left++;     }   }   uint32_t calc(uint32_t n, uint32_t k) {     map<uint32_t, uint32_t> xs;     for (size_t i = 0; i < n; i++) {       uint32_t x;       cin >> x;       xs[x]++;     }     skipInputLine();     skipInputLine();     uint32_t cumulative = 0;     vector<Datum> data(xs.size());     uint32_t index = 0;     for (map<uint32_t, uint32_t>::const_iterator it = xs.begin(); it != xs.end();          it++) {       cumulative += it->second;       data[index++] = Datum(it->first, cumulative);     }     xs.clear();     uint32_t width = data[data.size() - 1].x - data[0].x + 1;     if (width <= 2 * (k + 1)) {       return n;     }     vector<Datum> ranges;     ranges.reserve(2 * data.size());     pass(data, k, ranges);     data.clear();     map<uint32_t, uint32_t> best_sums;     uint32_t bs = 0;     for (size_t i = 0; i < ranges.size(); i++) {       const Datum &range = ranges[i];       bs = max(bs, range.count);       best_sums[range.x] = bs;     }     uint32_t best_sum = 0;     for (size_t i = 1; i < ranges.size(); i++) {       const Datum &range = ranges[i];       uint32_t sum = range.count;       int32_t x = int32_t(range.x) - int32_t(k + 1);       if (x < 0) {         x = 0;       }       map<uint32_t, uint32_t>::const_iterator it = best_sums.upper_bound(x);       if (it != best_sums.cbegin()) {         it--;         best_sum = max(best_sum, sum + it->second);       }     }     return best_sum;   }   int main() {     init();     uint32_t t = readNum<uint32_t>();     for (uint32_t i = 0; i < t; i++) {       uint32_t n, k;       cin >> n >> k;       uint32_t res = calc(n, k);       cout << res <<   n ;     }     cout << flush;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     register long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = (x << 1) + (x << 3) + (ch ^ 48);       ch = getchar();     }     return x * f;   }   const long long N = 1e5 + 10;   const long long M = N;   const long long INF = 1e16;   struct edge {     long long u, v, w, next;     bool operator<(const edge &x) const { return w < x.w; }   } e[M << 1];   long long head[N], cnt;   void add(long long u, long long v, long long w = 0) {     e[++cnt] = (edge){u, v, w, head[u]};     head[u] = cnt;   }   long long n, m, k, ans = INF;   long long dis[N], s[N], from[N];   bool vis[N];   struct node {     long long u, d;     bool operator<(const node &x) const { return d > x.d; }   };   priority_queue<node> q;   void Dij() {     for (long long i = 1; i <= n; i++) from[i] = vis[i] = 0, dis[i] = INF;     for (long long i = 1; i <= k; i++)       from[s[i]] = s[i], dis[s[i]] = 0, q.push((node){s[i], 0});     while (!q.empty()) {       long long u = q.top().u;       q.pop();       if (vis[u]) continue;       vis[u] = 1;       for (long long i = head[u]; i; i = e[i].next) {         long long v = e[i].v;         if (vis[v]) continue;         if (dis[v] > dis[u] + e[i].w) {           dis[v] = dis[u] + e[i].w;           from[v] = from[u];           q.push((node){v, dis[v]});         }       }     }   }   long long fa[N];   long long find(long long x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }   void krus() {     for (long long i = 1; i <= cnt; i++) {       e[i].w += dis[e[i].u] + dis[e[i].v];       e[i].u = from[e[i].u], e[i].v = from[e[i].v];     }     sort(e + 1, e + cnt + 1);     for (long long i = 1; i <= cnt; i++) {       long long fx = find(e[i].u), fy = find(e[i].v);       if (fx == fy) continue;       ans += e[i].w;       fa[fx] = fy;     }   }   signed main() {     n = read(), m = read();     for (long long i = 1; i <= n; i++) fa[i] = i;     for (long long i = 1; i <= m; i++) {       long long u = read(), v = read(), w = read();       add(u, v, w), add(v, u, w);     }     s[k = 1] = 1;     Dij();     k = read();     for (long long i = 1; i <= k; i++) {       s[i] = read();       ans = min(ans, dis[s[i]]);     }     Dij();     krus();     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s;     int n;     while (cin >> n) {       cin >> s;       int gold = 0, cnt = 0, prev = 0, ans = 0;       for (auto ch : s) {         if (ch ==  G )           gold++, cnt++;         else           prev = cnt, cnt = 0;         ans = max(ans, prev + cnt + 1);       }       ans = min(ans, gold);       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> t;     while (t--) {       int a, b, c;       cin >> a >> b >> c;       if (c == 0) {         if (a <= b)           cout << 0 << endl;         else           cout << 1 << endl;         continue;       } else if (a + c <= b) {         cout << 0 << endl;         continue;       }       int res;       if (a == b) {         res = c / 2;         if (c % 2 == 1) res++;       } else if (a > b) {         if (b + c < a)           res = c + 1;         else if (b + c == a)           res = c;         else {           if ((b + c - a) % 2 == 1)             res = (b + c - a) / 2 + 1 + a - b;           else             res = (b + c - a) / 2 + a - b;         }       } else {         if ((a + c - b) % 2 == 1)           res = (a + c - b) / 2 + 1;         else           res = (a + c - b) / 2;       }       cout << res << endl;     }   }