akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

const int INF = 1e18;

void solve()
{
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("./sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<int> A(x), B(y), C(z);
    rep(i, x) cin >> A[i];
    rep(i, y) cin >> B[i];
    rep(i, z) cin >> C[i];

    sort(rALL(A));
    sort(rALL(B));
    sort(rALL(C));

    map<string, bool> mp;

    priority_queue<pair<int, vector<int>>> pq;
    vector<int> a(3, 0);
    mp["0+0+0"] = true;
    pq.push(make_pair(A[0] + B[0] + C[0], a));

    int cnt = 0;
    while (cnt < k)
    {
        auto now = pq.top();
        pq.pop();
        int score = now.first;
        vector<int> index = now.second;
        if (index[0] < x - 1)
        {
            vector<int> vec(3);
            vec[0] = index[0] + 1;
            vec[1] = index[1];
            vec[2] = index[2];
            string key = "";
            key += to_string(vec[0]);
            key += '+';
            key += to_string(vec[1]);
            key += '+';
            key += to_string(vec[2]);
            if (mp[key] == false)
            {
                pq.push(make_pair(A[vec[0]] + B[vec[1]] + C[vec[2]], vec));
                mp[key] = true;
            }
        }
        if (index[1] < y - 1)
        {
            vector<int> vec(3);
            vec[0] = index[0];
            vec[1] = index[1] + 1;
            vec[2] = index[2];
            string key = "";
            key += to_string(vec[0]);
            key += '+';
            key += to_string(vec[1]);
            key += '+';
            key += to_string(vec[2]);
            if (mp[key] == false)
            {
                pq.push(make_pair(A[vec[0]] + B[vec[1]] + C[vec[2]], vec));
                mp[key] = true;
            }
        }
        if (index[2] < z - 1)
        {
            vector<int> vec(3);
            vec[0] = index[0];
            vec[1] = index[1];
            vec[2] = index[2] + 1;
            string key = "";
            key += to_string(vec[0]);
            key += '+';
            key += to_string(vec[1]);
            key += '+';
            key += to_string(vec[2]);
            if (mp[key] == false)
            {
                pq.push(make_pair(A[vec[0]] + B[vec[1]] + C[vec[2]], vec));
                mp[key] = true;
            }
        }

        cnt++;
        cout << score << endl;
    }
}

signed main()
{
    solve();
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main(){
	int W, H, r, x, y;
	cin >> W >> H >>x >> y>> r;
	if (0 <= y - r&&H >= y + r && 0 <= x - r&&W >= x + r){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
A, B = map(int,input().split())
cnt = 1
ans = 0
# 口の増え方　1,1+(A-1),1+(A-1)+(A-1),・・
# B-1個に増やしたい。1は壁にある口
# ポイントは切り上げ
while cnt<B:
    cnt+=A-1
    ans+=1
else:
    print(ans)

Measured memory_bytes: 2940
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#include <bits/stdc++.h>

using namespace std;

#define BOOST 			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ALL(a) 			(a).begin(), (a).end()
#define SZ(a) 			(int)(a).size()
#define FOR(a, b, c) 	for (int a = (b); a <  (c); a++)
#define FORR(a, b, c) 	for (int a = (b); a >= (c); a--)
#define TRAV(a, b) 		for (auto& a : b)
#define ELO 			exit(0)
#define SORT(a)         sort(ALL(a))
#define REV(a)          reverse(ALL(a))
#define SORTR(a)        SORT(a), REV(a)
#define PB              push_back
using ll = 				long long;
using ld = 				long double; // 'long double' is 2.2 times slower than double
using pii = 			pair<int, int>;
using pll = 			pair<ll, ll>;
using vi = 				vector<int>;
using vll = 			vector<ll>;
using vpii = 			vector<pii>;
using vpll = 			vector<pll>;

template <class T> inline bool setmin(T& a, T b) {if (a > b) return a = b, 1; return 0; }
template <class T> inline bool setmax(T& a, T b) {if (a < b) return a = b, 1; return 0; }

namespace fastio {
    template <class T> istream &operator>>(istream &os, vector<T> & vec){for (auto &u : vec)os >> u;return os;}
    template <class T> ostream &operator<<(ostream &os, const vector<T> & vec){for (auto &u : vec)os << u << " ";return os;}
    template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) { return os >> p.first >> p.second; }
    template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << p.first << " " << p.second; }
    template <class T> ostream &operator<<(ostream &os, set<T> & con) { for (auto &u : con) os << u << " "; return os; }

    void re() {}
    template <typename T, typename... args> void re(T& x, args&... tail) { cin >> x; re(tail...); }
    void pr() {}
    template <typename T, typename... args> void pr(T x, args... tail) { cout << x << " "; pr(tail...);}
    template <typename... args> void prln(args... tail) { pr(tail...); cout << "\n";}
}
using namespace fastio;

namespace debug {
    template < typename _T > inline void _debug(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
    template < typename _T, typename... args > void _debug(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _debug(s + 1, a...); }
    
    #if 1
        #define debug(...) _debug(#__VA_ARGS__, __VA_ARGS__)
        #define cerr cout
    #else
        #define debug(...) 1999
        #define cerr if(0) cout
    #endif
}
using namespace debug;

//////////////_________CODE_________//////////////

constexpr int MOD = 1e9 + 7; // 998244353
constexpr int INF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;

int main() {
    BOOST;
    int n, l; re(n, l);
    pii res{INF, -1};
    FOR(i, 1, n + 1) {
        setmin(res, {abs(l + i - 1), i});
    }
    int sum = 0;
    FOR(i, 1, n + 1) if(i != res.second) {
        sum += l + i - 1;
    }
    prln(sum);
    ELO;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
void sw(char* line);
int A[4]={0,0,0,0};
int main(void) {
	int i;
	char str[100],*line;

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		line=strtok(str," ,\n");
		line=strtok(NULL," ,\n");
		if(strcmp("A",line)==0)
			A[0]+=1;
		if(strcmp("B",line)==0)
			A[1]+=1;
		if(strcmp("AB",line)==0)
			A[2]+=1;
		if(strcmp("O",line)==0)
			A[3]+=1;
	}
	for(i=0;i<4;i++){
		printf("%d\n",A[i]);
	}
	return 0;
}

Measured memory_bytes: 520
#include <iostream>
#include <vector>

int main()
{
  int N, M;
  std::cin >> N >> M;
  std::vector<int> L(M), R(M);

  int l_max, r_min;
  std::cin >> l_max >> r_min;
  for(int i=1; i<M; i++) {
    int l, r;
    std::cin >> l >> r;
    l_max = std::max(l, l_max);
    r_min = std::min(r, r_min);
  }
  int ret = std::max(0, r_min - l_max + 1);
  std::cout << ret << std::endl;

  return 0;
}


Measured memory_bytes: 4024
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
	int n,m;
	n=scan.nextInt();
	m=scan.nextInt();
	if(n==0 && m==0)break;
	int p[]=new int[n];
	for(int i=0;i<n;i++)
	    {
		p[i]=scan.nextInt();
	    }
	for(int i=0;i<n-1;i++)
	    {
		for(int j=n-1;j>i;j--)
		    {
			if(p[j]>p[j-1])
			    {
				int t=p[j-1];
				p[j-1]=p[j];
				p[j]=t;
			    }
		    }
	    }
	
	int sum=0;
	int j=0;
for(int i=0;i<n;i++)
	    {
		
		if(j!=m-1)
		    {
			sum+=p[i];
			j++;
		    }
		else if(j==m-1)j=0;
		
	    }
System.out.println(sum);

	    }
    }
}

Measured memory_bytes: 52508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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 COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
COMinit();
    ll n,m,k;
	cin >> n>> m>> k;
    ll ans=0;
    ll mm[n];
    ll now=1;
    fr(i,n){
     mm[i]=now;
     now*=(m-1);
     now%=MOD;
    }
    fr(i,k+1){
    	ans+=(m*mm[n-i-1]%MOD)*COM(n-1,i);
        ans%=MOD;
    }
      cout << ans << endl;
}


Measured memory_bytes: 17084
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
//本の問題と全く同じ

int main(){
  //input1
  int le;
  cin>>le;
  for(int pp=0;pp<le;pp++){
    //input2
    string x,y;
    cin>>x>>y;
    int n,m;
    n=x.size();
    m=y.size();

    int dp[1001][1001];//dp[i+1][j+1]:x[0]~x[i]とy[0]~y[j]のLCSの長さ

    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if(x[i]==y[j])dp[i+1][j+1]=dp[i][j]+1;//後ろが同じなら１加えていいよね
	else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);}}//どっちかの共通部分列のうち長い方でいいよね
    cout<<dp[n][m]<<endl;
  }
  return 0;
}



Measured memory_bytes: 7084
var
  i, o, t, j, l, a, b: int64;
begin
  read(i);
  read(o);
  read(t);
  read(j);
  read(l);
  if (i>0) and (j>0) and (l>0) then begin
    a:=(i div 2 * 2) + (j div 2 * 2) + (l div 2 * 2);
    b:=((i-1) div 2 * 2) + ((j-1) div 2 * 2) + ((l-1) div 2 * 2) + 3;
    if a<b then write(b+o) else write(a+o);
  end else begin
    write(o + (i div 2 * 2) + (j div 2 * 2) + (l div 2 * 2));
  end
end.

Measured memory_bytes: 128
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    a = [i_input() for _ in range(n)]
    a.sort()

    ans = sum(a)
    if ans % 10 != 0:
        print(ans)
        exit()

    flg = False
    for i in a:
        if i%10 != 0:
            ans -= i
            flg = True
            break
    if flg:
        print(ans)
    else:
        print(0)



if __name__=="__main__":
    main()


Measured memory_bytes: 66444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false) , cin.tie(0) ;
#define w(x) cout << (#x) << " is " << x << "\n" ;

int main()
{
    //fast ;
//#ifndef ONLINE_JUDGE
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
//#endif
    int a,b,c,k,s=0,i;
    cin >> a >> b >> c >> k ;
    s+=min(a,k);
    k-=min(a,k);
    k-=min(b,k);
    s-=min(c,k);
    cout << s <<"\n";
    return 0;
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N, M;
  cin >> N >> M;

  int ans = 0;
  for (int i = 1; i * i <= M; i++) {
    if (M % i == 0) {
      if (N <= M / i) {
        ans = max(ans, i);
      }
      if (N <= i) {
        ans = max(ans, M / i);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const ll sqrtN = 512;
struct SqrtDecomposition {
  ll N, K;
  vector<ll> data;
  vector<ll> bucketSum;
  vector<ll> lazyUpdate;
  SqrtDecomposition(ll n) : N(n) {
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, 0);
    bucketSum.assign(K, 0);
    lazyUpdate.assign(K, 1111);
  }
  void eval(ll k) {
    if (lazyUpdate[k] != 1111) {
      for (ll i = k * sqrtN; i < (k + 1) * sqrtN; ++i) {
        data[i] = lazyUpdate[k];
      }
      lazyUpdate[k] = 1111;
    }
  }
  // [s, t)
  void update(ll s, ll t, ll x) {
    for (ll k = 0; k < K; ++k) {
      ll l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= s || t <= l)
        continue;
      if (s <= l && r <= t) {
        bucketSum[k] = x * sqrtN;
        lazyUpdate[k] = x;
      } else {
        eval(k);
        for (ll i = max(s, l); i < min(t, r); ++i) {
          bucketSum[k] += x - data[i];
          data[i] = x;
        }
      }
    }
  }
  // [s, t)
  ll find(ll s, ll t) {
    ll ans = 0;
    for (ll k = 0; k < K; ++k) {
      ll l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= s || t <= l)
        continue;
      if (s <= l && r <= t) {
        ans += bucketSum[k];
      } else {
        eval(k);
        for (ll i = max(s, l); i < min(t, r); ++i) {
          ans += data[i];
        }
      }
    }
    return ans;
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, q;
  cin >> n >> q;
  SqrtDecomposition sd(n);
  FOR(i,0,q) {
    ll f;
    cin >> f;
    if(f) {
      ll s,t;
      cin >> s >> t;
      cout << sd.find(s, t+1) << endl;
    } else {
      ll s,t,x;
      cin >> s >> t >> x;
      sd.update(s,t+1,x);
    }
  }
}


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

using CP = complex<long double>;
#define X real()
#define Y imag()
const long double PI = acos(-1);
const long double EPS = 1e10;
// conj(x) : complex conjugate,(0,1)->(0,-1)
// abs(x) : dist between(0,0) and x
// norm(x) : abs(x) * abs(x)
// arg(x) : argment
long double dot(CP a, CP b) { return (a * conj(b)).X; }
long double cross(CP a, CP b) { return (a * conj(b)).Y; }
long double corner(CP a, CP b) {
  //[0,pi]
  return acos(dot(a, b) / (abs(a) * abs(b)));
}

int n;
vector<CP> v;

long double solve();
long double calc(CP &nowv, CP &nowp, CP nextp);

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    v.push_back(CP(x, y));
  }
  cout << fixed << setprecision(10);
  cout << solve() << endl;
  return 0;
}
long double solve() {
  vector<int> perm;
  long double ans = 1e10;
  for(int i = 0; i < n; ++i) perm.push_back(i);
  do {
    long double nowans = 0;
    CP nowv(1, 0), nowp(0, 0);
    for(int i = 0; i < n; ++i)
      nowans += calc(nowv, nowp, v[perm[i]]);
    nowans += calc(nowv, nowp, CP(0, 0));
    ans = min(nowans, ans);
  } while(next_permutation(perm.begin(), perm.end()));
  return ans / (2 * PI) * 360.0;
}

long double calc(CP &nowv, CP &nowp, CP nextp) {
  long double ans = corner(nowv, nextp - nowp);
  if(ans != 0) nowv = nextp - nowp;
  nowp = nextp;
  return ans;
}


Measured memory_bytes: 3336
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;


int main(){
    string s;
    cin >> s;

    int a_count = 0;
    int b_count = 0;
    int c_count = 0;

    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'a'){
            a_count++;
        }
        else if(s[i] == 'b'){
            b_count++;
        }
        else{
            c_count++;
        }
    }
    
    if(abs(a_count - b_count) <= 1 and abs(b_count - c_count) <= 1 and abs(a_count - c_count) <= 1){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define flash ios_base::sync_with_stdio(false);     cin.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(v) v.begin(),v.end()
#define f first
#define s second



using namespace std;

int main()
{
  flash
  ll n;
  cin>>n;

  ll v[n][3];
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>v[i][j];
    }
  }
  ll dp[n][3];
  dp[0][0]=v[0][0];
  dp[0][1]=v[0][1];
  dp[0][2]=v[0][2];

  for(int i=1;i<n;i++){

    dp[i][0] = v[i][0]  + max( dp[i-1][1] , dp[i-1][2] );
    dp[i][1] = v[i][1]  + max( dp[i-1][0] , dp[i-1][2] );
    dp[i][2] = v[i][2]  + max( dp[i-1][0] , dp[i-1][1] );
  }

  cout<<max ( dp[n-1][0] ,  max( dp[n-1][1] , dp[n-1][2] ) )<<"\n";



}


Measured memory_bytes: 8260
#include <bits/stdc++.h>
#define turbo cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define ll long long
#define pii pair<int,int>
#define f first
#define pb push_back
#define mp make_pair
#define inf 99999999

using namespace std;

int tab[100005];
int dp[100005];

int main(){
    turbo
    int n,x;
    cin >> n;
    if(n==1){
      cout << "0";
      return 0;
    }
    for(int i=1;i<=n;i++){
      cin >> tab[i];
    }
    dp[2]=abs(tab[1]-tab[2]);
    for(int i=3;i<=n;i++){
      dp[i]=min(dp[i-1]+abs(tab[i]-tab[i-1]),dp[i-2]+abs(tab[i]-tab[i-2]));
    }
    cout << dp[n] << "\n";

    return 0;
}


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

using namespace std;

int main()
{
    int n;
    string t;
    vector<string> s;
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin >> t;
        s.push_back(t);
    }
    sort(s.begin(), s.end());
    
    int count = distance(s.begin(),unique(s.begin(), s.end()));
    cout<<count<<"\n";
                
}

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

int main() {
	int n;cin>>n;
	n=n%10;
	if(n==2 || n==4 || n==5 || n==7 || n==9)cout<<"hon\n";
	else if(n==0 || n==1 || n==6 || n==8 )cout<<"pon\n";
	else
	cout<<"bon\n";

	// your code goes here
	return 0;
}

Measured memory_bytes: 3540
#include <iostream>
using namespace std;
 
int main() {
  string str, order, addedStr, tmp;
  int roop, a, b;
  cin >> str;
  cin >> roop;
 
  for (int i = 0; i < roop; i++) {
    cin >> order;
    cin >> a >> b;
    if (order == "print") {
      cout << str.substr(a, b-(a-1)) << endl;
    }
    else if (order == "reverse") {
      for (int j = b; j >= a; j--) {
        tmp += str.at(j);
      }
      str.replace(a, b-(a-1), tmp);
      tmp = "";
    }
    else {
      cin >> addedStr;
      str.replace(a, b-(a-1), addedStr);
    }
  }
  return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <functional>
#include <string>
#include <math.h>
#include <queue>

using namespace::std;

// vector<int> find_reachable_child(int parent, vector<int> kodomo, vector<vector<int> > &reachable)
// {
// for(int i(0); i < kodomo[parent].size(); ++i)
// {
// int child = kodomo[parent][i];
// reachable[parent][child] = 1;
// find_reachable_child(child, kodomo, reachable);
// }
// return kodomo;
// }

// bool is_reachable(int child, int parent, vector<vector <int> > oya, int depth)
// {
//     if(child == parent)
//     {
//         if(depth > 2)
//             return true;
//     }
//     if(oya[child].size() == 0)
//         return false;
    
//     for(int i(0); i < oya[child].size(); ++i)
//     {
//         int dep = depth;
//         if(is_reachable(oya[child][i], parent, oya, ++dep))
//             return true;
//     }
//     return false;
// }

int main()
{
    int n, m;
    cin >> n >> m;

    vector<int> a;
    vector<int> b;

    vector< vector <int> > oya(n+1, vector<int>(0));
    vector< vector <int> > kodomo(n+1, vector<int>(0));
    vector<int> motomoto(n+1);

    for(int i(0); i < n + m - 1; ++i)
    {
        int ai, bi;
        cin >> ai >> bi;
        a.push_back(ai);
        b.push_back(bi);
        kodomo[ai].push_back(bi);
        oya[bi].push_back(ai);
    }

    int root;
    for(int i(1); i < n+1; ++i)
    {
        if(oya[i].size() == 0)
        {
            motomoto[i] == 0;
            root = i;
            break;
        }
    }

    queue<int> q;
    q.push(root);

    while(!q.empty())
    {
        int node = q.front();
        q.pop();

        for(int i(0); i < kodomo[node].size(); ++i)
        {
            int child = kodomo[node][i];
            oya[child].erase(oya[child].end() - 1);
            if(oya[child].size() == 0)
            {
                motomoto[child] = node;
                q.push(child);
            }
        }
    }

    for(int i(1); i < n+1; ++i)
    {
        cout << motomoto[i] << endl;
    }

//cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 12912
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;

#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))

typedef unsigned long long lu;
typedef vector<int> Poly;

const int mod = 1e9 + 7;

inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x = Sub(x - y); }
inline int Mul(int x, int y) { return (lu)x * y % mod; }
inline int Mul(int x, int y, int z) { return (lu)x * y % mod * z % mod; }

int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}

int Inv(int x) { return Pow(x, mod - 2); }

// ----------------------------------------

const int maxn = 1e5;

int n;
char ori[maxn + 1];
int sum[maxn + 1];
int fir_s[maxn + 1][3];
int fir_c[maxn + 1];
bool suf[maxn + 1];

int dp[maxn + 1];
int pat;

int FindFirst(int begin, int s) {
  if (ori[begin] == 'a' + s - 1) return begin + 1;
  int tar = (sum[begin] + s) % 3;
  int i = fir_c[begin];
  if (i == n + 1) return n + 1;
  return fir_s[i + 2][tar];
}

int Solve(void) {
  FILL(dp, n + 1, 0);
  dp[0] = 1;

  for (int L = 0; L < n; ++L) {
    // to the end
    if (suf[L]) {
      Add(dp[n], dp[L]);
    }

    // to the mid
    for (int x = 1; x <= 2; ++x) {
      int R = FindFirst(L, x);
      if (R < n) {
        Add(dp[R], dp[L]);
      }
    }
  }

  return dp[n];
}

int main(void) {
  scanf("%s", ori);
  n = strlen(ori);

  pat = 0;
  for (int i = n - 2; i >= 0; --i) {
    if (ori[i] == ori[i + 1]) {
      pat = i + 1;
      break;
    }
  }

  if (pat == 0) {
    puts("1");
    return 0;
  }

  sum[0] = 0;
  for (int i = 0; i < n; ++i) {
    sum[i + 1] = (sum[i] + (ori[i] - 'a' + 1)) % 3;
  }

  fir_s[n][0] = fir_s[n][1] = fir_s[n][2] = n + 1;
  for (int i = n - 1; i >= 0; --i) {
    COPY(fir_s[i + 1], 3, fir_s[i]);
    fir_s[i][sum[i]] = i;
  }

  fir_c[n] = n + 1;
  for (int i = n - 1; i >= 0; --i) {
    fir_c[i] = fir_c[i + 1];
    if (i + 1 < n && ori[i] == ori[i + 1]) {
      fir_c[i] = i;
    }
  }

  for (int i = 0; i < n; ++i) {
    suf[i] = (i == n - 1) || (fir_c[i] != n + 1 && sum[n] - sum[i] != 0) ||
      ((n - i & 1) && i >= pat);
  }

  int ans = Solve();
  printf("%d\n", ans);
  return 0;
}


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

int main() {
	int a, b, c, m;
	cin >> a >> b >> c;
	
	m = a;

	if (m < b)
		m = b;
	
	if (m < c)
		m = c;
	
	cout << a + b + c - m << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	ll a=100;
	int sum = 0;
	while (a < x) {
		a *= 1.01;
		++sum;
	}
	cout << sum;
}

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

int main(){
  int n,m,dif;
  cin >> n >> m;
  dif = n - m + 1;
  vector<string> A(n),B(m);
  for(int i = 0; i < n; i++)cin >> A.at(i);
  for(int i = 0; i < m; i++)cin >> B.at(i);  
  int flag = 0;
  int ans = 0;
  for(int i = 0; i < dif; i++){//x座標のずれ
    for(int j = 0; j < dif; j++){//y座標のずれ
      //全文字一致するか確認
      flag = 0;
      for(int k = 0; k < m; k++){
        for(int l = 0; l < m; l++){
          if(A.at(l+j).at(k+i)!=B.at(k).at(l)){
            flag = 1;
            break;
          }
        }
        if(flag)break;
      }
      if(flag)continue;
      else{
        ans = 1;
        break;
      }
    }
    if(ans)break;
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

string S;
int K;
int dp[110][2][5];

void _main() {
    cin >> S >> K;
    dp[0][0][0] = 1;
    REP (i, S.size()) REP (j, 2) REP (k, K + 1) {
        int lim = (j == 0 ? S[i] - '0' : 9);
        for (int d = 0; d < lim + 1; ++d) {
            dp[i + 1][j | (d < lim)][k + (d > 0)] += dp[i][j][k];
        }
    }
    cout << (dp[S.size()][0][K] + dp[S.size()][1][K]) << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

// C: Peak
int main() {
    int N, M;
    cin >> N >> M;

    int H[N];
    int m[N];
    for (int i=1; i <= N; i++) {
        cin >> H[i];
        m[i] = 0;
    }

    for (int j=1;j <= M; ++j) {
        int a, b;
        cin >> a >> b;
        m[a] = max(m[a], H[b]);
        m[b] = max(m[b], H[a]);
    }
    int ans = 0;
    for (int i=1; i<=N; ++i) {
        // cout << H[i] << " - " << m[i] << endl;
        ans += H[i] > m[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3964
while True:
    m,f,r = map(int,input().split())
    
    if m == -1 and f == -1 and r == -1:
        exit()
        
    if m == -1 or f == -1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif m+f >= 65:
        print("B")
    elif m+f >= 50:
        print("C")
    elif m+f >= 30 and r >= 50:
        print("C")
    elif m+f >= 30:
        print("D")
    else:
        print("F")


Measured memory_bytes: 5592
#define _CRT_SECURE_NO_WARNINGS
////#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
//#include<math.h>
#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main() {
	double stack[128];
	int top;
	char input[128], *p;
	for (; ~fscanf(stdin, "%[^\n]*s", input) != NULL; P(lf, stack[top])) {
		getchar();
		top = -1;
		for (p = strtok(input, " "); p != NULL; p = strtok(NULL, " ")) {
			if (strlen(p) == 1) {
				if (*p == '+') stack[top - 1] += stack[top--];
				else if (*p == '-') stack[top - 1] -= stack[top--];
				else if (*p == '*') stack[top - 1] *= stack[top--];
				else if (*p == '/') stack[top - 1] /= stack[top--];
				else stack[++top] = strtod(p, NULL);
			}
			else stack[++top] = strtod(p, NULL);
		}
	}
	return 0;
}

Measured memory_bytes: 612
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		String b=" ",n="\n";
        String[] rc=br.readLine().split(b);
        int r=Integer.parseInt(rc[0]);
        int c=Integer.parseInt(rc[1]);
        int[][] h=new int[r][c];
        
        for(int i=0;i<r;i++){
        	String[] row=br.readLine().split(b);
        	int s=0;
        	for(int j=0;j<c;j++){
        		h[i][j]=Integer.parseInt(row[j]);
        		sb.append(h[i][j]+b);
        		s+=h[i][j];
        	}
        	sb.append(s+n);
        }
        int ts=0;
        for(int j=0;j<c;j++){
        	int s=0;
        	for(int i=0;i<r;i++){
        		s+=h[i][j];
        		ts+=h[i][j];
        	}
        	sb.append(s+b);
        }
        sb.append(ts);
        System.out.println(sb);
	}
}

Measured memory_bytes: 25480
import sys, bisect, math, itertools, string, queue, copy
#import numpy as np
#import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
a = inpl()

cnt_even = defaultdict(int)
cnt_odd = defaultdict(int)
for i in range(0,n,2):
  cnt_even[a[i]] += 1
for i in range(1,n,2):
  cnt_odd[a[i]] += 1

cnt_even = list(reversed(sorted(cnt_even.items(),key=lambda x:x[1])))
cnt_odd  = list(reversed(sorted(cnt_odd.items(),key=lambda x:x[1])))

flg = False
for i in range(min(2,len(cnt_even),len(cnt_odd))):
  a,b = (cnt_even[i],cnt_odd[i])
  if a[0] != b[0]:
    if flg == False:
      n -= a[1]+b[1]
    else:
      n -= max(a[1],b[1])
    break
  else:
    n -= a[1]
    flg = True

print(n)


Measured memory_bytes: 25656
import java.util.*;
import java.util.stream.Collectors;
public class Main{

	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			int n = s.nextInt();
			s.nextInt();
			List<String> list = new ArrayList<>(n);
			for(int i=0; i<n; i++) {
				list.add(s.next());
			}
			System.out.println(list.stream().sorted().collect(Collectors.joining()));
		}
	}
}


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

using namespace std;

using i64 = int64_t;

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

bool isPrime(int num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

    for (int i = 3; i < sqrt(num); i += 2) {
        if (num % i == 0) return false;
    }
    return true;
}

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

    int i;
    for (i = X; ; i++) {
        if (isPrime(i)) break;
    }

    cout << i << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int dp[103][4][2];
//dp[i][j][k]
// i桁目まで決めてj個の0を使って
// k=0 そこまでの行はNと一致
// k=1そこまでの行ですでにN以下であることが確定


int main(){
  string s;
  cin >> s;
  int n = s.size();
  int K;
  cin >> K;
  dp[0][0][0] = 1;
  rep(i,n)rep(j,4)rep(k,2){
    //i桁目の値
    int nd = s[i] - '0';
    rep(d, 10){
      int ni = i + 1, nj = j, nk = k;
      //0でなければ次へ
      if(d != 0) nj++;
      if(nj > K) continue;
      if(k == 0){
        if(d > nd) continue;
        if(d < nd) nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  int ans = dp[n][K][0] + dp[n][K][1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n, m = map(int,input().split())
X = []
for _ in range(m):
  k, *A = list(map(int,input().split()))
  b = 0
  for a in A:
    b += 1 << (a-1)
  X.append(b)
P = list(map(int,input().split()))

ans = 0
for i in range(1<<n):
  for x, p in zip(X,P):
    y = i & x
    c = bin(y).count("1") % 2
    if c != p:
      break
  else:
    ans += 1
print(ans)

Measured memory_bytes: 3188
package main

import "fmt"

func main() {
	// Code for C - X: Yet Another Die Game
	var x int
	fmt.Scan(&x)

	var ans int
	if x%11 == 0 {
		ans = 2 * (x / 11)
	} else if x%11 < 7 {
		ans = 2*(x/11) + 1
	} else {
		ans = 2*(x/11) + 2
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1768
N,A,B=list(map(int,input().split()))
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

ans=0
for i in range(1,N+1):
  S=digitSum(i)
  if A<=S<=B:
    ans+=i
print(ans)

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

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	vector<double> exp(n);
	for (int& val : v) cin >> val;
	transform(begin(v), end(v), begin(exp), [] (int num) { return (double)(num + 1) / 2; });
	for (int i = 1; i < n; i++) exp[i] += exp[i-1];
	double maxi = exp[k-1];
	for (int i = k; i < n; i++) {
		maxi = max(maxi, exp[i] - exp[i-k]);
	}
	cout << setprecision(7) << fixed << maxi << endl;
	
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
//#include <cctype>
#include <string>
using namespace std;

int main(int argc, char const *argv[])
{
    string a;
    std::locale l = std::locale::classic();

    getline(cin, a);

    for (int i = 0; i < a.size(); i++)
    {
        if (islower(a[i]))
        {
            cout << toupper(a[i], l);
        }
        else if (isupper(a[i]))
        {
            cout << tolower(a[i], l);
        }
        else
        {
            cout << a[i];
        }
    }

    cout << '\n';
    return 0;
}



Measured memory_bytes: 3228
#include<iostream>
#include<vector>
#include<cmath>
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t N;
  cin>>N;
  std::vector<int64_t> L(N+1);
  L[0]=2;
  L[1]=1;
  for(int i=2;i<=N;i++)
    L[i]=L[i-1]+L[i-2];
  cout<<L[N]<<endl;
  return 0;
}


Measured memory_bytes: 3608
let n, c, k = Scanf.scanf "%d %d %d" (fun n c k -> n, c, k)
let t = Array.init n (fun _ -> Scanf.scanf " %d" (fun i -> i))

let rec f i t' p b =
  if i = n then b
  else if t' < t.(i) || p = c then f (i + 1) (t.(i) + k) 1 (b + 1)
  else f (i + 1) t' (p + 1) b

let () =
  Array.sort (fun x y -> x - y) t;
  let ans = f 0 0 0 0 in
  Printf.printf "%d\n" ans


Measured memory_bytes: 6696
#include "bits/stdc++.h"
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

// 定義
typedef long long           ll;
typedef pair<ll, ll>        P;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
const ll                    INF = 2e9;
const ll                    INF_LL = 1LL<<60;
const ll                    MOD = 998244353;
namespace {
	ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
	ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
	ll FloorN(ll x, ll n)     { return (x - x % n); }
	bool IsOdd(ll x)          { return ((x & 1) == 1); }
	bool IsEven(ll x)         { return ((x & 1) == 0); }
	template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
	template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
};

const int mod = 998244353;
class mint {
public:
	long long x;
	mint(long long x = 0) : x((x % mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}
};

/* 繰り返し二乗法 (xのy乗) */
ll binpow(ll x, ll y)
{
	ll res = 1LL;
	x %= MOD;
	while (y) {
		if (y & 1) res = (res * x) % MOD;
		y >>= 1;
		x = (x * x) % MOD;
	}
	return res;
}

// テーブルを作る前処理
const int MAX = 2 * 1000 * 1000;
long long fac[MAX], finv[MAX], inv[MAX];
void CombInit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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;
	}
}


// 二項係数計算(nCk)
long long CombExec(int n, int k)
{
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 処理
void Solve()
{
	ll N, M, K;
	cin >> N >> M >> K;

	CombInit();
	mint ans = binpow(M, N);
	for (ll i = K + 1; i < N; i++) {
		ll nokori = N - i - 1;
		ll ansOne = M * binpow(M - 1, nokori);
		ansOne %= MOD;
		ansOne *= CombExec(N - 1, i);
		ansOne %= MOD;
		ans -= ansOne;
	}
	cout << ans.x << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 50524
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B,C;
	while(cin>>A>>B>>C) {
		ll v = min(A-B, C);
		ll ans = C-v;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
main :: IO ()                                                                                                              
main = do                                                                                                                  
  n <- readLn :: IO Int                                                                                                    
  let k = powerset [3,5,7,11,13,17]                                                                                        
      a  = filter (<=n) $ map product $ filter ((==3) . length) k                                                          
      b1 = filter (<=n) $ map (\[x,y] -> x^3*y) $ filter ((==2) . length) k                                                
      -- b2 = filter (<=n) $ map (\[x,y] -> y^3*x) $ filter ((==2) . length) k                                             
      -- c  = filter (<=n) $ map (\[x] -> x^7) $ filter ((==1) . length) k                                                 
  print $ length $ a ++ b1                                                                                                 
                                                                                                                           
powerset :: [a] -> [[a]]                                                                                                   
powerset [] = [[]]                                                                                                         
powerset (x:xs) = [x:ys | ys <- powerset xs] ++ powerset xs

Measured memory_bytes: 508
#!/bin/bash

read line
length=`echo ${#line}`

num=`expr $length - 2`

min=999

for i in `seq 1 $num`
do
 a=`echo $line | cut -b $i`
 b=`echo $line | cut -b $((i+1))`
 c=`echo $line | cut -b $((i+2))`
 diff=`expr 753 - $a$b$c`
 if [ $diff -le 0 ] ; then
  diff=`expr 0 - $diff`
 fi
 if [ $diff -le $min ] ; then
  min=$diff
 fi
done

echo $min

Measured memory_bytes: 908
#include <stdio.h>

int main(void)
{
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);

    // A == B != C, A == C != B, B == C != A の全通りを書く
    if ((A == B && B != C) || (A == C && C != B) || (B == C && C != A))
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 1664
N, K = map(int, input().split())
A = list(map(int, input().split()))
bits = [0 for i in range(41)]
for i in range(N):
    for j in range(41):
        if A[i] & (1 << j):
            bits[40-j] += 1

bin_K = '0' * (43 - len(bin(K))) + bin(K)[2:]
x = 0
flag = 0
threshold = N // 2 + 1
for i in range(41):
    if flag == 1:
        if bits[i] < threshold:
            x += 1 << (40-i)
    elif flag == 0:
        if bits[i] < threshold and bin_K[i] == '1':
            x += 1 << (40-i)
        elif bits[i] >= threshold and bin_K[i] == '1':
            flag = 1

ans = 0
for i in range(N):
    ans += x ^ A[i]
print(ans)

Measured memory_bytes: 15144
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    int n, k;
    cin >> n >> k;
    if (n % 2 == 0) {
        if (k <= n / 2) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    else {
        if (k <= (n + 1) / 2) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN=500001;

char s[MAXLEN+1]; int slen;
int cnt[MAXLEN];

bool ok(int d0,int sum) {
	int rem=sum,carry=(sum-d0)/10;
	// have+rem*(p10[i]-1)/9 = carry*p10[i]+'suffix of last i characters'
	int err=-1;
	FORE(i,1,slen) {
		int di=i==slen?0:s[i]-'0';
		// (have+rem*(p10[i]+(p10[i]-1)/9))/p10[i]-cnt[i-1]=di -> cnt[i-1]=(carry+rem-di)%10
		if(di>carry+rem) { err=i; break; }
		cnt[i-1]=(carry+rem-di)%10;
		if(cnt[i-1]>rem) { err=i; break; }
		// have+cnt[i-1]*(p10[i]-1)/9)+(rem-cnt[i-1])*(p10[i+1]-1)/9 = ncarry*p10[i+1]+'suffix of last i characters'+p10[i]*di
		int nrem=rem-cnt[i-1];
		int ncarry=(rem-cnt[i-1]+carry-di)/10;
		rem=nrem,carry=ncarry;
	}
	//printf("%d:",sum); REP(i,err==-1?slen:err-1) printf(" %d",cnt[i]); printf(" | %d %d\n",rem,carry);
	return err==-1;
}

void run() {
	scanf("%s",s); slen=strlen(s); reverse(s,s+slen);
	int d0=s[0]-'0';
	int l=-1,h=1; while(!ok(d0,d0+10*h)) l=h,h+=h;
	while(l+1<h) {
		int m=l+(h-l)/2;
		if(!ok(d0,d0+10*m)) l=m; else h=m;
	}
	printf("%d\n",(d0+10*h+8)/9);
}

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


Measured memory_bytes: 2688
#include<stdio.h>

int main(){
		int n;
		scanf("%d",&n);
		long t[1000][2];int i,j;
		for(i=0;i<n;i++)scanf("%ld%ld",&t[i][0],&t[i][1]);
		for(i=1;i<n;i++){
				if(t[i-1][0]<=t[i][0]&&t[i-1][1]<=t[i][1]);
				else {
						long ti0,ti1;
						if(t[i-1][0]>t[i][0]&&t[i-1][1]<=t[i][1]){
									if(t[i-1][0]%t[i][0]==0){
											ti0=t[i-1][0]/t[i][0];
											t[i][0]=t[i][0]*ti0;
											t[i][1]=t[i][1]*ti0;
									}else {
											ti0=(t[i-1][0]/t[i][0]+1);
											t[i][0]=t[i][0]*ti0;
											t[i][1]=t[i][1]*ti0;
									}
							}
						else{
							if(t[i-1][0]<=t[i][0]&&t[i-1][1]>t[i][1]){
									if(t[i-1][1]%t[i][1]==0){
											ti1=(t[i-1][1]/t[i][1]);
											t[i][0]=t[i][0]*ti1;
											t[i][1]=t[i][1]*ti1;
									}else {
											ti1=(t[i-1][1]/t[i][1]+1);
											t[i][0]=t[i][0]*ti1;
											t[i][1]=t[i][1]*ti1;
									}
							}
							else{
								if(t[i-1][0]>t[i][0]&&t[i-1][1]>t[i][1]){
										if(t[i-1][0]%t[i][0]!=0)ti0=t[i-1][0]/t[i][0]+1;
										else ti0=t[i-1][0]/t[i][0];
										if(t[i-1][1]%t[i][1]!=0)ti1=t[i-1][1]/t[i][1]+1;
										else ti1=t[i-1][1]/t[i][1];
										if(ti0>=ti1){
												t[i][0]=t[i][0]*ti0;
												t[i][1]=t[i][1]*ti0;
										}
										else{
												t[i][0]=t[i][0]*ti1;
												t[i][1]=t[i][1]*ti1;
										}
								}
							}
						}
				}
//		printf("%ld,%ld\n",t[i][0],t[i][1]);
		}
		printf("%ld\n",t[n-1][0]+t[n-1][1]);
		return 0;
}



Measured memory_bytes: 128
/* 競プロ用のテンプレ
 * SKMT
 * 作成日   2020年09月13日  21:01
 * ファイル名    b.cpp
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;//long long型をllで

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

int main(int argc, char const* argv[]){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll maxval;
	ll arr[4];
	arr[0]=b*c;
	arr[1]=b*d;
	arr[2]=a*c;
	arr[3]=a*d;
	maxval=arr[0];
	rep(i,4){
		if(arr[i]>maxval)maxval=arr[i];
	}
	cout<<maxval<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>

typedef unsigned long ULONG;

using namespace std;
int main(){
  ULONG a, b, x;
  cin >> a >> b >> x;

  ULONG ret = b/x;
  if(a != 0) {
    ret -= (a-1UL)/x;
  } else {
    ret++;
  }
  cout << ret << endl;
  return 0;
}


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

using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str;
    cin>>str;
    long long int tot=0;
    for(auto ch:str){
			tot+=ch-'0';
	}
	if(tot %9 ==0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}



Measured memory_bytes: 3736