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

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef pair <ll, dl> iii;
typedef vector <ii> vii;
typedef vector <vi> graph;

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll mcm(ll a, ll b) {return (b * a) / gcd(a, b);}

bool comp(int a, int b) {
	return a > b;
}

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

	int n, k;
	cin >> n >> k;
	int in;
	bitset <15> p;
	p.reset();
	for (int i = 0; i < k; ++i)
	{
		cin >> in;
		p[in] = true;
	}
	bool band = true;
	int div = 1;
	for (; band; n++) {
		div = 1;
		band = false;
		while (div <= n) {
			if (p[(n / div) % 10]) {
				band = true;
				break;
			}
			div *= 10;
		}
	}
	n--;
	cout << n << "\n";
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod.m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


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

    int R_num=0;
    int ans=0;
    rep(i,n){
        if(c[i] == 'R') R_num++;
    }
    rep(i,R_num){
        if(c[i] == 'W') ans++;
    }
    cout << ans << endl;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> l(m), r(m);
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i];
  }
  int x = *max_element(begin(l), end(l));
  int y = *min_element(begin(r), end(r));
  cout << max(y - x + 1, 0) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<cstring>
#include<cmath>
using namespace std;
typedef pair<int,int> P;
int main(){
  string a0,s;
  int L,value[10000],cost,len,stoi,smax,smin,I,J;
  char trans[10000];
  map<string,P> mep;
  while(true){
    cin >> a0 >> L;
    if(a0 == "0" && L == 0)break;
    I=J=cost=0;
    mep.clear();
    while(true){
      s.clear();
      cost = 0;
      len = a0.length();
      if(I!=0){
      mep[a0].first++;
      if(mep[a0].first == 2){
	cout << mep[a0].second << " " << a0 <<" " << I-mep[a0].second << endl;
	break;
      }
      mep[a0].second = I;
      }

      //cout << "L = " << L << ", len = "<< len << ", L-len = " << L-len << endl;
      if(L-len > 0){
	for(int i=0;i<L;i++){
	  if(L-a0.length() >i){
	    s+="0";cost++;
	  }else{
	    s+=a0[i-cost];
	  }
	}
	a0 = s;
	len = a0.length();  //cout << "s =" <<  s << endl;
      }
    
      len = L;
      if(I == 0){
      mep[a0].first++;
      if(mep[a0].first == 2){
	cout << mep[a0].second << " " << a0 <<" " << I-mep[a0].second << endl;
	break;
      }
      mep[a0].second = I;
      }
    
      
      //cout << "value = ";
      for(int i=0;i<len;i++){
	value[i] = a0[i]-'0';
	//cout << value[i];
      }
      //cout << endl;
      
      sort(value,value+len);
      stoi=0;
      for(int i=0;i<len;i++){
	stoi += value[i]*pow(10,i);
      }
      smax = stoi;
      //cout << "smax = " << smax << endl;
      sort(value,value+len,greater<int>() );
      stoi=0;
      for(int i=0;i<len;i++){
	stoi += value[i]*pow(10,i);
      }
      smin = stoi;
      //cout << "smin = " << smin << endl;
      sprintf(trans,"%d",smax-smin);
      a0.clear();
      for(int i=0;i<strlen(trans);i++){
	a0+=trans[i];
      }
      //cout << "a0 = " << a0 << endl;
      I++;
    }

  }
  return 0;
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  if(K<A+1){
    cout << K << endl;
  }
  else if(K<A+B+1){
    cout << A << endl;
  }
  else {
    cout << A+A+B-K << endl;
  }
}


Measured memory_bytes: 3624
#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;
typedef int ll;
 
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
 
 
const ll N = 500002;
const ll mod = 1000000007;
const long long int inf = INT64_MAX;
#define pp pair<ll,ll>

typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
 
const ld pi = 3.14159265359;
 
 
void fastIO(void);
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);


int main()
{
	fastIO();
	ll n;
	cin>>n;
	cout<<(n+1)/2<<endl;
}


	


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define INF 100000000000000ll
#define MAX 100000
typedef long long ll;
using namespace std;
int main(){
  ll n,w;
  ll tv,tw;
  vector<vector<ll>> dp(101,vector<ll>(MAX+1,INF));
  cin >> n >> w;
  for(int i=0;i<101;i++){
    dp[i][0]=0;
  }
  for(int i=1;i<=n;i++){
    cin >> tw>>tv;
    for(int j=0;j<=MAX;j++){
      dp[i][j]=dp[i-1][j];
      if(j-tv>=0&&dp[i-1][j-tv]!=INF){
        dp[i][j]=min(dp[i][j],dp[i-1][j-tv]+tw);
      }
    }
  }
  for(int i=MAX;i>=0;i--){
    if(dp[n][i]!=INF&&dp[n][i]<=w){
      cout << i<<endl;
      break;
    }
  }
}


Measured memory_bytes: 80380
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int count=0;
    int answer = 0;
    REP(i,3){
        if(s[i]=='R')count++;
        else{
            answer = max(answer,count);
            count = 0;
        }
    }
    answer = max(answer,count);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define maxn 500005
#define ll long long
#define pdl pair<double,ll>
#define endl '\n'
using namespace std;
pdl deq[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,L;
	cin >> n >> L;
	int l = 0 , r = 0;
	ll sum_t = 0 , sum_v = 0;
	for(int i=1,t,v;i<=n;i++) {
		cin >> t >> v;
		while(l + 1 < r && deq[l+1].second + sum_v + v >= L)	l++;
		if(l < r && deq[l].second + sum_v + v > L) {
			double T = deq[l].first + sum_t - (l + 1 < r ? deq[l+1].first + sum_t : 0);
			int V = deq[l].second + sum_v - (l + 1 < r ? deq[l+1].second + sum_v : 0);
			int sub_V = deq[l].second + sum_v - (L - v);
			double base = T / V;
			deq[l].first -= base * sub_V;
			deq[l].second -= sub_V;
		}
		deq[r++] = pdl{-sum_t,-sum_v};
		sum_t += (ll)t * v;		sum_v += v;
		cout << fixed << setprecision(7) << (deq[l].first + sum_t) / (deq[l].second + sum_v) << endl;
		while(l < r - 1 && (deq[r-2].first + sum_t) / (deq[r-2].second + sum_v) > (deq[r-1].first + sum_t) / (deq[r-1].second + sum_v))	r--;
	}
	return 0;
}


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

using namespace std;

int main(){
	int n, cnt = 0;
	string s, t;
	cin >> n >> s >> t;
	for(int i = 0; i < n; i++){
		for(int j = 0; s[i + j] == t[j]; j++){
			if(i + j == (n - 1)){
				cnt = j + 1;
				break;
			}
		}
		if(cnt) break;
	}
	cout << 2 * n - cnt << endl;
	return 0;
}

Measured memory_bytes: 256
//http://abc054.contest.atcoder.jp/tasks/abc054_c
//https://book.mynavi.jp/manatee/detail/id=65960
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
typedef long long ll;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
int n,m,a,b;

bool con[8][8]={}; //con[i][j]:=iとjがつながっているか。
bool stay[8]={}; //既に訪問したか。

int dfs(int now,int d){ //今いる頂点(now), 深度(d)
	if(stay[now]) return 0;
	if(d==n) return 1;
	
	stay[now]=true;
	
	int c=0;
	REP(i,0,n) if(con[now][i]) c+=dfs(i,d+1);
	
	stay[now]=false;
	
	return c;
}
	
int main(){
	cin >> n >> m;
	REP(i,0,m){
		cin >> a >> b;
		con[a-1][b-1]=con[b-1][a-1]=true;
	}
	
	cout << dfs(0,1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
char a;
  cin >> a;
  if(a == 'A')cout << 'T' << endl;
  if(a == 'T')cout << 'A' << endl;
  if(a == 'G')cout << 'C' << endl;
  if(a == 'C')cout << 'G' << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A =sc.nextInt();
    int B =sc.nextInt();
    int array[] = new int[5];
    int cnt = 0;
   for(int i=A; i<=B; i++){
     int n =i;
     int index =0;
     while(n>0){
       array[index] = n%10;
       n=n/10;
       index++;
     }
     if(array[0]==array[4] && array[1] == array[3]){
     cnt++;
     }
   }
    System.out.println(cnt);
  }
}

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

struct Data {
	int n;
	string name;
};

int main() {
	int N;
	int timeStep;
	int time = 0;
	queue<Data> datas;
	queue<Data> ends;

	cin >> N;
	cin >> timeStep;

	for (int i = 0; i < N; i++) {
		Data buf;
		cin >> buf.name >> buf.n;
		datas.push(buf);
	}

	while (!datas.empty()) {
		Data d = datas.front();

		time += min(d.n, timeStep);
		d.n -= timeStep;

		if (d.n <= 0) {
			Data temp;
			temp.name = d.name;
			temp.n = time;
			ends.push(temp);
		}
		else {
			datas.push(d);
		}

		datas.pop();
	}

	while (!ends.empty()) {
		cout << ends.front().name << " " << ends.front().n << endl;
		ends.pop();
	}
	return 0;
}

Measured memory_bytes: 6128
#include <stdio.h>

int  main(void)
{
	int a,b;
	int sum=0;
	
	scanf("%d%d",&a,&b);
	
	for(int i=0;i<2;i++){
		
		if(a>b){
			sum=sum+a;
			a=a-1;
		}else{
			sum=sum+b;
			b=b-1;
		}
		
	}
	
	printf("%d\n",sum);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b;
  cin >> a >> b;
  a %= 3;
  b %= 3;
  ll c = a + b;
  c %= 3;
  if(a*b*c == 0)cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int x;
	int now1=1,now2=0;
	int ans1=0,ans2=0;
	for(x=0;x<a.size();x++)
	{
		if(now1==a[x]-'0')
		{
			ans1++;
		}
		if(now2==a[x]-'0')
		{
			ans2++;
		}
		now1++;
		now2++;
		now1%=2;
		now2%=2;
	}
	cout<<min(ans1,ans2)<<endl;
}

Measured memory_bytes: 512
S = input()
N = len(S)
dp = [[0] * 13 for _ in range(N + 1)]
dp[0][0] = 1
mod = 10 ** 9 + 7

for i in range(N):
    c = S[i]
    c = '?' if c == '?' else int(c)

    if c == '?':
        for c in range(10):
            for j in range(13):
                dp[i + 1][(j * 10 + c) % 13] += dp[i][j]
    else:
        for j in range(13):
            dp[i + 1][(j * 10 + c) % 13] += dp[i][j]

    for j in range(13):
        dp[i + 1][j] %= mod

print(dp[N][5])


Measured memory_bytes: 61788
import itertools

N = int(input())
p = list(list(map(int,input().split()))for _ in range(N))

orders = list(itertools.permutations(range(N),N))
dist = 0
for i in range(N-1):
    for j in range(i+1,N):
        dist += ((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)**0.5
ans = dist*2/N
print(ans)

Measured memory_bytes: 8180
k=int(input())
l=list(map(str,range(1,10)))
for i in range(k):
    x=l[i][-1]
    if x=='0':
        l.append(l[i]+x)
        l.append(l[i]+'1')
    elif x=='9':
        l.append(l[i]+'8')
        l.append(l[i]+x)
    else:
        n=int(x)
        l.append(l[i]+str(n-1))
        l.append(l[i]+x)
        l.append(l[i]+str(n+1))
print(sorted(map(int,l))[k-1])

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<int> t(101);
    for (int i = a; i <= b; i++)
        t[i]++;
    for (int i = c; i <= d; i++)
        t[i]++;

    int cnt = 0;
    rep(i, 101)
    {
        if (t[i] == 2)
            cnt++;
    }
    if (cnt > 0)
        cnt--;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=103;
const ll INF=1LL<<61;
vector<int> G[MAX];
int devide[MAX];

void solve(int u,int p,int depth){
    
    int cnt=0;
    
    for(int to:G[u]){
        if(to==p) continue;
        
        solve(to,u,depth+1);
        cnt++;
    }
    
    devide[depth]=max(devide[depth],cnt);
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    
    vector<pair<int,int>> E(N-1);
    for(int i=0;i<N-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
        
        E[i]={a,b};
        
    }
    
    pair<ll,ll> ans={INF,INF};
    
    if(N==2) ans={1,2};
    
    for(int i=0;i<N;i++){
        memset(devide,-1,sizeof(devide));
        
        solve(i,-1,0);
        
        pair<ll,ll> p={0,1};
        
        for(int j=0;;j++){
            if(devide[j]==-1) break;
            else if(devide[j]==0){
                p.first++;
            }else{
                p.first++;
                p.second*=devide[j];
            }
        }
        
        ans=min(ans,p);
        
        //cout<<p.first<<" "<<p.second<<endl;
    }
    
    for(int i=0;i<N-1;i++){
        for(int j=0;j<=N;j++){
            G[j].clear();
        }
        
        for(int j=0;j<N-1;j++){
            if(i==j) continue;
            int a=E[j].first,b=E[j].second;
            
            G[a].push_back(b);
            G[b].push_back(a);
        }
        int a=E[i].first,b=E[i].second;
        G[N].push_back(a);
        G[N].push_back(b);
        G[a].push_back(N);
        G[b].push_back(N);
        
        memset(devide,-1,sizeof(devide));
        
        solve(N,-1,0);
        
        pair<ll,ll> p={-1,1};
        
        for(int j=0;;j++){
            if(devide[j]==-1) break;
            else if(devide[j]==0){
                p.first++;
            }else{
                p.first++;
                p.second*=devide[j];
            }
        }
        
        ans=min(ans,p);
        
        //cout<<a<<" "<<b<<" "<<p.first<<" "<<p.second<<endl;
    }
    
    cout<<ans.first<<" "<<ans.second<<endl;
}



Measured memory_bytes: 384
package main

import "fmt"

const M = 1000000007

func main() {
	var s int
	fmt.Scan(&s)
	fmt.Println(solve(s))
}

func solve(s int) int64 {
	dp0 := make([]int64, s+1)

	for i := 3; i <= s; i++ {
		dp0[i] = 1
	}

	for min := 3; min < s; min += 3 {
		dp1 := make([]int64, s+1)
		dp1[s] = dp0[s]

		for i := min; i <= s-3; i++ {
			for j := 3; i+j <= s; j++ {
				dp1[i+j] = (dp1[i+j] + dp0[i]) % M
			}
		}
		dp0 = dp1
	}

	return dp0[s]
}


Measured memory_bytes: 6060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define INF (1e9)
typedef long long int ll;

using namespace std;
int N, W;
int w[101], v[101];
ll dp[101][100001];
int main(void){
    cin >> N >> W;
    rep(i,N) scanf("%d %d",&w[i+1], &v[i+1]);

    for(int i=1;i<=N;i++) for(int j=1;j<=W;j++){
        if(j >= w[i])
            dp[i][j] = max(dp[i-1][j-w[i]] + v[i], dp[i-1][j]);
        else
            dp[i][j] = dp[i-1][j];
    }

    cout << dp[N][W] << endl;
    return 0;
}



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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 100002
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

int main() {
	inn(h, a);

	out(h / a + (h % a ? 1 : 0));

	return 0;
}


Measured memory_bytes: 256
N, Q = map(int, raw_input().split())
possible = [False for _ in xrange(N)]
possible[0] = True
possible[1] = True
A = 0

for q in xrange(Q):
    a, b = map(lambda x:int(x)-1, raw_input().split())
    if a == A:
        A = b
    elif b == A:
        A = a
    possible[a], possible[b] = possible[b], possible[a]
    possible[max(0, A-1)] = True
    possible[min(N-1, A+1)] = True

print sum(possible)


Measured memory_bytes: 3688
#pragma GCC optimize("Ofast")  
#include<bits/stdc++.h>
using namespace std;

#define ll 				long long
#define eb 				emplace_back
const long long 		MOD = 1e9 + 7;
#define rep(i,n) 		for (int (i) = 0; (i) < (n); (i)++) 
#define REP(i,k,n)  	for (int (i) = (k); (i) <= (n); (i)++) 
#define REPR(i,k,n) 	for (int (i) = (k); (i) >= (n); (i)--)
#define watch(x) 		cout << (#x) << " = " << (x) << endl
#define t(x)			int x; cin >> x; while(x--)

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	
	/*---- continue Coding ;----*/

	int n;
    cin >> n;
    string a[n];
    int b[4] = {0};
    rep(i, n) cin >> a[i];
    rep(i, n){
        if(a[i] == "AC"){
            b[0]++;
        }else if(a[i] == "WA"){
            b[1]++;
        }else if(a[i] == "TLE"){
            b[2]++;
        }else if(a[i] == "RE"){
            b[3]++;
        }
    }
    cout << "AC x " << b[0] << "\n";
    cout << "WA x " << b[1] << "\n";
    cout << "TLE x " << b[2] << "\n";
    cout << "RE x " << b[3] << "\n";
	
	/*---- break ;----*/

	cerr<<"Execution time: "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
	return 0;
}

Measured memory_bytes: 6912
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10,mo=1000000007;
ll a[maxn],A,B;
int tree[maxn*4],f[maxn];
int i,j,k,l,r,t,n,m,ans;
void change(int p,int l,int r,int a,int b){
	if (l==r){
		(tree[p]+=b)%=mo;
		return;
	}
	int mid=(l+r)/2;
	if (a<=mid) change(p*2,l,mid,a,b);else change(p*2+1,mid+1,r,a,b);
	tree[p]=(tree[p*2]+tree[p*2+1])%mo;
}
int query(int p,int l,int r,int a,int b){
	if (a>b) return 0;
	if (l==a&&r==b) return tree[p];
	int mid=(l+r)/2;
	if (b<=mid) return query(p*2,l,mid,a,b);
	else if (a>mid) return query(p*2+1,mid+1,r,a,b);
	else return (query(p*2,l,mid,a,mid)+query(p*2+1,mid+1,r,mid+1,b))%mo;
}
int main(){
	scanf("%d%lld%lld",&n,&A,&B);
	if (A<B) swap(A,B);
	fo(i,1,n) scanf("%lld",&a[i]);
	a[0]=-A;
	a[n+1]=a[n]+A;
	f[0]=1;
	change(1,0,n,0,f[0]);
	l=0;r=0;
	fo(i,1,n+1){
		while (a[i]-a[r+1]>=A) r++;
		if (i>=2&&a[i-1]-a[i-2]<B) l=i-2;
		if (a[i]-a[i-1]>=A) f[i]=f[i-1];
		(f[i]+=query(1,0,n,l,min(i-2,r)))%=mo;
		if (i<=n&&a[i+1]-a[i-1]>=B) change(1,0,n,i,f[i]);
	}
	ans=f[n+1];
	(ans+=mo)%=mo;
	printf("%d\n",ans);
}

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

int main() {
    // 入力
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    for(;;){
        c-=b;
        if(c<=0){
            cout << "Yes";
            return 0;
        }
        a-=d;
        if(a<=0){
            cout << "No";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3584
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt(), w=sc.nextInt();
    String frame="";
    for(int i=1; i<=w+2; i++){
      frame +="#";
    }
    System.out.println(frame);
    for(int i=0; i<h;i++){
      String[] pic = sc.next().split("");
      System.out.print("#");
      for(int j=0; j<w; j++){
        System.out.print(pic[j]);
      }
      System.out.println("#");
    }
    System.out.println(frame);
  }
}

Measured memory_bytes: 22600
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
A_dic = defaultdict(int)

for i in A:
  A_dic[i] += 1

S = sum([(i*(i-1))//2 for i in list(A_dic.values()) if i >= 2])

for i in range(N):
  print(S - A_dic[A[i]] + 1)

Measured memory_bytes: 27036
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int kmaxN = 10000 + 10;
char c[kmaxN];
int mark1,mark2;

int main()
{
	cin >> c;
	int l = strlen(c);
	for(int i = 0;i < l;i++)
	{
		if(c[i] == 'C')
			mark1 = 1;
		if(mark1 == 1 && c[i] == 'F')
		{
			mark2 = 1;
			break;
		}
	}
	if(mark1 == 1 && mark2 == 1)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%MOD;
        a=a*a%MOD;
        b/=2;
    }
    return ans;
}

ll comb(ll a,ll b){
    ll ans=1;
    for(ll i=a;i>a-b;i--){
        ans=ans*i%MOD;
    }
    for(ll i=1;i<=b;i++){
        ans=(ans*rui(i,MOD-2))%MOD;
    }
    return ans;
}
 
signed main()
{
  ll x,y; cin>>x>>y;
  if((x+y)%3!=0){
    cout<<0<<endl;
    return 0;
  }
  ll a=(2*y-x)/3;
  ll b=(2*x-y)/3;
  
  if(x-2*b<0||y-2*a<0){
    cout<<0<<endl;
    return 0;
  }
  
  cout<<comb(a+b,a)<<endl;
}


Measured memory_bytes: 256
a, b, c, d = list(map(int, input().split()))

ans = []

if b <= 0 and d <= 0:
    ans.append(a*c)
if b < 0 and d >= 0:
    ans.append(max(c,1)*b)
if b >= 0 and d < 0:
    ans.append(max(a,1)*d)

ans.append(max(b*d, a*c))

print(max(ans))

Measured memory_bytes: 9188
#include<iostream>
#include<cmath>
using namespace std;
 int main(){
	long long x;
	cin>>x;
for(long long i=-1000;i<1000;i++){
	for(long long j=-1000;j<1000;j++){
		if(j*j*j*j*j-i*i*i*i*i==x){
			cout<<j<<" "<<i;
			return 0;
		}
	}
}
}

Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		int[] seq = null;
		
		try {
			seq = getSequence();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		seq = bubbleSort(seq);
	}
	
	public static int[] bubbleSort(int[] seq) {
		int count = 0;
		for (int i = 0; i < seq.length; i++) {
			final int check = count;
			int key = seq[0];
			for (int j = 1; j < seq.length-i; j++) {
				if (key <= seq[j]) {
					key = seq[j];
				} else {
					seq[j-1] = seq[j];
					seq[j] = key;
					count++;
				}
			}
			
			if (check == count) break;
		}
		
		printArray(seq);
		System.out.println(count);
		return seq;
	}
	
	public static void printArray(int[] seq) {
		StringBuilder p = new StringBuilder();
		String lb = System.getProperty("line.separator");
		
		for (int i = 0; i < seq.length; i++) {
			p.append(seq[i]).append(i < seq.length-1 ? " " : lb);
		}
		System.out.print(p);
	}
	
	public static int[] getSequence() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		final int n = Integer.parseInt(reader.readLine());
		final String[] line = reader.readLine().split(" ");
		reader.close();
		
		final int[] seq = new int[n];
		for (int i = 0; i < seq.length; i++) {
			seq[i] = Integer.parseInt(line[i]);
		}
		
		return seq;
	}
}

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

int N,A[4010],B[4010] = {0},W[4010] = {0};
int dp[2010][2010] = {{0}},Bcost[2010][4010] = {{0}},Wcost[2010][4010] = {{0}};
//dp[i][j]:黒をi個，白をj個並べたときの最適値,Bcost[i][j]:位置jまでに黒の番号iより大きいのボールがいくつあるか
char C[4010];

int main(){
	cin >> N;
	for(int i=1;i<=2*N;i++){
		cin >> C[i] >> A[i];
		if(C[i]=='B') B[A[i]] = i;
		else W[A[i]] = i;
	}
	for(int i=0;i<=N+1;i++){
		for(int j=0;j<=2*N;j++){
			Bcost[i][j+1] = Bcost[i][j] + (C[j]=='B'&&A[j]>i);
			Wcost[i][j+1] = Wcost[i][j] + (C[j]=='W'&&A[j]>i);
		}
	}
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			dp[i][j] = 1e9;
		}
	}
	dp[0][0] = 0;
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			if(i>=1) dp[i][j] = min(dp[i-1][j]+Bcost[i][B[i]+1]+Wcost[j][B[i]+1],dp[i][j]);
			if(j>=1) dp[i][j] = min(dp[i][j-1]+Wcost[j][W[j]+1]+Bcost[i][W[j]+1],dp[i][j]);
		}
	}
	cout << dp[N][N] << endl;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
string s,t;
cin>>s>>t;
int j=0;
rep(i,s.size()){
if(s[i]!=t[j]){
  j++;
}
j++;
}
//cout<<j<<endl;
if(j==s.size()-1||j==s.size()){
  cout<<"Yes"<<endl;
}
else
{
  cout<<"No"<<endl;
}

  return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

int fn(string s, lli k) {
  if (k == 0) return s[0] - '0';
  if (s[0] == '1') return fn(s.substr(1), k - 1);
  return s[0] - '0';
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  lli k;
  while (cin >> s >> k) {
    --k;
    cout << fn(s, k) << endl;
  }

  return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  cout << a * b / g << endl;
  return 0;
}


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

int main()
{
    lld N;
    cin >> N;
    vector<pair<lld, lld> > v(N);
    lld ans = 0;
    for(lld i = 0; i < N; i++) {
        cin >> v[i].first;
    }
    for(lld i = 0; i < N; i++) {
        cin >> v[i].second;
        ans += max(v[i].first - v[i].second, 0LL);
    }
    cout << ans;
}

Measured memory_bytes: 256
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long

class NCR{
  private:
    //MOD need to be prime number
    static const ll MAX = 1000000;
    static const ll MOD = 1000000007;
    ll fac[MAX],finv[MAX],inv[MAX];
  public:
    void COMinit(){
      fac[0] = fac[1] = 1LL;
      finv[0] = finv[1] = 1LL;
      inv[1] = 1LL;
      for(int i = 2 ; i < MAX ; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
      }
    }
    ll COM(int n,int k){
      if(n < k) return 0;
      if(n < 0 || k < 0){
        return 0;
      }
      return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
    }
};

bool is_integer(double x){
	return floor(x) == x;
}
int X,Y;
//here begins your code
signed main(){
  //std::ios::sync_with_stdio(false);
  //std::cin.tie(0);
  cin >> X >> Y;
  double n = (double)(2 * Y - X) / 3.0;
  double m = (double)(2 * X - Y) / 3.0;


  if(!is_integer(n) || !is_integer(m)){
  	cout << 0 << endl;
  	return 0;
  }
  if(n < 0 || m < 0){
  	cout << 0 << endl;
  	return 0;
  }
  NCR *ncr = new NCR();
  ncr -> COMinit();
  cout << ncr -> COM(n + m, m) << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007

using namespace std;

int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int x, n, t;
    cin >> x >> n;
    if (n == 0)
        cout << x << "\n";
    else
    {
        int arr[101];
        memset(arr, 0, sizeof(arr));
        for (int i = 0; i < n; i++)
        {
            cin >> t;
            arr[t]++;
        }
        int a = 101, b = 0;
        for (int i = x; i < 101; i++)
        {
            if (arr[i] == 0)
            {
                a = i;
                break;
            }
        }
        for (int i = x; i >= 0; i--)
        {
            if (arr[i] == 0)
            {
                b = i;
                break;
            }
        }
        if (x - b <= a - x)
            cout << b << "\n";
        else
            cout << a << "\n";
    }

    return 0;
}

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

int main(){

  int x,y;
  int i=0;

  do{
    i++;
    cin >>x >>y;
    if(x==0 && y==0) break;
    if(x>y) swap(x, y);
    cout <<x <<" " <<y <<endl;
  }while(x!=0||y!=0);

  return 0;
}

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

int A[303];
ll dp[303][101010],dp2[303][101010];

int main(){
  int N; cin>>N;
  int sum=0;
  rep(i,N){
    cin>>A[i];
    sum+=A[i];
  }
  ll ans=1;
  rep(i,N) (ans*=3)%=MOD;
  dp[0][0]=1;
  rep(i,N) rep(j,sum+1) if(dp[i][j]){
    (dp[i+1][j+A[i]]+=dp[i][j])%=MOD;
    // GとBに振り分ける
    (dp[i+1][j]+=dp[i][j]*2)%=MOD;
  }
  dp2[0][0]=1;
  rep(i,N) rep(j,sum+1) if(dp2[i][j]){
    (dp2[i+1][j+A[i]]+=dp2[i][j])%=MOD;
    // GとBの一方のみに振り分ける
    (dp2[i+1][j]+=dp2[i][j])%=MOD;
  }
  ll tmp=0;
  for(int i=sum/2+1;i<=sum;i++){
    (tmp+=dp[N][i])%=MOD;
  }
  if(sum%2==0){
    (tmp+=dp[N][sum/2])%=MOD;
    tmp=(tmp-dp2[N][sum/2]+MOD)%MOD;
  }
  tmp=tmp*3%MOD;
  ans=(ans-tmp+MOD)%MOD;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 475392
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 998244353;
Int INF = 1e18;
double EPS = 0.00000001;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    vector<Int> res(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
        res[a[i] - 1] = i + 1;
    }
    for (Int i = 0; i < n; i++) {
        cout << res[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
    ll N,K;
    cin >> N >> K;
    ll m;
    ll M;
    ll ans;
    
    m = N/K;
    M = m+1;
    ans = min(N-K*m,K*M-N);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
 long a,b,x;
 int c=0;
 
 scanf("%ld%ld%ld",&a,&b,&x);
 if(a%x==0)
  c=1;
 printf("%ld\n",(b/x)-(a/x)+c);
  return 0;
}

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

typedef long long ll;

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

    for (ll h = 1; h <= 3500; h++) {
        for (ll n = 1; n <= 3500; n++) {
            ll numerator = N * h * n;
            ll denominator = 4 * h * n - N * n - N * h;
            if (denominator <= 0) continue;
            if (numerator % denominator == 0) {
                ll w = numerator / denominator;
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 384
/*s1190073  Rina Sato
  File name: prog6c.c
  This is a quick sort program.
*/

#include <stdio.h>

int A[100000],order[100000];
char C[100000];

int Partition(int A[],char C[],int order[],int p,int r){
  int temp1,temp2,tempM,tempm,tempC,tempc;
  int i,j,x,stability,n;
  
  x = A[r];
  i = p-1;
  for(j = p ; j < r ; j++){
    if(A[j] <= x){
      i = i+1; 
      
      temp1 = A[i];
      tempM = C[i];
      tempC = order[i];
      
      A[i] = A[j];
      C[i] = C[j];
      order[i] = order[j];
      
      A[j] = temp1;
      C[j] = tempM;
      order[j] = tempC;
    }
  }
  temp2 = A[i+1];
  tempm = C[i+1];
  tempc = order[i+1];
  
  A[i+1] = A[r];
  C[i+1] = C[r];
  order[i+1] = order[r];
  
  A[r] = temp2;
  C[r] = tempm;
  order[r] = tempc;
  
  return i+1;
}

void Quicksort(int A[],char C[],int order[],int p,int r){
  int q;
  
  if(p < r){
    q = Partition(A,C,order,p,r);
    Quicksort(A,C,order,p,q-1);
    Quicksort(A,C,order,q+1,r);
  }
}

int main(void){
  int n,i,stability=0;
  
  scanf("%d",&n);
  
  for(i = 0 ; i < n ; i++){
    scanf(" %c%d",&C[i],&A[i]);
  }  
  for(i = 0 ; i < n ; i++){
    order[i] = i;
  }
  
  Quicksort(A,C,order,0,n-1);

  for(i = 0 ; i < n-1 ; i++){
    if(A[i] == A[i+1]){
      if(order[i] > order[i+1]){
	stability = 1;
	break;
      }
    }  
  }
  if(stability == 1){
    printf("Not stable\n");
  }
  else printf("Stable\n");
  
  for(i = 0 ; i < n ; i++){
    printf("%c %d\n",C[i],A[i]);
  }
  
  return 0;
}

Measured memory_bytes: 1296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int num = 1;
		while(n>0)
		{
			if(num  < k)
			{
				num*=2;
			}
			else 
			{
				num+=k;
				
			}
			n--;
		}
		System.out.println(num);

	}

}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int N,A,B,C;
vint l;

int rec(int i,int a,int b,int c){
    if(i==N){ 
        if(!a or !b or !c) return 1e18;
        return abs(a-A)+abs(b-B)+abs(c-C);
    }

    int res=rec(i+1,a,b,c);
    res=min(res,rec(i+1,a+l[i],b,c)+(a? 10:0));
    res=min(res,rec(i+1,a,b+l[i],c)+(b? 10:0));
    res=min(res,rec(i+1,a,b,c+l[i])+(c? 10:0));

    return res;
}

signed main()
{
    cin>>N>>A>>B>>C;
    l.resize(N);
    REP(i,N) cin>>l[i];

    cout<<rec(0,0,0,0)<<endl;
}


Measured memory_bytes: 256
import java.util.*;	
public class Main {

	public static void main(String[] args) {
		int x = 0,max = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String c = sc.next();
		for(int i = 0;i < c.length();i++ ) {
			if(c.charAt(i) == 'I') x++;
			else if(c.charAt(i) == 'D') x--;
			if(max < x)max = x;
		}
		System.out.println(max);
	}

}


Measured memory_bytes: 23892
#include <iostream>

int main() {
  int secs;
  std::cin >> secs;
  int hour, min, sec;
  hour = secs / (60 * 60);
  min = (secs - hour * 60 * 60) / 60;
  sec = secs % 60;
  std::cout << hour << ":" << min << ":" << sec << std::endl;
  return 0;
}


Measured memory_bytes: 3108
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<usize>();
    let m=read::<usize>();
    let mut x=read::<isize>();
    let mut y=read::<isize>();
    for _ in 0..n{
        let a=read::<isize>();
        if x<a{x=a}
    }
    for _ in 0..m{
        let a=read::<isize>();
        if y>a{y=a}
    }
    println!("{}War",if x<y{"No "}else{""})
}


Measured memory_bytes: 4352
// AOJ Volume 0 Problem 0002

#include <stdio.h>

int main(void)
{
    int i;
    int num, num1, num2;
    int digits;
    
    while (scanf("%d%d", &num1, &num2) != EOF){
        num = num1 + num2;
        digits = 0;
        while (num != 0){
            num /= 10;
            digits++;
        }
        printf("%d\n", digits);
    }
    
    return (0);
}

Measured memory_bytes: 0
#include<stdio.h>

int getLength(char a[]);

int main(void){
    int i,len,tmp,count=-1;
    char a[15];
    gets(a);
    len=getLength(a);
    if(a[0]!='A'){
        puts("WA");
        return 0;
    }
    for(i=2;i<len-1;i++){
        if(a[i]=='C'){
            tmp=i;
            count++;
        }
    }
    if(count){
        puts("WA");
        return 0;
    }
    for(i=1;i<len;i++){
        if(a[i]<'a' && i!=tmp){
            puts("WA");
            return 0;
        }
    }
    puts("AC");
    return 0;
}

int getLength(char a[]){
    int i=0;
    while(a[i]){
        i++;
    }
    return i;
}

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

double p[305][305][305]={0},ev[305][305][305]={0};

main()
{
	int n,num;
	cin>>n;
	
	int cnt[4]={0};
	
	for(int i=0;i<n;i++)
	{
		cin>>num;
		cnt[num]++;
	}
	
	p[cnt[1]][cnt[2]][cnt[3]]=1;
	
	for(int c=n;c>=0;c--)
	{
		for(int b=n;b>=0;b--)
		{
			for(int a=n;a>=0;a--)
			{
				if(a+b+c>n)
				continue;
				
				if(a==0 && b==0 && c==0)
				continue;
				
				double waste_p=((double)n-a-b-c)/n;
				double waste_ev=waste_p/(1-waste_p);
				
				ev[a][b][c]+=p[a][b][c]*waste_ev;
				
				if(a>0)
				{
					p[a-1][b][c]+=p[a][b][c]*((double)a)/(a+b+c);
					ev[a-1][b][c]+=((double)a)/(a+b+c)*ev[a][b][c];
				}
				
				if(b>0 && a<n)
				{
					p[a+1][b-1][c]+=p[a][b][c]*((double)b)/(a+b+c);
					ev[a+1][b-1][c]+=((double)b)/(a+b+c)*ev[a][b][c];
				}
				
				if(c>0 && b<n)
				{
					p[a][b+1][c-1]+=p[a][b][c]*((double)c)/(a+b+c);
					ev[a][b+1][c-1]+=((double)c)/(a+b+c)*ev[a][b][c];
				}
			}
		}
	}
	
	//cout<<p[0][0][0]<<endl;
	cout<<setprecision(15)<<cnt[1]+2*cnt[2]+3*cnt[3]+ev[0][0][0];
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;

#define MAX_V 2222
vector<int> v[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int a,int b){
	v[a].pb(b);
	v[b].pb(a);
}

bool matchdfs(int a)
{
  used[a] = true;
  for(int i = 0;i < v[a].size();i++)
    {
      int u = v[a][i],w = match[u];
      if(w < 0 || !used[w] && matchdfs(w))
	{
	  match[u] = a;
	  match[a] = u;
	  return true;
	}
    }
  return false;
}

//二部マッチング
int two_matching_max(int l)
{
  int res = 0;
  memset(match,-1,sizeof(match));
  for(int v=0;v<l;v++)
    {
      if(match[v] < 0)
	{
	  memset(used,0,sizeof(used));
	  if(matchdfs(v))res++;
	}
    }
  return res;
}
int gcd(int a,int b){
  int aa=max(a,b);
  int bb=min(a,b);
  int cc=aa%bb;
  while(cc!=0){
    int tmp=cc;
    cc=bb%cc;
    bb=tmp;
  }
  return bb;
}
int main(){
  int m,n;
  while(cin>>m>>n,m){
    for(int i=0;i<MAX_V;i++){
      v[i].clear();
    }
    vector<int>blue(m);
    //cout<<gcd(7,10)<<endl;
    for(int i=0;i<m;i++)
      cin>>blue[i];
    for(int i=0;i<n;i++){
      int num;cin>>num;
      for(int j=0;j<m;j++){
	if(gcd(num,blue[j])>1){
	  add_edge(i,j+n);
	}
      }
    }
    cout<<two_matching_max(n+m)<<endl;
  }
  return 0;
}



Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e3 + 5, INF = 0x3f3f3f3f, mod = 1e9 + 7;
const ll LNF = 0x3f3f3f3f3f3f3f3f;
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, r, l) for (int i = r; i >= l; i--)
#define repe(i, u) for (int i = head[u]; i; i = nxt[i])

ll dp[64][2][2][2], l, r;
ll dfs(int now, bool L, bool R, bool zero) {
  if (now == -1) return zero;
  if (~dp[now][L][R][zero]) return dp[now][L][R][zero];
  ll ret = 0;
  rep(i, 0, 1) rep(j, 0, 1) {
    if (i == 0 && L && ((l >> now) & 1)) continue;
    if (j && R && !((r >> now) & 1)) continue;
    if (i > j) continue;
    if (!zero && i != j) continue;
    ret += dfs(now - 1, (L && ((l >> now) & 1) == i), (R && ((r >> now) & 1) == j), zero || (i && j));
  }
  return dp[now][L][R][zero] = ret % mod;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> l >> r;
  rep(i, 0, 63) rep(j, 0, 1) rep(k, 0, 1) rep(p, 0, 1) dp[i][j][k][p] = -1;
  cout << dfs(61, 1, 1, 0) << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return (a / gcd(a,b)) * b; }
// ll nCr(ll n, ll r) {
//     return ( ( ( (fac[n] * powmod(fac[n-r], mod-2)) % mod ) * powmod(fac[r], mod-2) ) % mod );
// }
// const ll sz = 1e6 + 5;
// vector<ll> fac(sz, 1);

// * ALways PASS arrays, strings etc to functions BY REFERENCE

vector<vector<int>> adj;

int main() {
    // for (int i = 1; i < sz; i++)
    //     fac[i] = (fac[i-1] * i) % mod;
    
    int t = 1;
    // cin >> t;
    
    while(t--) {
        string s;
        cin >> s;
        ll sm = 0;
        for (auto c: s)
            sm += (c - '0');
        cout << ((sm % 9 == 0) ? "Yes" : "No") << endl;
    }
    
	return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <algorithm>
#include <string> 

using namespace std;
typedef long long ll;
int main(int argc, char const *argv[])
{
    int n;cin>>n;
    int cnt =0;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
        if(i>=2){
            if((p[i]>p[i-1] && p[i-1]>=p[i-2]) || (p[i-2]>p[i-1] && p[i-1]>=p[i]))cnt++;
        }
    }
    cout<<cnt<<endl ;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll b[10+5],x[10+5];
char a[10+5];
ll alen,t=0,tot,d,k,f;
ll ans=0;
ll Pow(int a,ll x)
{
	ll ret=1;
	while(x>0)
	{
		x--;
		ret*=a;
	}
	return ret;
}
int main()
{
	scanf("%s",a);
	alen=strlen(a);
	for(int i=0;i<alen;i++)
		b[t++]=a[i]-'0';
	for(int i=1;i<=t;i++)//处理每一位的系数,共有t位
	{
		f=i-1;
		d=0;
		k=0;
		tot=t-i+1;//系数位数
		if(tot==1)
			x[i]=pow(2,t-1);
		else
		{
			while(d<tot)
			{
				d++;
				if(d==2)
					f=i-1;
				k=1LL*k*10+Pow(2,f);
				f++;
			}
			x[i]=k;
		}
	}
	for(int i=1;i<=t;i++)
		ans+=b[i-1]*x[i];
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
  int N, input;
  cin >> N;
  if(N % 3 == 0){
    map<int, int> m;
    int count = 0, x, y, z;
    x = y = z = -1;
    rep(i, N){
      cin >> input;
      if(m.count(input) == 0){
        if(count < 3){
          if(x == -1) x = input;
          else if(y == -1) y = input;
          else z = input;
          m[input]++;
          count++;
        }else{
          cout << "No" << endl;
          return 0;
        }
      }else{
        m[input]++;
      }
    }
    if(y == -1){
      if(x == 0) cout << "Yes" << endl;
      else cout << "No" << endl;
    }else if(z == -1){
      if(x == 0 || y == 0){
        if(y == 0) swap(x, y);
        if(2*m[x] == m[y]) cout << "Yes" << endl;
        else cout << "No" << endl;
      }else cout << "No" << endl;
    }else{
      if(((x ^ y ^ z) == 0) && m[x] == m[y] && m[y] == m[z]) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  }else{
    rep(i, N){
      cin >> input;
      if(input != 0){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256