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

#define ll long long int

vector<ll> A;
vector<ll> B;
vector<ll> S;
vector<ll> T;

ll N,M,K;
int main(){
    cin>>N;
    cin>>M;
    cin>>K;
    for(ll i=0;i<N;i++){
        ll input=0;
        cin>>input;
        A.push_back(input);
    }
    for(ll i=0;i<M;i++){
        ll input=0;
        cin>>input;
        B.push_back(input);
    }
    S.push_back(0);
    for(ll i=0;i<N;i++){
        S.push_back(A[i]+S[i]);
    }
    T.push_back(0);
    for(ll i=0;i<M;i++){
        T.push_back(B[i]+T[i]);
    }
    ll lastAmount=M;
    ll res=0;
    for(ll i=0;i<=N;i++){
        ll amount=0;
        for(ll j=lastAmount;j>=0;j--){
            if(T[j]+S[i]<=K){
                lastAmount=j;
                ll count=i+j;
                res=max(i+j,res);
                break;
            }
        }
        if(S[i]>K)break;
    }
    cout<<res<<endl;
}

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

using namespace std;

int main()
{
    int n,ans=INT_MAX;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=-100; i<=100; i++){
        int sum=0;
        for(int j=0; j<n; j++){
            sum+= (a[j]-i)*(a[j]-i);
        }
        ans = min(ans,sum);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
long long f[4001];
const long long mod=1e9+7;
int main()
{
	int s;
	scanf("%d",&s);
	f[0]=1;
	for(int i=0;i<s;++i)
		for(int j=3;j<=s;++j)
			f[i+j]+=f[i],f[i+j]%=mod;
	printf("%lld",f[s]);
}

Measured memory_bytes: 1696
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    String T = scan.next();
    String judge = T.substring(0,S.length());
    if (S.equals(judge)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

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

using namespace std;

void solve(){
  int k;
  cin>>k;
  string s;
  cin >> s;
  if(s.size() <= k){
    cout << s << endl;
  }
  else{
    string an = "";
    for(int i = 0; i < k; ++i){
        an += s[i];
    }
    an += "...";
    cout << an << endl;
  }
}

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


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(void){
    int N, tmp;
    int n[1010];

    cin >> N;
    int max = 0, min = 2010;
    for(int i = 0; i < N; i++){
        cin >> n[i];
        if(n[i] > max) max = n[i];
        if(n[i] < min) min = n[i];
    }
    if((max - min) % 2 == 1) cout << (max - min + 1) / 2 << endl;
    else cout << (max - min) / 2 << endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

ll gcd(ll a,ll b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
map< ll, int > prime_factor(ll  n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
 int main()
 {
 	ll n,m,ans=0;
 	cin >> n>>m;
 	ll a=gcd(n,m);
 	auto x=prime_factor(a);
 	cout << x.size()+1 << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
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;
}

int main() {
    // 前処理
    COMinit();
    int s;
		cin >> s;
		ll ans = 0;
		int k = s / 3;
		for (int i = 1; i <= k; i++)
		{
			int m = s - i*3;
			ans += COM(m+i-1,i-1);
			ans %= MOD;
		}
		cout << ans << endl;		
}

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

#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)


typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

template <class T>
using pqueue = priority_queue<T>;
template <class T>
using rpqueue = priority_queue<T, vector<T>, greater<T> >;
template <class T>
using vec = vector<T>;

int sint() { int x; scanf("%d", &x); return x; }
ll sll() { ll x; scanf("%lld", &x); return x; }
double sdb() { double x; scanf("%lf", &x); return x; }


ll res[110][101000] = {};
ll ps[110][101000] = {};
ll arr[110];

const ll MOD = 1000000007;

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &arr[i]);
	}
	
	for(int j = 0; j <= k; j++) {
		ps[0][j] = 1;
	}
	
	for(int i = 1; i <= n; i++) {
		res[i][0] = ps[i][0] = 1;
		for(int j = 1; j <= k; j++) {
			if(j-arr[i] <= 0) {
				res[i][j] = (ps[i-1][j])%MOD;
			} else {
				res[i][j] = (ps[i-1][j]-ps[i-1][j-arr[i]-1]+MOD) %MOD;
			}
			ps[i][j] = ps[i][j-1] + res[i][j];
		}
	}
	
//	for(int i = 0; i <= n; i++) {
//		for(int j = 0; j <= k; j++) {
//			printf("%lld ", ps[i][j]);
//		}
//		printf("\n");
//	}
//	
//	for(int i = 0; i <= n; i++) {
//		for(int j = 0; j <= k; j++) {
//			printf("%lld ", res[i][j]);
//		}
//		printf("\n");
//	}
	
	printf("%lld\n", res[n][k]);
}

Measured memory_bytes: 162048
N = int(input())
A = list(map(int, input().split()))
ans=1
i=0
while ans<=1000000000000000000 and i<N:
    ans=ans*A[i]
    i+=1

if A.count(0)>0:
    print(0)
else:
    print(ans if ans<=1000000000000000000 else "-1")

Measured memory_bytes: 21608
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
 int a,b,c,d,e;
 cin >> a >> b >> c >> d >> e;
 if( a==0)
    cout << 1;
 else if (b==0)
    cout << 2;
 else if (c==0)
    cout << 3;
 else if (d==0)
    cout << 4;
 else if (e==0)
    cout << 5;    
return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e3+10;
int a[N],st[N],f[N][1<<13];
int main()
{
    int n,m,b;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>a[i]>>b;
        int t,c=0;
        for(int j=1;j<=b;j++)
        {
            cin>>t;
            t--;
            c|=1<<t;
        }
        st[i]=c;
    }
    memset(f,0x3f,sizeof f);
    f[0][0]=0;
    for(int i=1;i<=m;i++)
    for(int j=0;j<=(1<<n)-1;j++)
    {
        f[i][j]=min(f[i][j],f[i-1][j]);
        f[i][j|st[i]]=min(f[i][j|st[i]],f[i-1][j]+a[i]);
    }
    if(f[m][(1<<n)-1]==0x3f3f3f3f)  cout<<-1;
    else    cout<<f[m][(1<<n)-1];
}

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


int main(){
    string s;cin>>s;
    ll bc = 0;
    ll ans = 0;
    int n = s.size();
    rep(i,n){
        if(s[i]=='W') ans+=bc;
        else bc++;


    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3776
#include <stdio.h>
#include <string.h>

int main()
{
	char str[200] = { 0 };
	int len = 0;

	scanf("%s", str);
	len = strlen(str);

	while (1) {
		char tmp1[100] = { 0 };
		char tmp2[100] = { 0 };

		if ((strlen(str) % 2) != 0) {
			len -= 1;
		} else {
			len -= 2;
		}

		strncpy(tmp1, &str[0], len / 2);
		strncpy(tmp2, &str[len / 2], len / 2);

		if (strcmp(tmp1, tmp2) == 0) {
			break;
		}
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <queue>
#include<stdlib.h>
using namespace std;

struct pos{
    int a, b, v;
};

int h, w, aux[55][55], p=0;
char mat[55][55];
queue<pos> cola;
int a[]={0,1,0,-1}, b[]={1,0,-1,0};

int main(){
    scanf("%d %d", &h, &w);
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            scanf(" %c", &mat[i][j]);
            if(mat[i][j] == '.')
                p+=1;
        }
    }

    //BFS
    pos ini, nueva;
    ini.a = 0; ini.b = 0; ini.v = 0;
    mat[0][0] = '#';
    cola.push(ini);

    while(!cola.empty()){
        //printf("%d\n", cola.size());
        pos act = cola.front();
        cola.pop();
        for(int i=0; i<4; i++){
            int p1 = act.a + a[i], p2= act.b + b[i];
            if( p1 < h && p2 < w && p1 >= 0 && p2 >= 0){
                if(mat[p1][p2] == '.' && aux[p1][p2] == 0){
                    nueva.a = p1;
                    nueva.b = p2;
                    nueva.v = act.v+1;
                    cola.push(nueva);
                    aux[p1][p2] = act.v+1;
                }
            }
        }

    }
    if(aux[h-1][w-1] != 0)
        printf("%d\n", p-1-aux[h-1][w-1]);
    else
        printf("-1\n");


}


Measured memory_bytes: 256
module Main where

import Data.Functor

main :: IO ()
main = do
  { [a,b] <- getInts
  ; let result = hikaku (a,b)
  ; putStrLn result
  }


hikaku :: (Int,Int) -> String
hikaku (x,y)
  | x < y = "a < b"
  | x == y = "a == b"
  | x > y  = "a > b"

getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<algorithm>
#include<map>

using namespace std;
int main(void){
  int N, M, max = 0;
  string s[101], t[101];
  bool flag = false;
  cin >> N;
  for(int i = 0; i < N; i++){cin >> s[i];}
  cin >> M;
  for(int i = 0; i < M; i++){cin >> t[i];}
  //連想配列を作って，cinされたcodeのリストを作成
  //各々のcodeのリストでカウントをかける。
  map<string, int> code;
  for(int i = 0; i < N; i++){
    flag = false;
    for(auto j = code.begin(); j != code.end() ;j++){
      if(j -> first == s[i]){
        j -> second ++;
        flag = true;
        break;
      }
    }
    if(flag == false){
      code.insert(make_pair(s[i], 1));
    }
  }
  for(int i = 0; i < M; i++){
    flag = false;
    for(auto j = code.begin(); j != code.end() ;j++){
      if(j -> first == t[i]){
        j -> second --;
        flag = true;
        break;
      }
    }
    if(flag == false){
      code.insert(make_pair(s[i], -1));
    }
  }
  //codeの要素を1つずつ見ていき，最大の値を返す
  for(auto i = code.begin(); i != code.end(); i++){
    if(max < i -> second){max = i -> second;}
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

//Doctor's Research Rooms
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m)==0)break;
			boolean[][] door = new boolean[n][n];
			for(int i=0;i<m;i++){
				int a = sc.nextInt()-1;
				int b = sc.nextInt()-1;
				door[a][b]=door[b][a]=true;
			}
			String[] move = new String[n];
			String[] switchon = new String[n];
			String[] switchoff = new String[n];
			for(int i=1;i<=n;i++){
				move[i-1]="Move to room " + i + ".";
				switchon[i-1]="Switch on room " + i + ".";
				switchoff[i-1]="Switch off room " + i + ".";
			}
			int[][][] pre = new int[1<<n][n][2];
			String[][] mes = new String[1<<n][n];
			boolean[][] mark = new boolean[1<<n][n];
			int start = 0;
			for(int i=0;i<n;i++)start|=sc.nextInt()<<i;
			int[][] sw = new int[n][];
			for(int i=0;i<n;i++){
				int k = sc.nextInt();
				sw[i] = new int[k];
				for(int j=0;j<k;j++)sw[i][j]=sc.nextInt()-1;
				Arrays.sort(sw[i]);
			}
			if((start&1)==0){
				System.out.println("Help me!");
				continue;
			}
			mark[start][0] = true;
			pre[start][0][0] = -1;
			pre[start][0][1] = -1;
			int step = 0;
			List<int[]> l = new ArrayList<int[]>();
			l.add(new int[]{start, 0});
			boolean reachGoal = false;
			boolean trueEnding = false;
			while(!l.isEmpty()){
				List<int[]> next = new ArrayList<int[]>();
				for(int[] a:l){
					int s = a[0];
					int pos = a[1];
					if(pos==n-1){
						reachGoal = true;
						if(s==(1<<(n-1))){
							trueEnding = true;
							next.clear();
							break;
						}
					}
					for(int t=0;t<n;t++){
						if((s&(1<<t))>0 && !mark[s][t] && door[pos][t]){
							pre[s][t][0] = s;
							pre[s][t][1] = pos;
							mes[s][t] = move[t];
							mark[s][t] = true;
							next.add(new int[]{s, t});
						}
					}
					for(int k=0;k<sw[pos].length;k++){
						int v = sw[pos][k];
						if((s&(1<<v))>0){
							if(v==pos)continue;
							int ns = s - (1<<v);
							if(!mark[ns][pos]){
								pre[ns][pos][0] = s;
								pre[ns][pos][1] = pos;
								mark[ns][pos] = true;
								mes[ns][pos] = switchoff[v];
								next.add(new int[]{ns, pos});
							}
						}
						else {
							int ns = s + (1<<v);
							if(!mark[ns][pos]){
								pre[ns][pos][0] = s;
								pre[ns][pos][1] = pos;
								mark[ns][pos] = true;
								mes[ns][pos] = switchon[v];
								next.add(new int[]{ns, pos});
							}
						}
					}
				}
				step++;
				l = next;
			}
			if(trueEnding){
				System.out.println("You can go home in " + --step + " steps.");
				int state = 1<<(n-1);
				int p = n-1;
				Stack<String> stack = new Stack<String>();
				while(state!=-1){
					stack.push(mes[state][p]);
					int ns = pre[state][p][0];
					int np = pre[state][p][1];
					state = ns;
					p = np;
				}
				stack.pop();
				while(!stack.isEmpty())System.out.println(stack.pop());
			}
			else 
				System.out.println(reachGoal?"You can not switch off all lights.":"Help me!");
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

const int INF = 1001001001;
vector<int> to[100005];


void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
    rep(i,M){
        ll a = A[i]-1;
        ll b = B[i]-1;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    queue<int> q;
    vector<int> dist(N, INF);
    vector<int> pre(N,-1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()){
        int v = q.front(); q.pop();
        for(int u : to[v]){
            if(dist[u] != INF) continue;
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    rep(i,N){
        if(i == 0)continue;
        int ans = pre[i];
        ans++;
        cout << ans << endl;
    }

}

int main(){
    ll N,M;
    scanf("%lld",&N);
    scanf("%lld",&M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 13724
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
ll MD = 365,MN=26;
ll d,n=26;
vector<ll> c(MN),contest(MD),latest(MN,0);
vector<vector<ll>> s(MD,vector<ll>(MN));
signed main(){
  chrono::system_clock::time_point start,now;
  start = chrono::system_clock::now();
  init_io();
  cin >> d;
  vector<TP> vals;
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  for(int i=0;i<d;i++){
    for(int j=0;j<n;j++){
      cin >> s[i][j];
      vals.emplace_back(s[i][j],i,j);
    }
  }
  sort(vals.begin(),vals.end(),greater<>());
  for(int i=0;i<d;i++){
    ll b_score = -1e9,b_c=0;
    for(int j=0;j<n;j++){
      ll tmp = s[i][j];
      for(int k=0;k<n;k++){
        if(j==k) continue;
        ll last = 0;
        for(int l=i-1;l>=0;l--){
          if(contest[l]==k){
            last = l+1;
            break;
          }
        }
        tmp -= c[k]*(i+1-last);
      }
      if(tmp>b_score){
        b_score = tmp;
        b_c = j;
      }
    }
    contest[i] = b_c;
  }
  ll score = 0;
  for(int i=0;i<d;i++){
    score += s[i][contest[i]];
    for(int j=0;j<n;j++){
      ll day = 0;
      for(int k=i;k>=0;k--){
        if(contest[k]==j){
          day = k+1;
          break;
        }
      }
      score -= (i+1-day)*c[j];
    }
  }
  now = chrono::system_clock::now();
  double time = chrono::duration_cast<chrono::milliseconds>(now-start).count();
  while(time<=1700){
    for(int i=0;i<d*n;i++){
      auto [sv,day,con] = vals[i];
      if(contest[day]==con) continue;
      ll pre = contest[day];
      ll n_score = score;
      ll sum0=0,sum1=0;
      for(int j=0;j<d;j++){
        sum0 += c[con];
        sum1 += c[pre];
        if(contest[j]==con){
          sum0 = 0;
          n_score -= s[j][con];
        }else if(contest[j]==pre){
          sum1 = 0;
          n_score -= s[j][pre];
        }
        n_score = n_score + sum0 + sum1;
      }
      contest[day] = con;
      sum0=0,sum1=0;
      for(int j=0;j<d;j++){
        sum0 -= c[con];
        sum1 -= c[pre];
        if(contest[j]==con){
          sum0 = 0;
          n_score += s[j][con];
        }else if(contest[j]==pre){
          sum1 = 0;
          n_score += s[j][pre];
        }
        n_score = n_score - sum0 - sum1;
      }
      if(score < n_score){
        score = n_score;
      }else{
        contest[day] = pre;
      }
    }
    now = chrono::system_clock::now();
    time = chrono::duration_cast<chrono::milliseconds>(now-start).count();
  }
  for(int i=0;i<d;i++){
    cout << contest[i]+1 << endl;
  }
}


Measured memory_bytes: 3976
N, M, C = map(int, input().split())
B = [int(x) for x in input().split()]
A = []
count = 0
for i in range(N):
    A.append([int(x) for x in input().split()])
for i in range(N):
    tmp = 0
    for j in range(M):
        tmp += A[i][j]*B[j]
    if tmp + C > 0:
        count += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n,k;
  cin>>n>>k;
  if (k>1) {
    cout<<(n-k)<<endl;
  } else {
    cout<<0<<endl;
  }
  return 0;
}


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

int main() {
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '+') {
            ans += 1;
        } else {
            ans -= 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j;
    cin>>n;
    bool ok=1;
    for(i=0; i<n; i++)
    {
        cin>>j;
        if(!(j&1)&&(j%3!=0&&j%5!=0))
            ok=0;
    }
    if(!ok)
        cout<<"DENIED"<<endl;
    else cout<<"APPROVED"<<endl;
    return 0;

}


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

using namespace std;

typedef long long ll;

int main() {

    int N, K;

    cin>>N>>K;
    vector<ll> h;
    vector<ll> dp;
    h.resize(N);
    dp.resize(N+1);

    for(int i=0; i<N; ++i)
        cin>>h[i];

    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);

    for(int i=1; i<N-1; ++i)
    {
        ll minNum;
        minNum = 1000000000000000000;
        for(int k=0; k<K; ++k)
        {
           if(i-k>=0)
           {
               ll tmp1 = abs(h[i+1]-h[i-k]) + dp[i-k];
               minNum = min(minNum, tmp1);
           }
        }
        dp[i+1] = minNum;
    }

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



    return 0;
}



Measured memory_bytes: 1792
import java.util.Scanner

fun main(args: Array<String>){
  val cin = Scanner(System.`in`)
  val k = cin.nextInt()
  val s = cin.nextInt()

  var ct = 0

  for (i in 0..k){
    for (j in 0..k){
      if (s - (i + j) in 0..k) ct++
    }
  }

  println(ct)

  cin.close()
}

Measured memory_bytes: 21548
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve()
{ 
    ll n,W,i,j;
    cin >> n >> W;
    ll w[n],v[n];
    for(i=0;i<n;i++) cin >> w[i] >> v[i];
    ll k[n+1][W+1];
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=W;j++)
        {
            if(!i||!j) k[i][j]=0;
            else if(w[i-1]<=j) k[i][j]=max(k[i-1][j],v[i-1]+k[i-1][j-w[i-1]]);
            else k[i][j]=k[i-1][j];
        }
    }
    cout << k[n][W] << "\n";
}

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

Measured memory_bytes: 79104
n=int(input())
l=list(map(int,input().split()))
a=l[-1::-2]
if n%2==0:
    for i in range(0,n,2):
        a.append(l[i])
else:
    for i in range(1,n,2):
        a.append(l[i])
for i in a:
    print(i,end=" ")

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

using namespace std;

int main()
{
	int kosuu=0;
	int shurui=0;
	vector<int> cakes;
	cin >> kosuu >> shurui;
	for (int i = 0; i < shurui; i++)
	{
		int cakeNumber = 0;
		cin >> cakeNumber;
		cakes.push_back(cakeNumber);
	}

	int maxNumber = 0;
	for (int i = 0; i < shurui; i++)
	{
		if (maxNumber < cakes[i])
		{
			maxNumber = cakes[i];
		}
	}

	int elseCakeNumber = kosuu - maxNumber;
	
	int minDay = maxNumber - 1 - elseCakeNumber;
	if (minDay < 0)
	{
		minDay = 0;
	}
	cout << minDay << endl;
	
	

	return 0;
}

Measured memory_bytes: 256
let () =
    let main () =
        let n = Scanf.sscanf (read_line ()) "%d" (fun a -> a) in
        let arr = Array.init n (fun _ -> int_of_string (read_line ())) in
        let arr2 = Array.copy arr in
        Array.sort (fun a b -> compare b a) arr2;
        for i = 0 to n - 1 do
            Printf.printf "%d\n" (if arr.(i) = arr2.(0) then arr2.(1) else arr2.(0))
        done
    in
    main ()

Measured memory_bytes: 7936
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
   int r; cin >> r;
   cout << fixed << setprecision(10) << M_PI * 2 * r << endl;
   return 0;
}


Measured memory_bytes: 3780
from bisect import bisect_left, bisect_right
N, Q = map(int, input().split())
S = input()
def int_(num_str):
    return int(num_str) - 1

ans = 0
ACleft = []
ACright = []
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        ACleft.append(i)
        ACright.append(i+1)
for _ in range(Q):
    l, r = map(int_, input().split())
    ans = bisect_left(ACleft, r) - bisect_left(ACleft, l)
    print(ans)


Measured memory_bytes: 55384
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long 
#define int long long 
#define vll vector<long long>
#define pii pair<long long ,long long > 
#define vvi vector< vector<long long > > 
#define vpii vector<pair<int,int>> 
#define pll  pair<long long ,long long > 
#define pb  push_back
#define ff  first 
#define sec second  
#define SORT(a) sort(a.begin(),a.end())
#define SORTR(a) sort(a.rbegin(),a.rend()) 
#define m_p make_pair
#define all(x)   (x.begin(),x.end()) 
#define sz(v)     ((int)(v.size()))
#define INF 1e9+7
typedef vector< long long > vi ;
const int MOD=1e9 +7 ;
int size=10000000; 

int32_t main(){
  fast; 
    
  int n,k; cin>>n>>k; 

  vi p(n); 
  vector<double long > pref(n); double long  prev=0; 
  for(int i=0;i<n;i++){
    cin>>p[i];
    pref[i]=(double long )prev+(double)(p[i]+1)/2; 
    prev=pref[i]; 
  }

  double long sum=pref[k-1]; 

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

      sum=max(sum,pref[i]-pref[i-k]); 
    
  }

  cout<<setprecision(7)<<sum; 



}

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define N 12
using namespace std;
int Cal(int,int);

int main(){
  int M,W,inbm,inbw,ans,dp[(1<<N)];
  vector<int> bm,bw;
  while(1){
    cin >> M >> W;
    if(!M&&!W) break;
    for(int i=0;i<M;i++) cin >> inbm,bm.push_back(inbm);
    for(int i=0;i<W;i++) cin >> inbw,bw.push_back(inbw);
    if(M>W){
      swap(M,W);
      swap(bm,bw);
    }
    for(int i=0;i<(1<<N);i++) dp[i]=0;
    ans=0;
    for(int i=0;i<M;i++){
      for(int j=0;j<(1<<W);j++){
	if(i==__builtin_popcount(j)){
	  for(int k=0;k<W;k++){
	    if(!(j&(1<<k))){
	      dp[(j|(1<<k))]=max(dp[(j|(1<<k))],dp[j]+Cal(bm[i],bw[k]));
	      ans=max(ans,dp[(j|(1<<k))]);
	    }
	  }
	}
      }
    }
    bm.clear();
    bw.clear();
    cout << ans << endl;
  }
  return 0;  
}

int Cal(int m,int w){
  return abs(m-w)*(abs(m-w)-30)*(abs(m-w)-30);
}

Measured memory_bytes: 1236
#include <iostream>
using namespace std;
int main(){
  int n, k, x, y, a;
  cin >> n >> k >> x >> y;
  if (k >= n){
    cout << n * x << endl;
  }else{
    a = n - k;
    cout << (n - a) * x + a * y << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    bool ans=false;
    cin>>n;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(n==i*j){
                ans=true;
                break;
            }
        }
    }
    if(ans) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int W, A, B; 
	cin >> W >> A >> B; 
	int ans = 0; 	
	if(A + W <= B) ans = B - A - W;
	else if(B + W <= A) ans = A - B - W; 
	else ans = 0; 
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define m_p make_pair
#define p_b push_back
#define MOD 1000000007
int main()
{
	nfs;
	int t;
	t=1;
//	cin >> t;

	while(t--)
	{
		ll n,p;
		cin >> n >> p;
		ll k = (ll)sqrt(p);
		map<ll,ll> mp;
		ll i;
		//ll flag = 0;
		for(i=2;i<=k+1;i++)
		{
			if(p%i==0)
			{
				
				p /= i;
				mp[i]++;
				i--;
				
			}
		}
		
		mp[p] = 1;
		
		ll gcd = 1;
		for(auto x:mp)
		{
			if(x.second >= n)
			{
				while(x.second >= n)
				{
					gcd *= x.first;
					x.second -= n;
					
				}
			}
		}
		cout << gcd << endl;
		
	}
	return 0;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;

 class Main {

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String ss=sc.next();
		int a=0,b=0,c=0;
		if(ss.charAt(0)=='a'||ss.charAt(1)=='a'||ss.charAt(2)=='a')a++;
		if(ss.charAt(0)=='b'||ss.charAt(1)=='b'||ss.charAt(2)=='b')b++;
		if(ss.charAt(0)=='c'||ss.charAt(1)=='c'||ss.charAt(2)=='c')c++;
		System.out.println(a==1 && b==1 && c==1?"Yes":"No");
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    while (true){
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0){
            return 0;
        }

        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if(j == 0 || j == w - 1 || i == 0 || i == h-1) {
                    printf("%c", '#');
                }else {
                    printf("%c", '.');
                }

            }
            printf("\n");
        }

        printf("\n");
    }
}



Measured memory_bytes: 3080
N,K,S=gets.split.map(&:to_i)
as=Array.new
if S==1000000000
    N.times do |i|
        if i<K
            as.push(S)
        else
            as.push(1)
        end
    end
    puts as.join(" ")
    exit
end
N.times do |i|
    if i<K
        as.push(S)
    else
        as.push(1000000000)
    end
end
puts as.join(" ")

Measured memory_bytes: 4732
S = gets.chomp.split("") #1文字ずつ区切る

(0..S.length - 2).each do |cnt|
  if S[cnt] != S[cnt + 1]
    puts "Yes"
    exit
  end
end

if S[0] != S[2]
  puts "Yes"
  exit
end

puts "No"



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

using namespace std;

typedef vector<set<uint64_t>> EdgeMap;

struct QueueItem
{
  uint64_t src, dst, hop;
  QueueItem(uint64_t src, uint64_t dst, uint64_t hop)
    : src(src), dst(dst), hop(hop) {}
  bool operator>(const QueueItem &rhs) const {
    return hop > rhs.hop;
  }
};

const uint64_t Undefined = static_cast<uint64_t>(-1);

int64_t solve(uint64_t N, uint64_t S, uint64_t T, EdgeMap &edges)
{
  vector<uint64_t> dist((N + 2) << 2, Undefined);
  
  queue<QueueItem> q;
  dist[S] = 0;
  q.emplace(S, S, 0);
  
  while (!q.empty()) {
    QueueItem item = q.front(); q.pop();
    
    for (uint64_t next : edges[item.dst]) {
      if (item.hop + 1 < dist[next]) {
        dist[next] = item.hop + 1;
        q.emplace(item.src, next, item.hop + 1);
      }
    }
  }
  
  return (dist[T] == Undefined) ? -1 : static_cast<int64_t>(dist[T] / 3);
}

int main()
{
  ios::sync_with_stdio(false);
  
  uint64_t N, M;
  cin >> N >> M;
  
  EdgeMap edges((N + 2) << 2, set<uint64_t>());
  for (uint64_t m = 0; m < M; ++m) {
    uint64_t u, v;
    cin >> u >> v;
    
    edges[(u << 2) + 0].insert((v << 2) + 1);
    edges[(u << 2) + 1].insert((v << 2) + 2);
    edges[(u << 2) + 2].insert((v << 2) + 0);
  }
  
  uint64_t S, T;
  cin >> S >> T;
  
  cout << solve(N, (S << 2) + 0, (T << 2) + 0, edges) << endl;
  
  return 0;
}

Measured memory_bytes: 36224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll k;
	cin>>k;
	if(k==0)
	{
		cout<<"2\n";
		for(int i=1;i<=2;i++)
			cout<<"1 ";
		cout<<"\n";
		return 0;
	}
	if(k==1)
	{
		cout<<"2\n";
		cout<<"0 2"<<"\n";
		return 0;
	}
	for(ll i=2;i<=50;i++)
	{
		if(k%i==0&&(k/i+i-1)<=(10000000000000000+1000))
		{
			cout<<i<<"\n";
			for(ll j=0;j<i;j++)
				cout<<(k/i)+j<<" ";
			cout<<"\n";
			return 0;
		}
	}
	
	for(ll i=2;i<=50;i++)
	{
		ll x = k%i;
		ll z = k-x;
		if((z/i+i)<=(10000000000000000+1000))
		{
			ll li = z/i+i-1;
			int c=0;
			cout<<i<<"\n";
			while(x-->0)
			{
				cout<<li+1<<" ";
				li--;
				c++;
			}
			while(c<i)
			{
				cout<<li<<" ";
				c++;				
			}
			cout<<"\n";
			return 0;
		}

	}

}
	

	




Measured memory_bytes: 3640
mod = 10**9+7
N = int(input())
Ca = [int(input())-1 for i in range(N)]
C = []
p = -1
for c in Ca:
    if p != c:
        C.append(c)
    p = c
#print(C)
N = len(C)
if N<=2:
    print(1)
    exit()
L = [-1]*(2*10**5)
dp = [0]*N
dp[0] = 1
L[C[0]] = 0


for i, c in enumerate(C[1:], 1):
    if L[c] == -1:
        L[c] = i
        dp[i] = dp[i-1]
        continue
    else:
        dp[i] = (dp[i-1] + dp[L[c]]) % mod
        L[c] = i
print(dp[-1])



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

template <typename T> T gcd(T m, T n) {
  T temp = 0;
  while(m % n != 0) {
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> xs(N);
  int ans = 0;
  for(int i = 0; i < N; ++i) {
    cin >> xs[i];
    if(abs(xs[i] - X) != 0) {
      ans = abs(xs[i] - X);
    }
  }
  for(int i = 0; i < N; ++i) {
    auto x = abs(xs[i] - X);
    if(x != 0) {
      ans = gcd(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
/**
 *  author: Behradm
 *  Created: 2020.07.11 15:27:05
 *  In The Name Of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  int res = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (i % 2 == 1 && a[i] % 2 == 1)
      res += 1;
  }

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


Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>

int main(void){
    int x,y,z;
    int tmp;
    scanf("%d %d %d",&x, &y, &z);
    tmp = x;
    x = y;
    y = tmp;
    tmp = z;
    z = x;
    x = tmp;
    printf("%d %d %d",x,y,z);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 100000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,q,n_;
int a,b;
int x[200001];

ll labs(ll v){
	if(v<0LL)return -v;
	return v;
}

struct data{
	ll val,lazy;
	data(){}
	data(ll vv,ll la){
		val=vv;
		lazy=la;
	}
};

data dat[3][1000005];

void lazy_evaluate(int d,int k){
	dat[d][k].val+=dat[d][k].lazy;
	if(k<n_-1){
		dat[d][k*2+1].lazy+=dat[d][k].lazy;
		dat[d][k*2+2].lazy+=dat[d][k].lazy;
	}
	dat[d][k].lazy=0;
}

void lazy_update(int d,int k){
	dat[d][k].val=min(dat[d][k*2+1].val,dat[d][k*2+2].val);
}

void update(int a,int b,int d,ll v,int k=0,int l=0,int r=n_){
	lazy_evaluate(d,k);
	if(r<=a || b<=l)return;
	if(a<=l && r<=b){
		dat[d][k].lazy+=v;
		lazy_evaluate(d,k);
		return;
	}
	update(a,b,d,v,k*2+1,l,(l+r)/2);
	update(a,b,d,v,k*2+2,(l+r)/2,r);
	lazy_update(d,k);
	return;
}

void change(int a,int b,int d,ll v,int k=0,int l=0,int r=n_){
	lazy_evaluate(d,k);
	if(r<=a || b<=l)return;
	if(a<=l && r<=b){
		dat[d][k].val=min(v,dat[d][k].val);
		return;
	}
	change(a,b,d,v,k*2+1,l,(l+r)/2);
	change(a,b,d,v,k*2+2,(l+r)/2,r);
	lazy_update(d,k);
	return;
}

ll query(int a,int b,int d,int k=0,int l=0,int r=n_){
	lazy_evaluate(d,k);
	if(r<=a || b<=l)return INF;
	if(a<=l && r<=b)return dat[d][k].val;
	ll vl=query(a,b,d,k*2+1,l,(l+r)/2);
	ll vr=query(a,b,d,k*2+2,(l+r)/2,r);
	lazy_update(d,k);
	return min(vl,vr);
}
int main(void){
	scanf("%d%d%d%d",&n,&q,&a,&b);
	a--;
	b--;
	for(int i=1;i<=q;i++){
		scanf("%d",&x[i]);
		x[i]--;
	}
	x[0]=b;
	n_=1;
	while(n_<n){
		n_*=2;
	}
	update(0,n,0,INF);
	update(0,n,1,INF);
	update(0,n,2,INF);
	change(a,a+1,0,0);
	change(a,a+1,1,-a);
	change(a,a+1,2,a);
	for(int i=1;i<=q;i++){
		update(0,n,0,labs((ll)x[i]-x[i-1]));
		ll v1=(ll)query(0,x[i]+1,1)+x[i];
		ll v2=(ll)query(x[i]+1,n,2)-x[i];
		ll v=query(x[i-1],x[i-1]+1,0);
		update(0,n,1,labs((ll)x[i]-x[i-1]));
		update(0,n,2,labs((ll)x[i]-x[i-1]));
		if(v>min(v1,v2)){
			change(x[i-1],x[i-1]+1,0,min(v1,v2));
			change(x[i-1],x[i-1]+1,1,min(v1,v2)-x[i-1]);
			change(x[i-1],x[i-1]+1,2,min(v1,v2)+x[i-1]);
		}
	}
	printf("%lld\n",query(0,n,0));
	return 0;
}


Measured memory_bytes: 29056
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
bool kai(string s){
    string t = s;
    reverse(all(t));
    return s == t;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k,n;
    cin >> n >> k;
    vector<ll> p(n+1,0);
    rep(i,n) cin >> p[i+1];
    rep(i,n) p[i+1] += p[i];
    ll ans = 0;
    rep(i,k,n+1){
        chmax(ans,p[i]-p[i-k]);
    }
    printf("%.10lf\n",(ans+k)/2.0);
}


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


int main(){
	int N;cin >> N;
	int ans = 0;
	int m = 200000;
	rep(i,N){
		int tmp;
		cin >> tmp;
		if(m>=tmp){
			ans++;
			m = tmp;
		}
	}
	cout << ans << endl;
}














Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;
using namespace boost::multiprecision;

int main(){

    int n;
    cin >> n;

    string s;
    cin >> s;

    int ans = 0;

    rep(i, n - 2){
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
int fee4(int water) {
	if (water <= 0) return 0;
	return water * 160;
}
int fee3(int water) {
	if (water <= 0) return 0;
	return ((water > 10) ? 10 : water) * 140 + fee4(water - 10);
}
int fee2(int water) {
	if (water <= 0) return 0;
	return ((water > 10) ? 10 : water) * 125 + fee3(water - 10);
}
int fee1(int water) {
	return 1150 + fee2(water - 10);
}
int main() {
	int w;
	std::cin >> w;
	while (w != -1) {
		std::cout << 4280 - fee1(w) << std::endl;
		std::cin >> w;
	}
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(ll i=j;i<k;i+=in)
#define DF(i,j,k,in) for(ll i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); it++)
#define fitr(it,it1,itr2,in) for(auto it=itr1;it!=itr2;it+=in)
#define Dfeach(it,l) for (auto it = l.end()-1; it != l.begin()-1; it--)
#define Dfitr(it,it1,itr2,in) for(auto it=itr1;it!=itr2-1;it-=in)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define PI 3.1415926535897932384626433832795
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
const ll MOD=1000000007;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin>>n;
n=n%10;
if(n==3)  cout<<"bon";
else if((n==0)||(n==1)||(n==6)||(n==8)) cout<<"pon";
else cout<<"hon";
return 0;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{


  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    long in_N;
    long in_M;

    long ans;


    try
    {
      in_stream = new BufferedReader(new InputStreamReader(System.in));

      /*----------------
       * 引数
       *----------------*/
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");

      in_N   = Long.parseLong(in_str_split[0]);
      in_M   = Long.parseLong(in_str_split[1]);


      /*----------------
       * 計算
       *----------------*/
      ans = 0L;

      /* 両方が1なら、1 */
      if( (1 == in_N) && (1 == in_M) )
      {
        ans = 1L;
      }
      /* 片方が2なら、必ず0 */
      else if( (2 == in_N) || (2 == in_M) )
      {
        /* Nothing to do. */
      }
      /* 片方が1なら、大きい方 -2 */
      else if(1 == in_N)
      {
        ans = in_M - 2L;
      }
      /* 片方が1なら、大きい方 -2 */
      else if(1 == in_M)
      {
        ans = in_N - 2L;
      }
      /* 両方3以上 */
      else
      {
        ans = (in_N - 2L) * (in_M - 2L);
      }

      System.out.println("" + ans);

    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }

}


Measured memory_bytes: 21332
/*input
4 4
*/
#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 tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ll,ll>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll INF64=4e15;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const ll maxn=6*1e4+5;
const ll maxlg=__lg(maxn)+2;
int main(){
    int a,b;
    cin>>a>>b;
    cout<<max(0,a-2*b);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int r, g, b;
  cin >> r;
  cin >> g;
  cin >> b;
  int sum = 10 * g + b;
  if (sum % 4 == 0) {
    cout << "YES";
  }
  else {
    cout << "NO";
  }
  return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i,n) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	p[n-1] /= 2;
	int ans = 0;
	rep(i,n) {
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}


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

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

using namespace std;

int main() {
  string s;
  cin >> s;
  rep(i, s.length()) {
    if ((i + 1) % 2 == 1) cout << s[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.HashMap;
import java.util.Scanner;

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

    char[] s = scanner.next().toCharArray();
    char[] t = scanner.next().toCharArray();

    int[] si = number(s);
    int[] ti = number(t);

    if (equals(si, ti)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

  private static boolean equals(int[] si, int[] ti) {
    for (int i = 0; i < si.length; i++) {
      if (si[i] != ti[i]) {
        return false;
      }
    }
    return true;
  }

  private static int[] number(char[] chars) {
    HashMap<Character, Integer> map = new HashMap<>();
    int n = 0;
    int[] id = new int[chars.length];
    for (int i = 0; i < chars.length; i++) {
      char ch = chars[i];
      if (!map.containsKey(ch)) {
        map.put(ch, n++);
      }
      id[i] = map.get(ch);
    }
    return id;
  }
}


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

#define ll long long
#define pp pair<int, int>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPU(i, a, b, s) for(int i = a; i < b; i += s)
#define REPD(i, a, b, s) for(int i = a; i > b; i -= s)
#define endl "\n"

ll INF = 2e18;
ll MOD = 1e9 + 7;
int i, j, k, t;

int main() {
    double T, X;
    cin >> T >> X;
    cout << T / X << endl;
}

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

int main()
{
  int count = 0;
  string s;
  cin >> s;
  if (s[0] == '1') count++;
  if (s[1] == '1') count++;
  if (s[2] == '1') count++;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#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()
{
    string s, t;
    cin >> s;
    cin >> t;

    int size = s.size();
    if (t.size() == size + 1 && t.substr(0, size) == s)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			double a = sc.nextInt();
			double b = sc.nextInt();
			double h = sc.nextInt();
			double m = sc.nextInt();

			double hr = (((h * 60) + m) / 720) * 360 * Math.PI / 180;
			double mr = (m / 60) * 360 * Math.PI / 180;

			double ax = a * Math.cos(hr);
			double ay = a * Math.sin(hr);
			double bx = b * Math.cos(mr);
			double by = b * Math.sin(mr);

			double result = Math.sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
			System.out.println(result);
		}
	}
}


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

int main(){
	int n;
	string temp;
	cin >> n;
	vector<string> str;
	for(int i=0;i<n;i++){
		cin >> temp;
		str.push_back(temp);
	}
	vector<string> verdict;
	verdict.push_back("AC");
	verdict.push_back("WA");
	verdict.push_back("TLE");
	verdict.push_back("RE");
	vector<int> count;
	count.push_back(0);
	count.push_back(0);
	count.push_back(0);
	count.push_back(0);
	vector<string>::iterator itr;
	for(itr=str.begin();itr!=str.end();++itr){
		if(*itr == verdict[0])
			count[0] += 1;
		if(*itr == verdict[1])
			count[1] += 1;
		if(*itr == verdict[2])
			count[2] += 1;
		if(*itr == verdict[3])
			count[3] += 1;
		}
	for(int i = 0; i<4; i++)
		cout << verdict[i] <<' ' << 'x' << ' ' << count[i] << endl;
}


Measured memory_bytes: 7448