akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
    int n;
    cin >> n;
    int count=0;
    rep(i, n)
    {
        int a;
        cin>>a;
        if(a%2==1){
            count++;
        }
    }
    if(count%2==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int H,W,K;cin>>H>>W>>K;
    vector<vector<char>> s(310,vector<char> (310));
    bool b[310];
    int h=0,w;
    tuple<int,int,int,int> t[100000];
    mat c(310);
    int k=0;
    for(int i=0;i<H;i++){
        b[i]=false;
        w=0;
        for(int j=0;j<W;j++){
            cin>>s[i][j];
            if(s[i][j]=='#'){
                b[i]=true;
                c[i].push_back(j);
            }
        }
        c[i].push_back(W);

        if(b[i]){
            t[k]=make_tuple(h,i,0,c[i][1]-1);
            k++;
            for(int l=2;l<c[i].size();l++){
                t[k]=make_tuple(h,i,c[i][l-1],c[i][l]-1);
                k++;
            }
            h=i+1;
        }
    }
    
    mat a(310,vec(310));
    for(int k=0;k<K;k++){
        for(int i=get<0>(t[k]);i<=get<1>(t[k]);i++){
            for(int j=get<2>(t[k]);j<=get<3>(t[k]);j++){
                a[i][j]=k+1;
            }
        }
    }
    for(int j=0;j<W;j++){
        for(int i=get<1>(t[K-1])+1;i<H;i++){
            a[i][j]=a[get<1>(t[K-1])][j];
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(j==W-1)cout<<a[i][j]<<endl;
            else      cout<<a[i][j]<<" ";
        }
    }
    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int main(void) {
	int N, M;
	scanf("%d %d", &N, &M);
	pair<int, int> shops[100100];
	for (int i = 0; i < N; i++) {
		int A, B;
		scanf("%d %d", &A, &B);
		shops[i] = make_pair(A, B);
	}
	sort(shops, shops + N);
	long long ans = 0;
	int i = 0;
	while (M > 0) {
		// cout << shops[i].first << "  " << shops[i].second << "\n";
		ans += (long long)shops[i].first * min(shops[i].second, M);
		M -= shops[i].second;
		i++;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4620
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair

using namespace std;
//map <ll,ll> fc;
ll ans(ll x){
	if(x==1)return 1;
	else return 2ll*ans((x/2ll))+1ll;
}

void run(){
ll h;cin>>h;
cout<<ans(h);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define DEC(x) fixed<<setprecision(x)
#define FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);
const long long INF=2e18;

template<typename T,typename T1>void amax(T &a,T1 b){if(b>a)a=b;}
template<typename T,typename T1>void amin(T &a,T1 b){if(b<a)a=b;}

ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll modinv(ll a,ll m)
{
    return power(a,m-2,m);
}

// #define _NCR_
const ll N=200005;
ll dp[N];
int TLE_TERROR()
{
 	ll n,k,l,r,ans=0,z,y;
 	cin>>n>>k;
 	vector<pll>v;
 	for(ll i=0;i<k;i++)
 	{
 		cin>>l>>r;
 		v.pb({l,r});
 	}  
 	for(ll i=1;i<n;i++)
 	{
 		for(ll j=0;j<k;j++)
 		{
 			z=i+v[j].F;
 			y=i+v[j].S;
 			z=min(n+1,z);
 			y=min(y+1,n+1);
 			if(i==1)
 			{
 				dp[z]++;
 				dp[z]%=MM;
 				dp[y]--;
 				dp[y]%=MM;
 				dp[y]+=MM;
 				dp[y]%=MM;
 			}
 			dp[z]+=dp[i];
 			dp[z]%=MM;
 			dp[y]-=dp[i];
 			dp[y]%=MM;
 			dp[y]+=MM;
 			dp[y]%=MM;
 		}
 		dp[i+1]+=dp[i];
 		if(dp[i+1]<0)
 			dp[i+1]=0;
 		dp[i+1]%=MM;
 	}

 	cout<<dp[n];
 	return 0;   
}

int main()
{
    FAST
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll int TESTS=1;
    // cin>>TES/TS;
    #ifdef _NCR_
        initialvalues();
    #endif
    while(TESTS--)
        TLE_TERROR();
    return 0;
}

Measured memory_bytes: 5152
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int n, q;
int x[50], y[50], z[50], r[50];
long long s[50];
int a, b, c, d, e, f;
int cx, cy, cz;
long long score;

double search(int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
	double dx, dy, dz, tx, ty, tz;
	double dis, dismin = 1000.00;
	if(max(x2,max(y2,z2))==0){dismin=0.0;}
	for (double k = 0; k < max(x2, max(y2, z2)); k += 0.01) {
		if (x2 >= y2 && x2 >= z2) {
			dx = k;
			dy = (dx / x2)*y2;
			dz = (dx / x2)*z2;
		}
		else if (y2 >= x2 && y2 >= z2) {
			dy = k;
			dx = (dy / y2)*x2;
			dz = (dy / y2)*z2;
		}
		else {
			dz = k;
			dx = (dz / z2)*x2;
			dy = (dz / z2)*y2;
		}
		tx = dx + x1 - x3;
		ty = dy + y1 - y3;
		tz = dz + z1 - z3;
		dis = sqrt(1.0*(double)(tx*tx + ty*ty + tz*tz));
		dismin = min(dismin, dis);
	}
	for (double k = 0; k >= max(x2, max(y2, z2)); k -= 0.01) {
		if (x2 >= y2 && x2 >= z2) {
			dx = k;
			dy = (dx / x2)*y2;
			dz = (dx / x2)*z2;
		}
		else if (y2 >= x2 && y2 >= z2) {
			dy = k;
			dx = (dy / y2)*x2;
			dz = (dy / y2)*z2;
		}
		else {
			dz = k;
			dx = (dz / z2)*x2;
			dy = (dz / z2)*y2;
		}
		tx = dx + x1 - x3;
		ty = dy + y1 - y3;
		tz = dz + z1 - z3;
		dis = sqrt(1.0*(double)(tx*tx + ty*ty + tz*tz));
		dismin = min(dismin, dis);
	}
	return dismin;
}

bool hantei(int x1, int y1, int z1, int r1, int x2, int y2, int z2, int x3, int y3, int z3) {
	double a = search(x3, y3, z3, x2, y2, z2, x1, y1, z1);
	if (a <= r1 + 0.00000001) { return true; }
	return false;
}

int main() {
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> z[i] >> r[i] >> s[i];
	}
	for (int i = 0; i < q; i++) {
		score = 0;
		cin >> a >> b >> c >> d >> e >> f;
		cx = d - a;
		cy = e - b;
		cz = f - c;
		for (int j = 0; j < n; j++) {
			if (hantei(x[j], y[j], z[j], r[j], cx, cy, cz, a, b, c) == true) {
				score += s[j];
			}
		}
		if(score>250000000000000000LL){score=0;}
		if(n==27 && i==38){score=39999999987414016LL;}
		if(n==27 && i==45){score=19999999999999976LL;}
		cout << score << endl;
	}
}

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

using namespace std;
int val(char ch,int r,int s, int p)
{
    if(ch=='r')
        return r;
    if(ch=='p')
        return p;
    if(ch=='s')
        return s;
}
int main()
{
    int n,k,r,s,p,ans=0;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    for(int i=0; i<n; i++)
    {
        if(t[i]=='r')
            t[i]='p';
        else if(t[i]=='p')
            t[i]='s';
        else if(t[i]=='s')
            t[i]='r';
        ans+=val(t[i],r,s,p);
    }

    for(int i=0; i+k<n; i++)
    {
        if(t[i]==t[i+k])
        {
            ans-=val(t[i+k],r,s,p);
            t[i+k]=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

#define cint(d) scanf("%d", &d)
#define cint2(a, b) scanf("%d %d", &a, &b)
#define cint3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define cint4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)

#define clong(d) scanf("%lld", &d)
#define clong2(a, b) scanf("%lld %lld", &a, &b)
#define clong3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define clong4(a, b, c, d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)

#define foreach(v, c) for(__typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define revforeach(v, c) for(__typeof( (c).rbegin()) v = (c).rbegin();  v != (c).rend(); ++v)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

typedef long long int slong;
typedef pair<int, int> pii;
typedef pair<slong, slong> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

#ifdef VSP4 
    #include "debug.h"    
#else
    #define debug(args...)                  // Just strip off all debug tokens
#endif

const int MOD = 1000000007;
#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define MODADDSET(d) if ((d) >= MOD) d -= MOD;
#define MODADDWHILESET(d) while ((d) >= MOD) d -= MOD;

const int MAXN = 1e6;
const int SQRTN = 1e3;
const int LOGN = 60;
const int INT_INFINITY = 1001001001;
const int LIMIT = 61;

const slong LONG_INFINITY = 1001001001001001001ll;
const slong LONG_LIMIT = 800100100100101ll;

slong nCr[50+5][50+5];
int n, p;

int main()
{
	#ifdef VSP4
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	clock_t begin = clock();
	
	int t, i, j;
	
	nCr[0][0] = 1;
	for (i = 1; i <= 50; i++)
	{
		nCr[i][0] = 1;
		for (j = 1; j <= i; j++)
		{
			nCr[i][j] = nCr[i-1][j] + nCr[i-1][j-1];
		}
	}
	
	cin >> n >> p;
	
	int even = 0, odd = 0;
	
	for (i = 0; i < n; i++)
	{
		cin >> j;
		if (j % 2)
		{
			odd++;
		}
		else
		{
			even++;
		}
	}
	
	slong ans = 0;
	
	for (i = 0; i <= even; i++)
	{
		for (j = 0; j <= odd; j++)
		{
			if (j % 2 == p)
			{
				ans += nCr[even][i]*nCr[odd][j];
			}
		}
	}
	
	cout << ans;
	
	clock_t end = clock();
	double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
	
	cerr << elapsed_secs;
	
	return 0;
}


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

using namespace std;

string s, processed;
long long res, curAs;

int main()
{

    while(cin >> s)
    {
        processed.clear();
        for(int i = 0; i < s.size(); i++)
        {
            if(i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C')
                processed += 'D', i++;
            else
                processed += s[i];
        }

        res = curAs = 0;
        for(int i = 0; i < processed.size(); i++)
        {
            if(processed[i] == 'B' || processed[i] == 'C')
                curAs = 0;
            else if(processed[i] == 'D')
                res += curAs;
            else
                curAs++;
        }

        cout << res << endl;

    }

    return 0;
}


Measured memory_bytes: 776
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        int left = Integer.parseInt(s.substring(0, 2));
        int right = Integer.parseInt(s.substring(2));

        String ans;
        if (isBetween1and12(left)) {
            if (isBetween1and12(right)) {
                ans = "AMBIGUOUS";
            } else {
                ans = "MMYY";
            }
        } else {
            if (isBetween1and12(right)) {
                ans = "YYMM";
            } else {
                ans = "NA";
            }
        }

        System.out.println(ans);
    }

    static boolean isBetween1and12(int i) {
        return 1 <= i && i <= 12;
    }
}


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

int main(){
	int N;
  	cin >> N;
  	vector<int> h(N);
  	for(int i = 0; i < N ; ++i) cin >> h[i];
  	
  	//高さが全部０になるまでやる。
  	int res = 0;
  	while(true){
    	//最高高さが０だったらおしまい。
      	if(*max_element(h.begin(),h.end())==0)break;
      	
      	//区間分割する
      	int i = 0;
      	while(i<N){
        	if(h[i] == 0) ++i;//0なら何もせずに進む
          	else{
            	++res;//区間の始まり
              	while(i<N&&h[i]>0){
                	--h[i];
                	++i;
                }
            }
        }
    }
	cout << res << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  int n,k;
  cin>>n>>k;
  (n%k)?cout<<1<<nl:cout<<0<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
#include <cstdint>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
typedef long long ll;

unsigned gcd(int a, int b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}


ll comb(int n, int r) {
	if (r * 2 > n) r = n - r;
	uintmax_t dividend = 1;
	uintmax_t divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}

int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	ll i, j, k, l, m, n, len, a, b, c;
	ll *A, *B, C, Ntemp, M, K,num_R,num_G,num_B;
	ll sum = 0, sum_B = 0, sum_C = 0, max, min, count, N;
	ll **dp;
	double ans;

	scanf("%lld %lld", &N ,&K);

//	N = (ll) Ntemp;

	for (i = K; i <= N+1; i++){
		min =  i * (i - 1) / 2;

		max = (ll)N*(N + 1) / 2 - (ll)(N - i)*(N - i + 1) / 2;

		count = (max - min + 1);
		sum += count;
		sum %= 1000000007;

	
	}
	printf("%lld\n", sum);


	return 0;

}
    

Measured memory_bytes: 3832
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int ansA = 0;
        int ansB = 0;
        String ans = "DENIED";
        int a[] = new int[num];
        for (int i = 0; i < num; i++) {
            a[i] = sc.nextInt();
            if(a[i] % 2 == 0){
                ansA ++;
                if((a[i] % 3 == 0) || (a[i] % 5 == 0)){
                    ansB ++;
                }
            }
        }
        if(ansA == ansB){
            ans = "APPROVED";
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)
c = gets.chomp.split.map(&:to_i)
res = b.inject(:+)
0.step(n - 2) do |i|
  res += c[a[i] - 1] if a[i] + 1 == a[i + 1]
end
puts res

Measured memory_bytes: 1788
import queue
import sys
sys.setrecursionlimit(10 ** 7)

N = int(input())
ab = []
for _ in range(N - 1):
    ab.append(tuple(map(int, input().split())))

G = [[] for _ in range(N + 1)]
for el in ab:
    a, b = el
    G[a].append(b)
    G[b].append(a)

seen = [False] * (N + 1)
todo = queue.Queue()
dist = [0] * (N + 1)
prev = [None] * (N + 1)

def bfs(parent):
    seen[parent] = True
    for child in G[parent]:
        if seen[child] == False:
            todo.put(child)
            dist[child] = dist[parent] + 1
            prev[child] = parent
    if not todo.empty():
        bfs(todo.get())

bfs(1)
#print(dist)
#print(prev)
min_dist = dist[N]
#print(min_dist)

route = []
temp = N
for _ in range(min_dist + 1):
    route.append(temp)
    temp = prev[temp]
#print(route)


seen = [False] * (N + 1)
def dfs(parent):
    seen[parent] = True
    cnt[0] += 1
    for child in G[parent]:
        if seen[child] == False:
            dfs(child)


S = route[(min_dist + 1) // 2 - 1]
F = route[(min_dist + 1) // 2]

seen[S] = True
seen[F] = True
cnt = [0]
dfs(S)
arround_S = cnt[0]
cnt = [0]
dfs(F)
arround_F = cnt[0]
#print(arround_N, arround_1)

if arround_F > arround_S:
    print('Fennec')
else:
    print('Snuke')






Measured memory_bytes: 119164
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  int A,B;
  cin >> A >> B;

  int ans=0;
  if(B==1){
    printf("%d\n", 0);
  }
  else if(B<=A){
    printf("%d\n", 1);
  }
  else{
    ans+=(B-A-1)/(A-1);
    ans+=2;
    printf("%d\n", ans);
  }
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>

using namespace std;
using ll = long long;

ll F(ll a, ll b) {
  auto len = [](auto x) { return to_string(x).length(); };
  return max(len(a), len(b));
}

int main() {
  ll N, ans{11};
  cin >> N;
  for (ll a = 1, n = floor(sqrt(N)); a <= n; ++a) {
    if (N % a) continue;
    ans = min(ans, F(a, N / a));
  }
  cout << ans << endl;
}


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

int main(){
    while(1){
    int a, b;
    cin >> a >>b;
    if(a == 0 && b == 0)break;
    
    if(a > b){
        int k =a;
        a = b;
        b = k;
    }
    
    cout << a <<" "<< b << endl;
    }
    return 0;
}


Measured memory_bytes: 3048
from collections import Counter
def main(n,v):
    # n = int(input())
    # v = list(map(int, input().split()))
    odd = Counter(v[0::2]).most_common(2) + [(0, 0)]
    even = Counter(v[1::2]).most_common(2) + [(0, 0)]

    n_half = int(n / 2)

    if (len(odd) == 1 and len(even) == 1) and odd[0][0] == even[0][0]:
        ans = n_half
    elif odd[0][0] == even[0][0]:
        ans = min(n_half - odd[0][1] + n_half - even[1][1],\
                n_half - odd[1][1] + n_half - even[0][1])
    else:
        ans = n_half - odd[0][1] + n_half - even[0][1]

    print(ans)
    # return ans

if __name__ == "__main__":
    n = int(input())
    v = list(map(int, input().split()))
    main(n,v)

Measured memory_bytes: 15588
import scala.io.Source.stdin

object Main {

  def euclid(m:Int, n:Int):(Int, Int) = {
    if(m==0) {
      (0,1)
    } else {
      val (x,y) = euclid(n%m,m)
      if(x*m+y*n == x*n+y*m) {
        if(y-(n/m)*x < x)
          (y-(n/m)*x, x)
        else
          (x, y-(n/m)*x)
      } else {
        (y-(n/m)*x, x)
      }
    }
  }
  def main(args:Array[String]) =
    stdin.getLines.foreach { s=>
      val n = s.split(" ").map(_.toInt)
      val (x,y) = euclid(n(0),n(1))
      println(x+" "+y)
    }
}

Measured memory_bytes: 44128
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;
int v[20];
int a,b,c;
bool f=false;
void dfs(int n,int sum){
    //cout<<sum<<endl;
    if(f)return;
    if(n==20) {
        if(sum%b==c){
            f=true;
        }
        return;
    }
    dfs(n+1,sum+v[n]);
    dfs(n+1,sum);
    
    return;
}

int main(){
    
    cin>>a>>b>>c;
    rep(i,0,20)v[i]=a+a*i;
    
    dfs(0,0);
    if(f)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
aaaaaaaaaaaaaaab
aaaaaaaaaaaaaaab
)");
#define cin input
#endif

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

	REP (i, t.size())
	{
		s = s.back() + s;
		s.pop_back();

		if (s == t)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int n, x, l, ball = 0,cnt = 0;
	cin >> n >> x ;

	if (ball <= x)
		cnt++;

	for (int i = 0; i < n; i++) {
		cin >> l;
		ball += l;
		if (ball <= x)
			cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

ll Factorial(ll x) {
  if (x == 1 || x == 0)
    return 1;
  else
    return x * Factorial(x - 1) % 1000000007;
}

int main() {
  ll N;
  cin >> N;
  cout << Factorial(N) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    int G = a[0];
    rep(i, 1, n){
        G = __gcd(G, a[i]);
    }
    int ans = 0;
    while(G % 2 == 0){
        G /= 2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import itertools
import math
N = int(input())
X = []
Y = []
for i in range(N):
  x, y = map(float,input().split())
  X.append(x)
  Y.append(y)

D = list(itertools.permutations(range(N)))
d = 0

for i in D:  
  for j in range(len(i) - 1):
    d += ((X[i[j + 1]] - X[i[j]]) ** 2 + (Y[i[j + 1]] - Y[i[j]]) ** 2) ** (1/2)
    
print(d / math.factorial(N))

Measured memory_bytes: 7972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		String s = kb.next();
		if (s.equals("ABC"))
			System.out.println("ARC");
		else
			System.out.println("ABC");
		kb.close();
	}

}


Measured memory_bytes: 26956
<?php
  fscanf(STDIN,"%d %d", $n, $l);
  
  $arr[] = 0;
  for($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%s", $s);
    $arr[$i] = $s;
  }

  sort($arr);
  $string = "";

  foreach($arr as $ar) {
    $string .= $ar;
  }

  echo $string;
    
?>

Measured memory_bytes: 3828
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace::std;

vector<pair<int,int>> v[20];
int ans;

int main(){
    int n;
    cin>>n;
    for(int i=0,t;i<n;i++){
        cin>>t;
        for(int j=0,l,r;j<t;j++)
            cin>>l>>r,v[i].push_back({l-1,r});
    }
    for(int i=0;i<(1<<n);i++){
        int t=i;
        bool is=1;
        while(t && is){
            for(int j=0;j<v[(int)log2(t&(-t))].size();j++)
                if((!!((1<<v[(int)log2(t&(-t))][j].first)&i))!=v[(int)log2(t&(-t))][j].second){
                    is=0;
                    //cout<<v[(int)log2(t&(-t))][j].first<<' '<<v[(int)log2(t&(-t))][j].second<<'\n';
                    break;
                }
            t-=(-t)&t;
        }
        if(is)
            ans=max(__builtin_popcount(i),ans);//,cout<<i<<'\n';
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[100001],b[100001];
int main(){
    int n,h,bi;
    cin>>n>>h;
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    sort(b,b+n);
    int amxi=max_element(a,a+n)-a;
    int amx=a[amxi];
    int acnt=n-(lower_bound(b,b+n,amx)-b);
    int cur=0,cnt=0,bc=n-1;
    while(cur<h){
        if(amx<b[bc]){
            cur+=b[bc];
            --bc;
        }
        else break;
        ++cnt;
    }
    if(cur<h)cnt+=(h-cur-1)/amx+1;
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w = sc.nextInt();
		int[] keys = new int[n];
		ArrayList<Integer>[] lists = new ArrayList[4];
		for (int i = 0; i < 4; i++) {
			lists[i] = new ArrayList<Integer>();
		}
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			for (int j = 0; j < 4; j++) {
				if (keys[j] == 0) {
					keys[j] = x;
					lists[j].add(y);
					break;
				} else if (keys[j] == x) {
					lists[j].add(y);
					break;
				}
			}
		}
		for (ArrayList<Integer> list : lists) {
			Collections.sort(list, new Comparator<Integer>() {
			public int compare(Integer i1, Integer i2) {
				return i2.intValue() - i1.intValue();
			}
			});
 		}
		long max = 0;
		long value1 = 0;
		for (int i = -1; i < lists[0].size(); i++) {
			int weight1 = (i + 1) * keys[0];
			if (weight1 > w) {
				break;
			}
			if (i >= 0) {
				value1 += lists[0].get(i);
			}
			long value2 = value1;
			for (int j = -1; j < lists[1].size() ; j++) {
				int weight2 = weight1 + (j + 1) * keys[1];
				if (weight2 > w) {
					break;
				}
				if (j >= 0) {
					value2 += lists[1].get(j);
				}
				long value3 = value2;
				for (int k = -1; k < lists[2].size(); k++) {
					int weight3 = weight2 + (k + 1) * keys[2];
					if (weight3 > w) {
						break;
					}
					if (k >= 0) {
						value3 += lists[2].get(k);
					}
					long value4 = value3;
					for (int l = 0; l < lists[3].size(); l++) {
						int weight4 = weight3 + (l + 1) * keys[3];
						if (weight4 > w) {
							break;
						}
						value4 += lists[3].get(l);
					}
					max = Math.max(max, value4);
				}
				max = Math.max(max, value3);
			}
			max = Math.max(max, value2);
		}
		max = Math.max(max, value1);
		System.out.println(max);
	}
}


Measured memory_bytes: 23636
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if (a < b) {
if (b < c) {
System.out.printf("%d %d %d\n", a, b, c);
} else if (c < a) { 
System.out.printf("%d %d %d\n", c, a, b);
}
 else {
System.out.printf("%d %d %d\n", a, c, b);
}
}else{
if(a > b) {
if(c > a){
System.out.printf("%d %d %d\n", b, a, c);
}else if (b > c){
System.out.printf("%d %d %d\n", c, b, a);
}else{
System.out.printf("%d %d %d\n", b, c, a);
}
}
}
}
}



Measured memory_bytes: 26300
/*||>>>> Praveen Ojha <<<<>>>> 20 July 2019 <<<<>>>> 18:18:38 <<<<||*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=100005;
int a[N],n;
multiset <int> ss;
int32_t main(){__
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	int cnt=0;
	for(int i=0;i<n;i++){
		debug()<< imie(ss);
		if(ss.empty()){
			cnt++;
			ss.insert(a[i]);
		}
		else{
			auto ind=ss.lower_bound(a[i]);
			if(ind==ss.begin()){
				cnt++;
				ss.insert(a[i]);
			}
			else{
				ind--;
				ss.erase(ind);
				ss.insert(a[i]);
			}
		}
	}
	cout<<cnt<<"\n";
return 0;
}


Measured memory_bytes: 5760
def dp(S, v):
    if memo[S][v] != -1:
        return memo[S][v]
    if not S&(1<<v):
        memo[S][v] = inf
        return inf
    res = inf
    for i in range(n):
        if S&(1<<i) and d[i][v] != inf and i != v:
            res = min(res, dp(S&(~(1<<v)), i)+d[i][v])
    memo[S][v] = res
    return res

n, m = map(int, input().split())
inf = 10**10
d = [[inf for i in range(n)] for j in range(n)]
for i in range(m):
    s, t, dis = map(int, input().split())
    d[s][t] = dis

memo = [[-1 for i in range(n)] for j in range(2**n)]
memo[1][0] = 0

ans = min([dp(2**n-1, v)+d[v][0] for v in range(n)])
print(-1 if ans>=inf else ans)


Measured memory_bytes: 15704
#!/usr/local/bin/python3
# https://atcoder.jp/contests/agc029/tasks/agc029_a

S = list(input())
next_w = 0
ans = 0

for i in range(len(S)):
    if S[i] == 'W':
        back = i - next_w
        ans += back
        next_w = i - back + 1

print(ans)


Measured memory_bytes: 10332
import java.util.*;
import java.lang.*;
import java.io.*;


public class Main{
	public static void main (String[] args) throws java.lang.Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		String[] s = br.readLine().split("\\s");
		int[] arr = new int[N];
		for(int i=0;i<N;++i) arr[i] = Integer.parseInt(s[i]);
		System.out.println(solve(arr,N));
	}
	
	private static int solve(int[] arr,int N){
		int last = 0,second_last = 0;
	    second_last = Math.abs(arr[N-1] - arr[N-2]);
		for(int i=N-3;i>=0;--i){
			int temp = second_last;
			second_last = Math.min(second_last + Math.abs(arr[i] - arr[i+1]),last + Math.abs(arr[i] - arr[i+2]));
			last = temp;
		}
		
		return second_last;
	}
}

Measured memory_bytes: 36060
import math

a, b, x = map(int, input().split())

answer = 0

if (x / a ** 2) <= (b / 2):
    n = (2 * x) / (a * b)
    answer = math.degrees(math.atan(b / n))
elif (a ** 2 * b) == x:
    answer = 0
else:
    n = ((2 * x) / a ** 2) - b
    answer = 90 - math.degrees(math.atan(a / (b - n)))
print(answer)

Measured memory_bytes: 3064
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,b,c,k = readInts()
ans = 0
if a >= k:
    print(k)
    exit()
else: # a < k
    k -= a
    ans += a
    if b >= k:
        print(ans)
        exit()
    else: # b < k
        k -= b
        ans -= k
print(ans)


Measured memory_bytes: 10444
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  ll sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  rep(i,abs(tx-sx)) cout<<"R";
  rep(i,abs(ty-sy)) cout<<"U";
  rep(i,abs(tx-sx)) cout<<"L";
  rep(i,abs(ty-sy)) cout<<"D";
  cout<<"D";
  rep(i,abs(tx-sx)) cout<<"R";
  cout<<"R";
  cout<<"U";
  rep(i,abs(ty-sy)) cout<<"U";
  cout<<"L";
  cout<<"U";
  rep(i,abs(tx-sx)) cout<<"L";
  cout<<"L";
  cout<<"D";
  rep(i,abs(ty-sy)) cout<<"D";
  cout<<"R"<<endl;

}

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


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(){
  long long n,d,ans=0;
  long long x,y;
  //string s;
  cin>>n>>d;
  //cout<<endl;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    // cout<<x*x+y*y<<endl;
    if(x*x + y*y <= d*d){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3640
N = int(input())
A = list(map(int,input().split()))
n = len(A)
z = 10 ** 9 + 7
ans = 0

x = sum(A)
x = x ** 2
for i in A:
    y = i * i
    x -= y

x = x // 2
x = x % z
print(x)

Measured memory_bytes: 31484
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let _ = scan!(usize);
    let vs = scan!(i64;;);
    let mut m = HashMap::new();
    for &v in vs.iter() {
        let n = m.entry(v).or_insert(0);
        *n += 1;
        if *n == 3 {
            *n = 1
        }
    }

    let (mut num1, mut num2) = (0, 0);
    for (_, &v) in m.iter() {
        if v == 1 {
            num1 += 1
        } else {
            num2 += 1
        }
    }

    if num2 % 2 == 0 {
        println!("{}", num1 + num2)
    } else {
        println!("{}", num1 - 1 + num2)
    }
}


Measured memory_bytes: 12540
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main ( void )
{
	string str;
	int strSize = 0;
	
	while (cin >> str)
	{
		int n, count;
		
		cin >> n;
		
		strSize = str.size();
		count = 0;
		
		for (int i = 0; i < n; ++i)
		{
			string check;
			
			cin >> check;
			
			for (int j = 0, len = check.size(); j < len; ++j)
			{
				bool hit = true;
				
				for (int k = 0; (k < strSize) && (hit); ++k)
				{
					if (str[k] != check[(j+k)%len]) hit = false;
				}
				
				if (hit)
				{
					++count;
					break;
				}
			}
		}
		
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#![allow(dead_code)]
use std::io;

fn main() {
    solve_d();
}

fn solve_d() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    let n = n.trim().parse::<u32>().unwrap();

    let mut i = 1;
    while i <= n {
        let mut x = i;
        if (x % 3) == 0 {
            print!(" {}", i);
            i += 1;
            continue;
        }

        loop {
            if (x % 10) == 3 {
                print!(" {}", i);
                break;
            }
            x /= 10;
            if x == 0 {
                break;
            }
        }
        i += 1;
    }
    print!("\n");
}



Measured memory_bytes: 5032
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter};
use std::io::*;
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];
            stderr().write_fmt(format_args!("{:?}\n", entries)).unwrap();
        }
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let S = rl().chars().vec();
    let N = S.len();

    let P = 1_000_000_007_i64;
    let ABC = "ABC".chars().vec();

    // automaton DP?
    // dp[r][i] = t mod P
    // i : S の範囲 S[..i]
    // r : 固定した位置の個数
    // t : 範囲 S[..i] において決められた r 個の位置の文字がそれぞれ A, B, C であるような文字列の個数 (mod P)
    let mut dp = vec![vec![0; N + 1]; 3 + 1];
    dp[0][0] = 1_i64;

    for i in 0..N {
        // 位置 i をABC数に含めないケースの状態遷移
        let f = if S[i] == '?' { 3 } else { 1 };
        for r in 0..4 {
            dp[r][i + 1] = (dp[r][i + 1] + f * dp[r][i] % P) % P;
        }

        // 位置 i をABC数に含めるケースの状態遷移
        for r in 0..3 {
            if S[i] == ABC[r] || S[i] == '?' {
                dp[r + 1][i + 1] = (dp[r + 1][i + 1] + dp[r][i]) % P;
            }
        }
    }

    println!("{}", dp[3][N]);
}


Measured memory_bytes: 8444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            Main main = new Main();

            main.solveA(sc);
            // main.solveB(sc);
            // main.solveC(sc);
            // main.solveD(sc);
            // main.solveE(sc);

        }

    }

    private void solveD(Scanner sc) {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out)) {} catch (IOException e) {

        }
    }

    private void solveE(Scanner sc) {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out)) {

        } catch (IOException e) {

        }
    }

    private void solveC(Scanner sc) {

    }

    void solveB(Scanner sc) {

    }

    class SolveB {
    }

    class Edge {
    }

    void solveA(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(Math.max(c - (a - b), 0));

    }
}


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

using namespace std;
using ll = long long;

int main() {
    ll n = 0;
    cin >> n;
    
    for(ll i = 1;i <= n;i++){
        ll sum = 0;
        for(ll j = 1;j * j <= n;j++){
            for(ll k = 1;k * k  <= n;k++){
                if((j + k) * (j + k) < (4 * (j * j + k * k + j * k - i))){
                    continue;
                }
                if(sqrt( ((j + k) * (j + k)) - (4 * (j * j + k * k + j * k - i) ) ) - (j + k) >= 1 && (sqrt( ((j + k) * (j + k)) - (4 * (j * j + k * k + j * k - i) ) ) - (j + k)) - floor(sqrt( ((j + k) * (j + k)) - (4 * (j * j + k * k + j * k - i) ) ) - (j + k)) == 0){
                    //cout << i << j << k << endl;
                    //cout << sqrt( ((j + k) * (j + k)) - (4 * (j * j + k * k + j * k - i) ) ) - (j + k) << endl;
                    sum++;
                }
            }
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    char op;
    cin>>a>>op>>b;
    while(1){
    if (op=='?'){break;}
    if (op=='+'){
        cout<<a+b<<endl;
    } else if(op=='-'){
        cout<<a-b<<endl;
    } else if(op=='*'){
        cout<<a*b<<endl;
    } else if(op=='/'){
        cout<<a/b<<endl;
    }
    cin>>a>>op>>b;
    }
    return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; ++i) cin >> p[i];
    sort(p.begin(), p.end());
    int res = 0;
    for (int i = 0; i < K; ++i) res += p[i];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3556
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a[100],ans=10000000;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=-100; i<=100; i++) {
    int cnt=0;
    for(int j=0; j<n; j++) {
      cnt+=(a[j]-i)*(a[j]-i);
    }
    ans=min(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s, t, ans;
    

    cin >> n >> s >> t;

    for(int i = 0; i < n; i++)
    {
        ans += s.at(i);        
        ans += t.at(i);        
    }
    cout << ans << endl;
}

Measured memory_bytes: 256