akhauriyash/Code-Regression huggingface dataset:
face = [0]*6
class Dice():

    def __init__(self):
        self.number = [inp[i] for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'

    def setnumbers(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def spin(self, command):
        for i in range(6):
            face[i] = self.number[i]
        if command == 'S':
            self.setnumbers(face[4], face[0], face[2], face[3], face[5], face[1])
            # print('command is S')
        elif command == 'N':
            self.setnumbers(face[1], face[5], face[2], face[3], face[0], face[4])
            # print('command is N')
        elif command == 'E':
            self.setnumbers(face[3], face[1], face[0], face[5], face[4], face[2])
            # print('command is E')
        elif command == 'W':
            self.setnumbers(face[2], face[1], face[5], face[0], face[4], face[3])
            # print('command is W')
    def equal(self, another):
        set = False
        for i in self.order:
            self.spin(i)
            FLAG = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    FLAG = False
                    break
            if FLAG == True:
                return True
        return set
inp = list(map(int, input().split()))

dice1 = Dice()
dice2 = Dice()

dice1.setnumbers(inp[0], inp[1], inp[2], inp[3], inp[4], inp[5])
inp = list(map(int, input().split()))
dice2.setnumbers(inp[0], inp[1], inp[2], inp[3], inp[4], inp[5])
if dice1.equal(dice2):
    print('Yes')
else:
    print('No')



Measured memory_bytes: 5616
N,M,X = map(int,input().split())
a = [list(map(int,input().split())) for i in range(N)]
d = []
for i in range(2**N):
    b = [0] * (M+1)
    e = i
    for j in range(N):
        if e >= (2**(N-j-1)) :
            e -= (2**(N-j-1))
            for k in range(M+1):
                b[k] += a[j][k]
    c = 1
    for j in range(1,M+1):
        if b[j] < X:
            c = 0
            break
    if c == 1:
        d.append(b[0])
if len(d) > 0:
    ans = min(d)
else:
    ans = -1
print(ans)

Measured memory_bytes: 9228
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]
    def find(self, x):
        """
        x が属するグループを探索して親を出す。
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]
    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)
    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]


N,M = map(int,input().split())
E = []
for i in range(M):
  a,b = map(int,input().split())
  a-=1;b-=1 #0index
  E.append((a,b))

ans = 0

for ng in range(M):
  uf = UnionFind(N)
  for i in range(M):
    if i == ng:
      continue
    else:
      uf.union(E[i][0],E[i][1])
  if uf.get_size(0) != N:
    ans += 1

print(ans)
  

Measured memory_bytes: 74076
# -*- coding: utf-8 -*-
from sys import stdin

Dic = {}
n = int(stdin.readline().rstrip())
for i in range(n):
  line = stdin.readline().rstrip()
  if line[0] == 'i':
    Dic[line[7:]] = 0
  else:
    print('yes' if line[5:] in Dic else 'no')


Measured memory_bytes: 33444
n = int(input())
a = list(map(int, input().split()))

b=[0 for i in range(10**5+1)]

for i in range(n):
    b[a[i]]+=1

maxim = -1
maximid=-1
if(n>=3):
    c = [b[i]+b[i+1]+b[i+2] for i in range(n-2)]
    for i in range(n-2):
        if(maxim<c[i]):
            maxim = c[i]
            maximid = i+1
    print(maxim)
else:
    if(len(a) == 2 and abs(max(a)-min(a))<=1):
        print(2)
    else:
        print(1)
    

    

Measured memory_bytes: 57580
/*
    ~A_Pessimist~:)
*/

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

void solve()
{
    ll n,i,cnt=0,j,k;
    cin>>n;
    ll ar[n];
    for(i=0;i<n;i++) cin>>ar[i];
    //sort(ar, ar+n);
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if(ar[i]!=ar[j] && ar[j]!=ar[k] && ar[k]!=ar[i])
                {
                    if(ar[i]+ar[j]>ar[k] && ar[j]+ar[k]>ar[i] && ar[k]+ar[i]>ar[j]) cnt++;
                }
            }
        }
    }
    cout<<cnt<<endl;
}

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

    int t=1;
    //cin>>t;

    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3652
#E
H,N=map(int,input().split())

A=[]
B=[]
DP=[0]+[float('Inf')]*(2*10**4)

for i in range(N): 
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)

for j in range(10**4):
  for i in range(N):
    DP[j+A[i]]=min(B[i]+DP[j],DP[j+A[i]])

print(min(DP[H:]))

Measured memory_bytes: 47068
#include <stdio.h>
#define MAX 250
int main(){
  int i, n, H[MAX+1];
  scanf("%d",&n);
  for ( i = 1 ; i <=n ; i++) {
    scanf("%d",&H[i]);
  }
  for( i=1 ; i<=n ; i++ ){
    printf("node %d: key = %d, ", i, H[i]);
    if(parent(i)>0){
      printf("parent key = %d, ",H[parent(i)]);
    }
    if(left(i)<=n){
      printf("left key = %d, ",H[left(i)]);
    }
    if(right(i)<=n){
      printf("right key = %d, ",H[right(i)]);
    }
      printf("\n");
  }
 
  return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}
 
int right(int i){
  return 2*i + 1;
}

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

using namespace std;

int N, ans=0;
char sir[20];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%s", sir + 1), N = strlen (sir + 1);
for (int i=1; i<=N; i++)
    sir[i] -= '0';
for (int i=0; i<=N; i++)
if (i == N || sir[i + 1] > 0)
{
    int s = 0;
    for (int j=1; j<=i; j++)
        s += sir[j];
    if (i < N) s += sir[i + 1] - 1;
    for (int j=i+2;j<=N;j++)
        s+=9;
    if(s>ans)
        ans=s;
}
printf("%d\n", ans);
return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
const int N=555;
map <ll,ll> st;
ll n,ans=1e18;
int a,b,c,d;
void solve(ll m,ll sum){
	if (sum>=ans)	return;
	if (m<=1e18/d)
		ans=min(ans,sum+m*d);		
	if (m<=1){
		ans=min(ans,sum+m*d);
		return;
	}
	if (st[m]){
		if (sum>=st[m])	return;
		else st[m]=sum;
	}
	else st[m]=sum;
	if (m%2==0)	solve(m/2,sum+a);
	else{
		solve(m/2,sum+a+m%2*d);
		solve(m/2+1,sum+a+(2-m%2)*d);
	}
	if (m%3==0)	solve(m/3,sum+b);
	else{
		solve(m/3,sum+b+m%3*d);
		solve(m/3+1,sum+b+(3-m%3)*d);
	}
	if (m%5==0)	solve(m/5,sum+c);
	else{
		solve(m/5,sum+c+m%5*d);
		solve(m/5+1,sum+c+(5-m%5)*d);	
	}
}
int main(){
	int T;
	scanf("%d",&T);
	while (T--){
		ans=1e18;
 	   	scanf("%lld%d%d%d%d",&n,&a,&b,&c,&d);
   		solve(n,0);
   		st.clear();
		printf("%lld\n",ans);
	}
    return 0;
}

Measured memory_bytes: 4044
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 200000
#define INF 0x3f3f3f3f
#define lc(x) (x<<1)
#define rc(x) (x<<1|1)
#define mn(x) t[x]
#define mid ((lef+rig)>>1)
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
struct SegmentTree
{
	int t[524289]; void BD(int p, int lef, int rig){lef^rig ? BD(lc(p),lef,mid), BD(rc(p),mid+1,rig), mn(p) = min(mn(lc(p)),mn(rc(p))) : mn(p) = !!lef*INF;}
	void ED(int p, int lef, int rig, int x, int v){lef^rig ? x<=mid ? ED(lc(p),lef,mid,x,v) : ED(rc(p),mid+1,rig,x,v), mn(p) = min(mn(lc(p)),mn(rc(p))) : mn(p) = v;}
	int QU(int p, int lef, int rig, int L, int R){return L^lef||R^rig ? min(L<=mid?QU(lc(p),lef,mid,L,min(mid,R)):INF,R>mid?QU(rc(p),mid+1,rig,max(mid+1,L),R):INF) : mn(p);}
}T[2]; int n, q, c[2][MAXN+5], Ans; struct S{int l,r; S(){} S(int _l, int _r){l=_l,r=_r;}}s[MAXN+5]; inline bool operator < (S a, S b){return a.l^b.l ? a.l<b.l : a.r<b.r;}
int main()
{
	n = read(); for(rint i = 1; i <= n; c[1][i] = c[1][i-1]+read(), c[0][i] = i-c[1][i], i++); Ans = c[1][n];
	q = read(); for(rint i = 1; i <= q; s[i].l = read(), s[i].r = read(), i++); sort(s+1,s+q+1); T[0].BD(1,0,n); T[1].BD(1,0,n);
	for(rint i = 1, f; i <= q; T[0].ED(1,0,n,s[i].r,f-c[0][s[i].r]), T[1].ED(1,0,n,s[i].r,f-c[1][s[i].r]), Ans = min(Ans,f+c[1][n]-c[1][s[i].r]), i++)
		f = min(T[0].QU(1,0,n,s[i].l,s[i].r)+c[0][s[i].r],T[1].QU(1,0,n,0,s[i].l-1)+c[0][s[i].r]-c[0][s[i].l-1]+c[1][s[i].l-1]); printf("%d\n",Ans); return 0;
}

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

typedef long long ll;


vector<ll> is_prime(999999+1,true);

void init_prime() {
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<=999999; i++) {
	if(is_prime[i]) {
	    for(int j=i*2; j<=999999; j+=i)
		is_prime[j] = false;
	}
    }
}

int table[1000000] = {0};

int main() {

    init_prime();

    for(int i=1; i<1000000; i++) {
	if(is_prime[i]) 
	    table[i] = table[i-1]+1;
	else
	    table[i] = table[i-1];

    }
    
    
    int a;
    
    while(cin >> a) {
	cout << table[a] << endl;
	
    }


    return 0;
}

Measured memory_bytes: 14224
#include <stdio.h>

int main() {
  int S,W;
  scanf("%d %d",&S,&W);
  if(S>=1 && S<=100 && W>=1 && W<=100) {
    if(W>=S) {
      printf("unsafe");
    }else {
      printf("safe");
    }
  }
  return 0;
}

Measured memory_bytes: 1692
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define pb push_back
#define f first
#define s second
#define pi 3.141592653589793238
using namespace std;

ll gcd( ll a, ll b )
{
	if(b==0)
	{
		return a;
	}
	else
	{
		return gcd( b, a%b );
	}
}
ll lcm (ll a, ll b)
{
	return (a*b)/gcd(a,b);
}

ll power(ll a, ll b)	//a is base, b is exponent
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	if(b%2 == 1)
		return (power(a,b-1)*a)%mod;
	ll q = power(a,b/2);
	return (q*q)%mod;
}
ll n;
ll sum;
ll w[200];
ll v[200];
ll dp[100005][105];
ll solve(ll idx,ll W)
{
	if(W<=0||idx>n)return 0;
	else if(dp[W][idx]!=-1)return dp[W][idx];
	else 
	{
		if(w[idx]<=W) return dp[W][idx] = max(solve(idx+1,W-w[idx])+v[idx],solve(idx+1,W));
		else return dp[W][idx] = solve(idx+1,W);
	}
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> sum;
	for(int i=1;i<=n;i++) cin >> w[i] >> v[i];
	for(int i = 1;i<100005;i++) for(int j =1;j<105;j++) dp[i][j] =-1;
	cout<< solve(1,sum)<< endl;
	

	return 0;
}


//Hello, this is a snippet.


Measured memory_bytes: 82304
mod = 10**9+7

def Mod_Combination(n, k):
    p, q = 1, 1
    for i in range(n-k+1, n+1):
        p = (p * i) % mod
    for i in range(2, k+1):
        q = (q * i) % mod
    return p * pow(q, mod-2, mod) % mod

N, K = map(int, input().split())
M = N - K + 1
for i in range(1, K+1):
    print(Mod_Combination(M, i) * Mod_Combination(K-1, i-1) % mod)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 2000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
    fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  init();
  std::cout << fac[n] << '\n';
  return 0;
}


Measured memory_bytes: 47104
#include<stdio.h>
int main(void){
    int loop,a,b,c=0,d=0;
while(1){ scanf("%d",&loop);
    if(loop==0)break;
    
    	a=0,b=0,c=0,d=0;
    for(;loop--;){
        scanf("%d %d",&a,&b);
        if(a!=b){
            if(a>b){
                c+=a+b;
            }else{
                d+=a+b;
            }
        }else{
            c+=a;
            d+=b;
        }
    }
    printf("%d %d\n",c,d);
}
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }
 
   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};

vector<ll> v;
ll n,m;

int main(){
  cin >> n >> m;
  ll a[m],b[m];
  rep(i,m){
    cin >> a[i] >> b[i];
    a[i]--,b[i]--;
  }
  UnionFind uf(n);
  ll temp=n*(n-1)/2;
  v.push_back(temp);
  for(int i=m-1;i>0;i--){
    if(uf.find(a[i])!=uf.find(b[i]))temp-=uf.size(a[i])*uf.size(b[i]);
    /*
    cout << "component" << endl;
    rep(j,n){
      cout << "i:" << j << ' ' << "size:" << uf.size(j) << endl;
    }
    cout << endl;
    */
    uf.unite(a[i],b[i]);
    v.push_back(temp);
  }
  rep(i,m)cout << v[m-1-i] << endl;
return 0;}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pii;

int gcd (int a, int b) {
	while (b) {
		a %= b;
		swap (a, b);
	}
	return a;
}

int main(){
	int n;
	cin >> n;
	vector <int> d(n);
	for(int i = 0; i < n; i++)
		cin >> d[i];
		
		
	bool flag2 = false;
	int res = d[0];
	for(int i = 1; i < n; i++){
		res = gcd(res, d[i]);
		if(res == 1){
			flag2 = true;
			break;
		}
	}
	
	bool flag1 = true;
	
	set <int> s;
	for(int i = n-1; i >= 0; i--){
		for(int j = 2; j <= sqrt(d[i]); j++){
			if(d[i] % j == 0){
				if(s.count(j)){
					flag1 = false;
					break;
				}
				else
					s.insert(j);
				while(d[i] % j == 0)
					d[i] /= j;
			}
		}
		
		if(d[i] > 1){
			if(s.count(d[i]))
				flag1 = false;
			else
				s.insert(d[i]);
		}
	}	
	
	if(flag1)
		return cout << "pairwise coprime" << endl, 0;	
	
	if(flag2)
		return cout << "setwise coprime" << endl, 0;
		
	cout << "not coprime" << endl;
	return 0;
}


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

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

  string S; cin >> S;
  deque<char> d;
  for (ll i = 0; i < S.size(); i++) {
    d.push_back(S[i]);
  }

  ll Q; cin >> Q;
  bool reverse = false;
  for (ll i = 0; i < Q; i++) {
    ll t; cin >> t;
    if (t == 1) {
      reverse = !reverse;
    } else {
      ll f; cin >> f;
      char c; cin >> c;
      if (!reverse && f == 1 || reverse && f == 2) {
        d.push_front(c);
      } else {
        d.push_back(c);
      }
    }
  }

  ll N = d.size();
  for (ll i = 0; i < N; i++) {
    ll p = i;
    if (reverse) p = N - 1 - i;
    cout << d[p];
  }
  return 0;
}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;

  if (a >= b) {
    puts("delicious");
    return 0;
  }

  if (b - a <= x) {
    puts("safe");
    return 0;
  }

  puts("dangerous");
  return 0;
}

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

int main(){
    int n; cin >> n;
    string s1, s2; cin >> s1 >> s2;
    ll ans = 1LL;
    int from = -1; // 前が縦なら1
    for(int i = 0; i < n; ){
        if(s1[i] == s2[i]){ // 縦
            if(i == 0){
                ans *= 3;
            }else{
                if(from) ans *= 2;
            }
            from = 1;
            i += 1;
        }else{              // 横
            if(i == 0){
                ans *= 6;
            }else{
                if(from) ans *= 2;
                else ans *= 3;
            }
            from = 0;
            i += 2;
        }
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a)  (a).begin(),(a).end()
#define P pair<int, int>
#define ll long long
const int MOD = 1000000007;
//bitset<64>(x).count()
//fixed << setprecision(15) << 

int main(){
  int n, l;
  cin >> n >> l;
  ll ans = (n*(n+2*l-1))/2;
  if(l>=0)
    ans -= l;
  else
    if(n+l-1<0)
      ans -=n+l-1;
  cout << ans << endl;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0;i<N;i++)
        cin >> h[i];

    vector<int> dp(N);
    long long candidate = 1e9;
    // Base cases
    dp[0] = 0;
    int offset = K - 1;
    for (int i = 1; i < N;i++)
    {
        for (int k = 1; k <= K - offset; k++)
        {
            if (candidate > dp[i - k] + abs(h[i] - h[i - k]))
                candidate = dp[i - k] + abs(h[i] - h[i - k]);
        }
        dp[i] = candidate;
        candidate = 1e9;
        if (offset > 0)
            offset--;
    }

    cout << dp[N - 1];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  for (int i = 0; i < 100; i++){
    if (n < i * 7) break;
    else if ((n - i * 7) % 4 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main(void){
  vector<int> cost(3);
  cin >> cost[0] >> cost[1] >> cost[2];
  sort(cost.begin(), cost.end());
  cout << cost[2]-cost[1] + cost[1]-cost[0] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            for(int i = 0;i < H;i++){
                if(i == 0 || i == H-1){
                    for(int j = 0; j < W; j++){
                        System.out.printf("#");
                    }
                    System.out.printf("\n");
                }else{
                    for(int k = 0; k < W; k++){
                        if(k == 0 || k == W-1){
                            System.out.printf("#");
                        }else{
                            System.out.printf(".");
                        }
                    }
                    System.out.printf("\n");
                }
               
            }
            System.out.printf("\n");
        }
        sc.close();
    }
}                                                    


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

typedef long long ll;
typedef map<int, int> M;
typedef pair<int, int> P;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ((int)(x).size())

int main() {
  string s, t;
  cin >> s >> t;
  int tmp, result = 1001;
  REP(i, SIZE(s) - SIZE(t) + 1) {
    tmp = 0;
    REP(j, SIZE(t)) {
      if (s[i+j] != t[j]) tmp++;
    }
    if (tmp < result) result = tmp;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3564
/*****************************************************************************************
******************************AUTHOR:***************************************************
****************************ASHISH RANJAN***********************************************
*****************************************************************************************/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<chrono>
#include<vector>
#include<string>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define mod 1000000007
#define fr(i,n) for(int i=0;i<(int)n;i++)
int main(){
  fast();
string s;
  cin>>s;
  if(s.size()<2){cout<<"-1 -1";return 0;}
  if(s.size()==2){
  if(s[0]==s[1]){cout<<"1 2";return 0;}
    else{cout<<"-1 -1";return 0;}
  }
  fr(i,s.size()-2){
  if(s[i]==s[i+1]){cout<<i+1<<" "<<i+2;return 0;}
    if(s[i]==s[i+2]){cout<<i+1<<" "<<i+3;return 0;}
    if(s[i+1]==s[i+2]){cout<<i+2<<" "<<i+3;return 0;}
  }
  cout<<"-1 -1";
 return 0;
  
}


Measured memory_bytes: 3772
using System;
using System.Collections.Generic;
using System.Linq;
#if !DEBUG
    using System.IO;
#endif

public class Program {
    struct Point {
        public int x;
        public int y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    struct PQ {
        public long p;
        public long q;

        public PQ(long p, long q) {
            this.p = p;
            this.q = q;
        }
    }

    public static void Main() {
        #region SetAutoFlushIsFalse
#if !DEBUG
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
#endif
        #endregion
        var n = ReadLib.ReadAsInt();
        var points = ReadLib
            .ReadNTimesAsIntArray(n)
            .Select(a => new Point(a[0], a[1])).ToArray();
        if (n == 1) {
            Console.WriteLine(1);    
        } else {
            var pqs = new List<PQ>();
            for (var i = 0; i < n - 1; i++) {
                for (var j = i + 1; j < n; j++) {
                    pqs.Add(new PQ(points[i].x - points[j].x, points[i].y - points[j].y));
                    pqs.Add(new PQ(points[j].x - points[i].x, points[j].y - points[i].y));
                }
            }

            var maxSkip =
                pqs.Where(pq => pq.p != 0 || pq.q != 0)
                   .GroupBy(pq => pq)
                   .Select(g => new KeyValuePair<PQ, int>(g.Key, g.Count()))
                   .Max(kv => kv.Value);

            Console.WriteLine((n - maxSkip).ToString());
        }

        #region Flush
#if !DEBUG
        Console.Out.Flush();
        sw.Close();
#endif
        #endregion
    }
}


static class ReadLib {
    public static long ReadAsLong() {
        return long.Parse(Console.ReadLine());
    }

    public static int ReadAsInt() {
        return int.Parse(Console.ReadLine());
    }

    public static int[] ReadAsIntArray() {
        return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

    public static string[] ReadAsStringArray() {
        return Console.ReadLine().Split(' ');
    }

    public static int[] ReadNTimesAsInt(int n) {
        return Enumerable.Range(1, n).Select(s => int.Parse(Console.ReadLine())).ToArray();
    }

    public static int[][] ReadNTimesAsIntArray(int n) {
        return Enumerable.Range(1, n).Select(s => ReadAsIntArray()).ToArray();
    }

}

Measured memory_bytes: 13920
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

int main(){
    ll x;
    cin>>x;
    ll a=1;
    while(1){
        ll a5=pow(a,5);
        if(a5==x){
            cout<<a<<' '<<0<<endl;
            return 0;
        }else if(a5<x){
            ll b=1,b5=1;
            while(a5+b5<=x){
                if(a5+b5==x){
                    cout<<a<<' '<<-b<<endl;
                    return 0;
                }
                b++;
                b5=pow(b,5);
            }
        }else{
            ll b=1,b5=1;
            while(a5-b5>=x){
                if(a5-b5==x){
                    cout<<a<<' '<<b<<endl;
                    return 0;
                }
                b++;
                b5=pow(b,5);
            }
        }
        a++;
    }
}

Measured memory_bytes: 4096
#include<iostream>
#include<cstdio>

using namespace std;
int main()
{
int w, h, x, y;
cin>>w>>h>>x>>y;
printf("%lf ", double(w)*double(h) / 2);
if(2*x==w && 2*y==h) 
    cout<<1<<endl;
else 
    cout<<0<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

vector<pair<ll, ll>> factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll i = 2; (i * i) <= n; i++) {
        if (n % i) continue;
        res.emplace_back(i, 0);
        while((n % i) == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    auto fac = factorize(n);
    vector<ll> ans;
    rep(i, sz(fac)) {
        rep(j, fac[i].second) {
            ans.push_back(fac[i].first);
        }
    }
    printf("%lld:", n);
    rep(i, sz(ans)) printf(" %lld", ans[i]);
    printf("\n");
    return 0;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N;
vector<ll> A;

int main(){
    cin >> N;
    A.resize(N);
    rep(i,N){
        cin>>A[i];
    }
    sort(all(A));

    vector<ll> csum(N+1,0);
    csum[0] = A[0];
    for(int i=1;i<N;i++){
        csum[i] = csum[i-1] + A[i];
    }

    ll ans = 0;
    for(int i=0;i<N-1;i++){
        if(csum[i] * 2 < A[i+1]){
            ans = 0;
        }else{
            ans++;
        }
    }
    cout << ans+1 << endl;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==1){
	   if(b==0){
	 	  cout<<"Close"<<endl;
	   }
	   else{
		   cout<<"Open"<<endl;
	   }
	}
	else{
		if(c==1){
			cout<<"Open"<<endl;
		}
		else{
			cout<<"Close"<<endl;
		}
	}
	return 0;
}			



Measured memory_bytes: 3072
#!/usr/bin/env python3
(n, m), *q = [[*map(int, i.split())] for i in open(0)]
b = [1] + [0] * (n - 1)
c = [1] * n
for x, y in q:
    c[x - 1] -= 1
    c[y - 1] += 1
    b[y - 1] |= b[x - 1]
    b[x - 1] *= c[x - 1] > 0
print(sum(b))


Measured memory_bytes: 29192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i > 0; i--)

int main() {
    int N;
    cin >> N;
    
    printf("%.10f",(double)(N-N/2) / N);

    return 0;
}

Measured memory_bytes: 256
N = int(input())
ls = list(map(int,input().split()))

boxes = [[] for i in range(N)]
impossible = False
for idx,num in enumerate(ls):
    if num>=N:
        impossible=True
        break
    boxes[num].append(idx)

check_start=-1
ans = 1

if impossible:
    ans = 0
elif len(boxes[0])==0:
    ans = 0
elif boxes[0][0]!=0:
    ans = 0
elif len(boxes[0])>=2:
    ans = 0
else:
    for i in range(N-1):
        a = len(boxes[i])
        b = len(boxes[i+1])
        if a == 0:
            check_start = i
            rest_ls = boxes[i:]
            if rest_ls.count([])!=len(rest_ls):
                ans = 0
            break
        ans*=a**b
baisu = ans//998244353
print(ans-(998244353*baisu))

Measured memory_bytes: 62060
a,b,c,d,e,f=map(int,input().split())
aa=-1
ans=[0,0]
for i in range(0,f+1,a*100):
  for j in range(0,f+1-i,b*100):
    for k in range(0,int(e*(i+j)/100)+1,c):
      for l in range(0,int(e*(i+j)/100)+1-k,d):
        if i+j+k+l>f:
          continue
        if i+j>0 and aa<(k+l)/(i+j+k+l):
          aa=(k+l)/(i+j+k+l)
          ans=[i+j+k+l,k+l]
print(ans[0],ans[1])
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,C;
  cin >> N >> M >> C;
  vector<int> B(M);
  vector<vector<int>> A(N,vector<int>(M));
  for(int i=0;i<M;i++){
    cin >> B.at(i);
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>> A.at(i).at(j);
    }
  }
  int ans=0;
  int check=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      check=check+B.at(j)*A.at(i).at(j);
    }
    if(check+C>0){
      ans++;
    }
    check=0;
  }
  cout << ans <<endl;
}
      
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    string str;
    cin>>k>>str;
    n=str.length();
    if(n<=k)cout<<str;
    else
    {
        cout<<str.substr(0,k)<<"...";
    }
    
}

Measured memory_bytes: 3656
M=10**9+7
h=Hash.new{0}
h[1]=0
(2..gets.to_i).each do |x|
  (2..x).each do |i|
    while (x%i).zero?
      x /= i
      h[i] += 1
    end
  end
end
p h.map{|k,v|v+1}.inject(:*)%M


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    long long N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<long long> raw;
    int flag;
    if(S[0] == '0') flag = 0;
    else flag = 1;
    raw.push_back(0);
    int cnt = 1;
    for(int i = 1; i < S.size(); i++){
        if(S[i] != S[i - 1]){
            raw.push_back(cnt);
            cnt = 1;
        }
        else cnt++;
    }
    raw.push_back(cnt);
    int l = 0, r;
    for(int i = 1; i < raw.size(); i++) raw[i] += raw[i - 1];
    if(flag == 0) r = 2 * K;
    else r = 2 * K + 1;
    long long ans = 0;
    int flag2 = 0;
    int flag3 = 0;
    while(r < raw.size()){
        ans = max(ans, raw[r] - raw[l]);
        if(flag3 == 0 && r + 2 >= raw.size()) r += 1;
        else r += 2;
        if(l ==0 && flag == 0) l++;
        else l += 2;
        flag2 = 1;
    }
    if(flag2 == 0){
        cout << S.size() << endl;
        return 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1528
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	int a,b,c;
	bool f = false;
	cin >> a>>b>>c;
	for (int i = b;i <= c;i++) {
		if (i % a == 0) {
			f = true;
			break;
		}
	}
	if (f) cout << "OK";
	else cout << "NG";
}


Measured memory_bytes: 3636
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let N = get!(usize);
    let mut d = get!(Vec<usize>);

    // dの右中央値と左中央値の差が解
    d.sort();
    let ans = d[N / 2] - d[N / 2 - 1];

    println!("{}", ans);
}

Measured memory_bytes: 6396
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    A = list( map( int, input().split()))
    if sum(A)%(N*(N+1)//2) != 0:
        print("NO")
        return
    t = sum(A)//(N*(N+1)//2)
    d = [0]*N
    for i in range(N):
        d[i] = A[i] - A[i-1] - t
    for i in range(N):
        if d[i] > 0 or d[i]%N != 0:
            print("NO")
            return
    print("YES")
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 14260
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define N 200001
const int MOD = 1000000007;

int cmp(const void* a, const void* b);
int cmp(const void* a, const void* b)
{
	return *(ll*)a > * (ll *) b ? 1 : -1;
}


int main(void)
{
	ll a[N] = { 0 };
	int n = 0;
	int i = 0, j = 0, num = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%lld", &a[i]);
	}
	qsort(a, n, sizeof(a[i]), cmp);
	for (i = 1; i < n; i++)
	{
		if (a[i] == a[i - 1])
		{
			num = 1;
			break;
		}
	}
	if (num)
	{
		printf("NO\n");
	}
	else
	{
		printf("YES\n");
	}
	return 0;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 #define PI 3.14159265359

int main(){
    int N, sum = 0;
    cin >> N;
    for(int i = 1 ; i <= N ; ++i){
        for(int j = 1 ; j <= N ; ++j){
            for(int k = 1 ; k <= N ; ++k){
                sum += __gcd(__gcd(i,j) ,k);
            }
        }
    }
    cout << sum <<endl;
    return 0;
}

Measured memory_bytes: 3628
n = int(input())
h = list(map(int, input().split()))

maxNum = max(h)
countNumber = 0
countWatering = 0
isfinished = False
for c in range(1, maxNum+1):
    array = []
    for index, num in enumerate(h):
        if (num >= c):
            array.append(index)
    if (len(array) == 0 or c > maxNum):
        break
    startIndex = 0
    beforeVlaue  = array[0]-1
    for a in array:
        if (a-1 != beforeVlaue):
            countWatering+=1
        if (a == array[-1]):
            countWatering+=1
        beforeVlaue = a
    
print(countWatering)

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

int n,m;
struct range {
	range(int l, int r ){
		l_ = l;
		r_ = r;
	}
	int l_;
	int r_;
};
class lessd
{
public:
bool operator()(const struct range& r1, const struct range& r2) const {
    	return (r1.r_-r1.l_) < (r2.r_-r2.l_);
    }
};

class rightd
{
public:
bool operator()(const struct range& r1, const struct range& r2) const {
    	return r1.r_ < r2.r_;
    }
};

vector< struct range > v;
vector< struct range > v2;

bool check( struct range& rn )
{
	for( int i = 0; i < v2.size(); i++ ) {
		struct range chk = v2[i];
		if( rn.l_ < chk.r_ ) return false;
	}
	return true;
}
int main()
{
	cin >> n >> m;
	for(int i = 0; i < m; i++ ) {
		int l, r;
		cin >> l >> r;
		struct range rn = range(l, r );
		v.push_back( rn );
	}
//	sort( v.begin(),  v.end(), lessd() );
	sort( v.begin(),  v.end(), rightd() );
	for(int i = 0; i < m; i++ ) {
		struct range rn = v[i];
		//cout << "r=(" << rn.l_ << ", " << rn.r_ << ")" << endl;
	}
	for(int i = 0; i < m; i++ ) {
		struct range rn = v[i];
		if( check(rn) ) {
			v2.push_back( rn );
		}
	}
	cout << v2.size() << endl;
}


Measured memory_bytes: 1400
if __name__ == '__main__':
    a = input().split()
    countWords = []
    lenWords =[]
    for x in a:
        countWords.append(a.count(x))
        lenWords.append(len(x))
    print(a[[i for i,x in enumerate(countWords) if x == max(countWords)][0]],a[[i for i,x in enumerate(lenWords) if x == max(lenWords)][0]])

Measured memory_bytes: 5564
N, K = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7
H =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

ans=0
for h in H:
	if h>=K: ans+=1

print(ans)



Measured memory_bytes: 11908
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};
vector<int> vec;

int main() {

	while(1){
		int n;
		cin>>n;
		if(cin.eof())break;
		if(n==0){
			cout<<vec[vec.size()-1]<<endl;
			vec.pop_back();
		}else vec.push_back(n);
	}

	return 0;
}



Measured memory_bytes: 3132
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
	a=list(map(int,input().split()))
	tmp=0
	for j in range(m):
		tmp+=a[j]*b[j]
	if tmp+c>0:
		ans+=1
print(ans)

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ll MOD = 1e9 + 7;

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

	int h, w;
	cin >> h >> w;

	string a[h];
	rep(i, h) cin >> a[i];

	ll dp[h][w];
	// dp[i][j] : i-1, j-1のマスに行く経路の場合の数
	rep(i, h) rep(j, w) dp[i][j] = 0;
	dp[0][0] = 1;

	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if((i == 0 && j == 0) || a[i][j] == '#') continue;

			if(i-1 >= 0){
				dp[i][j] += dp[i-1][j];
				dp[i][j] %= MOD;
			}

			if(j-1 >= 0){
				dp[i][j] += dp[i][j-1];
				dp[i][j] %= MOD;
			}
		}
	}

	cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,s,x=0;
  long long t[200009];
  cin>>n>>s;
  for(int i=0;i<n;i++)cin>>t[i];
  sort(t,t+n);
  for(int i=0;i<n;i++){
    if(i+1==n||t[i]+s<t[i+1])x+=s;
    else x+=t[i+1]-t[i];
  }
  cout<<x<<endl;
  return(0);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define em emplace
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int INF = 1<<30;
constexpr ll LINF = 1LL<<58;
constexpr int mod = 1000000007;

bool dp[200010];

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    for (int i = 0; i < n; i++) cin >> A[i];
    for (int i = 0; i < k; i++) {
        if(dp[i]) continue;
        for (int j = 0; j < n; j++) {
            dp[i + A[j]] = 1;
        }
    }
    cout << (dp[k] ? "First" : "Second")<< endl;
}


Measured memory_bytes: 384
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    long i = 1;
    long B = long.max;
    while (i * i <= N)
    {
        if (N % i == 0)
        {
            B = B.min(N / i);
        }
        i++;
    }
    writeln(B.to!string().length);
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
 int n;
  cin>>n;
  if(n%2==0) cout<<n/2;
  else cout<<n/2+1;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	int i,j,k,res=0;
     cin>>a>>b;
     if(b==1)
	 {
	 	cout<<0<<'\n';
	 }
	 else {
     res=a;
     a--;
     int co=1;
     while(res<b)
	 {
	 	res=res+a;
	 	co++;
	 }
	
	cout<<co<<'\n';
	 }
	return 0;
}

Measured memory_bytes: 256
N = int(input())
sticks1 = list(map(int, input().split()))

#N=len(sticks)
sticks = sorted(sticks1, reverse=True)
#sticks.sort(reverse = True)
count = 0
jmax = N-2
kmax = N-1
i=0
while i<N-2:
    j= i+1
    while j<jmax+1:
        k=kmax
        while j<k:
            #sticks[i]>sticks[j]>sticks[k]
            if sticks[i]<sticks[j]+sticks[k]:
                count += k-j
                kmax = k
                break
            else:
                k -= 1
                continue
        jmax = kmax-1
        j += 1
    kmax = N-1
    jmax = N-2
    i += 1
      
print(count)

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

int main()
{ 
  int n ;
  string s ;
  cin >> n >> s ;
  int r = count(s.begin(), s.end(), 'R') ;
  int b = count(s.begin(), s.end(), 'B') ;

  if(r > b)
  {
    cout << "Yes" << endl ;
  }
  else
  {
    cout << "No" << endl ;
  }
  
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"

int N;
bool check(const int from, const vector<long long int>&sums, const long long int norma) {
	long long int base = *(sums.begin() + from);
	auto it = lower_bound(sums.begin() + from, sums.begin() + from + N + 1, base + norma);
	if (it == sums.begin() + from + N + 1)return false;
	base = *it;
	auto jt = lower_bound(it, sums.begin() + from + N + 1, base + norma);
	if (jt == sums.begin() + from + N + 1)return false;
	base = *jt;
	if (*(sums.begin() + from + N) - base >= norma)return true;
	else return false;

}
int main() {
	cin >> N;
	vector<long long int>nums;
	for (int i = 0; i < N; ++i) {
		long long int a; cin >> a;
		nums.push_back(a);
	}
	long long int sum = 0;
	vector<long long int>sums;
	sums.push_back(sum);
	for (int t = 0; t < 2; ++t) {

		for (int i = 0; i < N; ++i) {
			sum += nums[i];
			sums.push_back(sum);
		}
	}
	long long int ans = 0;
	for (int i = 0; i < N; ++i) {
		long long int amin = 0;
		long long int amax = 1e18;
		while (amin + 1 != amax) {
			long long int amid = (amin + amax) / 2;
			if (check(i,sums, amid)) {
				amin = amid;
			}
			else {
				amax = amid;
			}
		}
		ans = max(ans, amin);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5728
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;

    cout<<((c>a-b)? c-(a-b):0)<<endl;

	return 0; 
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int S = 0; // ??\?????????????§?
		int h = 0; // ???
		int m = 0; // ???
		int s = 0; // ?§?

		S = sc.nextInt();

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

		System.out.println( h + ":" + m + ":" + s  );
	}
}

Measured memory_bytes: 26348
#include<bits/stdc++.h>
using namespace std;
int main()
{
 	int n;
  	cin >> n;
  	if(n == 1){
     	cout << "Hello World"; 
    }
  	else{
		int a , b;
      	cin >> a >> b;
      	cout << a + b << endl;
    }
 	return 0; 
}

Measured memory_bytes: 256