akhauriyash/Code-Regression huggingface dataset:
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int t,r,b,c;(t=s.nextInt())>0;System.out.println(r))for(int[]a=new int[]{5,4,r=1,3,2};t-->0;r+=a[2]){b=a[1];c=s.next().charAt(0);if(c==69){a[3]=a[2];a[2]=a[1];a[1]=7-a[3];}if(c==76){a[1]=a[0];a[0]=a[3];a[3]=a[4];a[4]=b;}if(c==78){a[0]=a[2];a[2]=a[4];a[4]=7-a[0];}if(c==82){a[1]=a[4];a[4]=a[3];a[3]=a[0];a[0]=b;}if(c==83){a[4]=a[2];a[2]=a[0];a[0]=7-a[4];}if(c==87){a[1]=a[2];a[2]=a[3];a[3]=7-a[1];}}}}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<map>
#define int long long int

using namespace std;

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

    int i;

    for(i = 1; i < 10; i++){
        if( (i * 100 + i * 10 + i) < N ){
            if( N <= (i + 1) * 100 + (i + 1) * 10 + (i + 1) ){
                cout << (i + 1) * 100 + (i + 1) * 10 + (i + 1) << endl;
                return 0;
            }
        }
    }

    cout << "111\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a[12] = {0, 1, 0, 2, 0, 2, 0, 0, 2, 0, 2, 0};
    int x, y;
    cin >> x >> y;

    if (a[x-1] == a[y-1]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
int c[10][10];

int main(){
  int h,w;
  scanf("%d %d",&h,&w);
  rep(i,10) rep(j,10) scanf("%d",&c[i][j]);
  rep(k,10) rep(i,10) rep(j,10)
      if(c[i][j]>c[i][k]+c[k][j]) c[i][j]=c[i][k]+c[k][j];
  int a,res=0;
  rep(i,h) rep(j,w){
    scanf("%d",&a);
    if(a>=0) res+=c[a][1];
  }
  printf("%d",res);
  return 0;
}


Measured memory_bytes: 384
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
J = [list(map(int, input().split())) for _ in range(N)]
"""
J: [かかる時間, 締め切り時刻]
"""

# print(J)
J = sorted(J, key=lambda x: x[1])
# print(J)

t = 0
for i in range(N):
    t += J[i][0]
    if t > J[i][1]:
        print("No")
        sys.exit()
print("Yes")


Measured memory_bytes: 55284
using System;

namespace abc111B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            if (N <= 111)
                Console.WriteLine(111);
            else if (N >= 112 && N <= 222)
                Console.WriteLine(222);
            else if (N >= 223 && N <= 333)
                Console.WriteLine(333);
            else if (N >= 334 && N <= 444)
                Console.WriteLine(444);
            else if (N >= 445 && N <= 555)
                Console.WriteLine(555);
            else if (N >= 556 && N <= 666)
                Console.WriteLine(666);
            else if (N >= 667 && N <= 777)
                Console.WriteLine(777);
            else if (N >= 778 && N <= 888)
                Console.WriteLine(888);
            else
                Console.WriteLine(999);
        }
    }
}


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

using namespace std;
using ll = long long;

class Osa_k {
private:
	int n;
	vector<int> factor;
public:
	Osa_k(int _n):n(_n) {
		factor.assign(n, 0);
		iota(factor.begin(), factor.end(), 0);
		for(int i = 2; i*i < n; i++) {
			if(factor[i] < i)continue;
			for(int j = i * i; j < n; j += i) {
				if(factor[j] == j)factor[j] = i;
			}
		}
	}

	map<int, int> sieve(int v) {
		map<int, int> ret;
		while(v != factor[v]) {
			ret[factor[v]]++;
			v /= factor[v];
		}
		if(v != 1)ret[v]++;
		return ret;
	}


}fact(1000001);


int main()
{
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++)cin >> a[i];
	vector<int> num(1000001);
	for(int i = 0; i < n; i++) {
		auto v = fact.sieve(a[i]);
		for(auto j : v)num[j.first]++;
	}
	int cnt = count_if(num.begin(), num.end(), [](int a){return a > 1;});
	int GCD = accumulate(a.begin(), a.end(), 0, [](int a, int b){return gcd(a, b);});
 
	if(cnt == 0) {
		cout << "pairwise coprime" << endl;
	} else if(GCD == 1) {
		cout << "setwise coprime" << endl;
	} else {
		cout << "not coprime" << endl;
	}	

}

Measured memory_bytes: 14796
n,k = (int(i) for i in input().split())

res = 0
for i in range(1,n+1):
    cnt = 0
    now = i
    while True:
        if now >= k:
            break    
        now = now*2
        cnt+=1
    
    res += 1/(n*2**cnt)

print(res)

Measured memory_bytes: 39664
#include <stdio.h>

int main(void)
{
	int x[3000],y[3000];
	int i,k,keep;
	
	i=0;
	
	while(1){				//	0?????§????????§?????????
		scanf("%d %d",&x[i],&y[i]);
		if(x[i]==0 && y[i]==0){
			break;
		}
		i++;
	}

	for(k=0;k<i;k++){
		
		if(x[k]>y[k]){//x???y???????????§????????¨?????\?????????
			keep=x[k];
			x[k]=y[k];
			y[k]=keep;
		}
		
		printf("%d %d\n",x[k],y[k]);
	}
return 0;
}

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

int main(){
  string a,b;
  cin >> a >> b;
  string s=a+b;
  //xが左で0から始まってなんちゃらって意味わからない
  int x=0;
  for (int i=0;i<s.length();++i){
     x=x*10+(s[i]-'0');
  }
  for (int i=0;i<1000;++i){
     if (x==i*i){
        cout << "Yes" << endl;
        return 0;
     }
  }
  cout << "No" << endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    string s;cin>>s;
    int n=s.size();
    vl a(100001);
    a[0]=1;
    for(int i=1;i<=100000;++i){
        a[i]=10*a[i-1]%13;
    }
    ll dp[n+1][13];
    mem(dp,0);
    dp[0][0]=1;
    for(int i=0;i<n;++i){
        if(s[i]!='?'){
            for(int j=0;j<13;++j){
                dp[i+1][(j+a[n-1-i]*(s[i]-'0'))%13]=dp[i][j];
            }
        }
        else{
            for(int j=0;j<13;++j){
                for(int k=0;k<10;++k){
                    dp[i+1][(j+k*a[n-i-1])%13]+=dp[i][j];
                    dp[i+1][(j+k*a[n-1-i])%13]%=MOD;
                }
            }
        }
    }
    cout<<dp[n][5]<<endl;
}

Measured memory_bytes: 11392
#include<iostream>
#include<string>
#include<cstdio>
#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;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#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<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	int sum = 0;
	rep(i, n) {
		int a;
		cin >> a; sum += a - 1;
	}
	cout << sum << endl;
    return 0;
}

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

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)round(x))<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

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

  int T;
  cin >> T;

  while (T--) {
    int N, D;
    cin >> N >> D;

    int now = D;
    int ans = 0;
    
    for (int i = 0; i < N - 1; i++) {
      ans += 127;
      now = (127 ^ now);
    }
    ans += now;

    cout << ans << endl;
  }
}


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

typedef long long ll;

ll gcd( ll x, ll y );
ll lcm( ll x, ll y );

int main()
{
    int t;
    int n;
    int s, f;

    cin >> t;

    while ( t != 0 ) {
        cin >> n;
        int work = 0;
        for ( int i = 0; i < n; ++i ) {
            cin >> s >> f;
            work += f - s;
        }
        if ( t > work ) {
            cout << t - work << endl;
        } else {
            cout << "OK" << endl;
        }
        cin >> t;
    }

    return 0;
}

ll gcd( ll x, ll y )
{
    if ( y == 0 ) return x;
    return gcd( y, x % y );
}

ll lcm( ll x, ll y )
{
    return x / gcd( x, y ) * y;
}




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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    for(int i=0;i<a;i++){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	    for(int i=0;i<t;i++){ fact[i+1]=fact[i]*(i+1)%MOD;}
	fact_inv[t]=power(fact[t], MOD-2);
	for(int i=0;i<t;i++){ fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;}
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

int i,j,k,tmp;
ll ans = 0;

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

  string s; cin >> s;
  int n; n=s.length();
  if(s[n-1]=='s'){cout << s << "es" << endl; return 0;}
  cout << s << "s" << endl;

  return 0;
}


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

using namespace std;
int main(){
  int n;
   cin >>n;
  
  int p[n][11],f[n][10];

  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++) cin >> f[i][j];
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<11;j++) cin >> p[i][j];  
  }

  long res=-(1<<30);
  for(int b=1; b<(1<<10);b++){
    long prof=0;
     for(int i=0;i<n;i++){
      int cnt=0;
       for(int j=0;j<10;j++){
         if((b>>j)&1&&f[i][j]) cnt++;
          }
       prof+=p[i][cnt];
     }
    res=max(res,prof);
  
  }
  
  
cout << res << endl;

  
    
  
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
using ll = long long;
using vi = vector<int>;

int main()
{
    int N;
    cin >> N;
    ll sum = 0, a;
    REP(i, N) {
        cin >> a;
        sum += a;
    }
    if(sum % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  cnt=0
  mx=0
  for _ in range(n):
    a,b=LI()
    if a==b:
      cnt+=1
    else:
      mx=max(mx,cnt)
      cnt=0
  mx=max(mx,cnt)

  if mx>=3:
    return 'Yes'
  return 'No'

# main()
print(main())


Measured memory_bytes: 10780
from collections import deque

def main():
    n = int(input())
    A = list(map(int, input().split()))
    ans = 0
    B = [0] * n
    # ansList = []
    ansList = deque()

    def makeList(num):
        start = num + 1
        mul = n // start
        return [start * j - 1 for j in range(1, mul+1)]


    def makeRes(indices):
        flag = 0
        for elm in indices:
            if B[elm] == 1:
                flag = (flag + 1) % 2
        return flag


    for i in range(n-1, -1, -1):
        if i + 1 >  n / 2:
            if A[i] == 1:
                B[i] = 1
                ans += 1
                ansList.appendleft(i+1)
        else:
            indices = makeList(i)
            # print(indices)
            res = makeRes(indices)
            # print(res)
            if A[i] != res:
                B[i] = 1
                ans += 1
                ansList.appendleft(i+1)

    print(ans)

    if ans != 0:
        print(*(list(ansList)))


if __name__ == "__main__":
    main()

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

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

int main() {
  int a,b,c,n ;
  cin >> a >> b >> c >> n  ;
  int ans = 0 ;
  
  
  rep(i,3000){
    rep(j,3000){
      int now = n - (a*i + b*j) ;
      if(now % c == 0 && now >=0 ) ans ++ ;
    }
  }
  
  cout << ans ; 
}


Measured memory_bytes: 3544
import math

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

S = sum(a)
th = S / (4*m)

if isinstance(th, int):
    th -= 1

ls = [i for i in a if i >= th]

if len(ls) >= m:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int N,A,x[51];
long long ans,d[51][51][2501];
int main(){
	scanf("%d%d",&N,&A);
	for(int i=1;i<=N;i++)
		scanf("%d",x+i);
	d[0][0][0]=1;
	for(int i=1;i<=N;i++){
		for(int j=0;j<=N;j++){
			for(int k=0;k<=2500;k++){
				d[i][j][k]=d[i-1][j][k]+((k>=x[i] and j)?d[i-1][j-1][k-x[i]]:0);
			}
		}
	}
	for(int i=1;i<=N;i++)
		ans+=d[N][i][A*i];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 50048
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,suf[200005],a[200005];
int32_t main(){
CODE_START;
cin>>n;
for(ll i=1;i<=n;i++)
{
    cin>>a[i];
}
for(ll i=n;i>=1;i--)
{
    suf[i]=suf[i+1]+a[i];
    suf[i]%=mod;
}
ll ans=0;
for(ll i=1;i<=n;i++)
{
    ans+=(a[i]*suf[i+1])%mod;
    ans%=mod;
}
cout<<ans<<endl;
}



Measured memory_bytes: 6708
local N = io.read("n")
local jobs = {}
for i=1, N do
    local a, b = io.read("n", "n")
    jobs[i] = {a, b}
end
table.sort(jobs, function(x1, x2)
    return x1[2] < x2[2]
end)
local cursor = 0
for i=1, N do
    local a, b = jobs[i][1], jobs[i][2]
    if cursor + a > b then
        print("No")
        return
    else
        cursor = cursor + a
    end
end
print("Yes")

Measured memory_bytes: 26232
use std::io::stdin;

fn main() {
    let mut is = String::new();
    stdin().read_line(&mut is).ok();
    let n: usize = is.trim().parse::<usize>().unwrap();
    is.clear();
    stdin().read_line(&mut is).ok();
    let mut a = is
        .split_whitespace()
        .map(|e| e.parse::<usize>().unwrap())
        .collect::<Vec<_>>();
    let mut ans = 0;

    for i in 0..n {
        ans ^= a[i];
    }

    for i in 0..n {
        println!("{}", ans ^ a[i]);
    }
}


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

void printbi(int S){
  for(int i=0;i<19;i++){
    cout<<i<<' '<<(S>>i&1)<<endl;
  }
}

string s;

int t[7][7]={
  {0,1,3,4,5,8,9},
  {1,2,4,5,6,9,10},
  {3,4,7,8,9,12,13},
  {4,5,8,9,10,13,14},
  {5,6,9,10,11,14,15},
  {8,9,12,13,14,16,17},
  {9,10,13,14,15,17,18}
};


int f(int num){
  return s[num]-'0';
}

bool check(int S){
  int a=0,b;
  for(int i=0;i<7;i++){
    b=0;
    for(int j=0;j<7;j++){
      int x=(S>>t[i][j])&1;
      b|=(x<<j);
    }
    b=f(b);
    a|=(b<<i);
  }

      
  int A=(a>>3&1);
  int B=f(a);
  
  if(B==A)return true;
  return false;
}

bool solve(){
  for(int i=0;i<(1<<19);i++)
    if(!check(i))return false;
  return true;
}

int main(){
  while(1){
    cin>>s;
    if(s=="#")break;
    cout<<(solve()?"yes":"no")<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180
from random import randint
from time import time
t1=time()

d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
	r=list(map(int,input().split()))
	s.append(r)

def score(T):
	last=[0]*26
	happy=0
	for i in range(d):
		last[T[i]-1]=i+1
		happy+=s[i][T[i]-1]
		for j in range(26):
			happy-=(i+1-last[j])*c[j]
	return happy

t=[]
for i in range(d):
	t.append(i%26+1)

t2=time()
while t2-t1<1.85:
	tt=t.copy()
	if t2-t1<0.5:
		x=2
	else:
		x=1
	for i in range(x):
		tt[randint(1,d)-1]=randint(1,26)
	if score(tt)>score(t):
		t=tt.copy()
	t2=time()
for x in t:
	print(x)


Measured memory_bytes: 85200
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5 + 5;
const int INF = 1e9 + 5;

int h, a;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> h >> a;
	cout << h / a + (h % a > 0);
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
*/

Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1], C = ip[2], D = ip[3];
	max(A*B, C*D).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    int A[N];
    for (int i=0; i<N; i++) cin >> A[i];
    sort(A, A+N);
    int sum=0;
    for (int i=0; i<K; i++) sum+=A[i];
    cout << sum << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 2e9+7;

int main() {
    int n, k;
    cin >> n >> k;
    if (n % k == 0) puts("0");
    else puts("1");
    return 0;
}

Measured memory_bytes: 256
local n=io.read("n")
local testimony={}
for i=0,n-1 do
    testimony[i]={}
    local a=io.read("n")
    for j=1,a do
        local x,y=io.read("n","n")
        table.insert(testimony[i],{x-1,y})
    end
end

local function check(bit)
    local checker=true
    for i=0,n-1 do
        if (bit & 1<<i)>0 then
            for k,v in pairs(testimony[i]) do
                local x=v[1]
                local y=v[2]
                if y==1 and (bit & 1<<x)==0 then
                    checker=false
                end
                if y==0 and (bit & 1<<x)>0 then
                    checker=false
                end
            end
        end
    end
    return checker
end

local max=0
for bit=0,(1<<n)-1 do
    if check(bit) then
        local counter=0
        for i=0,n-1 do
            if (bit & (1<<i))>0 then
                counter=counter+1
            end
        end
        max=math.max(counter,max)
    end
end
print(max)

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

int main(){
  int i, j, k=0, c=0, n, q;
  int S[10000];
  int T[500];

  scanf("%d",&n);
  if( n>10000 ) exit(1);

  for( i=0 ; i<n ; i++ ){
    scanf("%d",&S[i]);
    if( S[i]<0 || 1000000000<S[i] ) exit(2);
  }

  scanf("%d",&q);
  if( q>500 ) exit(3);

  for( i=0 ; i<q ; i++ ){
    scanf("%d",&T[i]);
    if( T[i]<0 || 1000000000<T[i] ) exit(4);
  }
       
  for( i=0 ; i<n ; i++ ){
    for( j=0 ; j<q ; j++ ){
      if(S[i] == T[j]){
	c++;
	T[j] = T[q-1];
	q--;
	break;
      }
    }
  }

  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long

const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

signed main(){
    int N, M;
    cin >> N >> M;
    int bigger = max (N, M);
    int smaller = min (N, M);

    if (bigger -smaller > 1) {
      cout << 0;
      return 0;
    } else{
      int answer = 1;
      for (int i = 1; i <= bigger; i++)
      {
        answer *= i;
        answer %= 1000000007;
      }
      for (int i = 1; i <= smaller; i++)
      {
        answer *= i;
        answer %= 1000000007;
      }

       if (bigger == smaller){
         answer *= 2;
         answer %= 1000000007;
       } 
       cout << answer;
    }
    return 0;
}


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

int main() {
    char c[3][3];
    rep(i, 3) {
        rep(j, 3) {
            cin >> c[i][j];
        }
    }

    rep(i, 3) {
        cout << c[i][i];
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
module Memoizable
	def memoize(name)
		original = "__original_#{name}__"
		([Class, Module].include?(self.class) ? self : self.class).class_eval {
			alias_method(original, name)
			private(original)
			cache = {}
			define_method(name){|*args|
				cache[args] ||= send(original, *args)
			}
		}
	end 
end

include Memoizable

def check(s)
	return true if s == ''
	return s == 'mew' if s.size <= 3
	return false unless s[0] == 'm' && s[-1] == 'w'
	
	if s[1] == 'm'
		l = 0
		(1..s.size-1).each{|i|
			c = s[i]
			l += 1 if c == ?m	
			l -= 1 if c == ?w
			if l == 0
				return s[i+1] == ?e && check(s[1..i]) && check(s[i+2..-2])
			end
		}
		return false
	elsif s[1] == 'e'
		return check(s[2..-2])
	end
end

memoize :check

str = gets.chomp
puts check(str) ? 'Cat' : 'Rabbit'

Measured memory_bytes: 9312
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define BR printf("\n")
#define INF 2000000000

//E,W,N,S
int countT[4] = {};
int path[26] = {};

int main(){
    path['E'-'E'] = 0;
    path['W'-'E'] = 1;
    path['N'-'E'] = 2;
    path['S'-'E'] = 3;
    char S[1001];
    cin >> S;
    int len = strlen(S);
    REP1(i,len){
        countT[path[S[i]-'E']]++;
    }
    
    bool B[2];
    B[0] = (countT[0] == 0 && countT[1] != 0)||(countT[1] == 0 && countT[0] != 0);
    B[1] = (countT[2] == 0 && countT[3] != 0)||(countT[3] == 0 && countT[2] != 0);
    if (B[0]||B[1]) {
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}

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

typedef unsigned long long  ull;

int main(){
	ull x, y, t, a, n, m;
	cin >> n;

	x = 1;
	y = 1;

	for(int i = 0;i < n;++i){
		cin >> t >> a;
		m = max((x + t - 1) / t, (y + a - 1) / a);
		x = m * t;
		y = m * a;
	}

	cout << x + y << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
even = Counter(v[::2]).most_common(2)
odd = Counter(v[1::2]).most_common(2)
even.append((0,0))
odd.append((0,0))
if even[0][0] != odd[0][0]:
    print(n - even[0][1] - odd[0][1])
else:
    print(min(n - even[0][1] - odd[1][1], n - even[1][1] - odd[0][1]))


Measured memory_bytes: 15588
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}

int main(void){
    ll x,y,i,ans=1;
    scanf("%lld%lld",&x,&y);
    i = y/x;
    while(1){
        i/=2;
        if(i<1) break;
        ans++;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
/*
 * written by Yaqi Zhang (zhang623@wisc.edu)
 * University of Wisconsin-Madison
 * 2020
 */
#include <bits/stdc++.h>

#define INF 0x3f3f3f3f

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r, D, x;
    cin >> r >> D >> x;
    for(int i = 0; i < 10; ++i) {
        x = r * x - D;
        cout << x << endl;
    }
    return 0;
    
}



Measured memory_bytes: 256
import sys

ABCD = raw_input()

for op1 in "+-":
    for op2 in "+-":
        for op3 in "+-":
            e = ABCD[0] + op1 + ABCD[1] + op2 + ABCD[2] + op3 + ABCD[3]
            if eval(e) == 7:
                print e + "=7"
                sys.exit(0)


Measured memory_bytes: 2692
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int n;

int main(){
	while(cin>>n){
		int ans=0;
		for(int i=0;i<n;i++)ans+=pow(3,i/2);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define ll long long
#define int long long
#define ld long double
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 1e5 + 10 , N = 1e5 + 5 , SQ = 600 , base = 1999 , mod = 1e9 + 7 , INF = 1e18 , lg = 17;

int D, G , p[maxn] , c[maxn] , ans = INF;

int32_t main() {
    FAST
    cin >> D >> G;
    for (int i = 0; i < D; ++i) {
        cin >> p[i] >> c[i];
    }
    for (int mask = 0; mask < (1ll << D); ++mask) {
        int badmaxi = -1 , sum = 0 , prob = 0;
        for (int i = 0; i < D; ++i) {
            if(mask & (1ll << i)) {
                sum += ((i + 1) * 100 * p[i]) + c[i];
                prob += p[i];
            }
            else {
                badmaxi = i;
            }
        }
        if(badmaxi != -1 && sum < G) {
            int point = 100 * badmaxi + 100;
            int need = (G - sum + (point - 1)) / point;
            if(need >= p[badmaxi]) {
                continue;
            }
            prob += need;
        }
        ans = min(ans , prob);
    }
    cout << ans << '\n';
 }


Measured memory_bytes: 3664
gets;
a = gets.split(' ').map{|x|x.to_i}

a = a.map{|x|
	case x
		when    1...400  then 0
		when  400...800  then 1
		when  800...1200 then 2
		when 1200...1600 then 3
		when 1600...2000 then 4
		when 2000...2400 then 5
		when 2400...2800 then 6
		when 2800...3200 then 7
		else 8
	end
}

n_over3200 = a.count{|x| x == 8 }

n_colors = a.reject{|x| x == 8 }.uniq.size

puts "#{[1,n_colors].max} #{n_colors + n_over3200}"


Measured memory_bytes: 1788
#include<stdio.h>
int main(){
  int N,M;
  int i,j,p;
  int x[20],y[20],l,houseki[20],sum_houseki,sumx,sumy;
  char d;

  while(1){
    scanf("%d",&N);
    if(N==0)break;
    sum_houseki=N;
    sumx=10;
    sumy=10;
    for(i=0;i<N;i++){
      scanf("%d%d",&x[i],&y[i]);
      houseki[i]=1;
    }

    scanf("%d",&M);
    for(j=0;j<M;j++){
      scanf(" %c%d",&d,&l);
      for(p=1;p<=l;p++){
	if(d=='E')sumx+=1;
	else if(d=='W')sumx-=1;
	else if(d=='N')sumy+=1;
	else if(d=='S')sumy-=1;
      for(i=0;i<N;i++){
	if(sumx==x[i] && sumy==y[i] && houseki[i]==1){
	  houseki[i]=0;
	  sum_houseki--;
	}
      }
      }
    }
   if(sum_houseki==0)printf("Yes\n");
      else if(sum_houseki!=0)printf("No\n");
  }
return 0;
}

Measured memory_bytes: 584
H,W=map(int,input().split())
L=["#"*(W+2)]
n=0
for i in range(H):
  S=input()
  n+=S.count(".")
  L.append("#"+S+"#")
L.append("#"*(W+2))
r=[(1,1)]
dic={(1,1):1}
m=[(1,1)]
i=1
mm=[]
nyan=[(0,1),(0,-1),(1,0),(-1,0)]
while m:
  i+=1
  for a,b in m:
    for c,d in nyan:
      x,y=a+c,b+d
      if L[x][y]=="." and (x,y) not in r:
        r.append((x,y))
        mm.append((x,y))
        dic[(x,y)]=i
  m=mm[:]
  mm=[]
if (H,W) in r:
  print(n-dic[(H,W)])
else:
  print(-1)

Measured memory_bytes: 41692
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int

	fmt.Scan(&n)
	ns := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&ns[i])
	}

	sort.Float64s(ns)

	x := (ns[0] + ns[1]) / 2.0
	for i := 1; i < n-1; i++ {
		x = (x + ns[i+1]) / 2.0
	}

	fmt.Println(x)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define PI acos(-1.0)

typedef long long ll;
const int maxn=1e5+10;

int main()
{
    char s[maxn];
    scanf("%s",s);
    int len=strlen(s);
    for(int i=0,j=len-1;i<j;i++,j--)
    {
        if(s[i]!=s[j])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define FORD(i, b, e) for (int i = (b); i >= (int)(e); i--)
#define ll long long
#define st f
#define nd s
#define pb PB
#define eb emplace_back
#define mp make_pair				
#define siz(c) SIZ(c)
const int inf = 1e9 + 7;
const LL INF = 1e18L + 7;
 
#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type
{int o = 0; p << "{"; for (auto c : y) {if (o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if (p > y) p = y;}
sim, class s> void maxi(n &p, s y) {if (p < y) p = y;}

#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "

#ifndef LOCAL
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

template <typename T>
using ordered_set =
	tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#else
#include</Users/dawid/algo/mac/ordered_set>
#endif

#define int ll
const int N = 1e6+7;

int n, sum, ans = INF;

int a[N];

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

	cin >> n;

	for(int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		sum += a[i];
	}

	int pref = 0;

	for(int i = 1; i < n; ++i)
	{
		pref += a[i];
		ans = min(ans, abs(sum-2*pref));
	}

	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    string s[n];
    for (int i = 0; i < n; i++)
    {
        cin>>s[i];
    }
    int AC = 0, WA = 0, TLE = 0, RE = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == "AC")AC++;
        else if (s[i] == "WA")WA++;
        else if (s[i] == "TLE")TLE++;
        else if (s[i] == "RE")RE++;
    }
    cout << "AC x "<<AC<<endl;
    cout << "WA x "<<WA<<endl;
    cout << "TLE x "<<TLE<<endl;
    cout << "RE x "<<RE<<endl;

    return 0;
}


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

int main()
{
  string S;
  cin >> S;

  int max = 0;
  int x = 0;
  for (int i = 0; i < S.size(); i++)
  {
    bool b = false;
    string A = "AGCT";
    for (int j = 0; j < 4; j++)
    {
      if (A.at(j) == S.at(i))
        b = true;
    }

    if (b)
    {
      x++;
      if (max < x)
      {
        max = x;
      }
    }
    else
      x = 0;
  }
  cout << max << endl;
}

Measured memory_bytes: 256
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    string s;
    cin >> s;
    int n=s.size();
    
    fff(i,n) {
        if(i%2==0) {
            if(s[i]!='R' and s[i]!='U' and s[i]!='D') {
                cout << "No" ;
                return 0;
            }
        }
        else {
            if(s[i]!='L' and s[i]!='U' and s[i]!='D') {
                cout << "No" ;
                return 0;
            }
    }
    }
    cout << "Yes";
    
	return 0;
    
}

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

int main(){
    double n,k;    cin>>n>>k;

    int a=0;
    int x=1;
    while(x<k){
        x*=2;
        a++;
    }
    //cout<<a<<endl;

    double ans=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=a;j++){
            if(i*pow(2,j)>=k){
                ans+=(1/n)*(1/pow(2,j));
                break;
            }
        }
    }

    //cout<<ans<<endl;
    printf("%.16f",ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
using namespace std;

int main(){
  int n;
  cin>>n;
  int x=n,ans=0,a=0;
  if(n<10){
    cout<<n<<endl;
    return 0;
  }
  for(int i=0;;i++){
    ans+=(x%10);
    if(x%10!=0){
      a++;
    }
    x/=10;
    if(x<=0) break;
  }
  if(ans==1){
    cout<<"10"<<endl;
  }else{
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
#include<string>
#include <math.h>
#include<algorithm>
#include<functional>

#define ll long long
#define inf  1000000007
#define mod 1000000007
#define pa pair<int,int>
#define pal pair<ll,ll>
#define ppa pair<int,pa>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

class Point{
  public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y) {}
  Point operator + (Point p) {return Point(x+p.x,y+p.y);}
  Point operator - (Point p) {return Point(x-p.x,y-p.y);}
  Point operator * (double a) {return Point(x*a,y*a);}
  Point operator / (double a) {return Point(x/a,y/a);}
  double absv() {return sqrt(norm());}
  double norm() {return x*x+y*y;}
  bool operator < (const Point &p) const{
    return x != p.x ? x<p.x: y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
  }
};
typedef Point Vector;

struct Segment{
Point p1,p2;
};

double hen(Vector a){
if(fabs(a.x)<EPS && a.y>0) return acos(0);
else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
else if(fabs(a.y)<EPS && a.x>0) return 0.0;
else if(a.y>0) return acos(a.x/a.absv());
else return 2*acos(0)+acos(-a.x/a.absv());

}

double dot(Vector a,Vector b){
  return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
  return a.x*b.y-a.y*b.x;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ru[11]={1,2,4,8,16,32,64,128,256,512,1024};

ll frac[100010];
ll inv[100010];

ll saikif(ll a,int n){
  if(n==1) return a%mod;
  else if(n%2==0){
    ll q=saikif(a,n/2);
    return (q*q)%mod;
  }
  else return (a*saikif(a,n-1))%mod;
}

void gyakugen(){
  frac[0]=1;
  for(int i=1;i<=100000;i++) frac[i]=(frac[i-1]*i)%mod;
  for(int i=0;i<=100000;i++) inv[i]=saikif(frac[i],mod-2);
}


//----------------kokomade temple------------
int dp[1000002];
int dp2[1000002];
vector<int> ve;
vector<int> ve2;
int num,num2;

int dfs(int n){
if(dp[n]<inf) return dp[n];
else{
//  cout<<n<<endl;
  int ans=inf;
for(int j=0;j<num;j++){
  if(ve[j]>=n) break;

  ans=min(ans,1+dfs(n-ve[j]));
}
  dp[n]=ans;
  return ans;
}

}

int dfs2(int n){
if(dp2[n]<inf) return dp2[n];
else{
//  cout<<n<<endl;
  int ans=inf;
for(int j=0;j<num2;j++){
  if(ve2[j]>=n) break;

  ans=min(ans,1+dfs2(n-ve2[j]));
}
  dp2[n]=ans;
  return ans;
}

}



int main(){
  fill(dp,dp+1000002,inf);
  fill(dp2,dp2+1000002,inf);
int z=1,w;
while(1){
  w=z*(z+1)*(z+2)/6;
  //cout<<w<<endl;
  if(w>1000000) break;
  else{
    ve.push_back(w);
    if(w%2==1){
      ve2.push_back(w);
      dp2[w]=1;
    }
    z++;
    dp[w]=1;

  }
}
num=ve.size();
num2=ve2.size();
for(int i=1;i<1000001;i++){
  dfs(i);
  dfs2(i);
}

int n;

while(cin>>n){
  if(n==0) break;
  cout<<dp[n]<<" "<<dp2[n]<<endl;
}


return 0;
}

Measured memory_bytes: 9404
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
   ll n,x;
   cin>>n>>x;
   cout<<(n*500>=x?"Yes\n":"No\n");
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


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


return 0;
}

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

int main(){
  int a=-1,b=-1,n;
  string s;
  cin >> s;
  char c[4];
  n=s.size();
  
  REP(i,n-1){
    c[0]=s.at(i);
    c[1]=s.at(i+1);
    if(c[0]==c[1]){
      a=i+1;
      b=i+2;
      break;
    }else if(i<n-2){
      c[2]=s.at(i+2);
      if(c[0]==c[2] && c[0]!=c[1]){
        a=i+1;
        b=i+3;
        break;
      }
    } 
  }

  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	int h, w, i, j;
	while(scanf("%d %d", &h, &w)){
		if(h == 0 && w == 0)
			return 0;
			
		for(i=0;i<h;i++) {
			for(j=0;j<w;j++) {
				if(i==0 || i==h-1 || j==0 || j==w-1) {
					printf("#");
				} else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

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

const int M=2e5+9;
const int MOD=1e9+7;
const long long MOD2=10000004873;
const long long N=1e12+7;

using namespace std;

long long pwr(long long b,int p){
    if(p<=0)return 1;
    long long sq=pwr(b,p>>1);
    sq=(((sq%MOD)*(sq%MOD))%MOD);
    if(p&1)
        sq=(((sq%MOD)*(b%MOD))%MOD);
    return sq;
}

int r;
int main(){
    scanf("%d",&r);
    cout<<fixed<<setprecision(20)<<(double)M_PI*r*2<<endl;
    return 0;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  int sum=0;
  vi A(N);
  rep(i,0,N){
    cin>>A[i];
    sum+=A[i];
  }
  int cnt=0;
  int X=(sum+4*M-1)/4/M;
  rep(i,0,N){
    if(X<=A[i]) cnt++;
  }
  string ans="No";
  if(cnt>=M) ans="Yes";
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#python 3.5.2

N, x = input().split()
N = int(N)
x = int(x)

a_list = [int(v) for v in input().split()]
a_list.sort()

person = 0

break_flag = False

for a in a_list[:-1]:
    if a <= x:
        x -= a
        person += 1
    else:
        break_flag=True
        break
  
if not break_flag:
    if x == a_list[-1]:
        person += 1

print(person)

Measured memory_bytes: 3188
n=int(input())
li=list(map(int,input().split()))
dic={}
ans=0
for i in range(n):
  val=dic.get(li[i],-1)
  if val==-1:
    dic[li[i]]=1
  else:
    dic[li[i]]=val+1
  ans+=li[i]
q=int(input())
for i in range(q):
  a,b=map(int,input().split())
  val=dic.get(a,-1)
  if val==-1 or val==0:
    print(ans)
  else:
    nb=dic.get(b,-1)
    if nb==-1:
      dic[b]=val
    else:
      dic[b]=val+nb
    ans+=(b-a)*val
    dic[a]=0
    print(ans)
  

   


  




Measured memory_bytes: 20800
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)     for(long long int i=a; i<n; i++)
#define loop(i,a,n)     for(long long int i=a; i>=n; i--) 

int main()
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	int a;
	cin>>a;
	string s;
	cin>>s;
	int tl=0, tr=0,l=0, r=0, ans=0, j=0;
	forr(i, 0, s.size())
	{
		if(s[i]=='W')
			tl++;
		else
			tr++;
	}
	while(tr)
	{
		if(s[j]=='W')
			ans++;
		tr--;
		j++;
	}
	cout<<ans;
		
	return 0;
}


Measured memory_bytes: 3768
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = n - 1
    val a = Array(m) { 0 }
    val b = Array(m) { 0 }
    val adj = Array(n) { mutableSetOf<Int>() }
    for (i in 0 until m) {
        val u = sc.nextInt() - 1
        val v = sc.nextInt() - 1
        adj[u].add(v)
        adj[v].add(u)
        a[i] = minOf(u, v)
        b[i] = maxOf(u, v)
    }
    var ans = 0L
    for (i in 1..n) {
        ans += i * (i + 1L) / 2
    }
    for (i in 0 until m) {
        ans -= (a[i] + 1L) * (n - b[i])
    }
    println(ans)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 125352
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int taro = 0;
        int hanako = 0;
        int n = scan.nextInt();
        for (int i = 0; i < n; ++i) {
            int c = scan.next().compareTo(scan.next());
            if (c > 0) {
                taro += 3;
            } else if (c == 0) {
                taro++;
                hanako++;
            } else {
                hanako += 3;
            }
        }
        System.out.println(taro + " " + hanako);
    }
}

Measured memory_bytes: 20800