akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;

int main(){
    // あとで消す
    //std::ifstream in("ain1.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N,A,B,C,D;
    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    string S;
    cin >> S;

    //cout << N << " " << A << B << C << D << endl;
    //cout << S << endl;

    int i,j;
    /*
    for(i=0;i<S.length();i++){
        if(S[i]=='.'){
            cout << S[i] << endl;
        }else if(S[i]=='#'){
            cout << "stone" << endl;
        }
    }
    */

    // 目的地，出発地の判定
    if(S[A-1]=='#'){ cout << "No" << endl; return 0;}
    if(S[B-1]=='#'){ cout << "No" << endl; return 0;}
    if(S[C-1]=='#'){ cout << "No" << endl; return 0;}
    if(S[D-1]=='#'){ cout << "No" << endl; return 0;}

    int judge;

    // パターン分け
    if(C<D){
        j=0;
        for(i=A-1;i<=C-1;i++){
            if(S[i]=='#'){
                if(j==1){ cout << "No" << endl; return 0;}
                j=1;
            }else{
                j=0;
            }
        }
        j=0;
        for(i=B-1;i<=D-1;i++){
            if(S[i]=='#'){
                if(j==1){ cout << "No" << endl; return 0;}
                j=1;
            }else{
                j=0;
            }
        }
        cout << "Yes" << endl;
    }else{
        // 飛び越え可能判定
        judge = 0;
        for(i=B-2;i<=D-2;i++){
            if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.'){
                judge = 1;
                break;
            }
        }
        if(judge==0){ cout << "No" << endl; return 0;}

        // 通過可能判定
        j=0;
        for(i=A-1;i<=D-1;i++){
            if(S[i]=='#'){
                if(j==1){ cout << "No" << endl; return 0;}
                j=1;
            }else{
                j=0;
            }
        }
        cout << "Yes" << endl;

    }

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ld, ld> fP;
int relat(fP a, fP b) {
	if (a.first <= b.first+eps && b.second <= a.second + eps)return 2;
	if (a.second <= b.first+eps || b.second <= a.first+eps) return 0;
	return 1;
}
int main() {
	cout << fixed << setprecision(6);
	int k; ld r, l, p, e, t;
	cin >> k >> r >> l >> p >> e >> t;
	ld p1 = (ld)1 - p;
	fP bas = { t - e,t + e };
	queue<pair<fP, ld>> q;
	fP sta = { r,l };
	ld pos=0.0;
	if (relat(bas, sta) == 0) {
		pos = 0.0;
	}
	else if (relat(bas, sta) == 2) {
		pos = 1.0;
	}
	else {
		q.push({ {r,l},(ld)1.0 });
		rep(i, k) {
			int len = q.size();
			rep(j, len) {
				pair<fP, ld>now = q.front(); q.pop();
				ld x = now.first.first; ld y = now.first.second;
				ld mid = (x + y) / (ld)2;
				pair<fP, ld> nex1;
				pair<fP, ld> nex2;
				if (mid > t) {
					nex1 = { {x,mid},p1*now.second };
					nex2 = { {mid,y},p*now.second };
				}
				else {
					nex1 = { {x,mid},p*now.second };
					nex2 = { {mid,y},p1*now.second };
				}
				if (relat(bas, nex1.first) == 2) {
					pos += nex1.second;
				}
				if (relat(bas, nex2.first) == 2) {
					pos += nex2.second;
				}
				if (relat(bas, nex1.first) == 1) {
					q.push(nex1);
				}
				if (relat(bas, nex2.first) == 1) {
					q.push(nex2);
				}
			}
		}
		int len2 = q.size();
		rep(i, len2) {
			pair<fP, ld> aa = q.front(); q.pop();
			ld mid = (aa.first.first + aa.first.second) / (ld)2;
			if (bas.first<=mid+eps&&mid-eps<=bas.second) {
				pos += aa.second;
			}
		}
	}
	cout << pos << endl;
	return 0;
}


Measured memory_bytes: 3304
#include <stdio.h>

int main (void)
{
	int S,h,m,s;

	scanf("%d", &S);

	h = S / 3600;
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;

	printf("%d:""%d:""%d\n",h,m,s);

	return(0);
}

Measured memory_bytes: 592
#include <cstdio>
using namespace std;
int main(){
    int a, b, c;
    char op;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if (op == '?') break;
        switch(op){
            case '+': c = a + b; break;
            case '-': c = a - b; break;
            case '*': c = a * b; break;
            case '/': c = a / b;
        }
        printf("%d\n", c);
    }
    return 0;
}



Measured memory_bytes: 2732
words = lambda t : list(map(t, input().split()))



n = int(input())
a = words(int)
b = words(int)

def getNext(i):
    if i == n-1:
        return 0
    else:
        return i+1

def getPrev(i):
    if i == 0:
        return n-1
    else:
        return i-1

from collections import deque
q = deque()

def verify(i):
    if b[i] != a[i] and b[i] - (b[getNext(i)] + b[getPrev(i)]) >= a[i]:
        return True
    else:
        return False

for i in range(len(b)):
    if b[i] >= a[i] and verify(i):
        q.append(i)

ans = 0
succeed = True
while not len(q) == 0:
    i = q.popleft()
    ni = getNext(i)
    pi = getPrev(i)
    #print(i, b)
    d = b[ni] + b[pi]
    if b[i] % d == a[i] % d:
        ans += b[i] // d - (a[i] // d)
        b[i] = a[i]
    else:
        ans += b[i] // d
        b[i] %= d
    if b[i] < a[i]:
        succeed = False
        break
    if verify(ni):
        q.append(ni)
    if verify(pi):
        q.append(pi)

for i in range(len(b)):
    if a[i] != b[i]:
        succeed = False
        break

if succeed:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 134296
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    int a, b, c ,d;

    cin >> a >> b >> c >> d;

    int winflag = 0;
    while(a > 0 && c > 0){
        c -= b;
        if(c <= 0){
            winflag = 1;
        }
        a -= d;

        // cout << c << " " << b << endl;
    }

    if(winflag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,M; cin>>N>>M;
    vector<int> Q(N,0);
    rep(m,0,M){
        int a,b; cin>>a>>b;
        Q.at(a-1)++;
        Q.at(b-1)++;
    }

    string ans="YES";
    for(auto q:Q){
        if(q%2) ans="NO";
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll binpow(ll x,ll y){
    ll res=1;
    while(y>0){
        if(y&1)
            res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,k,i,m,temp;
    double sum=0,temp1,l=1;
    cin>>n>>k;
    for(i=1;i<=n;i++){
        temp=i;
        m=0;
        while(temp<k){
            temp*=2;
            m+=1;
        }
        sum+=(l/(n*binpow(2,m)));
    }
    cout<<fixed<<setprecision(12)<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int N,K,P,n,m;

scanf("%d",&N);

	for( n=0; n<N; n++ ){
		scanf("%d %d",&K,&P);
		m=K%P;
		if( m==0 ){
			printf("%d\n",P);
		}
		else{
			printf("%d\n",m);
		}

	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
# define ll long long int
#define mp	make_pair
#define pb	push_back
ll mod=1000000007;
const ll INF=1e18L +5;
int main() {
   
   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll n,W;
	cin>>n>>W;
	
	ll w[n+1];ll v[n+1];
	for(int i=1;i<=n;i++){
	   cin>>w[i]>>v[i];
	}
	ll sum=0;
	for(int x=1;x<=n;x++ ){
	   sum+=v[x];
	}
	//cout<<sum<<" ";
	ll dp[n+1][sum+1];
	//repersents minimum wieght to get value i;

	for(int i=0;i<=n;i++){
	   for(int j=0;j<=sum;j++)
	      dp[i][j]=INF;
	}
	dp[0][0]=0;
	for(int i=1;i<=n;i++) dp[i][0]=0;
	
	
	for(int i=1;i<=n;i++){
	   for(int j=1;j<=sum;j++){
	      if(v[i]>j){
	         dp[i][j]=dp[i-1][j]; 
	      }
	      if(v[i]<=j){
	         dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
	      }
	   }
	}
	ll ans;
	for(int i=1;i<=sum;i++){
	   if(dp[n][i]<=W)
	      ans=i;
	//  cout<<dp[n][i]<<" "<<i<<"    \n";
   }
	cout<<ans;
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

bool ok=true;
ll n,l=1;
string s;

void init(){
	cin>>s;
	n = s.size();
	s="0"+s;
}

int main(void){
	init();
	reg(i,0,n)if(s[i]!=s[n-i])ok=false;
	if(s[1]=='0')ok=false;
	if(!ok){
		cout<<-1<<endl;
		return 0;
	}
	reg(i,1,n-1){
		cout<<l<<" "<<i+1<<endl;
		if(s[i]=='1'){
			l=i+1;
		}
	}
	return 0;
}

Measured memory_bytes: 1660
program main
    implicit none
    character(101):: s
    integer(8):: dp(0:1,0:3,0:105)=0, k, n
    integer(4):: i1, i2, i3, d, i
    integer(4):: nd, ni1,ni2,ni3, ans=0

    read*, s
    read*, k
    n = len_trim(s)
    dp(0,0,0) = 1


    do i1=0, n-1
        do i2=0, 3
            do i3=0, 1
                read(s(i1+1:i1+1),*) nd
                do d=0,9
                    ni1 = i1+1; ni2 = i2; ni3 = i3 
                    if (d /= 0) ni2=ni2+1
                    if (ni2 > k) cycle
                    if (i3==0) then
                        if (d > nd) cycle
                        if (d < nd) ni3=1
                    end if
                    dp(ni3,ni2,ni1) = dp(ni3,ni2,ni1) + dp(i3,i2,i1)
                end do
            end do
        end do
    end do
    do i=0,n
        ! print*,'--'
        ! print*, dp(0,:,i)
        ! print*, dp(1,:,i)
    end do
    ans = dp(0,k,n)+dp(1,k,n)

    print*, ans
end program main

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

int main() {

	int string_length, string_substr;
	int substr_left, substr_right;
	string input_string;

	//===文字列の長さ、部分文字列の数、元の文字列の格納

	cin >> string_length >> string_substr >> input_string;
	vector<int> substr_counter(string_length);
	vector<int> substr_answer(string_substr);

	//===1文字目から、[AC]が何個出てきたかを記録する

	for (int counter = 1; counter < input_string.length(); counter++) {
		if (input_string[counter - 1] == 'A' && input_string[counter] == 'C') {
			substr_counter[counter] = substr_counter[counter - 1] + 1;
		}
		else {
			substr_counter[counter] = substr_counter[counter - 1];
		}
	}

	//===右側までで出てきたACの数から左側までで出てきたACの数の差を取る。

	for (int counter = 0; counter < string_substr; counter++) {
		cin >> substr_left >> substr_right;
		substr_answer[counter] = substr_counter[--substr_right] - substr_counter[--substr_left];
	}

	//===解答の出力

	//for (int counter = 0; counter < string_length; counter++) {//debug
		//cout << substr_counter[counter] << " ";
	//}cout << endl;

	for (int counter = 0; counter < string_substr; counter++) {
		cout << substr_answer[counter] << endl;
	}

	//===

	return 0;
}
//*/

Measured memory_bytes: 1792
import itertools

N = input()
K = int(input())
lN = len(N)

if K == 1:
    ans = int(N[0])+9*(lN-1)
    print(ans)

elif K == 2:
    not0 = 1000
    for i in range(1,lN):
        if int(N[i]) != 0:
            not0 = i
            break

    ans = 0
    n = [i for i in range(lN)]

    for v in itertools.combinations(n,2):
        #print(v)
        if v[0] != 0:
            ans += 9*9
        else:
            if not0 >= v[1]:
                ans += max(0,int(N[0])-1)*9 + int(N[v[1]])
            else:
                ans += int(N[0])*9
    print(ans)

else:
    not0f = 1000
    not0s = 1000
    for i in range(1,lN):
        if int(N[i]) != 0:
            not0f = i
            break
    for i in range(not0f+1,lN):
        if int(N[i]) != 0:
            not0s = i
            break
    ans = 0
    n = [i for i in range(lN)]
    for v in itertools.combinations(n,3):
        if v[0] != 0:
            ans += 9*9*9
        else:
            if not0f == v[1]:
                if not0s >= v[2]:
                    ans += max(0,int(N[0])-1)*9*9
                    ans += max(0,int(N[v[1]])-1)*9
                    ans += int(N[v[2]])
                else:
                    ans += max(0,int(N[0])-1)*9*9
                    ans += int(N[v[1]])*9
            elif not0f < v[1]:
                ans += int(N[0])*9*9
            else:
                ans += max(0,int(N[0])-1)*9*9

    print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define fr(j,a,b) for(j=a;j<b;j++)


int power(int x, unsigned int y, int p)  
{    int res = 1;    
     x = x % p;
     if (x == 0) return 0;
     while (y > 0)  
     {  if (y & 1)  
        res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
     }  
    return res;  
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli t,i,m,j,n,x,k,f,g,q,r,w,l,b,c;
    cin>>n>>k;
    cout<<min(n%k,k-(n%k));
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <queue>
#include <assert.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <complex>
#include <numeric>
#include <map>
#include <time.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<int,ull> piu;
typedef pair<ull,ull> puu;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pii,ll> ppl;
typedef pair<ll,pii> plp;
typedef pair<ll,pll> plP;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<double,int> pdi;
typedef pair<int,double> pid;
typedef pair<double,pii> pdp;
typedef pair<double,double> pdd;
typedef pair<pdd,double> pd3;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
#define repn(i,a,n) for (int (i) = (a); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SORT(x) sort((x).begin(),(x).end())
#define SORTN(x,n) sort((x),(x)+(n))
#define ERASE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define COUNT(x,c) count((x).begin(),(x).end(),(c))
#define REMOVE(x,c) (x).erase(remove((x).begin(),(x).end(),(c)),(x).end())
#define REVERSE(x) reverse((x).begin(),(x).end())
#define FORIT(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))-(x).begin()
#define lb(x,a) lower_bound((x).begin(),(x).end(),(a))
#define LBN(x,a,n) lower_bound((x),(x)+(n),(a))-(x)
#define lbN(x,a,n) lower_bound((x),(x)+(n),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))-(x).begin()
#define ub(x,a) upper_bound((x).begin(),(x).end(),(a))
#define BS(x,a) binary_search((x).begin(),(x).end(),(a))
#define BS2(x,n,a) binary_search((x),(x)+(n),(a))
#define NB(x) (((x)&~((x)+((x)&-(x))))/((x)&-(x))>>1)|((x)+((x)&-(x)))
#define NP(x) next_permutation((x).begin(),(x).end())
#define MM(x,p) memset((x),(p),sizeof(x))
#define SQ(x) (x)*(x)
#define SC(c1,c2) strcmp(c1,c2)==0
#define mp make_pair
#define INF (1<<29)
#define INFL (1LL<<61)
#define fi first
#define se second
#define EPS 1e-9
#define MOD 1000000007
#define MIN(x,a) x=min(x,a)
#define MAX(x,a) x=max(x,a)
#define madd(x,a) x=(x+a)%MOD
#define msub(x,a) x=(x+MOD-a)%MOD
#define OUTPUT(x) rep(__,x.size())printf("%d%c",x[__],__+1==x.size()?'\n':' ')

int N;
ll A[100000];
ll res=11451419198104504LL;

int main()
{
	scanf("%d",&N);
	rep(i,N)scanf("%lld",&A[i]);
	repn(i,1,N)A[i]+=A[i-1];
	if(1)
	{
		ll ad=0;
		ll rr=0;
		rep(i,N)
		{
			if(i%2==0&&A[i]+ad<=0)
			{
				rr+=1-A[i]-ad;
				ad+=1-A[i]-ad;
			}
			if(i%2==1&&A[i]+ad>=0)
			{
				rr+=A[i]+ad+1;
				ad-=A[i]+ad+1;
			}
		}
		MIN(res,rr);
	}
	if(1)
	{
		ll ad=0;
		ll rr=0;
		rep(i,N)
		{
			if(i%2==1&&A[i]+ad<=0)
			{
				rr+=1-A[i]-ad;
				ad+=1-A[i]-ad;
			}
			if(i%2==0&&A[i]+ad>=0)
			{
				rr+=A[i]+ad+1;
				ad-=A[i]+ad+1;
			}
		}
		MIN(res,rr);
	}
	printf("%lld\n",res);
}

Measured memory_bytes: 1024
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll K;
    cin >> K;
    print(a[K-1]);

}

Measured memory_bytes: 764
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, X; cin >> N >> X;
	VI M(N);
	int sum = 0;
	REP(i, N) {
		cin >> M[i];
		sum += M[i];
	}
	X -= sum;
	SORT(M);
	cout << N + X / M[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

#define max(a,b) (a >= b ? a : b)
#define min(a,b) (a >= b ? b : a)


typedef long long ll;

int main(void){
    int A, B, C, D;

    scanf("%d %d %d %d", &A, &B, &C, &D);
    
    int i;

    for(i=0;i>=0;i++){
        if(i%2==0){
            C-=B;
        }else{
            A-=D;
        }
        if(A<=0){
            printf("No");
            break;
        }
        if(C<=0){
            printf("Yes");
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 1732
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	String s = Character.toString(S.charAt(0));
    	String tmp = "";
    	int count = 1;
    	for (int i = 1; i < S.length(); i++) {
    		tmp += Character.toString(S.charAt(i));
    		if (!s.equals(tmp)) {
    			s = tmp;
    			tmp = "";
    			count++;
    		} 
    	}
    	System.out.println(count);
    }
}

Measured memory_bytes: 47008
#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 n,k;
  cin >> n >> k;
  n--,k--;
  ll res = 0;
  res = n / k;
  if(n % k != 0)res++;
  cout << res << endl;
}




Measured memory_bytes: 3584
def main():
    stack = []
    for char in input().split():
        if char in ['+', '-', '*']:
            right = int(stack.pop())
            left = int(stack.pop())
            if char == '+':
                c = left + right
            elif char == '-':
                c = left - right
            elif char == '*':
                c = left * right
            else:
                raise AssertionError
            stack.append(c)
        else:
            stack.append(int(char))

    print(stack[0])
    return


main()


Measured memory_bytes: 5600
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}
int main() {
	int N, A, B;
	cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else{
		cin >> A >> B;
		cout << A + B << endl;
	}

}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    n <- getInt
    let as = filter ((== 0) . (n `mod`)) $ takeWhile (\k -> k^2 <= n) [1..n]
    print . minimum $ map (\a -> f a (n `div` a)) as

f a b = max (length (show a)) (length (show b))

Measured memory_bytes: 892
N, X = map(int, input().split())

T, P = [1], [1]
for i in range(N):
    T.append(T[i] * 2 + 3)
    P.append(P[i] * 2 + 1)

def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + T[N - 1]:
        return f(N - 1, X - 1)
    else:
        return P[N - 1] + 1 + f(N - 1, X - 2 - T[N - 1])

print(f(N, X))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#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;



int main(){

    int a,b;
    cin >> a >> b;

    int aa = a;
    int bb = b;

    rep(i,b - 1){
        aa = aa * 10 + a;
    }

    rep(i,a - 1){
        bb = bb * 10 + b;
    }

    if(a < b){
        cout << aa << endl;
    }else{
        cout << bb << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
int m;

int hmp[1500 * 1000 + 1];
int wmp[1500 * 1000 + 1];

int main(){
	while(cin >> n >> m,n){
		fill(hmp , hmp + 1 + 1500 * 1000,0);
		fill(wmp,wmp + 1 + 1500 * 1000,0);

		vector<int> h(n + 1,0),w(m + 1,0);

		for(int i = 1;i <= n;i++){
			cin >> h[i];
			h[i] += h[i - 1];
		}
		for(int i = 1;i <= m;i++){
			cin >> w[i];
			w[i] += w[i - 1];
		}

		for(int i = 0;i <= n;i++){
			for(int j = i + 1;j <= n;j++){
				int len = h[j] - h[i];
				hmp[len]++;
			}
		}
		for(int i = 0;i <= m;i++){
			for(int j = i + 1;j <= m;j++){
				int len = w[j] - w[i];
				wmp[len]++;
			}
		}

		i64 result = 0;

		for(int i = 1;i <= 1500 * 1000;i++){
			result += hmp[i] * wmp[i];
		}
		cout << result << endl;
	}
}



Measured memory_bytes: 14752
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <boost/range/adaptors.hpp>
#include <iomanip>

int main() {
    int L;
    std::cin >> L;

    double a = static_cast<double>(L) / 3.0;
    std::cout << std::fixed<< std::setprecision(7) << static_cast<double>(L * L * L) / 27.0 << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int [] weight = new int[n + 1];
        int[] value = new int[n + 1];
        for (int i = 1; i <= n; ++i) {
            weight[i] = scanner.nextInt();
            value[i] = scanner.nextInt();
        }
        long [][] result = new long[n + 1][100005];
        for (int v = 0; v < 100005; ++v) {
            result[1][v] = Long.MAX_VALUE;
        }
        result[1][0] = 0;
        result[1][value[1]] = weight[1];
        for (int i = 2; i <= n; ++i) {
            for (int v = 0; v < 100005; ++v) {
                result[i][v] = result[i - 1][v];
                if (v >= value[i] && result[i - 1][v - value[i]] != Long.MAX_VALUE) {
                    result[i][v] = Math.min(
                            result[i][v],
                            result[i - 1][v - value[i]] + weight[i]
                    );
                }
            }
        }
        for (int v = 100004; v >= 0; --v) {
            if (result[n][v] >= 0 && result[n][v] <= w) {
                System.out.println(v);
                return;
            }
        }
    }
}


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

typedef long long ll;
typedef unsigned long long ull;

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

  vector<ll> a(n, 0);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }
  
  vector<ll> b(n, 0);
  for (ll i = 0; i < n; ++i) {
    cin >> b[i];
  }

  vector<ll> c(n, n-1);
  for (ll i = 0; i < n-1; ++i) {
    cin >> c[i];
  }

  ll ans = b[a[0]-1];
  ll prev = a[0];
  for (ll i = 1; i < n; ++i) {
    ans += b[a[i]-1];
    if (prev+1 == a[i]) ans += c[prev-1];
    prev = a[i];
  }

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

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

int main() {
  int n; cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }

  int b = 0, ans = 0;
  bool c[n] = {};
  c[0] = true;
  while (!c[a[b]]) {
    b = a[b];
    ans++;
    if (b == 1) {
      cout << ans << endl;
      return 0;
    }
    c[b] = true;
  }
  cout << -1 << endl;
}

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

int ans=0;
int n;

void calc(int sum,int m){
	int i;
	if(m==4){
		if(sum==n)ans++;
		return;
	}
	if(sum>n)return;
	for(i=0; i<=9; i++){
		calc(sum+i,m+1);
	}

}

int main(){
	while(scanf("%d",&n)!=EOF){
		ans=0;
		calc(0,0);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 596
//
//  main.cpp
//  backToProblemSolving
//
//  Created by Khaled Abdelfattah on 6/27/17.
//  Copyright © 2017 Khaled Abdelfattah. All rights reserved.
//

#include <bits/stdc++.h>
// #include <iostream>
using namespace std;

typedef long long ll;
#define MAX 1000000000
#define BASE1 23
#define BASE2 31
#define MOD1 1000000007
#define MOD2 217645177
#define eps 1e-6

int main() {
    int n, occ[100005];
    cin >> n;
    vector<int> arr(n);
    memset(occ, 0, sizeof occ);
    for (int i = 0; i < n; i ++)
        cin >> arr[i], occ[arr[i]] ++;
    sort(arr.begin(), arr.end());
    int res = n;
    int idx = 0;
    bool visited[100005];
    memset(visited, 0, n + 1);
    for (int i = 1; i < n; i ++) {
        if (arr[i] == arr[idx] && !visited[i] && idx != i) {
            res -= 2;
            visited[i] = true;
            occ[arr[i]] --;
            int flag = i + 1;
            while (flag < n && occ[arr[flag ++]] <= 1);
            if (flag == n)
                flag = i + 1;
            visited[flag] = true;
            occ[arr[flag]] --;
        }
        if (arr[i] != arr[idx] && !visited[i])
            idx = i;
    }
    cout << max(res, 1);
    return 0;
}

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

using namespace std;
#define ll long long int
#define pb push_back
#define rep(i, a, v) for(int i = a; i <= v; ++i)
#define vi vector<int>
#define vll vector<ll>
#define maxi 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
const double pie = 3.1415926535;
const string spaces = "    ";

ll i, j, k;
ll temp;

int main(){
    cout.tie(0);
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<int> heights(n + k, 0), dp(n + k, maxi);
    for(int i = 0; i < n; ++i){
        cin >> heights[i];
    }
    
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 1; j <= k; ++j){
            dp[i + j] = min(dp[i + j], dp[i] + abs(heights[i + j] - heights[i]));
        }
    }

    cout << dp[n - 1] << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;

template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int n;

int main()
{
    //~ freopen("file.in", "r", stdin);
	string s,t;
	cin>>s>>t;
	n=s.size();
	for(int i=0;i<n;i++){
		if(s==t)
			return puts("Yes")*0;
		s=s[n-1]+s;
		s.erase(n,1);
	}    
    puts("No");

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cout << (n + 1) / 2 << endl;
    return 0;
}

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

typedef long long ll;

const ll infl = 1LL << 60;

bool chmin(ll &a,ll &b)
{
    if(a > b){
        a = b;
        return 1;
    }
    return 0;
}

int N;
ll s[404];    //入力値
ll s_sum[404];//s_sum[i]:入力値i番目までの和

//初期化関数
void init()
{
    s_sum[0] = s[0];
    for(int i = 1; i < N; i++) s_sum[i] = s_sum[i - 1] + s[i];
}

//入力値L番目からR番目までの和を返す
ll get(int L,int R)
{
    ll res = s_sum[R];
    if(L) res -= s_sum[L - 1];
    return res;
}

//メモ化再帰
ll memo[404][404];
bool vis[404][404]; //探索済みフラグ

//L番目からR番目までのコストの最小値
ll dp(int L,int R)
{
    if(L == R) return 0;
    else if(vis[L][R] == true) return memo[L][R];//探索済みならリターン
    vis[L][R] = true;//フラグを立てる  
    
    ll res = infl;//resは十分大きい
    for(int c = L; c < R; c++) res = min(res,dp(L,c) + dp(c+1,R) + get(L,R));//c番目で二つに区切る
    return memo[L][R] = res;//メモしながらリターン
}

int main()
{
    cin >> N;
    for(int i = 0; i < N; i++) cin >> s[i];
    init();
    cout << dp(0,N - 1) << endl;
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
map<char, string>m1; map<string, char>m2;
signed main() {
	{
		m1[' '] = "101";
		m1['\''] = "000000";
		m1[','] = "000011";
		m1['-'] = "10010001";
		m1['.'] = "010001";
		m1['?'] = "000001";
		m1['A'] = "100101";
		m1['B'] = "10011010";
		m1['C'] = "0101";
		m1['D'] = "0001";
		m1['E'] = "110";
		m1['F'] = "01001";
		m1['G'] = "10011011";
		m1['H'] = "010000";
		m1['I'] = "0111";
		m1['J'] = "10011000";
		m1['K'] = "0110";
		m1['L'] = "00100";
		m1['M'] = "10011001";
		m1['N'] = "10011110";
		m1['O'] = "00101";
		m1['P'] = "111";
		m1['Q'] = "10011111";
		m1['R'] = "1000";
		m1['S'] = "00110";
		m1['T'] = "00111";
		m1['U'] = "10011100";
		m1['V'] = "10011101";
		m1['W'] = "000010";
		m1['X'] = "10010010";
		m1['Y'] = "10010011";
		m1['Z'] = "10010000";
	}
	{
		m2["00000"] = 'A';
		m2["00001"] = 'B';
		m2["00010"] = 'C';
		m2["00011"] = 'D';
		m2["00100"] = 'E';
		m2["00101"] = 'F';
		m2["00110"] = 'G';
		m2["00111"] = 'H';
		m2["01000"] = 'I';
		m2["01001"] = 'J';
		m2["01010"] = 'K';
		m2["01011"] = 'L';
		m2["01100"] = 'M';
		m2["01101"] = 'N';
		m2["01110"] = 'O';
		m2["01111"] = 'P';
		m2["10000"] = 'Q';
		m2["10001"] = 'R';
		m2["10010"] = 'S';
		m2["10011"] = 'T';
		m2["10100"] = 'U';
		m2["10101"] = 'V';
		m2["10110"] = 'W';
		m2["10111"] = 'X';
		m2["11000"] = 'Y';
		m2["11001"] = 'Z';
		m2["11010"] = ' ';
		m2["11011"] = '.';
		m2["11100"] = ',';
		m2["11101"] = '-';
		m2["11110"] = '\'';
		m2["11111"] = '?';
	}

	string s;
	while (getline(cin, s)) {
		string s1 = "", ans = "";
		for (char ch : s) s1 += m1[ch];
		while (s1.size() % 5 != 0)s1 += '0';
		for (int i = 0; i < s1.size(); i += 5) ans += m2[s1.substr(i, 5)];
		cout << ans << endl;
	}
}


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

typedef long long ll;
const int mod=1000000007;

int n,cnt;
int c[200005];
int pre[200005];
int dp[200005];

int main(){

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

    cin>>n;
    dp[0]=1;
    cnt=1;
    for(int i=1;i<=n;i++){
        cin>>c[cnt];
        if(c[cnt]!=c[cnt-1])cnt++;
    }
    n=cnt-1;
    for(int i=1;i<=n;i++){
        dp[i]=(dp[i-1]+pre[c[i]])%mod;
        pre[c[i]]=(pre[c[i]]+dp[i-1])%mod;
        //cerr<<dp[i]<<' ';
    }
    //cerr<<endl;
    cout<<dp[n]<<endl;

    return 0;
}

Measured memory_bytes: 2560
import java.util.*;

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

    int N = in.nextInt();
    long K = in.nextLong();

    int[] path = new int[N];
    for (int i = 0; i < N; i++) {
      path[i] = in.nextInt() - 1;
    }

    int slow = path[0];
    int fast = path[path[0]];

    while (slow != fast) {
      slow = path[slow];
      fast = path[path[fast]];
    }

    // Found out the distance to the start of the loop
    int count = 0;
    slow = 0;
    while (slow != fast) {
      slow = path[slow];
      fast = path[fast];
      count++;
    }

    // Found out the distance in the loop
    int loop = 1;
    fast = path[slow];
    while (slow != fast) {
      fast = path[fast];
      loop++;
    }

    int k;

    // Doesn't go into the loop.
    if (((long) count) >= K) {
      k = (int) K;
      slow = 0;
    } else {
      k = (int) ((K - count) % ((long) loop));
    }

    for (int i = 0; i < k; i++) {
      slow = path[slow];
    }

    System.out.println(slow + 1);
  }
}


Measured memory_bytes: 59892
#include <iostream>
#include <stdio.h>
#include <cctype>
using namespace std;

int main() {
    char ch;
    while(1) {
	scanf("%c", &ch);
	if(islower(ch)) {
	    ch = toupper(ch);
	} else if(isupper(ch)) {
	    ch = tolower(ch);
	}
	if(ch == '\n') break;
	printf("%c", ch);
    }
    cout << endl;
}

Measured memory_bytes: 1144
#include<stdio.h>
int main()
{
	char S[100000];
	int i,left;
	gets(S);
	for(left=0,i=1;S[i]!='\0';i++)
	{
		if(S[i-1]==S[i])
		{
			left++;
			if(S[i]=='1')
				S[i]='0';
			else 
				S[i]='1';
		}
	}
	printf("%d\n",left);
	return 0;
}


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

int main() {

    int N;
    cin >> N;
    
    if (N % 2 == 0) {
        cout << 0.5000000000 << endl;
    }
    
    else {
        cout << ((N / 2) + 1.0) / N << endl;
    }
    
}


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

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

ll dp[101][100001];

int main(){
    int N,W;
    cin >> N >> W;
    ll w,v;
    cin >> w >> v;
    dp[0][w] = v;
    for(int i=1; i<N; i++){
        cin >> w >> v;
        rep(j,W+1){
            dp[i][j] = dp[i-1][j]; 
            if(j-w>=0) dp[i][j] = max(dp[i][j], dp[i-1][j-w]+v);
        }
        dp[i][w] = max(dp[i][w], v);
    }
    ll ans = 0;
    rep(j,W+1){
        ans = max(ans, dp[N-1][j]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 77568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define maxn 100
int N;
int X[maxn];
ll ret = LONG_LONG_MAX;
ll fun(int P)
{
    ll tmp = 0;
    for(int i = 0;i < N;i ++)
    {
        tmp += (X[i]-P)*(X[i]-P);
    }
    return tmp;
}
int main(void)
{
    cin>>N;
    int _min = 100;
    int _max = 1;
    for(int i =0 ;i <N;i ++)
    {
        cin>>X[i];
        _min = min(_min,X[i]);
        _max = max(_max,X[i]);
    }
    sort(X,X+N);
    int l1 = _min,r1 = _max, mid, mmid;
    while(l1<r1-2)
    {
        mid = (l1+r1)/2;
        mmid = (mid + r1)/2;
        if(fun(mid) > fun(mmid))
            l1 = mid;
        else r1 = mmid;
    }
    mid=(l1+r1)/2;
    printf("%lld\n",min(fun(mid),min(fun(l1),fun(r1))));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,ans;
    cin>>n;
    int a[n][3];
    for(i=0;i<n;i++)
    for(j=0;j<3;j++)cin>>a[i][j];
    int dp[n][3];//dp[i][j]stores the total happiness value when i days passed and he does jth task out of the three on the ith day
    for(i=0;i<3;i++)
    dp[0][i]=a[0][i];
    for(i=1;i<n;i++)
    {
        for(j=0;j<3;j++)
        dp[i][j]=a[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
    }
    ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        if (a <= b + c) {
            b = Math.min(a, b);
            System.out.println(b);
        } else {
            long d = a / (b + c);
            long e = a % (b + c);
            
            e = Math.min(e, b);
            
            System.out.println(d * b + e);
        }
    }
}


Measured memory_bytes: 23892
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

const MOD: usize = 1_000_000_007;
const MAX: usize = 510_000;
fn com_init(fac: &mut [usize], finv: &mut [usize], inv: &mut [usize]) {
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for i in 2..MAX {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

fn bin_coef(n: usize, k: usize, fac: &mut [usize], finv: &mut [usize], inv: &mut [usize]) -> usize {
    if k > n/2 {
        bin_coef(n-k, k, fac, finv, inv)
    } else {
        fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
    }
}


use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque, HashMap};
use std::iter::FromIterator;
fn main() {
    input!{
        N: usize,
        W: usize,
        budget: [(usize, usize); N],
    }
    let mut vals = vec![0; W+1];
    for &(w, v) in budget.iter() {
        for prev in (1..W-w+1).rev() {
            if vals[prev] > 0 {
                vals[prev+w] = max!(vals[prev+w], vals[prev]+v);
            }
        }
        vals[w] = max!(vals[w], v);
    }

    let max = vals.iter().max().unwrap();
    println!("{}", max);
}

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

#define MAX 100
#define MAXW 100000
#define INF (INT32_MAX/2)

int N, W;
int w[MAX];
int v[MAX];

long long dp[MAXW + 1];

int main() {
	cin >> N >> W;
	for( int i = 0; i < N; i++ ) {
		cin >> w[i] >> v[i];
	}

	for( int i = 0; i < N; i++ ) {
		for( int j = W; j >=w[i]; j-- ) {
			dp[j] = max( dp[j], dp[j - w[i]] + v[i] );
		}
	}
	long long ans = dp[W];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
i=list(map(int, input().split()))
a=list(map(int, input().split()))
b=list(map(int, input().split()))
A=i[0]
B=i[1]
M=i[2]
x = []
y = []
c = []
for j in range(M):
    x1,y1,c1=[int(j) for j in input().split()]
    x.append(x1)
    y.append(y1)
    c.append(c1)
d=200001
e=100001
f=100001
for k in range (A):
    if a[k]<e:
        e=a[k]

for l in range (B):
    if b[l]<f:
        f=b[l]
d=e+f

for p in range (M):
    if a[x[p]-1]+b[y[p]-1]-c[p]<d:
        d= a[x[p]-1]+b[y[p]-1]-c[p]

print(d)




Measured memory_bytes: 25388
#include <iostream>
using ll = long long;
using namespace std;


int main() {
    int n, R[200000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d", &R[i]);
    }
    int maxv = -2000000000;
    int minv = R[0];
    for (int j = 1; j < n; ++j) {
        maxv = max(maxv, R[j]-minv);
        minv = min(minv, R[j]);
    }
    cout << maxv << "\n";
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	vector<int> v(2*n);
	for(auto &x : v){
		cin>>x;
	}
	sort(v.begin(), v.end());
	int ans = 0;
	for(int i = 0; i < n; i++){
		ans += v[i<<1];
	}
	cout<<ans<<endl;

	return 0;
}

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

  int N ;
  cin >> N ;
  if(N==25 )cout << "Christmas" <<endl ;
  if(N==24 )cout << "Christmas Eve" <<endl ;
  if(N==23 )cout << "Christmas Eve Eve" <<endl ;
  if(N==22 )cout << "Christmas Eve Eve Eve" <<endl ;
}


Measured memory_bytes: 256
/**
 * 線形探索
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_A&lang=ja
 */

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector <int>S(n);
  for (int i = 0; i < n; i++) {
    cin >> S.at(i);
  }

  int q;
  cin >> q;
  vector <int>T(q);
  for (int i = 0; i < q; i++) {
    cin >> T.at(i);
  }

  // 線形探索
  int cnt = 0;
  // Tに含まれる整数で、Sに含まれているものの個数をカウントする
  for (int i = 0; i < q; i++) {
    for (int j = 0; j < n; j++) {
      if (T.at(i) == S.at(j)) {
        cnt++;
        break;
      }
    }
  }
  
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3116
//9-A
 
import java.util.Scanner;
 
class Main {
    public static void main(String [] args){
         
        Scanner sc = new Scanner(System.in);
         
        String W = sc.next();//??????
        
        int count = 0;
        
        while(true){
        	
        	String T = sc.next();//??????
        	
        	if(T.equals("END_OF_TEXT")){
        		break;
        	}
        	
        	//????????????????????¨?????§????????£????????? str ?????\???
        	String[] str = T.split(" ");
        	
        	for(int i=0; i<str.length; i++){
        		//?????????????£?????????? equalsIgnoreCase(W) ??§
        		//????????????boolean
        		if(str[i].equalsIgnoreCase(W)){
        			count++;
        		}
        	}
        	
        }
        
         System.out.println(count);
        
    }
}

Measured memory_bytes: 26248
#include<cstdio>
#include<cstdlib>
#include<cmath>
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a == 5 && b == 5 && c == 7) printf("YES\n");

	else if(a == 5 && b == 7 && c == 5) printf("YES\n");
	else if( a== 7 && b == 5 && c == 5) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int date;
    cin>>date;
    int qian,hou;
    qian=date/100;
    hou=date%100;
    if((1<=qian && qian<=12) && (hou==0 || hou>12)) printf("MMYY");
    else if((1<=hou && hou<=12) && (qian==0 || qian>12)) printf("YYMM");
    else if((1<=qian && qian<=12)&&(1<=hou && hou<=12)) printf("AMBIGUOUS");
    else printf("NA");
    return 0;
}


Measured memory_bytes: 256
#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>;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  stringstream ss(s);
  string item;
  while (getline(ss, item, delim)) {
    if (!item.empty()) {
      elems.push_back(item);
    }
  }
  return elems;
}

int to_seconds(vector<string> t) {
  int h = atoi(t[0].c_str()) * 3600;
  int m = atoi(t[1].c_str()) * 60;
  int s = atoi(t[2].c_str());
  return h + m + s;
}

const int MAX_M = 24 * 60 * 60;
int sum[MAX_M];

int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    rep(i, MAX_M) sum[i] = 0;
    rep(i, n) {
      string a, b;
      cin >> a >> b;
      int dep = to_seconds(split(a, ':'));
      int arr = to_seconds(split(b, ':'));
      sum[dep]++;
      if (arr < MAX_M) sum[arr]--;
    }
    rep(i, MAX_M - 1) sum[i + 1] += sum[i];
    int ans = 0;
    rep(i, MAX_M) ans = max(ans, sum[i]);
    cout << ans << endl;
  }
  return 0;
}


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


int main() {
  int h,w;
  cin >> h>>w;
  int sum=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      char a;
      cin >> a;
      if(a=='#'){
        sum++;
      }
    }
  }
  cout <<  ( sum == h+w-1?"Possible":"Impossible");
    
}

Measured memory_bytes: 256