akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    cin>>n>>m;
    int a[n+1]; rep(i,1,n) cin>>a[i];
    a[0]=0;
    rep(i,1,n) a[i]+=a[i-1];
    rep(i,m,n){
        ans=max(ans,a[i]-a[i-m]);
    }
    double t=ans+m;
    t/=(double)2;
    cout<<fixed<<setprecision(10)<<t;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    int dp[n][3];
    dp[0][0]=a[0][0]; dp[0][1]=a[0][1]; dp[0][2]=a[0][2];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            if(j==0){dp[i][j]=max(dp[i-1][1],dp[i-1][2])+a[i][j];}
            else if(j==1) {dp[i][j]=max(dp[i-1][0],dp[i-1][2])+a[i][j];}
            else if(j==2) {dp[i][j]=max(dp[i-1][1],dp[i-1][0])+a[i][j];}
        }
    }
    int m=0;
    for(int i=0;i<3;i++){
        m=max(m,dp[n-1][i]);
    }
    cout<<m<<endl;
return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")



int main() {

    ll n,m; cin >> n >> m;
    ll a,b,ans = 0;

    vector<pair<ll,bool>> h(n);

    rep(i,n){
        cin >> h[i].first;
        h[i].second = true;
    }

    rep(i,m){
        cin >> a >> b;
        a --; b --;
        if(h[a].first == h[b].first) {
            h[a].second = false;
            h[b].second = false;
        }else
        if(h[a].first > h[b].first) h[b].second = false;
        else h[a].second = false;
    }

    rep(i,n){
        if(h[i].second) ans ++;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 4772
#include <iostream>
using namespace std;
int main(void){
    
    int n;
    int k;
    cin >> n >> k;
    int w[n];
    int s = 0;
    for(int i=0;i<n;i++){
        cin >> w[i];
        s += w[i];
    }
    int m;
    m = (s + (k - 1)) / k;
    int flag = 1;
    //cout << m << endl;
    m--;
   // m=1;
    while(flag == 1){
        int tmp = 0;
        int c = 0;
        m++;
        for(int i=0;i<n;i++){
            if(tmp+w[i]<=m){
                tmp += w[i];
            }else{
                tmp = w[i];
                c++;
            }
            //cout << tmp<<" "<<c << endl;
            if(c>=k||tmp>m) break;
            if(i==n-1) flag = 0;
        }
    }
    cout << m << endl;
}



Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//ll GCD(ll x,ll y){
//    if(y == 0) return x;
//    else return GCD(y,x%y);
//}
const int MOD = 1000000007;


int main() {
    ll n;
    cin >> n;
    ll m = LLONG_MAX;
    for(int i = 0;i < 5;i++){
        ll a;
        cin >> a;
        m = min(m,a);
    }
    cout << ((n+m-1)/m)+4;
    
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

struct BinomialCoefficient {
    BinomialCoefficient() {}
    BinomialCoefficient(int n) : fac(n + 2), finv(n + 2), inv(n + 2) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= n; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    
    long long factorial(int n) {
        return fac[n];
    }
    
    long long combination(int n, int r) {
        if ((n < r) || (n < 0) || (r < 0)) return 0;
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
    
    long long permutation(int n, int r) {
        if ((n < r) || (n < 0) || (r < 0)) return 0;
        return fac[n] * finv[n - r] % mod;
    }
    
private:
    int mod = 998244353;
    vector<long long> fac, finv, inv;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll mod = 998244353;
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll ans = 0;
    BinomialCoefficient bc(n);
    rep(acnt, n + 1) {
        ll rem = k - acnt * a;
        if (rem % b != 0) continue;
        ll bcnt = rem / b;
        if (bcnt > n) continue;
        ans = (ans + bc.combination(n, acnt) * bc.combination(n, bcnt)) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10308
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

ll p(ll k) {
    return k*k*k*k*k;
}

int main() {
    ll X; cin >> X;
    for(ll i=-200; i<=200; i++) {
        ll A = p(i);
        for(ll j=-200; j<=200; j++) {
            ll B = p(j);
            if(A - B == X) {
                printf("%lld %lld\n", i, j);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3764
def calc(l,m,k,ans):
    if k == 0:
        s = ""
        for i in m:
            s += str(l[i])
        ans.add(s)
        return
    for i in range(len(l)):
        if not i in m:
            m.append(i)
            calc(l,m,k-1,ans)
            m.remove(i)
while 1:
    n = input() 
    if n == 0: break
    k = input()
    l = [input() for i in range(n)]
    ans = set()
    calc(l,[],k,ans)
    print len(ans)

Measured memory_bytes: 6424
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import numpy as np

def main():
    S = np.array(list(map(int,input().rstrip())))
    L = len(S)
    A = np.arange(L) & 1
    B = 1 - A
    x1 = (A!=S).sum()
    x2 = (B!=S).sum()
    print(min(x1,x2))

if __name__=="__main__":
    main()

Measured memory_bytes: 29640
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define ll long long
#define INF 1000000000

int main()
{
	ll nowp,cost=0;
	int n,a,b;
	cin >> n >> a >> b;

	vector<ll> x(n);
	REP(i,n){
		int y;
		cin >> y;
		x[i]=y;
	}

	nowp = x[0];

	for(int i=1;i<n;i++){
		if(a*(x[i]-x[i-1])<b)cost+=a*(x[i]-x[i-1]);
		else cost+=b;
	}

	cout << cost << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


signed main(signed argc, char** argv){
	string s;
	cin >> s;
	int n = s.size();

	bool f = true;
	for(int i = 0; i < n-1; ++i) {
		f = f && s[i] == s[n - 2 - i];
	}
	if(s[0] == '0' || s[n-1] == '1' || !f) {
		cout << -1 << endl;
		return 0;
	}
	s[n-1] = '1';
	set<int> p;
	for(int i = 0; i < n; ++i) {
		if(s[i] == '1') p.insert(i);
	}
	for(int i = 0; i < n-1; ++i) {
		int t = *p.upper_bound(i);
		cout << i + 1 << " " << t + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 6144
#include<iostream>
using namespace std;

const int max_n = 3010;
const int max_t = 3010;

struct store{
};


int main()
{
  int N,T,S;
  while(cin>>N>>T>>S){
    int A[max_n], B[max_n];
    
    for(int i = 0; i < N; ++i){
      cin >> A[i] >> B[i];
    }
    
    static int dp[max_n][max_t];
    
    for(int i = 0; i <= N; ++i){
      for(int j = 0; j <= T; ++j){
	dp[i][j] = 0;
      }
    }
    
    for(int i = 0; i < N; ++i){
      for(int j = 0; j <= T; ++j){
	dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
	dp[i][j+1] = max(dp[i][j+1], dp[i][j]);
	if( j+B[i] <= T ){
	  if( !(j < S && S < j+B[i]) ){
	    //printf("dp[%d][%d] = max(dp, dp[%d][%d] + A[%d]) : %d <- dp,%d\n",
	    // i+1,j+B[i],i,j,i,dp[i+1][j+B[i]],dp[i][j]+A[i]);
	    dp[i+1][j+B[i]] = max(dp[i+1][j+B[i]], dp[i][j] + A[i] );
	  }
	}
      }
    }
    
    cout << dp[N][T] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define getchar getchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int getint() {
	char C;
	while (!isdigit(C = getchar()));
	int x = C - '0';
	while (isdigit(C = getchar())) x = x * 10 + C - '0';
	return x;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N, Q;
	N = getint();
	Q = getint();
	char S[200000];
	fread(S, 1, N, stdin);
	char T[200000][4];
	fread(T, 1, 4 * Q, stdin);
	int L = 0;
	int R = N;
	for (int i = Q - 1; i >= 0; i--) {
		if (R > 0 && T[i][3] == 'R' && S[R - 1] == T[i][1]) R--;
		else if (R < N && T[i][3] == 'L' && S[R] == T[i][1]) R++;
		if (L > 0 && T[i][3] == 'R' && S[L - 1] == T[i][1]) L--;
		else if (L < N && T[i][3] == 'L' && S[L] == T[i][1]) L++;
	}

	co(R - L);

	Would you please return 0;
}

Measured memory_bytes: 1280
N,x=map(int,input().split())
a=[int(x) for x in input().split()]
cnt=0
if a[0]>x:
    cnt += a[0] - x
    a[0]=x 
for i in range(N-1):
    if a[i]+a[i+1] >x:
        cnt += a[i] + a[i+1] - x
        a[i+1]=x-a[i]
print(cnt)


Measured memory_bytes: 14540
n = int(input())
l = list(map(int, input().split()))
a = []
for i in range(1, n):
    if l[i] != l[i - 1]: a.append(l[i - 1])
a.append(l[n - 1])
n = len(a)

# print(a)

hi = []
for i in range(1, n - 1):
    if a[i - 1] < a[i] and a[i + 1] < a[i]: hi.append(i)
mn = a[0]
p1 = 0
money = 1000
stocks = 0

# print(hi)

for i in hi:
    while p1 < i:
        mn = min(mn, a[p1])
        p1 -= -1
    stocks = money // mn
    money = money % mn
    money += stocks * a[i]
    mn = a[i]
# print(money, stocks)
for i in range(p1 + 1, n):
    mn = min(mn, a[i])
stocks = money // mn
money = money % mn
money += stocks * a[n - 1]

print(money)

Measured memory_bytes: 61948
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define endl "\n"
using namespace std;
void solve1();
void solve()
{
    int t;cin>>t;
    while(t--)
    {
        solve1();
    }
}
signed main()
{
    solve1();
}
void solve1()
{
    vector<char> vec;
    int n;cin>>n;
    while(n!=0)
    {
        int m=n%26;
        if(m!=0)
        {vec.pb('a'+m-1);}
        else
        {
            vec.pb('z');n--;
        }
        n/=26;
    }

    for(int i=vec.size()-1;i>=0;i--)
    {
        cout<<vec[i];
    }cout<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e5+7;

int n;
int h[Maxn], dp[Maxn];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> h[i];
    dp[2] = abs(h[2]-h[1]);
    for(int i = 3; i <= n; ++i)
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
int a,b,c;
int x;
scanf("%d %d %d\n",&a,&b,&c);
if(a<=b&&b<=c){
printf("%d %d %d\n",a,b,c);
}
else if(a<=c&&c<=b){
printf("%d %d %d\n",a,c,b);
}
else if(b<=a&&a<=c){
printf("%d %d %d\n",b,a,c);
}
else if(b<=c&&c<=a){
printf("%d %d %d\n",b,c,a);
}
else if(c<=a&&a<=b){
printf("%d %d %d\n",c,a,b);
}
else{
printf("%d %d %d\n",c,b,a);
}
return 0;
}

Measured memory_bytes: 2736
#include <bits/stdc++.h>
#define tt this->
#define ll long long
using namespace std;
int main ()
{
int x,y,z;
cin>>x>>y>>z;
int a,b,c;
b=x;
a=z;
c=y;
cout<<a<<" "<<b<<" "<<c<<endl;

    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;

int main(){
  
  int N, K, i, n;
  cin >> N >> K;
  map<int, int> data;
  
  for(i=0; i<N; i++){
    cin >> n;
    data[n]++;
  }
  vector<int> vec(data.size());
  i = 0;
  for(auto p : data){
    vec[i] = p.second;
    i++;
  }  
  
  int Sum = 0;
  sort(vec.begin(), vec.end());
  for(i=0; i<(long long) vec.size()-K; i++){
    Sum += vec[i];
  }
  cout << Sum << endl;
  return 0;
}

Measured memory_bytes: 13348
from collections import deque
from bisect import bisect_left

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    d = deque([])
    d.append(A[0])
    for i in range(1,N):
        p = bisect_left(d, A[i])
        if p == 0:
            d.appendleft(A[i])
        else:
            d[p-1] = A[i]

    print(len(d))


if __name__ == "__main__":
    main()

Measured memory_bytes: 53720
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
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 inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int32_t main()
{
	fastIO
	inp_out();

	int a[5]; 
	for(int i = 0; i < 5; ++i)
		cin >> a[i]; 

	for(int i = 0; i < 5; ++i)
		if(a[i] == 0)
		{
			cout << i + 1; 
			break; 
		}

	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

vector<long> vec;
vector<long> vec2;

int main() {

	int n;
	cin >> n;

	for (int i = 0; i < n; ++i) {
		long tmp;
		cin >> tmp;
		vec.push_back(tmp);
	}


	/*
	vec2 = 2,3,1,4,5,6
	vec = 1,2,3,4,5,6
	aを中央値計算の小さい方(3),bを大きい方(4)にする
	vec2でループしてその各要素がa以下なら答えはbになる
	例)2,1,4,5,6⇒1,2,4,5,6⇒4
	そうでないならaになる
	例)2,3,1,4,5⇒1,2,3,4,5⇒3
	*/

	vec2 = vec;

	sort(vec.begin(), vec.end());

	int a = vec.at(n / 2 - 1);
	int b = vec.at(n / 2 );

	for (int j = 0; j < n; ++j) {
		if (vec2.at(j) <= a) cout << b << endl;
		else cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 5488
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int a, b; cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {

	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	var N, M int
	fmt.Scan(&N, &M)

	A := make([]int, N)
	vote := 0

	for i := 0; i < N; i++ {
		A[i], _ = strconv.Atoi(nextString())
		vote = vote + A[i]
	}

	sort.Sort(sort.Reverse(sort.IntSlice(A)))

	voteborder := 4 * M

	flag := true
	for i := 0; i < M; i++ {
		if A[i]*voteborder < vote || A[i] == 0 {
			flag = false
		}
	}

	if flag {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int T = int.Parse(str[1]);
            string[] strTimes = Console.ReadLine().Split(' ');
            List<int> lstTimes = new List<int>();
            foreach (string t in strTimes)
            {
                lstTimes.Add(int.Parse(t));
            }

            int Total = 0;
            for (int i = 1; i < lstTimes.Count; i++)
            {
                if (lstTimes[i] - lstTimes[i-1] <= T)
                {
                    Total += lstTimes[i] - lstTimes[i - 1];
                }
                else
                {
                    Total += T;
                }
            }
            Total += T;
            Console.WriteLine(Total);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 26464
#include <bits/stdc++.h>
using namespace std;

int main(){
	int i, j;
	string s;
	cin >> s;
	for(i = 0; s[i] != 'A'; i++);
	for(j = s.size() - 1; s[j] != 'Z'; j--);
	printf("%d\n", j - i + 1);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<sstream>
using namespace std;
const int maxn=1e5+5;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(b+c<=a) cout<<0;
	else cout<<c-(a-b);
}



Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
c=[0]*n
d=0
sums=0
for j in range(n):
    if j-a[j]<1:
        das=0
    else:
        b[j-a[j]]=b[j-a[j]]+1
    if j+a[j]>n-2:
        das=0
    else:
        c[j+a[j]]=c[j+a[j]]+1
for k in range(n):
    d=b[k]*c[k]
    sums=sums+d
print(sums)


Measured memory_bytes: 32188
#28
import sys
N = int(input())
a = list(map(int,input().split()))
cou = 0
l = len(a)
while cou >=0:
    for i in range(l):
        if a[i]%2 !=0:
            print(cou)
            sys.exit()
        a[i] /=2
    cou +=1

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =998244353 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
void solve(){
    ll a , b , c ;
    cin >> a >> b >> c ;
    int k ;
    cin >> k ;
    while(b<=a && k)
        b *= 2 , k--;
    while(c<=b && k)
        c *=2 , k--;
    if(b>a&& c>b){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
  // cin >> t ;
    while(t--){
        solve( );
    }
}




Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int x[100010];
int idx[100010][32][2];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll N, L, Q;
	cin >> N;
	for(int i = 1; i <= N; i++) {
		cin >> x[i];
	}
	x[N + 1] = 2e9 + 10;

	cin >> L >> Q;
	for(int i = 1; i <= N; i++) {
		idx[i][0][0] = upper_bound(x, x + N + 2, x[i] + L) - x - 1;
		idx[i][0][1] = lower_bound(x, x + N + 2, x[i] - L) - x;
	}
	for(int j = 0; j < 30; j++) {
		for(int i = 1; i <= N; i++) {
			idx[i][j + 1][0] = idx[idx[i][j][0]][j][0];
			idx[i][j + 1][1] = idx[idx[i][j][1]][j][1];
		}
	}

	while(Q--) {
		int a, b;
		cin >> a >> b;
		if(a < b) {
			int ng = 0, ok = N;
			while(abs(ng - ok) > 1) {
				int mid = (ng + ok) / 2;
				bool flag = false;
				int pos = a;
				for(int i = 20; i >= 0; i--) {
					if(mid >> i & 1) {
						pos = idx[pos][i][0];
						if(pos >= b) {
							flag = true;
							break;
						}
					}
				}
				if(flag) ok = mid;
				else ng = mid;
			}
			cout << ok << endl;
		}
		else {
			int ng = 0, ok = N;
			while(abs(ng - ok) > 1) {
				int mid = (ng + ok) / 2;
				bool flag = false;
				int pos = a;
				for(int i = 20; i >= 0; i--) {
					if(mid >> i & 1) {
						pos = idx[pos][i][1];
						if(pos <= b) {
							flag = true;
							break;
						}
					}
				}
				if(flag) ok = mid;
				else ng = mid;
			}
			cout << ok << endl;
		}
	}
}

Measured memory_bytes: 26240
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <climits>
using namespace std;


int main()
{
    int N, K;
    cin >> N >> K;
    vector<pair<int,int>> point(N);
    for( int i = 0; i < N; ++i ){
        int x, y;
        cin >> x >> y;
        point[i] = make_pair( x, y );
    }


    long ans = LONG_MAX;
    for( int l = 0; l < N; ++l ){
        for( int r = 0; r < N; ++r ){
            for( int u = 0; u < N; ++u ){
                for( int d = 0; d < N; ++d ){
                    int num = 0;
                    for( int i = 0; i < N; ++i ){
                        if( point[l].first <= point[i].first && point[i].first <= point[r].first
                         && point[d].second <= point[i].second && point[i].second <= point[u].second ){
                             ++num;
                         }
                    }
                    if( num >= K ){
                        long area = (long) (point[r].first - point[l].first) * (point[u].second - point[d].second);
                        ans = min( ans, area );
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;


void solve(std::string S){
  cout << S << (*S.rbegin() != 's' ? "s" : "es") << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>

using namespace std;

int  main() {
    int n, x, y;
    cin >> n >> x >> y;

    vector<int> distance(n, 0);
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (j <= x || y <= i) {
                distance.at(j - i)++;
            }
            if (x < i && j < y) {
                distance.at(min(j - i, i - x + 1 + y - j))++;
            }
            if (i <= x && y <= j) {
                distance.at(x - i + 1 + j - y)++;
            }
            if (i <= x && x < j && j < y) {
                distance.at(min(j - i, x - i + 1 + y - j))++;
            }
            if (x < i && i < y && y <= j){
                distance.at(min(j - i, i - x + 1 + j - y))++;
            }
        }
    }

    for (int i = 1; i < n; i++) {
        cout << distance.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;

    int ans = 0;
    int ketasu = 1;
    for (size_t i = 1; i <= n; i++) {
        if (i == 10 || i == 100 || i == 1000 || i == 10000 || i == 100000) ketasu++;
        if (ketasu%2 == 1) ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3576
#define George_Plover
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define EPS (1e-9)
#define MAXN 300001
#define MOD 1000000007
#define ull unsigned long long
#define LL long long

using namespace std;
int n;
int color[MAXN];
int dp[MAXN];
int lst[MAXN];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&color[i]);
    dp[0]=0;
    dp[1]=1;
    lst[color[1]]=1;
    for(int i=2;i<=n;i++)
    {
        if(color[i-1]==color[i])
            dp[i]=dp[i-1];
        else dp[i]=(dp[lst[color[i]]]+dp[i-1])%MOD;
        lst[color[i]]=i;
        //cout<<i<<" "<<dp[i]<<endl;
    }
    printf("%d\n",dp[n]);
    
    return 0;
}




Measured memory_bytes: 6084
#include<bits/stdc++.h>
using namespace std;

int main()
{
long long n;
cin>>n;
string s="";
 
while(n>0)
{
long long r=n%26;

if(r==0)
{
s+='z';
n=(n/26)-1;    
}

else
{
s+=(char)(r+96);
n=n/26;
}
  
}
 
reverse(s.begin(), s.end()); 
cout<<s<<"\n";
 
 
return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

void merge_max ( map<int, int>& dest, map<int, int> src )
{
	map<int, int>::iterator it;
	for ( it = src.begin(); it != src.end(); ++it ) {
		int key = it->first;
		dest[key] = max( dest[key], src[key] );
	}
}

int main ( void )
{
	int front, side;

	while ( cin >> front >> side, front | side ) {
		int in;
		map<int, int> mf, ms;

		for ( int i = 0; i < front; ++i ) {
			cin >> in;
			++mf[in];
		}
		for ( int i = 0; i < side; ++i ) {
			cin >> in;
			++ms[in];
		}

		merge_max( mf, ms );

		int ans = 0;
		for ( map<int, int>::iterator it = mf.begin(); it != mf.end(); ++it ) {
			ans += it->first * it->second;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;

using ll=long long;
const ll MOD=1000000007;

int main() {
  int N,D;
  cin >> N >> D;
  vector<vector<int>> vec(N,vector<int>(D,0));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin >> vec[i][j];
    }
  }
  int cnt=0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      ll a=0;
      for(int k=0;k<D;k++){
        a +=(vec[i][k]-vec[j][k])*(vec[i][k]-vec[j][k]);
      }
      for(int b=0;b<200;b++){
        if(a==b*b){
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#h,w=map(int,input().split())
n=int(input())
ans=[0]*(n+1)
a=[0]+[int(i) for i in input().split()]
an=0
for i in range(1,n+1):
    r=a[i]
    ans[i]=r
    if ans[r]==i:
        an+=1
    
print(an)

Measured memory_bytes: 53680
#include<iostream>
using namespace std;
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
ll mob=1000000007;
using namespace std;
int main()
{ 
int n;
cin>>n;
int a,b,c;
c=n%10;
n=n/10;
b=n%10;
n=n/10;
a=n%10;
if(a==7||b==7||c==7)
cout<<"Yes";
else
cout<<"No";




return 0;
}










Measured memory_bytes: 3104
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint i,n,ans=0;cin>>n;
	vector<llint>b(n);
	for(i=0;i<n;i++){cin>>b[i];b[i]-=(i+1);}
	SO(b);
	for(i=0;i<n;i++){ans+=abs(b[n/2]-b[i]);}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  map<int, int> mp;
  rep(i, n) ++mp[a[i]];
  int cnt = 0;
  bool exist = false;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) ++cnt;
  if (cnt == 1 && mp[0] > 0) exist = true;
  if (cnt == 2 && 3 * mp[0] == n) exist = true;
  if (cnt == 3) {
    auto itr = mp.begin();
    int a1 = itr->first;
    int n1 = (itr++)->second;
    int a2 = itr->first;
    int n2 = (itr++)->second;
    int a3 = itr->first;
    int n3 = (itr++)->second;
    if (a1 ^ a2 == a3 && n1 == n2 && n1 == n3) exist = true;
  }

  int sum = 0;
  rep(i, n) sum ^= a[i];

  if (exist && sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 7228
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int a[100];
int main(){
int n,d,x;
cin>>n>>d>>x;
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n;i++)
for(int j=1;j<=d;j+=a[i])
x++;
cout<<x;
system("pause");
return 0;
}

Measured memory_bytes: 504
fun main(){
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val h = readLine()!!.split(" ").map { it.toInt() }
    val hikaku = List(n){ 1 }.toMutableList()
    for (i in 0 until m){
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        if (h[a-1] > h[b-1]){
            hikaku[b-1] = 0
        } else if (h[b-1] > h[a-1]) {
            hikaku[a-1] = 0
        } else {
            hikaku[b-1] = 0
            hikaku[a-1] = 0
        }
    }
    var count = 0
    for (i in 0 until n){
        if (hikaku[i] == 1){
            count++
        }
    }
    println(count)
}

Measured memory_bytes: 62844
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<vector<int> > v(10, vector<int>(10, 0));
    for(int a=1; a<=n; ++a){
        string s = to_string(a);
        int i = s.front() - '0';
        int j = s.back() - '0';
        ++ v[i][j];
    }

    long long ans = 0;
    for(int a=1; a<=n; ++a){
        string s = to_string(a);
        int i = s.front() - '0';
        int j = s.back() - '0';
        ans += v[j][i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main(){
  int64_t N;
  string S;
  cin >> N;
  cin >> S;
  vector<int64_t> R, G, B;
  for(int64_t i=0LL; i<N; i++){
    if(S.at(i)=='R'){
      R.push_back(i);
    }
    if(S.at(i)=='G'){
      G.push_back(i);
    }
    if(S.at(i)=='B'){
      B.push_back(i);
    }
  }
  int64_t r=R.size();
  int64_t g=G.size();
  int64_t b=B.size();
  int64_t Ans=r*g*b;
  int64_t Max, Middle, Min;
  for(int64_t i=0LL; i<r; i++){
    for(int64_t j=1LL; j<=(N-R.at(i)-1)/2; j++){
      if(S.at(R.at(i)+j)=='G' && S.at(R.at(i)+2*j)=='B'){
        Ans--;
      }
      if(S.at(R.at(i)+j)=='B' && S.at(R.at(i)+2*j)=='G'){
        Ans--;
      }
    }
  }
  for(int64_t i=0LL; i<g; i++){
    for(int64_t j=1LL; j<=(N-G.at(i)-1)/2; j++){
      if(S.at(G.at(i)+j)=='B' && S.at(G.at(i)+2*j)=='R'){
        Ans--;
      }
      if(S.at(G.at(i)+j)=='R' && S.at(G.at(i)+2*j)=='B'){
        Ans--;
      }
    }
  }
  for(int64_t i=0LL; i<b; i++){
    for(int64_t j=1LL; j<=(N-B.at(i)-1)/2; j++){
      if(S.at(B.at(i)+j)=='R' && S.at(B.at(i)+2*j)=='G'){
        Ans--;
      }
      if(S.at(B.at(i)+j)=='G' && S.at(B.at(i)+2*j)=='R'){
        Ans--;
      }
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 3716
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string s[11111],t;
int n;

int F(string a,string b){
	bool ok[2]={0,0};
	for(int i=0;i<a.size();i++){
		if(i==b.size()){ok[0]=1;break;}
		if(a[i]=='?')if('z'>b[i]){ok[0]=1;break;}
		if(a[i]>b[i]){ok[0]=1;break;}
		if(a[i]<b[i])break;
	}//大きい可能性

	for(int i=0;i<a.size();i++){
		if(i==b.size()){break;}
		if(a[i]=='?')if('a'<b[i]){ok[1]=1;break;}
		if(a[i]<b[i]){ok[1]=1;break;}
		if(a[i]>b[i])break;
		if(i==a.size()-1&&b.size()>a.size()){ok[1]=1;break;}
	}//小さい可能性

	if(ok[0]&&ok[1])return 2;
	if(!ok[0]&&ok[1])return 1;
	if(ok[0]&&!ok[1])return 0;
	return 2;
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>s[i];
	cin>>t;
	int a=0,b=0,c;
	for(int i=0;i<n;i++){
		c=F(s[i],t);
		if(c==1)a++;
		if(c==2)b++;
	}
	bool f=0;
	for(int i=a;i<=a+b;i++){
		if(f)cout<<" ";
		f=1;
		cout<<i+1;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 896
# -*- coding: utf-8 -*-
"""
C - 次のアルファベット / Next Letter
https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_c

"""
import sys

from string import ascii_lowercase

def solve(s, K):
    ans = []
    lut = 'a' + ascii_lowercase[::-1]
    for ch in s:
        distance = lut.index(ch)
        if distance <= K:
            K -= distance
            ans.append('a')
        else:
            ans.append(ch)
    ans[-1] = ascii_lowercase[(ord(ans[-1]) - ord('a') + K) % 26]
    return ''.join(ans)


def main(args):
    s = input()
    K = int(input())
    ans = solve(s, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

ll sum[100100];

signed main() {

    int n, m;

    cin >> n >> m;

    vector<int> x(n), y(m);

    for(auto&&i:x) cin >> i;
    for(auto&&i:y) cin >> i;
    
    for(int i = 1; i < n; i++) 
        sum[i] = sum[i - 1] + x[i] - x[0];
    
    ll sumx = sum[n - 1];

    for(int i = 1; i < n-1; i++) 
        sumx += sum[n - 1] -= (x[i] - x[i - 1]) * (n - i);

    sumx %= SMOD;
    
    for(int i = 1; i < m; i++)
        sum[i] = sum[i - 1] + y[i] - y[0];
    
    sum[m - 1] %= SMOD;
    ll ans = 0;
    
    for(int i = 1; i < m; i++) {
        ans += sum[m - 1] * sumx % SMOD;
        ans %= SMOD;
        sum[m - 1] = (SMOD + sum[m - 1] - (y[i] - y[i - 1]) * (m - i) % SMOD) % SMOD;
    }

    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main() {
  ll n;
  cin >> n;
  ll ans=0;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    ans += a[i];
  }
  sort(a.begin(),a.end());
  if(ans%10==0) {
    for(ll i=0;i<n;i++) {
      if(a[i]%10) {
        ans-=a[i];
        break;
      }
    }
  }
  if(ans%10==0) {
    ans=0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  int N;
  cin >> N;
  map<int, int> col;
  col[N] = 1;
  int fn = N;
  for(int i = 2; i < 100000; i++){
    if(fn % 2 == 0) fn = fn / 2;
    else fn = 3 * fn + 1;
    
    if (col.count(fn)) {
      cout << i << endl;
      break;
    }
    else col[fn] = i ;
  }
  
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int ans=b+MIN(c,a+b+1);
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int A, B, C, i = 0;
    cin >> A >> B >> C;
    while (A != B || B != C || C != A) {
        if (max({A, B, C}) - min({A, B, C}) >= 2) {
            if (min({A, B, C}) == A) {
                A += 2;
                i++;
                continue;
            }
            if (min({A, B, C}) == B) {
                B += 2;
                i++;
                continue;
            }
            if (min({A, B, C}) == C) {
                C += 2;
                i++;
                continue;
            }
        }
        if (A == B){
            A++;
            B++;
            i++;
            continue;
        }
        if (C == B){
            C++;
            B++;
            i++;
            continue;
        }
        if (A == C){
            A++;
            C++;
            i++;
            continue;
        }
    }
    cout << i << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD (int)1e9 + 7
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dx[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] = { 0, 0, 1, -1, 1, -1, 1, -1 };

ll a, b, c, k, ans;

int main() {
	cin >> a >> b >> c >> k;
	ans += min(a, k);
	k -= min(a, k);
	k -= min(b, k);
	ans -= min(c, k);
	cout << ans;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int D, C;
int d[32][32];
int c[502][502];


int main(){
  cin >> C >> D;
  rep(i, 1, D + 1){
    rep(j, 1, D + 1){
      cin >> d[i][j];
    }
  }
  rep(i, 1, C + 1){
    rep(j, 1, C + 1){
      int x;
      cin >> x;
      c[(i + j) % 3][x]++;
    }
  }
  int ans = mod;
  rep(i, 1, D + 1){
    rep(j, 1, D + 1){
      if(i == j){continue;}
      rep(k, 1, D + 1){
        if(k == i || k == j){continue;}
        int count = 0;
        REP(l, D + 1){
          count += d[l][i] * c[0][l] + d[l][j] * c[1][l] + d[l][k] * c[2][l];
        }
        ans = min(ans, count);
      }
    }
  }
  print(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) ans++;
  }

  cout << ans << '\n';
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    lld N;
    string S = "";
    cin >> N;
    lld num = 26;
    lld now = 26;
    while(N > 0){
        N--;
        lld d = N % 26;
        N /= 26;
        S += 'a' + d;
    }
    reverse(S.begin(),S.end());
    cout << S << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

vector<int> x;

int main(int, char**)
{
	ll a, b, c, ans = 0;
	cin >> a >> b >> c;

	if (a > b) {
		if (c > b && a > c)
			cout << "Yes" << endl;
		else 
			cout << "No" << endl;
	} else {
		if (b > c && c > a)
			cout << "Yes" << endl;
		else 
			cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = Math.max(a + b, Math.max(a - b, a * b));
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
#include <unistd.h>

char ibuf[(11<<18)+5];
char *ibufe = ibuf-1;

extern inline void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

int read_uint(){
  int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');

  return x;
}

char buf[40];
char *bufe = buf;

void write_uintln(int x){
  int i;
  static char tmp[13];
  if(x==0){
    *bufe++ = '0';
    *bufe++ = '\n';
    return;
  }

  for(i=0; x; i++){
    tmp[i] = '0' + x % 10;
    x /= 10;
  }
  for(i--; i >= 0; i--){
    *bufe++ = tmp[i];
  }
  *bufe++ = '\n';
}

extern inline void writeall(){
  int k, t = 0;
  while((k=write(STDOUT_FILENO, buf+t, bufe-buf-t))>0) t += k;
}


#define MAX(x, y) ((x) > (y) ? (x) : (y))

int n;
int A[1<<18];
int B[1<<18];

void zeta(int n){
  int i, j;
  int m = 1 << n;
  for(i=1;i<m;i<<=1){
    for(j=0;j<m;j++){
      if(j&i){
        int max = MAX(A[j], A[j^i]);
        B[j] = MAX(MAX(max^A[j]^A[j^i], B[j]), B[j^i]);
        A[j] = max;
      }
    }
  }
}


int main(){
  int i, max;
  readall();
  n = read_uint();
  for(i=0;i<(1<<n);i++){
    A[i] = read_uint();
  }
  zeta(n);
  max = 0;
  for(i=1;i<(1<<n);i++){
    max = MAX(max, A[i]+B[i]);
    write_uintln(max);
  }
  writeall();
  return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()


using namespace std;

const ll N = 4e5;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;

string a;
bool x[N];

int main() {
    speed;
    cin >> a;
    for(auto u : a) {
    	x[u] = 1;
	}
	if((x['N'] == x['S']) && (x['W'] == x['E']))
		cout << "Yes\n";
	else
		cout << "No\n";
}

/*
*/



Measured memory_bytes: 3612
N = int(input())
L = list(map(int,input().split()))

SUM = sum(L)

partSUM = 0

diff = [float("inf")] * N

for i in range(0,N):
	partSUM += L[i]
	diff[i] = abs((2 * partSUM)- SUM)

min = min(diff)

print(min)

Measured memory_bytes: 3064