akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(i, a) for(auto& i: a)
// #define int long long
using namespace std;
using ll = long long;

// GLOBAL VARS START
const int INF = INT_MAX >> 2;


// GLOBAL VARS END

void solve() {
    unordered_set<int> seen;
    int n;
    cin >> n;
    vector<int> v(n);

    trav(i, v) cin >> i;
    sort(all(v));
    int ans = 0;
    int maxNum = v.back();
    rep(i, 0, n) {
        int dem = v[i];
        dem = min(dem, maxNum - dem);
        ans = max(dem, ans);
    }
    rep(i, 0, n) {
        int dem = v[i];
        if (dem == ans) {
            swap(dem, maxNum);
            cout << dem << " " << maxNum;
            return;
        } else if (dem == maxNum - ans) {
            swap(dem, maxNum);
            cout << dem << " " << maxNum;
            return;
        }
    }
}

int main() {
    int t = 1;
//    cin >> t;
    while (t--) solve();
    return 0;
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n;
ll a[MAXN];
pair<ll, ll> L[MAXN], R[MAXN];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

void solve() {
    int l = 0;
    ll lsum = a[0];
    ll rsum = 0;

    for (int i = 1; i < n; ++i) {
        rsum += a[i];

        while (true) {
            if (l + 1 < i && abs(lsum + a[l + 1] - (rsum - a[l + 1])) <= abs(lsum - rsum)) {
                ++l;
                lsum += a[l];
                rsum -= a[l];
            } else {
                break;
            }
        }

        L[i] = {lsum, rsum};
    }

    l = n - 1;
    lsum = 0;
    rsum = a[n - 1];

    for (int i = n - 2; i >= 0; --i) {
        lsum += a[i];

        while (true) {
            if (l - 1 > i && abs(lsum - a[l - 1] - (rsum + a[l - 1])) <= abs(lsum - rsum)) {
                --l;
                lsum -= a[l];
                rsum += a[l];
            } else {
                break;
            }
        }

        R[i] = {lsum, rsum};
    }

    ll ans = INF * INF;

    for (int i = 1; i < n - 2; ++i)
        ans = min(ans, max({L[i].f, L[i].s, R[i + 1].f, R[i + 1].s}) - min({L[i].f, L[i].s, R[i + 1].f, R[i + 1].s}));

    for (int i = 1; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
            for (int k = j + 1; k < n; ++k) {
                int A = accumulate(a, a + i, 0ll);
                int B = accumulate(a + i, a + j, 0ll);
                int C = accumulate(a + j, a + k, 0ll);
                int D = accumulate(a + k, a + n, 0ll);

                if (max({A, B, C, D}) - min({A, B, C, D}) == 36) {
                    dbg(A, B, C, D);
                }
            }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 14592
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
	chutiyaap;
	ll x,a;cin>>x>>a;
	if(x<a)cout<<"0";
	else cout<<"10";
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int N;
    cin >> N;

    vector<vector<int>> G(N);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> color(N, -1);
    color[0] = 0, color[N - 1] = 1;

    queue<int> q;
    q.push(0);
    q.push(N - 1);

    int cnt[] = {0, 0};
    while (!q.empty()) {
        int n = q.front(); q.pop();
        cnt[ color[n] ]++;
        for (int i : G[n]) {
            if (color[i] == -1) {
                color[i] = color[n];
                q.push(i);
            }
        }
    }

    if (cnt[0] > cnt[1]) {
        puts("Fennec");
    } else {
        puts("Snuke");
    }
}

Measured memory_bytes: 6144
#include <iostream>
#include <cmath>
using namespace std;
long long n;
int main() {
	cin>>n;
	for (long long i=sqrt(n); i>=1; i--) {
		if (n%i==0) {
			cout<<i+(n/i)-2<<endl;
			return 0;
		}
	}

}

Measured memory_bytes: 256
/*
 ============================================================================
 Name        : AOJ1.c
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
	int a,b;
	while(scanf("%d",&a)!=EOF){
		scanf("%d",&b);
		printf("%d\n",(int)log10(a+b)+1);
	}


	return 0;
}

Measured memory_bytes: 644
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll K; cin >> K;
    // if(K == 2) return -1;
    
    ll T = 0;
    for(int i = 1; i <= 10000000;i++){
        T = 10*T + 7;
        
        T %= K;
        if(T == 0) return i;
    }
    return -1;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<long long>;
using ld = long double;

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MaxN = 512;

ll rgt_cost[MaxN][MaxN], lft_cost[MaxN][MaxN];
ll rgt_pref[MaxN][MaxN], lft_pref[MaxN][MaxN];
int n;

void MakePref(ll src[MaxN][MaxN], ll dest[MaxN][MaxN]) {
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      dest[i][j] = dest[i-1][j] + dest[i][j-1] - dest[i-1][j-1] + src[i-1][j-1];
      debug(i, j, dest[i][j]);
    }
  }
}

ll GetRect(ll pref[MaxN][MaxN], int x1, int x2, int y1, int y2) {
  ll ans = pref[x2][y2] - pref[x1][y2] - pref[x2][y1] + pref[x1][y1];
  debug(x1, x2, y1, y2, pref[x2][y2], pref[x1][y2], pref[x2][y1], ans);
  return ans;
}

ll dp[MaxN][MaxN];

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  cin >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) { continue; }
      if (i < j) {
        cin >> rgt_cost[i][j];
      } else {
        cin >> lft_cost[i][j];
      }
    }
  }

  MakePref(rgt_cost, rgt_pref);
  MakePref(lft_cost, lft_pref);

  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      dp[i][j] = 1e18;
    }
  }

  for (int r = 0; r < n; ++r) {
    dp[0][r] = GetRect(rgt_pref, 0, r, 0, r);
    debug(r, dp[0][r]);
  }

  ll ans = 1e18;

  for (int L = 0; L < n; ++L) {
    mini(ans, dp[L][n]);
    for (int R = L + 1; R < n; ++R) {
      for (int nxt = R + 1; nxt <= n; ++nxt) {
        ll cand = dp[L][R];
        cand += GetRect(rgt_pref, R, nxt, R, nxt);
        cand += GetRect(lft_pref, R, nxt, 0, L);
        mini(dp[R][nxt], cand);
      }
    }
  }

  cout << ans << "\n";
}



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

int main()
{
	int n, i, a;
	double b, c;
	map<double, int> m;
	map<double, int>::iterator it;
	while (cin>>n, n) {
		m.clear();
		for (i = 0; i < n; i++) {
			cin>>a>>b>>c;
			c = 22.0 - (10000.0*c/b/b);
			if (c<0) c *= -1;
			if (m.count(c)) {
				if (m[c] > a) m[c] = a;
			}
			else m[c] = a;
		}
		cout<<(*m.begin()).second<<endl;
	}
	return 0;
}

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


typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;


#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define asd cout << "ok" << endl;


#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(it, m) for(auto it = m.begin(); it!= m.end(); it++)

const int MOD = 1e9 + 7;
const ll INF = 1e19;
const ld PI = acos((ld)-1);
const int MX = 2e5 +5;
const char nl = '\n';


int main(){

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int r, c; cin >> r >> c;
  char a[r][c];
  bool row[r+1] = {}, col[c+3] = {};
  for(int i = 0; i < r; i++){
    for(int j = 0; j < c; j++){
      cin >> a[i][j];
      if(a[i][j] == '#'){
        row[i] = true;
        col[j] = true;
      }
    }
  }
  for(int i = 0; i < r; i++){
    bool ok = 0;
    for(int j = 0; j < c; j++){
      if(row[i] && col[j]){
        cout << a[i][j];
        ok= 1;
      }
    }

    if(ok)
      cout << nl;
  }





  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long int ll;
#define pb push_back
#define F first
#define S second
#define mkp make_pair
#define pow2(i) (1 << (i))
#define modi(a,b) ((a%b+b)%b)
#define uni(a,b) (((a+b)*(a+b+1)/2)+b)
const int MAXN=1e9+7;
ll int_pow(ll base, ll exp){
	ll result=1;
	while (exp){
		if (exp & 1)
		   result *= base;
		exp/=2;
		base*=base;
	}
	return result;
}
int main() {
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  ll q,h,s,d,n;cin >> q >> h >> s >> d >> n;
  s = min(4*q,min(2*h,min(2*q+h,s)));
  cout << min(n*s,(n/2)*d+(n%2)*s);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX = 10005;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;

int main()
{
    int n;
    cin >> n;
    int ans = 1;
    int ma = 0;
    for(int i = 1; i <= n; ++i)
    {
        int t = i;
        int now = 0;
        while(t%2 == 0)
        {
            now++;
            t /= 2;
        }
        if(now > ma) ma = now, ans = i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<deque>
#include<ctype.h>
#include<map>
#include<set>
#include<stack>
#include<string>
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MAX=1e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
#define gcd(a,b) __gcd(a,b)
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll qpow(ll a,ll b){ll r=1,t=a; while(b){if(b&1)r=(r*t)%mod;b>>=1;t=(t*t)%mod;}return r;}
inline ll inv1(ll b){return qpow(b,mod-2);}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll r=exgcd(b,a%b,y,x);y-=(a/b)*x;return r;}
inline ll read(){ll x=0,f=1;char c=getchar();for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;for(;isdigit(c);c=getchar()) x=x*10+c-'0';return x*f;}
//freopen( "in.txt" , "r" , stdin );
//freopen( "data.txt" , "w" , stdout );



char s[100005];
int vis[30]={0},sum;
int main()
{
    int len,i,j;
    scanf("%s",s+1);
    len=strlen(s+1);
    if(s[1]==s[len])
    {
        if((len-2)%2)
            printf("Second\n");
        else
            printf("First\n");
    }
    else
    {
        if((len-2)%2)
            printf("First\n");
        else
            printf("Second\n");
    }
    return 0;
}



Measured memory_bytes: 384
N = int(input())
list_V = list(map(int,input().split()))
list_C = list(map(int,input().split()))
i = 0
ans = 0
while i < N:
    value = list_V[i] - list_C[i]
    if value > 0:
        ans += value
    i += 1
print (ans)

Measured memory_bytes: 3060
import itertools

def check(queen):
    for r1, c1 in queen:
        if not all((r1 == r2 and c1 == c2) or (r1 + c1 != r2 + c2 and r1 - c1 != r2 - c2) for r2, c2 in queen):
            return False
    return True

k = int(input())
R, C = [[i for i in range(8)] for _ in range(2)]
q = []
for _ in range(k):
    r, c = map(int, input().split())
    q.append((r, c))
    R.remove(r)
    C.remove(c)

for l in itertools.permutations(C):
    q_tmp = q[:] + list(zip(R, l))
    if check(q_tmp):
        for i, j in sorted(q_tmp):
            print("." * j + "Q" + "." * (8 - j - 1))
        break


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

typedef long long ll;
typedef unsigned long long ull;

#define int long long
#define endl "\n"
#define all(x) x.begin(), x.end()
#define deb(x) cout << #x << " --> " << (x) << endl
#define pb push_back
#define mod 1000000007  // 1e9 + 7
#define prec(x, y) fixed << setprecision(y) << x
#define print(v)                       \
    for (auto x : v) cout << x << " "; \
    cout << endl

int costCalc(int n, int *h, int *dp, int i) {
    if (i >= n) return 0;

    int cost = min(
        abs(h[i + 1] - h[i]) + costCalc(n, h, dp, i + 1),
        abs(h[i + 2] - h[i]) + costCalc(n, h, dp, i + 2));
    return 0;
}

int s(int i, int *h, int n, int *dp) {
    if (i == n) return 0;
    if (dp[i] != -1) {
        return dp[i];
    }
    int op1 = INT_MAX, op2 = INT_MAX;
    if (i + 1 <= n) op1 = abs(h[i + 1] - h[i]) + s(i + 1, h, n, dp);
    if (i + 2 <= n) op2 = abs(h[i + 2] - h[i]) + s(i + 2, h, n, dp);

    return dp[i] = min(op1, op2);
}

void solve() {
    int i, j, n, k;
    cin >> n;
    int h[n + 1];
    for (i = 1; i <= n; ++i) cin >> h[i];
    int dp[n + 1];
    memset(dp, -1, sizeof(dp));
    cout << s(1, h, n, dp) << endl;
}

//Fuck Ratings
//Once a Charas always a Charas

int32_t main() {

    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int _t = 1;

    // cin >> _t;
    while (_t--)
        solve();
}

Measured memory_bytes: 12972
#include <iostream>
#include <algorithm>
using namespace std;
long long  i,nr,n,k,a,v[200001],s;
int main()
{
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
        cin>>a;
        v[a]++;
        if(v[a]==1)
        {
            nr++;
        }
    }
    sort(v+1,v+n+1);
    if(nr<=k)
    {
        cout<<0<<'\n';
    }
    else
    {
        i=n-k;
        while(v[i]>0 && i>0)
        {
            s=s+v[i];
            i--;
        }
        cout<<s<<'\n';
    }
    return 0;
}


Measured memory_bytes: 1792
#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 sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll h, n;
    cin >> h >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll sum = accumulate(all(a), 0LL);
    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1024
/*  ex3_4 81
    pandacodeb  */

#include <stdio.h>

int main(void){
    int num;
    scanf("%d", &num);
    //if it is more than 9x9 -> No
    if (num > 81)
        printf("No\n");

    //if it is a digit (0~9) -> Yes
    else if (num < 10)
        printf("Yes\n");

    //if it is between 10~80    
    else{
        //try divide num with 2,3,...,9
        for (int digit = 2; digit < 10; digit++){
            //if there is any divisible digit and its quotient < 10 -> Yes
            if (num%digit == 0 && num/digit < 10){
                printf("Yes\n");
                break;
            }
            //if no divisible digit at all -> No
            if (digit == 9)
                printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std ;
#define int long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e6+7 ;
string s ;

int32_t main(){fast ;
	int n ,k ;
	vector<int> a(5) ;
	cin >> n ;
	F(i,0,5)
		cin >> a[i] ;
	int mx = -1 ;
	F(i,0,5){
		int x = ceil((n-1)/a[i]) ;
		mx = max(mx,x) ;
	}
	cout << mx + 5 << endl ;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) { cin >> A[i]; }
    ll s = accumulate(A.begin(), A.end(), 0LL);
    //とりあえず強引に分割してしまう
    int index = 0;
    ll sum = 0;
    while(sum < s / 2) {
        sum += A[index];
        index++;
    }
    //とりあえず右を増やす
    ll a = 2 * sum - s;
    //とりあえず左を増やす
    sum -= A[index - 1];
    ll b = s - 2 * sum;
    cout << min(a, b) << endl;
    return 0;
}

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

void doAction(int n, string id[], string str){
	static int status = 0,i;
	for(i=0;i<n;i++){
		if(!id[i].compare(str)){
			status = !status;
			if(status) cout<<"Opened by " << str << endl;
			else cout << "Closed by " << str << endl;
			break;
		}
	}
	if(i==n) cout<< "Unknown " << str <<endl;
}

int main(){
	int n,m;
	string id[256],str;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> id[i];
	}
	cin >> m;
	for(int i=0;i<m;i++){
		cin >> str;
		doAction(n,id,str);
	}
}

Measured memory_bytes: 1220
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, Q;
  cin>>N>>Q;
  string S;
  cin>>S;
  int arr[N+1];
  for(int i=0;i<N+1;++i) arr[i] = 0;
  for(int i=1;i<N;++i){
    if(S[i-1]=='A' && S[i]=='C'){
      arr[i+1] = 1;
    }
  }
  for(int i=1;i<=N;++i){
    arr[i] += arr[i-1];
  }
  int l, r;
  int ans[Q];
  for(int i=0;i<Q;++i){
    cin>>l>>r;
    ans[i] = arr[r] - arr[l];
  }
  for(int i=0;i<Q;++i){
    cout<<ans[i]<<endl;
  }
}



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

bool LinnerSearch(int vect[], int num, int target)
{
    int left  = 0;
    int right = num;
    int mid;

    while (left < right) {
        mid = (left + right) / 2;
        if (vect[mid] == target) {
            break;
        }
        else if (target < vect[mid]) {
            right = mid;
        }
        else {
            left  = mid + 1;
        }
    }

    return (left != right);
}

int main(void)
{
    int i;
    int num1, num2;
    int vect[100000];
    int target;
    int cnt = 0;

    scanf("%d", &num1);
    for (i = 0; i < num1; i++) {
        scanf("%d", &vect[i]);
    }

    scanf("%d", &num2);
    for (; num2 > 0; num2--) {
        scanf("%d", &target);
        if (LinnerSearch(vect, num1, target) == true) {
            ++cnt;
        }
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 1576
#include <stdio.h>
#include <math.h>

int main(void) {
   
   int N,K;
   
   scanf("%d%d",&N,&K);

   int i;
   double p = 0;
   double temp;
   
   for (i = 1; i <= N; i++) {
      if (i >= K) {
         p = p + 1;
      }
      else {
         temp = ceil(log2((double)K/i));
         p = p + pow(0.5,temp);
      }
   }
   p = p/N;
   
   printf("%.15lf\n",p);
   
   return 0;
}




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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll k; cin >> k;
	string s; cin >> s;

	if (sz(s) <= k) cout << s << endl;
	else cout << s.substr(0,k) << "..." << endl;

}



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

int fabs( int a )
{
    return a > 0 ? a : -a;
}

int min( int a, int b )
{
    return a < b ? a : b;
}

//全探索
void roadSearched( int* a, int x, int y, int cost, int& min )
{
    if( x == y )
    {
        if( cost < min )
            min = cost;
        return;
    }
    
    roadSearched( a, x + 1, y, fabs( a[x] - a[x+1] ) + cost, min );
    if( x + 2 <= y )
        roadSearched( a, x + 2, y, fabs( a[x] - a[x+2] ) + cost, min );
}

//これが動的計画法か！？
int memo[100000];
int calcMin( int* a, int n )
{
    for( int i = 2; i < n; i++ )
        memo[i] = min( memo[i-2] + fabs( a[i-2] - a[i] ), memo[i-1] + fabs( a[i-1] - a[i] ) );
}

int main()
{
    int n, min = 10000;

    cin >> n;

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

    // roadSearched( a, 0, n - 1, 0, min );
    // cout << min << endl;


    memo[1] = fabs(a[0]-a[1]);
    calcMin( a, n );

    cout << memo[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include <math.h>  


using namespace std;


int main()
{

	int N, tmp, ans;

	cin >> N;
	tmp = 1;
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		if (n % 2 == 0) tmp *= 2;
	}
	cout << pow(3, N) - tmp << endl;
	
	return 0;
}




Measured memory_bytes: 256
n,m = map(int,input().split())
a = list(map(int,input().split()))
p = 0
q = 0
for i in range(n):
    p += a[i]
for i in range(n):
    if(a[i] >= p/(4*m)):
        q += 1
if(q >= m):
    print("Yes")
else:
    print("No")

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

vector<vector<int>> dp(100005, vector<int>(4,-1));

int rec(int day, int type, vector<vector<int>>& a)
{
    int n = a.size();
    if(day == n) return 0;

    if(dp[day][type] != -1) return dp[day][type];

    int points = 0;

    if(type == 3)
    {
        points = max( points, rec(day+1, 0, a) + a[day][0]);
        points = max( points, rec(day+1, 1, a) + a[day][1]);
        points = max( points, rec(day+1, 2, a) + a[day][2]);
    }

    if(type == 0)
    {
        points = max( rec(day+1, 1, a) + a[day][1], rec(day+1, 2, a) + a[day][2] );
    }
    else if(type == 1)
    {
        points = max( rec(day+1, 0, a) + a[day][0], rec(day+1, 2, a) + a[day][2] );
    }
    else if(type == 2)
    {
        points = max( rec(day+1, 1, a) + a[day][1], rec(day+1, 0, a) + a[day][0] );
    }

    return dp[day][type] = points;
}

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> act(N, vector<int>(3));
    for(int i = 0 ; i < N ; i++)
    for(int j = 0 ; j < 3 ; j++)
       cin >> act[i][j];

    cout << rec(0,3,act);
}





Measured memory_bytes: 20036
using System;
using System.Linq;

namespace _057
{
    class Program
    {
        static void Main(string[] args)
        {
            // A - Remaining Time
            var line = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
            var a = line[0];
            var b = line[1];

            Console.WriteLine(a + b < 24 ? a + b : a + b - 24);
        }
    }
}


Measured memory_bytes: 13396
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;

  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

  #define ff first
  #define ss second
  #define pb push_back
  #define pf push_front
  #define mp make_pair
  #define in insert
  #define ld long double


  #define TRACE
  #ifdef TRACE
  #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
  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...);
  }
  #else
  #define trace(...) 1
  #endif
  template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
  template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}

  typedef long long int ll;

  typedef vector<int> vi;
  typedef vector<ll> vl;
  typedef vector<vi> vvi;
  typedef vector<vl> vvl;
  typedef pair<int,int> pii;
  typedef pair<ll,ll> pll;
  typedef vector<pii> vpii;
  typedef vector<pll> vpll;
  const ll mod =1e9+7;
  const ll MAX_NODES =200001;
  const ll MAX_LOG =50;
  const ll maxn = 200000+10;
  #define endl '\n'
  ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
      if (n & 1) res = (res * x) % mod;
      x = (x * x) % mod;
      }
      return res;
  }


  int main()
  {

  IOS
  ll n;
  cin>>n;
  ll a[n];
  ll sum=0;
  for(ll i=0;i<n;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  sum/=n;
  ll ans=0,ans1 = 0;
  ll sum1 = sum+1;
  for(ll i=0;i<n;i++)
  {
    ans+=(a[i]-sum)*(a[i]-sum);
    ans1+=(a[i]-sum1)*(a[i]-sum1);
  }
  cout<<min(ans,ans1)<<endl;


  

  
  

}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

using namespace std;
int N;
string S;



int main(){
	cin >> N;
	for(int iii=0;iii<N;iii++){
		cin >> S;
		set<string> st;
		for(int i=0;i<S.size();i++){
			string s1 = S.substr(0,i+1);
			string s2 = S.substr(i+1,S.size());
			string s11 = s1;
			reverse(s11.begin(),s11.end());
			string s22 = s2;
			reverse(s22.begin(),s22.end());
			st.insert(s1+s2);
			st.insert(s11+s2);
			st.insert(s11+s22);
			st.insert(s1+s22);
			st.insert(s2+s1);
			st.insert(s22+s1);
			st.insert(s22+s11);
			st.insert(s2+s11);			
		}
		cout << st.size() << endl;
	}
	return 0;
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

	string S;
	cin >> S;

	vector<vector<int>> Oc(27);

	for(int i = 0; i < S.size(); i++){
		Oc[S[i] - 'a'].pb(i);
	}

	bool can = 0;

	for(int i = 0; i < 27; i++){
		for(int l = 0; l < Oc[i].size(); l++){
			for(int r = l + 1; r < Oc[i].size(); r++){
				if(r - l + 1 > (Oc[i][r] - Oc[i][l] + 1)/2){
					can = 1;
					cout << Oc[i][l] + 1 << " " << Oc[i][r] + 1 << endl;
				}
				if(can) break;
			}
			if(can) break;
		}
		if(can) break;
	}

	if(!can){
		cout << -1 << " " << -1 << endl;
	}

	return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;
    if(a>b)cout << a-1 << endl;
    else cout << a << endl;
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
k=int(input())
while k>0:
  if not b>a:
    b*=2
    k-=1
  elif not c>b:
    c*=2
    k-=1
  else:
    break

if c>b and b>a:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 61572
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cctype>
#define int long long
#define rg register
using namespace std;
inline int read(){
	rg int s=0,f=0;
	rg char ch=getchar();
	while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
	while(isdigit(ch)) s=(s<<1)+(s<<3)+(ch^48),ch=getchar();
	return f?-s:s;
}
int n,cnt,ans,top,num;
const int MAX=1000015;
struct edge{
	int nxt;
	int to;
}e[MAX];
int head[MAX],a[1015][1015],mp[1015][1015],s[MAX],val[MAX],in[MAX];
void add(int u,int v){
	e[++cnt].nxt=head[u];
	e[cnt].to=v;
	head[u]=cnt;
}
void topo(){
	for(rg int i=1;i<=top;i=-~i){
		int u=s[i];
		for(rg int j=head[u];j;j=e[j].nxt){
			int v=e[j].to;
			val[v]=val[u]+1;
			--in[v];
			if(!in[v]) s[++top]=v;
		}
	}
	for(rg int i=1;i<=num;i=-~i) ans=max(ans,val[i]);
}
signed main(){
	n=read();
	for(rg int i=1;i<=n;i=-~i){
		for(rg int j=1;j<n;j=-~j){
			a[i][j]=read();
			if(!mp[i][j] and !mp[j][i]) mp[i][j]=mp[j][i]=++num;
		}
	}
	for(rg int i=1;i<=n;i=-~i){
		for(rg int j=2;j<n;j=-~j){
			add(mp[i][a[i][j-1]],mp[i][a[i][j]]);
			++in[mp[i][a[i][j]]];
		}
	}
	for(rg int i=1;i<=num;i=-~i){
		if(!in[i]){
			s[++top]=i;
			val[i]=1;
		}
	}
	topo();
	if(top!=num) printf("-1");
	else printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 55040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

//　最大値注意!!
const int MAX_N = 100001;

//　選べる仕事の中で、終了時間が最も小さいものを選ぶことを繰り返す.

int main(){
    ll n, time = 0;
    cin >> n;
    vector<ll> x(n), l(n);
    vector<ll> s(n), t(n);
    rep(i, n) cin >> x[i] >> l[i];
    rep(i, n){
        s.at(i) = x.at(i) - l.at(i);
        t.at(i) = x.at(i) + l.at(i);
    }
    pair<ll, ll> itv[n];

    // pairは辞書順で比較される。
    //　終了時間が早い順にしたいため、Tをfirstに、Sをsecondに入れる。
    rep(i, n) {
        itv[i].first = t[i];
        itv[i].second = s[i];
    }
    sort(itv, itv+n);

    // timeは最後に選んだ仕事の終了時間
    ll answer = 0;
    time = -1000000000;
    rep(i, n) {
        if(time <= itv[i].second) {
            answer++;
            time = itv[i].first;
        }
    }

    cout << answer << endl;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(begin(h), end(h));
  ll ans = 0;
  rep(i, n - k) ans += h[i];
  cout << ans << endl;
}


Measured memory_bytes: 1024
def main():
    n, m = map(int, input().split())
    a = set(map(int, input().split()))

    # type(x) == type(y) == string
    def bigger(x, y):
        if len(x) > len(y):
            return x
        elif len(x) < len(y):
            return y
        elif x < y:
            return y
        else:
            return x

    l = []
    if 1 in a:
        l.append((2, '1'))

    if 7 in a:
        l.append((3, '7'))

    if 4 in a:
        l.append((4, '4'))

    if 5 in a:
        l.append((5, '5'))
    elif 3 in a:
        l.append((5, '3'))
    elif 2 in a:
        l.append((5, '2'))

    if 9 in a:
        l.append((6, '9'))
    elif 6 in a:
        l.append((6, '6'))

    if 8 in a:
        l.append((7, '8'))

    dp = [None] * (n+1)
    dp[0] = ''
    for i in range(1, n+1):
        for cost, char in l:
            if i - cost < 0 or dp[i-cost] is None:
                continue
            candidate = max(dp[i-cost] + char, char + dp[i-cost])
            if dp[i] is None:
                dp[i] = candidate
            else:
                dp[i] = bigger(dp[i], candidate)

    print(dp[n])

main()

Measured memory_bytes: 36304
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <iomanip>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(W,H);
    Cinii(X,Y);
    int c = 0;
    if(W==X*2 && H==Y*2){
        c = 1;
    }
    cout << std::setprecision(9) <<  (double)W * (double)H / 2.0;
    cout << " ";
    cout << c << nn;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 

  string s, t;
  cin >> s >> t;

  sort(begin(s), end(s));
  sort(begin(t), end(t), greater<int>());

  if (s < t) cout << "Yes" << "\n";
  else cout << "No" << "\n";
}


Measured memory_bytes: 3636
import java.util.*;

class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int k=sc.nextInt();
		int n=sc.nextInt();
		int ans=0;
		int[] an=new int[n+1];
		
		for(int i=0;i<n;i++){
			an[i]=sc.nextInt();
		}
		an[n]=an[0]+k;
		for(int i=0;i<n;i++){
			ans=Math.max(ans,an[i+1]-an[i]);
		}
		int aa=k-ans;
		System.out.println(aa);
	}
}

Measured memory_bytes: 65592
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int get_abs(int x);

int main(){
    int n, m;
    cin >> n >> m;
    vector<string> picA;
    for(int i = 0; i < n; i++){
        string a;
        cin >> a;
        picA.push_back(a);
    }

    vector<string> picB;
    for(int i = 0; i < m; i++){
        string b;
        cin >> b;
        picB.push_back(b);
    }

    bool exist_template = false;
    for(int upper_edge = 0; upper_edge < n - m + 1; upper_edge++){
        for(int left_edge = 0; left_edge < n - m + 1; left_edge++){
            for(int i = upper_edge; i < upper_edge + m; i++){
                if(picB[i - upper_edge] == picA[i].substr(left_edge, m)){
                    if(i == upper_edge + m - 1){
                        exist_template = true;
                        goto SEARCHFIN;
                    }
                }else{
                    break;
                }
            }
        }
    }

SEARCHFIN:
    string ans = (exist_template)? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

int get_abs(int x){
    return (x > 0)? x : -x;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	cout << max(0, C - (A - B)) << endl;

	return 0;
}

Measured memory_bytes: 256
input()
c=input()
a=0
while 1:
	w=c.find('W')
	r=c.rfind('R')
	if w<0 or r<0 or r<w:break
	c=c[:w]+'R'+c[w+1:r]+'W'+c[r+1:]
	a+=1
print(a)

Measured memory_bytes: 9780
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define MAXS 100000;
#define p pair <int,int>
using namespace std;
int main(int argc,char const* argv[])
{
  string s;
  cin >> s;
  int n=s.size();
  int sec=0;
  for(int i=0;i<n-1;i++)
    {
      if(s[i] != s[i+1]) sec++;
    }
  cout << sec << endl;
  return 0;
}


Measured memory_bytes: 512
from collections import Counter

H, W = map(int,input().split())
A = ""
for _ in range(H): A += input()

a_count = Counter(A)
sym4 = [0, 0]
sym2 = [0, 0]
sym1 = [0, 0]
sym4[0] = (H//2) * (W//2)
sym2[0] = (H%2) * (W//2) + (H//2) * (W%2)
sym1[0] = (H%2) * (W%2)

for i in a_count.values():
    sym4[1] += i // 4
    sym2[1] += (i % 4) // 2
    sym1[1] += i % 2

if sym4[1] >= sym4[0]:
    sym2[1] += 2 * (sym4[1] - sym4[0])
    if sym2[1] == sym2[0]:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 3316
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		float array[] = new float[2 * n - 1];
		for (int i = 0; i < n; i++) {
			array[i] = scan.nextInt();
		}
		for (int i = 0; i < n - 1; i++) {
			Arrays.sort(array);
			array[i] = (array[n + i - 1] + array[n + i]) / 2;
			array[n+i - 1] = 0;
			array[n+i] = 0;
		}
		Arrays.sort(array);
		System.out.println(array[2 * n - 2]);
	}

}

Measured memory_bytes: 22612
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d=0;
  	cin>>a;
  cin>>b;
  cin>>c;
  if(a==b){
  	if(a!=c){
    	cout<<"Yes";
      d++;
    }
    
  }
  if(a!=b){
  	if(a==c){
    	cout<<"Yes";
      d++;
    }
    
  }
  if(c==b){
  	if(a!=c){
    	cout<<"Yes";
      d++;
    }
    
  }
  if(d==0){
    cout<<"No";
  }
  cout<<endl;
}



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

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fast_work {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

const ll INF = 1e18, NMAX = 1e6 + 5, MOD = 1000000007, N = 1e9 + 5, LOG = 25;
const ld EPS = 1e-8, pi = 3.14159265358979323846;

const int MAX_CNT = 3;
ll a[3005][3005], dp[5][3005][3005];

signed main() {
    fast_work
    int r, c, k;
    cin >> r >> c >> k;

    while(k --> 0) {
        ll r1, c1, v1;
        cin >> r1 >> c1 >> v1;
        a[r1][c1] = v1;
    }

    if(a[1][1] != 0) {
        dp[1][1][1] = a[1][1];
    }

    for(int i = 1; i <= r; ++i)
        for(int j = 1; j <= c; ++j) {
            if(i == 1 && j == 1) continue;

            if(i > 1) {
                for(int k = 0; k <= MAX_CNT; ++k) {
                    dp[0][i][j] = max(dp[0][i][j], dp[k][i - 1][j]);
                }

                if(a[i][j] != 0) {
                    for(int k = 0; k <= MAX_CNT; ++k) {
                        dp[1][i][j] = max(dp[1][i][j], dp[k][i - 1][j] + a[i][j]);
                    }
                }
            }

            if(j > 1) {
                for(int k = 0; k <= MAX_CNT; ++k) {
                    dp[k][i][j] = max(dp[k][i][j], dp[k][i][j - 1]);

                    if(k > 0 && (dp[k - 1][i][j - 1] != 0 || k == 1) && a[i][j] != 0) {
                        dp[k][i][j] = max(dp[k - 1][i][j - 1] + a[i][j], dp[k][i][j]);
                    }
                }
            }
        }

    ll answer = 0;
    for(int k = 0; k <= MAX_CNT; ++k) answer = max(answer, dp[k][r][c]);
    cout << answer;
}


Measured memory_bytes: 355680
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int a;
	cin>>a;
	string s;
	cin>>s;
	if(a<3200){
		cout<<"red"<<endl;
	}else{
		cout<<s<<endl;
	}
}


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

int main(){
  int N;
  cin >> N;
  int a[N], flag[9];

  int count = 0, max = 0, min = 0;
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  for(int i=0;i<9;i++){
    flag[i] = 0;
  }
  for(int i=0;i<N;i++){
    if(1 <= a[i] && a[i] <= 399){
      flag[0] = 1;
    }else if(400 <= a[i] && a[i] <= 799){
      flag[1] = 1;
    }else if(800 <= a[i] && a[i] <= 1199){
      flag[2] = 1;
    }else if(1200 <= a[i] && a[i] <= 1599){
      flag[3] = 1;
    }else if(1600 <= a[i] && a[i] <= 1999){
      flag[4] = 1;
    }else if(2000 <= a[i] && a[i] <= 2399){
      flag[5] = 1;
    }else if(2400 <= a[i] && a[i] <= 2799){
      flag[6] = 1;
    }else if(2800 <= a[i] && a[i] <= 3199){
      flag[7] = 1;
    }else if(a[i] >= 3200){
      flag[8] = 1;
      count += 1;
    }
  }
  for(int i=0;i<8;i++){
    if(flag[i]==1){
      min += 1;
    }
  }
  if(flag[8]==1){
    max = min + count;
  }else{
    max = min;
  }
  if(min==0){
    min = 1;
  }
  cout << min << " " << max << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace beginner_contest047_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var candy_packs = Console.ReadLine().Split(' ').Select((x, idx) => new { x = Convert.ToInt32(x), idx}).ToArray();
            var max = candy_packs.Max(x => x.x);
            var max_candy = candy_packs.First(x => x.x == max);
            if (max_candy.x == candy_packs.Where(x => x.idx != max_candy.idx).Sum(x => x.x))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            return;
        }
    }
}


Measured memory_bytes: 3416
package main

import (
	"fmt"
)

func main() {
	var n, l int
	fmt.Scan(&n, &l)
	s := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s[i])
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if s[j] > s[i] {
				s[i], s[j] = s[j], s[i]
			}
		}
	}
	for _, v := range s {
		fmt.Print(v)
	}
	fmt.Println()
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    string S,a[5]={"dream","dreamer","erase","eraser"};
    cin>>S;
    bool f=1;
    int s=S.size();
    while(f&&s>0){
        int i;
        for(i=0;i<4;i++){
            int j;
            for(j=0;j<a[i].size();j++) if(a[i][j]!=S[s-a[i].size()+j]) break;
            if(j==a[i].size()){ s-=a[i].size(); break;}
        }
        if(i==4) f=0;
    }
    if(f) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 512