akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<string> &s, string a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


int main() {
    int n, k;
    cin >> n >> k;
    map<int, int> m;
    rep(i, n) {
        int a;
        cin >> a;
        m[a]++;
    }

    vector<int> ns;
    for (auto e: m) ns.push_back(e.second);
    sort(ns.rbegin(), ns.rend());
    if (ns.size() <= k) {
        cout << 0 << endl;
        return 0;
    }
    int ans = accumulate(ns.begin() + k, ns.end(), 0);
    cout << ans << endl;

}



Measured memory_bytes: 10748
#include <stdio.h>

int main(void)
{
	int m, j, b, a, c;
	
	scanf("%d" "%d" "%d", &m, &j, &b);
	
	a = b - m;
	if(a > 0){
		c = j - a;
	 	if(c < 0){
		printf("NA\n");
		}
		else{
			printf("%d\n", a);
		}
	}
	
	else{
		printf("0\n");
	}
		
	
	return 0;
}


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

int arr[1000001];
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	memset(arr,-1,sizeof(arr));
	int n;

	cin >> n;

	int a = n;
	n = 1;
	arr[a] = 1;
	while(1)
	{
		if(a%2==0)
		{
			a/=2;
		}
		else
		{
			a = 3*a + 1;
		}
		n++;
		if(arr[a]!=-1)
		{
			cout << n << '\n';
			break;
		}
		arr[a] = n;
	}
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(void){

  map <string , vector<int > > m;
  string s;
  int n;

  while( cin >> s >> n ){
    m[s].push_back(n);
  }

  map<string , vector<int> >::iterator it;
  for( it = m.begin() ; it != m.end() ; it++ ){
    cout << it->first << endl;
    sort(it -> second.begin() , it -> second.end() );
    int i;
    for( i = 0 ; i < it -> second.size() - 1 ; i++ ){
      cout << it -> second[i] << " ";
    }
    cout << it -> second[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
import java.util.Scanner;

public class Main {

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

		int a = N / 10;
		int b = N % 10;
		if(a != 9 && b != 9) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}

	}
}


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

int main() {

	UL X, Y; cin >> X >> Y;
	bool ok = true;
	if (Y % 2) ok = false;
	if (Y < X * 2) ok = false;
	if (Y > X * 4) ok = false;
	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


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

using namespace std;

#define li long long int
#define FOR(i,l,r) for( int i = l-(l>r); i != r-(l>r); i += 1-2*(l>r) )
#define all(X) (X).begin(),(X).end()
#define vi vector<int>
#define vl vector<li>
#define vvi vector<vector<int>>

int nax = 30000;

void upd( li & a, li b ) {
    a = max(a,b);
}

bool comp( vi & a, vi & b ) {
    return a[0]+a[1] < b[0]+b[1];
}

int main() {
    int n; cin>>n;
    vvi B(n,vi(3,0));
    FOR(i,0,n) {
        FOR(j,0,3) cin>>B[i][j];
    }
    sort(all(B),comp);
    vl dp(nax,0);
    vl temp(nax,0);
    FOR(i,0,n) {
        int w = B[i][0], s = B[i][1];
        li v = B[i][2];
        temp = dp;
        FOR(j,0,s+1) {
            upd(temp[j+w],dp[j]+v);
        }
        dp = temp;
    }
    li ans = 0;
    FOR(i,0,nax) ans = max(ans,dp[i]);
    cout<<ans<<"\n";
    return 0;
} 

Measured memory_bytes: 768
def where(cond, A):
    return [ i for i in range(len(A)) if cond(A[i])]

N = int(input())
S = [ input() for _ in range(N) ]
uv = [ where(int, s) for s in S ]

ans = -1
for i in range(N):
    used = [False]*N
    used[i] = True
    cur = {i}
    nxt = set(uv[i])
    k = 1
    while nxt:
        k += 1
        prev = cur
        cur = nxt
        for c in cur:
            used[c] = True
        nxt = set()
        for u in cur:
            for v in uv[u]:
                if v in prev:
                    continue
                elif used[v]:
                    k = -1
                    break
                else:
                    nxt.add(v)
            else:
                continue
            break
        else:
            continue
        break
    else:
        if k > ans:
            ans = k

print(ans)

Measured memory_bytes: 43372
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unordered_set<ll> uset;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=0;i<=n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("unroll-loops")
#pragma gcc target("avx2,see4")
#define M 210
int n;
bool thedge(ll a,ll b){//頂点aと頂点bの間に辺があるか
	string s="";
	rep(i,n)s+="0";
	s[a]=s[b]='1';
	cout<<"? "<<s<<"\n"<<flush;
	ll res;
	cin>>res;
	return res==1;
}
bool thedge_set(set<ll> S,ll x){//独立集合Sのいずれかと頂点xの間に辺があるか
	S.insert(x);
	string s="";
	rep(i,n)s+="0";
	for(auto t:S)s[t]='1';
	cout<<"? "<<s<<"\n"<<flush;
	ll res;
	cin>>res;
	return res>=1;
}

vector<ll> FANS_A,FANS_B;//FANS_A[i]とFANS_B[i]の間に辺がある
void dfs(ll x,set<ll> S){//xとSの間の辺を探す(一つはある）
	if(S.size()==1){
		FANS_A.push_back(x);
		FANS_B.push_back(*S.begin());
		return;
	}
	set<ll> L,R;
	bool flag=0;
	for(auto s:S){
		if(flag)L.insert(s);
		else R.insert(s);
		flag=flag^1;
	}
	if(thedge_set(L,x))dfs(x,L);
	if(thedge_set(R,x))dfs(x,R);
}
int main(){
	cin>>n;
	vector<ll> v[M];//v[d]:=0を根として深さdの頂点のidの集合
	{//2000~4500回でv[]を求める
		v[0].push_back(0);
		set<ll> cand;//まだ決まっていないもの
		for(int i=1;i<n;i++)cand.insert(i);
		for(ll d=0;d<M;d++){
			if(cand.size()==0)break;
			set<ll> cur;
			for(auto x:v[d])cur.insert(x);
			for(auto x:cand){
				if(thedge_set(cur,x)){
					v[d+1].push_back(x);
				}
			}
			for(auto x:v[d+1])cand.erase(x);
		}
	}
	{//dとd+1の間の辺を求める
		for(ll d=0;d<M;d++){
			if(v[d+1].size()==0)break;
			set<ll> A,B;
			for(auto x:v[d])A.insert(x);
			for(auto x:v[d+1])B.insert(x);
			if(A>B)swap(A,B);
			//|A|<=|B|、Aの要素に対して、辺がある方を探す
			/*for(auto x:A){
				dfs(x,B);
			}*/
			for(auto x:A)for(auto y:B){
				if(thedge(x,y)){
					FANS_A.push_back(x);
					FANS_B.push_back(y);
				}
			}
		}
	}
	/*if(n-1!=FANS_A.size()){
		ll x=0,y=0;
		while(1){
			if(x%2==0&&y%2==1)break;
			x++,y++;
		}
		cout<<x<<endl;
	}*/
	cout<<"!";
	for(int i=0;i<n-1;i++){
		cout<<" ("<<FANS_A[i]<<","<<FANS_B[i]<<")";
	}
	cout<<"\n"<<flush;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=998244353;
const int N=3e3+10;
int n,s;
int a[N];
int dp[N][N];
int go(int pos,int m)
{
    if(m>s)
        return 0;
    if(pos==n+1)
    {
        if(m==s)
            return 1;
        return 0;
    }
    int &ans=dp[pos][m];
    if(ans!=-1)
        return ans;
    ans=0;
    ans+=2*go(pos+1,m);
    ans%=MOD;
    ans+=go(pos+1,m+a[pos]);
    ans%=MOD;
    return ans;
}
int32_t main()
{
    IOS;
    cin>>n>>s;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<go(1,0)<<endl;


    
 
}

Measured memory_bytes: 74604
from math import sqrt, factorial
from sys import setrecursionlimit
setrecursionlimit(10000000)

def inpl(): return list(map(int, input().split()))
N = int(input())
S = int(input())

RN = int(sqrt(N)) + 1
RN += ((RN+1)**2 == N)

def func(b, N):
    if b <= 1:
        return -1
    tmp = 0
    while N:
        N, d = divmod(N, b)
        tmp += d
    return tmp

for b in range(2, RN+1):
    tmp = func(b, N)
    if tmp == S:
        print(b)
        break
else:
    for x in range(RN, 0, -1):
        b = (N-S+x)//x
        if func(b, N) == S:
            print(b)
            break
    else:
        if func(S+1, N) == S:
            print(S+1)
        else:
            print(-1)

Measured memory_bytes: 3188
val mod = 1000000007L

fun exp(base:Long, exponent:Long):Long {
    return when(exponent){
        0L -> 1
        1L -> base
        else -> exp(base, exponent / 2).let{it mul it mul exp(base, exponent % 2)}
    }
}
infix fun Long.div(n:Long):Long {
    return this mul exp(n, mod - 2)
}
infix fun Long.mul(n:Long):Long {
    return this * n % mod
}
infix fun Long.mul(n:Int):Long = this mul n.toLong()
infix fun Long.plus(n:Long):Long{
    return (this + n) % mod
}
infix fun Long.minus(n:Long):Long {
    return (this - n) plus mod
}

fun main(args:Array<String>):Unit{
    val N = readLine()!!.toInt()
    val factorial = Array(N + 1){1L}.apply{
        for (i in 1 .. N){
            this[i] = this[i - 1] mul i
        }
    }
    val divFactorial = factorial.mapIndexed{index, fact -> if (index % 2 == N % 2) exp(fact, mod - 2) else 0L}
    val G = Array(N){
        factorial[N - 1] minus (if (it * 2 >= N) (factorial[it - 1] mul factorial[it] mul divFactorial[2 * it - N]) else 0L)
    }
    println((0 until N - 1).map{G[it]}.fold(0L){a, b -> a plus b})
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
  int d, n;
  cin >> d >> n;
  int p=1;
  rep(i, 0, d)p *= 100;
  if(n < 100)cout << n*p << endl;
  else cout << 101*p<< endl;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	// int tmp = N - K;

	int ans = 0;
	if (K > 1){
		ans = N-K;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5;
char s[N*3];
int main(){
	int d=0,S=N-1,t,m,op,f;char s1[2];
	scanf("%s%d",s+N,&m);for(t=N;s[t];t++);
	for(int i=0;i<m;i++){
		scanf("%d",&op);
		if(op==1)d^=1;
		else{
			scanf("%d%s",&f,s1),f--;
			if(f^d)s[t++]=s1[0];
			else s[S--]=s1[0];
		}
	}
	if(d)for(int i=t-1;i>S;i--)putchar(s[i]);
	else for(int i=S+1;i<t;i++)putchar(s[i]);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>

using namespace std;

const int MAXN=100005;

int K;
int T;
vector<int>var(MAXN);

int main(){	
	scanf("%d%d",&K,&T);
	for(int i=0;i<T;++i){
		scanf("%d",&var[i]);
	}
	sort(var.begin(),var.begin()+T);
	int ans;
	if(var[T-1]*2>K){
		ans=var[T-1]-(K-var[T-1]);
		--ans;
		ans=max(ans,0);
	}
	else{
		ans=0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n;
    cin>>n;

    long long int a[n];
    for(long long int i = 0; i < n; i++) cin>>a[i];
    
    sort(a, a+n);
    long long int ans = 1, sum = 0;
    for(long long int i = 0; i < n-1; i++){
        sum = sum + a[i];
        if( 2*sum >= a[i+1] ) ans++;
        else ans = 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
p=list(map(float,input().split()))

mid=(n+2)//2
dp=[[0]*(n+1) for i in range(n)]
dp[0][0]=1-p[0]
dp[0][1]=p[0]

for i in range(n-1):
    for j in range(n+1):
        if dp[i][j]!=0:
            #表が出るとき
            dp[i+1][j+1]+=dp[i][j]*p[i+1]
            #裏
            dp[i+1][j]+=dp[i][j]*(1-p[i+1])
print(sum(dp[-1][mid:]))

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

int	main() {
	int N;
	cin >>N;
	vector<string> S(N+1, "");
	for (int i=1; i<=N; i++) {
		char C;
		cin >>C;
		S.at(i)=C;
	}
	int SS=0;
	for (int i=1; i<=N; i++) {
		if ("("==S.at(i))
			SS++;
		else {
			SS--;
			if (0>SS) {
				S.at(0) +="(";
				SS++;
			}
		}
	}
	while (SS>0) {
		S.at(N) +=")";
		SS--;
	}
	for (int i=0; i<=N; i++)
		cout <<S.at(i);
	cout <<endl;
	return 0;
};


Measured memory_bytes: 256
// In the name of Allah. Ya ali!
#include<bits/stdc++.h>
#define double long double
typedef long long ll;
const ll MAX_N = 2e5+100;
const ll MOD = 1e9+7;
using namespace std;

int a[MAX_N];
set<int> d[50];
map<int,int> cnt;

int main()
{
    int n;
    cin >> n;
    for(int i = 0;i<n;++i)
        cin >> a[i];
    for(int i = 0;i<n;++i)
    {
        int l = log2(a[i]&-a[i]);
        d[l].insert(a[i]);
        cnt[a[i]]++;
    }
    ll ans = 0;
    for(int i = 0;i<50;++i)
    {
        vector<int> vc;
        for(auto x:d[i])
            vc.push_back(x);
        reverse(vc.begin(),vc.end());
        for(auto t:vc)
        {
            if (!cnt[t])
                continue;
            if (log2(t)==(int)log2(t))
            {
                ans+=cnt[t]/2;
                cnt[t] = 0;
                continue;
            }
            ll x = (1ll<<((int)ceil(log2(t))))-1;
            x^=t;
            x++;
            if (cnt[x])
            {
                ll f = min(cnt[x],cnt[t]);
                cnt[t]-=f;
                cnt[x]-=f;
                ans+=f;
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 29296
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
   int A, B;
   cin >> A >> B;
   // int A1 = ceil(A / 0.08);
   // int B1 = ceil(B / 0.1);
   // // cout << A1 << " " << B1 << endl;
   // // if (to_string(A1)[0] != to_string(B1)[0]){
   // //    cout << -1 << endl;
   // // }
   // if ((B - A)>2){
   //    cout << -1 << endl;
   // }
   // else{
   //    cout << max(A1, B1) << endl;
   // }

   for(int i = 1; i < 1010; ++i){
      if ((floor(i*0.08) == A) & (floor(i*0.1) == B)){
         cout << i << endl;
         return 0;
      }
   }
   cout << -1 << endl;

   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define max(a,b) a > b ? a : b

int main(void){
	int n, m, a, h, p, q, flag[1000][100], i, j, k, mx;
	while(1){
		scanf("%d%d%d",&n,&m,&a);
		if(n == 0 && m == 0 && a == 0)
			break;
		memset(flag,-1,sizeof(flag));
		mx = -1;
		a--;
		for(i = 0;i < m;i++){
			scanf("%d%d%d",&h,&p,&q);
			flag[h - 1][p - 1] = q - 1;
			flag[h - 1][q - 1] = p - 1;
			mx = max(mx,h - 1);
		}
		for(i = mx;i >= 0;i--){
			for(j = 0;j < n;j++){
				if(flag[i][a] != -1){
					a = flag[i][a];
					break;
				}
			}
		}
		printf("%d\n",a + 1);
		
	}
	return 0;
}

Measured memory_bytes: 1428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
    string s;
    cin >> s;

    int num=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='1') num++;
    }

    cout << num << endl;

    return 0;
}

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

int main() {
  // input
  string s;  cin >> s;
  
  // judge
  int count_0 = 0, count_1 = 0, ans;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') count_0++;
    if (s[i] == '1') count_1++;
  }
  ans = min(count_0, count_1) * 2;
  
  // output
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);

            long ans = 1;
            for (int i = 0; i < n; i++) {
                ans *= 3;
            }

            long tmp = 1;
            for (int i = 0; i < n; i++) {
                if (a[i] % 2 == 0) {
                    tmp *= 2;
                }
            }

            out.println(ans - tmp);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21460
from fractions import gcd
from functools import reduce
import sys


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

# def lcm_list(numbers, maxvalue):
#     first = 1
#     second = 1
#     for i in numbers:
#         second = i
#         lcm_result = lcm_base(first, second)
#         if lcm_result > maxvalue:
#             return -1
#         first = lcm_result
#     return lcm_result


n, m = map(int, input().split())
A = list(map(int, input().split()))

max_value = 2 * m

try:
    lcm = lcm_list(A)
except:
    print("0")
    sys.exit(0)

if lcm > max_value:
    print("0")
    sys.exit(0)

if lcm == -1:
    print("0")
    sys.exit(0)

if any((lcm / a) % 2 != 1 for a in A):
    print("0")
    sys.exit(0)

max_product = max_value // lcm
print((max_product + 1) // 2)


Measured memory_bytes: 16344
#include <iostream>
#include <string>

using namespace std;

int main() {
    string line1, line2;
    int h, w;
    
    cin >> h >> w;
    
    while(h != 0 || w != 0) {
        for(int i = 0;i < w;i++) {
            if(i % 2 == 0) {
                line1 += "#";
                line2 += ".";
            } else {
                line1 += ".";
                line2 += "#";
            }
        }
        
        for(int i = 0;i < h;i++) {
            if(i % 2 == 0) {
                cout << line1 << endl;
            } else {
                cout << line2 << endl;
            }
        }
        
        cout << endl;
        line1 = line2 = "";
        cin >> h >> w;
    }

    return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int K, N;
    cin >> K >> N;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
    }

    ll ans = INF;
    repd(i, 1, N - 1) {
        ll r = A[i + 1] - A[i] + (K - A[i + 1] + A[i - 1]);
        ll l = A[i] + K - A[i + 1];
        chmin(ans, min(r, l));
    }

    chmin(ans, A[N - 1] - A[0]);
    chmin(ans, A[0] + (K - A[1]));

    chmin(ans, A[N - 2] + (K - A[N - 1]));

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

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int a,b,c,d ;
  cin >> a >> b >> c >> d ;
  
  int e,f,g,h ;
  e = c - (d-b) ;    
  f = d + (c-a) ;
  g = a - (d-b) ;
  h = b + (c-a) ;
  
  cout << e << " " << f << " " << g << " " << h << " " << endl ; 
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    bool one = false;
    rep(i, n) {
        char c;
        cin >> c;
        a[i] = c - '0';
        a[i]--;
        if (a[i]%2==1) one = true;
    }
    if (!one) {
        rep(i, n) a[i] /= 2;
    }
    int ans = a[0] % 2;
    int num = 0, den = 0;
    for (int i=1; i<n; i++) {
        int fact = n - i;
        int factr = i;
        while (fact%2==0) {
            ++num;
            fact /= 2;
        }
        while (factr%2==0) {
            ++den;
            factr /= 2;
        }
        if (den>=num) ans = (ans + a[i]) % 2;
    }
    if (!one) ans *= 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4096
N, Y = list(map(int, input().split()))

for i in range(0, N+1):
  for j in range(0, N+1 - i):
    if i*10000 + j*5000 + (N-i-j)*1000 ==Y:
      print('{} {} {}'.format(i,j,N-i-j))
      exit()

print('-1 -1 -1')
  

Measured memory_bytes: 2940
#include<stdio.h>
int m[10][10];
#define r(i) for(i=0;i<10;i++)
void ink(int x,int y){
	if(x<0 || y<0|| x>9 ||y>9)return;
	m[x][y]++;
}
void show(){
	int i,j;
	r(i){
		r(j)printf("%d",m[i][j]);
		printf("\n");
	}
}
int main(){
	int i,j,c,max,x,y,s;
	r(i)r(j)m[i][j]=0;
	while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
		for(i=s;i>=0;i--){
			if(i==3){ink(x+2,y);ink(x-2,y);ink(x,y-2);ink(x,y+2);}
			else if(i==2){ink(x+1,y+1);ink(x+1,y-1);ink(x-1,y+1);ink(x-1,y-1);}
			else if(i==1){ink(x+1,y);ink(x-1,y);ink(x,y-1);ink(x,y+1);ink(x,y);}
		}
	}
	c=0;max=0;
	r(i)r(j){if(!m[i][j])c++;if(max<m[i][j])max=m[i][j];}
	printf("%d\n%d\n",c,max);
	return 0;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int main() {  // TODO
  int N, K;
  cin >> N >> K;
  int MAXN = N + 5;
  int h[N];
  rep(i, N) cin >> h[i];
  int dp[MAXN];
  rep(i, MAXN) dp[i] = 1e9;
  dp[0] = 0;

  for (int i = 0; i < N; i++) {
    for (int k = 1; k <= K; k++) {
      if (i + k > N) continue;
      dp[i + k] = min(dp[i + k], dp[i] + abs(h[i] - h[i + k]));
    }
  }
  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 4356
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <math.h>

#define MOD 1000000007
#define REP(i,n) for ((i)=0;i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define LL long long
#define ULL unsigned long long

int compare_ll(const void *a, const void *b){
	return *(ULL*)b - *(ULL*)a;
}



int main(void) {

	int a,b,h;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &h);

	printf("%d", ((a+b)*h/2));




	return 0;
}

/* 最後の改行忘れるな！！ */


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#define MAXN ()
#define LL long long
#define ULL unsigned long long
#define pii pair<int, int>
using namespace std;
int main()
{
	LL a, b, c, k;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
	if (k & 1)
		printf("%lld\n", b - a);
	else
		printf("%lld\n", a - b);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;
int n,m;
vector<vector<int>> nei;
int ans=0;
void dfs(int ii,int size,vector<int> dist,int last){
    if(ii==size){
        ans++;
        return;
    }
    for(int i=0;i<nei[last].size();i++){
        if(dist[nei[last][i]]!=-1){
            continue;
        }
        dist[nei[last][i]]=dist[last]+1;
        dfs(ii+1,size,dist,nei[last][i]);
        dist[nei[last][i]]=-1;
    }
}

int main(){    
    cin>>n>>m;
    nei.resize(n);
    vector<int> dist(n,-1);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        nei[a].push_back(b);
        nei[b].push_back(a);
    }
    dist[0]=0;
    dfs(1,n,dist,0);
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	long long q, h, s, d; cin >> q >> h >> s >> d;
	long long n; cin >> n;
	h = min(q * 2, h);
	s = min(h * 2, s);
	if(2 * s <= d) cout << n * s << endl;
	else cout <<  (long long)(n / 2 * d) +(long long)(n  % 2 *s) << endl;
	return 0;	
}





  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int E,Y,ans;
   cin >> E >> Y;
   if(E == 0){
        if(Y <= 1911){
                ans = Y - 1868;
                cout << "M";
        }
        else if(Y <= 1925){
                ans = Y - 1912;
                cout << "T";
        }
        else if(Y <= 1988){
                ans = Y - 1926;
                cout << "S";
        }
        else{
                ans = Y - 1989;
                cout << "H";
        }
        cout << ans + 1 << "\n";
   }
   else{
           if(E == 1) ans = 1868 + Y;
           else if(E == 2)ans = 1912 + Y;
           else if (E == 3)ans = 1926 + Y;
           else ans = 1989 + Y;
           cout << ans - 1 << "\n";
   }
   
}



Measured memory_bytes: 3136
from math import sqrt
N, M = map(int, input().split())
cand = 1
for i in range(1, int(sqrt(M))+1):
    if M % i == 0:
        if M >= (M // i) * N:
            cand = max(cand, M//i)
        elif M >= i * N:
            cand = max(cand, i)
print(cand)

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int n;
    cin >> n;
    V<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    for(int i = 1; i < n-1; i++) {
        int tot = a[i-1] + a[i] + a[i+1];
        if(a[i] == tot - max({a[i-1], a[i], a[i+1]}) - min({a[i-1], a[i], a[i+1]}))
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i, N) {
    cin >> P[i];
  }
  vector<int> Q(N);
  rep(i, N) {
    cin >> Q[i];
  }

  int p;
  int q;

  int i = 1;
  vector<int> v(N);
  iota(v.begin(), v.end(), 1);
  do {
    bool match = true;
    rep(j, N) {
      if (P[j] != v[j])
        match = false;
    }
    if (match)
      p = i;

    match = true;
    rep(j, N) {
      if (Q[j] != v[j])
        match = false;
    }
    if (match)
      q = i;

    i++;
  } while (next_permutation(v.begin(), v.end()));

  cout << abs(p-q) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
#include <vector>
#include <limits.h>
#include <stack>
#include <queue>

using namespace std;

#define PI 3.14159265359
#define INF LLONG_MAX


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

    int A1[N];
    int A2[N];

    // input for A array
    for (int i = 0; i < N; ++i) {
        cin >> A1[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> A2[i];
    }

    // dp
    // simply sum for A1
    for (int j = 1; j < N; ++j) {
        A1[j] += A1[j-1];
    }

    // compare for A2
    int a, b;
    A2[0] += A1[0];
    for (int j = 1; j < N; ++j) {
        // from upper
        a = A2[j] + A1[j];
        // from left
        b = A2[j] + A2[j-1];
        A2[j] = max(a, b);
    }

    cout << A2[N-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

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

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

int main()
{
    ll n,ans=0;
    cin >> n;
    vll b(n-1),c(n);
    rep(i,n-1) cin >> b[i];
    c[0]=b[0];
    c[n-1]=b[n-2];
    REP(i,1,n-1) c[i]=min(b[i],b[i-1]);
    rep(i,n) ans+=c[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>

using namespace std;

#define sz(X) ((int)(X).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define all(X) (X).begin(),(X).end()
#define FOR(i, a, n) for(int i=(a), __ ## i=(n); i<__ ## i; i++)
#define REP(I,N) FOR(I,0,N)
#define PR(X) cout<<#X<<" = "<<(X)<<" "
#define PRL cout<<endl
#define PRV(X) {cout<<#X<<" = {";REP(__prv,sz(X)-1)cout<<(X)[__prv]<<",";if(sz(X))cout<<*(X).end();cout<<"}"<<endl;}

template<class T> ostream &operator<<(ostream &os, const vector<T> &vec)
{
	os << '{';
	REP(i, sz(vec))
	{
		os << vec[i];
		if (i + 1 != sz(vec))
			os << ',';
	}
	os << '}';
	return os;
}

template<class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &par)
{
	os << '(' << par.X << ',' << par.Y << ')';
	return os;
}

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<bool> VB;
typedef vector<unsigned long long> VULL;
typedef vector<vector<int>> VVI;
typedef queue<int> QI;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : abs(x);
}

template<class T> T sqr(T x)
{
	return x * x;
}

int main()
{
	ios::sync_with_stdio(false);

	string s;
	cin >> s;
	int n = s.length();

	int best = 100;
	REP(c, 26)
	{
		int j = 0;
		int cur = 0;
		REP(i, n)
		{
			if (s[i] == c + 97)
			{
				cur = max(cur, j);
				j = 0;
			}
			else
				j++;
		}
		cur = max(cur, j);
		best = min(cur, best);
	}

	cout << best;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007

int main(){
  ll n;
  cin >> n;
  ll a[n],ans=0;
  rep(i,n)cin >> a[i];
  rep(i,n)ans+=a[i]-1;
  cout << ans << endl;
}


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

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

    int count = 1;
    int prev = -1;
    while (n > 0) {
        int rem = n % 10;
        if (rem == prev) {
            count++;
        }
        else {
            prev = rem;
            count = 1;
        }
        if (count >= 3) break;

        n /= 10;
    }
    cout << (count >= 3 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int h,i;
  int A[250];
  
  scanf("%d",&h);
  for(i=1;i<=h;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i!=1){printf("parent key = %d, ",A[i/2]);}
    if(i*2<=h){printf("left key = %d, ",A[2*i]);}
    if(i*2+1<=h){printf("right key = %d, ",A[2*i+1]);}
    printf("\n");
  }
  return 0;
}

	
      

  

  



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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (i==n-1?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, r;
string s;
map<char,bool> m;

signed main() {
	cin >> n;
	rep(i,n) {
		cin >> s;
		if (!m[s[0]]) r++;
		m[s[0]] = true;
	}
	if (r==3) cout << "Three" << ln;
	else cout << "Four" << ln;
}

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

bool check = true;

int main(){
    int a,b;
    string s;
    cin >> a >> b >> s;
    for(int i=0;i<a;i++)if(s[i]>'9'||s[i]<'0')check=false;
    if(s[a]!='-')check=false;
    for(int i=a+1;i<s.size();i++)if(s[i]>'9'||s[i]<'0')check=false;
    if(check)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
vector<int>vec;
  vec={3,0,1,0,2,0,2,0,0,2,0,2,0};
  int X,Y;
  cin >>X>>Y;
  if(vec[X]==vec[Y]){
    cout <<"Yes";
  }
  else{
    cout <<"No";
  }
     

}
 

Measured memory_bytes: 256
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(6);

  map<string,int> nums;

  int a;
  char del;
  string blood;
  while(cin>>a>>del>>blood){
    nums[blood]++;
  }

  cout << nums["A"] << endl;
  cout << nums["B"] << endl;
  cout << nums["AB"] << endl;
  cout << nums["O"] << endl;
  return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>
int main(void)
{
	int m,f,b;
	scanf("%d %d %d",&m,&f,&b);
	if(m>=b){
		printf("%d\n",0);
	}
	else	if(m+f<b){
		printf("NA\n");
	}
	else	if(m+f>=b){
		printf("%d\n",b-m);
	}
	return 0;
}
	


Measured memory_bytes: 2708
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
using namespace std::chrono;
long long int p=1e9 +7;
int n;
bool compatibility[21][21];
ll ans[1ll<<21];
ll solve(int N,int left){
    ll currans=0;//initialise with 0
    if(ans[left]!=-1){//check if we have already found the answer
        return ans[left];
    }
    if(N==1){
        for(int j=0;j<n;j++){
            int x=1<<j;
            if(left & x){//check if the jth women is left
                if(compatibility[N-1][j]){ 
                    ans[left]=1;
                    return 1;//If they are compatible return 1
                }
                else{
                    ans[left]=0;
                    return 0;//If the last 2 aren't compatible return 0
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        if(left & (1ll<<i)){//If the ith women is left
            if(compatibility[N-1][i]){//If the 2 are compatible
            currans+=solve(N-1,left - (1ll<<i));
            //Find the number of pairs after pairing them
            //and add all of them
            }
        }
    }
    currans%=p;//mod p
    ans[left]=currans;//memoise
    return ans[left];
}
ll solve(){
    cin>>n;
    for(int j=0;j<(1ll<<n);j++){
       ans[j]=-1;//memoisation initialisation
            //ans[i][j] represents i people left and
            //j is the bitmask for women left
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>compatibility[i][j];
        }
    }
    return solve(n,(1<<n)-1);//all men available, all women available because all bits set in mask
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout<<solve()<<"\n";
}

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

int N, A[200001];

int main() {
    cin >> N;
    int j;
    for (int i = 1; i < N; i++) {
        cin >> j;
        A[j]++;
    }
    for (int i = 1; i <= N; i++) {
        cout << A[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 4312
import java.util.*;
     
    public class Main {
        public static void main(String[] args) {
            // Your code here!
            Scanner sc = new Scanner(System.in);
            String line = sc.nextLine();
            String[] nt = line.split(" ");
            int n = Integer.parseInt(nt[0]);
            int t = Integer.parseInt(nt[1]);
            
            String rel = "TLE";
            for (int i = 0; i < n; i++) {
                String keiro = sc.nextLine();
                String[] k = keiro.split(" ");
                if (Integer.parseInt(k[1]) <= t) {
                    if (rel.equals("TLE")) {
                        rel = String.valueOf(k[0]);
                    } else if (Integer.parseInt(rel) > Integer.parseInt(k[0])) {
                        rel = String.valueOf(k[0]);
                    }
                }    
            }
            System.out.println(rel);
            sc.close();
        }
    }

Measured memory_bytes: 22996
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
void solve();

ll n;

int main(){
	solve();
	return 0;
}
void solve(){
	cin>>n;
	ll x4=0,x2=0,odd=0,buf=0;
	bool ans=false;
	for(ll i=0;i<n;i++){
		cin >>buf;
		if(!(buf%4)){x4++;}
		else if(!(buf%2)){x2++;}
		else{odd++;}
	}
	if(x2){
		ans=(x4>=odd);
	}
	else{
		ans=(x4>=(odd-1));
	}
	cout <<(ans?"Yes":"No")<<endl;
}	

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int a, b;
   string s;
   cin >> a >> b >> s;

   bool is_ok = true;

   if(s.size() != a + b + 1){
      is_ok = false;
   }
   for(int i = 0; i < s.size(); i++){
      if(i == a){
         if(s[a] != '-'){
            is_ok = false;
         }
      }
      else{
         if(not(s[i] == '0'||
            s[i] == '1'||
            s[i] == '2'||
            s[i] == '3'||
            s[i] == '4'||
            s[i] == '5'||
            s[i] == '6'||
            s[i] == '7'||
            s[i] == '8'||
            s[i] == '9')){
            is_ok = false;
         }
      }
   }
   cout << (is_ok ? "Yes" : "No") << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  int x = (N + 999)/1000;

  cout << 1000 * x - N << endl;
  
  return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
#include<cmath>
#define ll long long
#define N 105
#define inf 0x3fffffff
#define rep(i, l, r) for(int i=l; i<=r; ++i)
using namespace std;
int n;
struct node{
    int x, y;
    ll h;
    void read(){scanf("%d%d%lld", &x, &y, &h);}
}a[N];
int main(){
    scanf("%d", &n);
    int pos=1;
    rep(i, 1, n){
        a[i].read();
        if(a[i].h) pos=i;
    }
    rep(cx, 0, 100){
        rep(cy, 0, 100){
            ll h=a[pos].h+abs(cx-a[pos].x)+abs(cy-a[pos].y);
            bool f=true;
            rep(i, 1, n){
                if(a[i].h!=max(h-abs(cx-a[i].x)-abs(cy-a[i].y), 0ll)) f=false;
            }
            if(f){
                printf("%d %d %d", cx, cy, h);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <algorithm>
using namespace std;

using ll = long long;

#define MOD 1000000007

#define FOR(i, m, n) for (ll i = m; i <= n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)

ll gcd(ll a, ll b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll A[110];

int main() {
    ll N, M;
    cin >> N >> M;
    FOR(i, 1, N) cin >> A[i];

    sort(&A[1], &A[N + 1], greater<ll>());

    ll V = 0;

    FOR(i, 1, N) V += A[i];
    
    ll ans = 0;

    FOR(i, 1, N) {
        if (V % (4 * M) == 0 && A[i] >= V / (4 * M) || V % (4 * M) != 0 && A[i] > V / (4 * M)) ans++;
        else break;
    }

    cout << (ans >= M ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;

int nums[105];

void trace(int n) {
    for (int i = 0; i < n - 1; ++i) {
        printf("%d ", nums[i]);
    }
    printf("%d\n", nums[n - 1]);
}

int cnt;

void select_sort(int n) {
    for (int j = 0; j < n - 1; ++j) {
        int index = j;
        for (int i = j + 1; i < n; ++i) {
            if(nums[index] > nums[i]) index = i;
        }
        if(index != j) {
            ++cnt;
            int tmp = nums[index];
            nums[index] = nums[j];
            nums[j] = tmp;
        }
    }
}

int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }
    if(1 == n) {
        printf("%d\n", nums[0]);
        cout << "0" << endl;
    } else {
        select_sort(n);
        trace(n);
        cout << cnt << endl;
    }

    return 0;
}



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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using v = vector<T>;
template <class T>
using vv = v<v<T>>;
#define ALL(c) (c).begin(), (c).end()

int main()
{
    int N;
    cin >> N;
    v<ll> A(N);

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

    ll ans = 0;

    for (int i = 1; i < N; i++)
    {
        ll dif = A[i - 1] - A[i];
        if(dif>0){
            ans+=dif;
            A[i]+=dif;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4852