akhauriyash/Code-Regression huggingface dataset:
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Map.Entry;

/**
 * Main
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
    
        Map<String,Integer> map = countMultiple(s);
        final String result = isBeanty(map)? "Yes" : "No";
        System.out.println(result);
        sc.close();    
    }
    
    public static boolean isBeanty(Map<String,Integer> map){
        for (Entry<String,Integer> t: map.entrySet()) {
            if(t.getValue()%2 == 1) {
                return false;
            }
        }
        return true;
    }

    public static Map<String,Integer> countMultiple(String[] chars){
        Map<String,Integer> map = new HashMap<>();
        for (String s : chars) {
            if(map.containsKey(s)) {
                map.put(s, map.get(s) + 1);
            }else{
                map.put(s, 1);
            }
        }
        return map;
    }
}

Measured memory_bytes: 22868
#include<stack>
#include<map>
#include<set>
#include<cstdio>
#include<vector>
#include<iostream>
#include<string>
#include<algorithm> 
using namespace std;
int main(){
	int a,b,c,x,y,ans=0;
	cin>>a>>b>>c>>x>>y;
	if(c*2<a+b){
		int sma=min(x,y);
		ans+=sma*c*2;
		x-=sma;
		y-=sma;
		int big=max(x,y);
		int yen=0;
		if(x){
			yen=a;
		}else{
			yen=b;
		}
		if(c*2<yen){
			ans+=big*c*2;
		}else{
			ans+=big*yen;
		}
		cout<<ans<<endl;
		return 0;
	}else{
		ans+=x*a;
		ans+=y*b;
		cout<<ans<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main(){
	ll n,m;	cin>>n>>m;
	vector<ll> x(n),y(m);
	for(int i=0;i<n;i++)	cin>>x[i];
	for(int i=0;i<m;i++)	cin>>y[i];
	ll xx=0;
	for(int i=1;i<n;i++){
		ll w=x[i]-x[i-1];
		xx+=(i*w%mod)*(n-i)%mod;
		xx%=mod;
	}
	ll ret=0;
	for(int i=1;i<m;i++){
		ll h=y[i]-y[i-1];
		ll s=(i*h%mod)*(m-i)%mod;
		ret=(ret+s*xx)%mod;
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 1792
import sys

global stamp, counter
stamp = {}
counter = 0

def dfs(key, GRAPH):
    global stamp, counter
    if stamp[key][0] == 0:
        counter += 1
        stamp[key][0] = counter
    elif stamp[key][1] != 0:
        return

    for e in GRAPH[key]:
        try:
            if stamp[e][0] == 0:
                dfs(e, GRAPH)
        except:
            pass
    counter += 1
    stamp[key][1] = counter
    return

n = int(raw_input())
x = {}
for i in range(n):
    seq = map(int, raw_input().split())
    key = seq[0]
    if key != 0:
        x[key] = seq[2:]
    else:
        x[key] = []  
    stamp[key] = [0, 0]

for e in x.keys():
    dfs(e, x)

for e in x.keys():
    print e, stamp[e][0], stamp[e][1]

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

using namespace std;

int main() {
    int n;
    long long k;
    cin >> n >> k;
    vector<long long> a(n), b(n);
    vector<int> idx(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        idx[i] = i;
    }
    sort(idx.begin(), idx.end(), [&](int i, int j) {
       return a[i] < a[j];
    });
    for (int i = 0; i < n; i++) {
        k -= b[idx[i]];
        if (k < 1) {
            cout << a[idx[i]] << endl;
            break;
        }
    }
    return 0;
}

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

#define INF 1e9
using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,r;
    cin >> n >> m >> r;
    vector<int> s(r);
    for(int i = 0; i < r; i++) {
        cin >> s[i];
    }

    int wf[n][n];
    for(int i = 0; i < n*n; i++) {
        wf[i/n][i%n]=INF;
    }
    for(int i = 0; i < m; i++) {
        int a,b,c;
        cin >> a >> b >> c;
        --a;
        --b;
        wf[a][b]=c;
        wf[b][a]=c;
    }

    for(int k = 0; k < n; k++) {
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
            }
        }
    }

    vector<int> vis(r);
    for(int i = 0; i < r; i++) {
        vis[i]=i;
    }

    int ans=INT32_MAX;
    while(next_permutation(vis.begin(),vis.end())) {
        int tans=0;
        for(int i = 1; i < r; i++) {
            tans+=wf[s[vis[i-1]]-1][s[vis[i]]-1];
        }
        ans=min(tans,ans);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3788
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
	String[] vowel ={"a","i","u","e","o"};
	String C =sc.next();
	for(int i=0;i<vowel.length;i++){
	if(C.equals(vowel[i])){
	System.out.println("vowel");
	break;
	}
	if(i==vowel.length-1)System.out.println("consonant");
	}
	}
	}

Measured memory_bytes: 21844
N, M , Q = list(map(int,input().split()))
L = []
for _  in range(Q):
    l = list(map(int,input().split()))
    L.append(l)
A = []
ans = []
def solve(A,i,ans):
    A.append(i)
    if len(A) >= N:
        #print(A)
        tmp = 0
        for x in L:
         #   print(x[1]-1,x[0]-1,A)
            if A[x[1] - 1] - A[x[0] - 1] == x[2]:
                tmp += x[3]
        ans.append(tmp)
        A.pop()
        return 
    pre = A[-1]
    for i in range(pre,M+1):
        solve(A,i,ans)
    A.pop()
solve(A,1,ans)
print(max(ans))


Measured memory_bytes: 78980
n = int(input())
a = 0
b = 0
import math
root_n = math.sqrt(n)
root_n = math.ceil(root_n)
for i in range(1,root_n+1):
    if(n % i == 0):
        if(i > a):
            a = i
b = n / a
print(int(a + b -2))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

int main(){
    ll p,n;
    cin>>p>>n;
    ll a;
    cin>>a;
    ll b,prevb=a,sum=0,mx=-1;
    for(ll i=2;i<=n;i++){
        cin>>b;
        sum+=(b-prevb);
        mx=max(b-prevb,mx);
        prevb=b;
    }
    sum+=(p-(b-a));
    mx=max(mx,p-(b-a));
    cout<<sum-mx;

return 0;
}


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

using namespace std;

long long inf=1000000007;

int main(){
	string s,t;
	cin>>s>>t;
	long long ans=0;

	for(int i=0;i<s.size();i++){
		if(s.at(i)!=t.at(i)) ans++;
	}

	cout<<ans<<endl;

	return 0;
}


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

const int inf=1<<20;
const int vmax=1010;
struct edge{int to,cap,rev;};
vector<edge> graph[vmax];

void add_edge(int f,int t){
	graph[f].push_back({t,1,(int)graph[t].size()});
	graph[t].push_back({f,0,(int)graph[f].size()-1});
}

bool visited[vmax];
int dfs(int v,int t,int f){
	if(v==t) return f;
	visited[v]=true;

	for(auto &e:graph[v]){
		if(visited[e.to]) continue;
		if(e.cap==0) continue;
		int d=dfs(e.to,t,min(f,e.cap));
		if(d>0){
			e.cap-=d;
			graph[e.to][e.rev].cap+=d;
			return d;
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int ret=0;
	while(1){
		memset(visited,0,sizeof(visited));
		int f=dfs(s,t,inf);
		if(f==0) break;
		ret+=f;
	}
	return ret;
}

bool sreach[vmax],treach[vmax];
void bfs(int s,bool reach[vmax],int can){


	queue<int> q;
	reach[s]=true;
	q.push(s);

	while(!q.empty()){
		int cur=q.front();q.pop();
		for(auto &e:graph[cur]){
			if(e.cap==(can^1)) continue;
			if(reach[e.to]==false){
				reach[e.to]=true;
				q.push(e.to);
			}
		}
	}

	return;
}

int a[10010],b[10010];

int main(void){
	int n,m,s,t;
	while(cin >> n >> m >> s >> t,n){
		rep(i,vmax) graph[i].clear();

		s--,t--;
		rep(i,m){
			cin >> a[i] >> b[i];
			a[i]--,b[i]--;
			add_edge(a[i],b[i]);
		}

		int ans=max_flow(s,t);
		memset(sreach,false,sizeof(sreach));
		memset(treach,false,sizeof(treach));
		bfs(s,sreach,1),bfs(t,treach,0);

		int num=0;
		rep(i,m){
			bool ok=false,ok2=false;
			for(auto &e:graph[a[i]]) if(e.to==b[i]&&e.cap==1) ok=true;
			if((sreach[a[i]]&&treach[b[i]])||(sreach[b[i]]&&treach[a[i]]))
				ok2=true;
			if(ok&&ok2) num++;
		}

		if(num) ans++;
		cout << ans << " " << num << endl;
	}
	return 0;
}

Measured memory_bytes: 3588
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from copy import deepcopy

def main():
  n = int(input())  
  la = sorted([int(input()) for _ in range(n)])
  
  lo = deepcopy(la)
  ind = 0
  def f(la, ind):
    lx = []
    while len(la) > 0:
      lx.append(la.pop(ind))
      ind = -1 if ind == 0 else 0
    ls = ([abs(lx[i] - lx[i-1]) for i in range(len(lx))])
    return sum(ls)-min(ls)
  print(max(f(deepcopy(la), 0), f(deepcopy(la), -1)))

  
if __name__=='__main__':
  main()



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

int main(){
    int num[3];
    int j5 = 0, j7 = 0;
    cin >> num[0] >> num[1] >> num[2];

    for(int i = 0; i < 3; i++){
        if(num[i] == 5) j5++;
        else if(num[i] == 7) j7++;
    }

    if(j5 == 2 && j7 == 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);

int main() {
    int N, MAX = 1e6 + 1;
    cin >> N;
    vi a(N);
    rep(i, N) { cin >> a[i]; }
    vb dp(MAX, true);
    unordered_set<int> used;
    rep(i, N) {
        if (used.find(a[i]) != used.end()) {
            dp[a[i]] = false;
            continue;
        }
        if (dp[a[i]]) {
            rep2(j, 2, MAX / a[i] + 1) { dp[a[i] * j] = false; }
        }
        used.insert(a[i]);
    }
    int ans = 0;
    rep(i, N) {
        if (dp[a[i]]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12244
# coding:utf-8

import itertools
n = int(input())
a = ''.join(input().split(' '))  # a: str
b = ''.join(input().split(' '))  # b: str

p = 0
q = 0
i = 0
for it in itertools.permutations(range(1, n + 1)):
    it = list(it)  # itをtupleからlistに変換
    it = ''.join([str(num) for num in it])  # itをlistからstrに変換
    if it == a:  # str同士で比較する
        p = i
    if it == b:  # str同士で比較する
        q = i

    i += 1
print(abs(p-q))


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

int main(){
    int n;
	cin >> n;
	vector<int> input;
	for(int i=0; i<n; i++){
		double tmp;
		cin >> tmp;
		input.push_back(tmp);
	}
	sort(input.begin(), input.end());
	
	double prev=input[0];
	double cur=input[1];
	int i=1;
	while(i<input.size()){
		cur = input[i];
		prev = (prev+cur)/2.0;
		i++;
	}
	cout << prev << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 998244353
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main(){
  ll x;
  cin >> x;
  ll ans = 0;
  ans += x/11*2;
  if(x%11==0) cout << ans << endl;
  else if(x%11<=6) cout << ans+1 << endl;
  else cout << ans+2 << endl;
  return 0;
}
      


Measured memory_bytes: 3608
//
//  main.cpp
//  codeforces
//
//  Created by cfhaiteeh on 29/5/2018.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#define  LL long long

using namespace  std;
int n,k;

int a,b;
void init(){
 
}

int ans;

int ai[100];
int dp[123456];
void play(){
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=12;i++){
        dp[ai[i]]=1;
        for(int j=1;j<=100000;j++){
            if(dp[j]!=0){
                int t=j+ai[i];
                if(t<=n){
                    if(dp[t]==0)dp[t]=dp[j]+1;
                    else dp[t]=min(dp[t],dp[j]+1);
                }
            }
        }
    }
}
void pri(){
    printf("%d\n",dp[n]);
}

int main() {
    ai[1]=1;
    int st=6;
    int idx=2;
    while(st<=100000){
        ai[idx]=st;
        st*=6;
        idx++;
    }
    
    st=9;
    while(st<=100000){
        ai[idx]=st;
        st*=9;idx++;
    }
   
 
    while(scanf("%d",&n)!=EOF){
        init();
        play();
        pri();
    }
    
    return 0;
}


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

public class Main {
    public static void main(String args[]) throws Exception {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int a = Integer.parseInt(br.readLine());
	System.out.println(3 * a * a);
    }
}

Measured memory_bytes: 22996
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
          float[] n = ReadLine().Split(' ').Select(float.Parse).ToArray();
          float[] a = ReadLine().Split(' ').Select(float.Parse).ToArray();

          float can = a.Sum() / (n[1] * 4);
          float[] anser = a.Where(o => o >= can).ToArray();
          if(anser.Length >= n[1]) WriteLine("Yes");
          else WriteLine("No");
      }
   }
}

Measured memory_bytes: 13396
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <map>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)

using namespace std;

typedef long long ll;

ll vs[200000+10];
ll cs[200000+10];

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%lld", &vs[i]);
  }
  REP(i, n) {
    cs[i+1] = cs[i] + vs[i];
  }
  map<ll, ll> mm;
  REP(i, n+1) {
    mm[cs[i]]++;
  }

  ll res = 0;
  FOR(it, mm) {
    ll k = it->second;
    res += k * (k-1) / 2;
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 15872
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(" ");
        var N = int.Parse(input[0]);
        var M = int.Parse(input[1]);

        var H = new List<int>();
        H.Add(0);
        var line = Console.ReadLine().Split(" ");
        for (int i = 0; i < N; i++)
        {
            H.Add(int.Parse(line[i]));
        };

        var graph = new List<List<int>>();
        for (int i = 0; i <= N; i++)
        {
            graph.Add(new List<int>());
        }

        for (int i = 0; i < M; i++)
        {
            var ab = Console.ReadLine().Split(" ");
            var A = int.Parse(ab[0]);
            var B = int.Parse(ab[1]);
            graph[A].Add(B);
            graph[B].Add(A);
        }

        var count = 0;
        for (int i = 1; i <= N; i++)
        {
            var route = graph[i];
            if (!route.Any(x => H[i] <= H[x])) count++;
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 56892
#include<stdio.h>
int main()
{
    int a,b;
    char ar[10000],br[1000],cr[1000];

    scanf("%s%s",ar,br);
    scanf("%d%d",&a,&b);
    scanf("%s",cr);

    int d=strcmp(ar,cr);
    if(d==0)printf("%d %d\n",a-1,b);
    else printf("%d %d\n",a,b-1);




    return 0;
}


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

int main() {
  int A[5], B[5], min10 = 10, ans = 0;
  for(int i=0;i<5;i++) {
    cin >> A[i];
    ans += 10 * ((A[i] - 1) / 10 + 1);
    if(A[i] % 10 > 0) {
      min10 = min(min10, A[i] % 10);
    }
  }
  cout << ans + min10 - 10 << endl;
}
  

Measured memory_bytes: 256
import copy
import random
d = int(input())
c = list(map(int,input().split()))
s = []
t = [0 for _ in range(d)]
for i in range(d):
  si = list(map(int,input().split()))
  s.append(si)
lastd = [-1 for _ in range(26)]
for i in range(d):
  mx = 0
  mj = 0
  for j in range(26):
    if s[i][j] + (i-lastd[j])*c[j] > mx:
      mx = s[i][j] + (i-lastd[j])*c[j]
      mj = j
  lastd[mj] = i
  t[i] = mj
lastd = [-1 for _ in range(26)]
ans = 0
for i in range(d):
  di = t[i]
  lastd[di-1] = i
  ans += s[i][di-1]
  for j in range(26):
    ans -= (i-lastd[j])*c[j]
mxans = ans
mxt = copy.deepcopy(t)
for time in range(9000):
  da = random.randint(0, d-1)
  qb = t[da]
  if random.random() < 0.8:
    bord = c[qb]*(0.8)
    qac = []
    cap = qac.append
    for i in range(0,qb):
      if s[da][i] > bord:
        cap(i)
      continue
    for i in range(qb+1,26):
      if s[da][i] > bord:
        cap(i)
      continue
    if len(qac) == 0:
      continue
    qa = random.choice(qac)
  else:
    bord = c[qb]//2
    qac = []
    cap = qac.append 
    for i in range(0,qb):
      if c[i] > bord:
        cap(i)
    for i in range(qb+1,26):
      if c[i] > bord:
        cap(i)
    if len(qac) == 0:
      continue
    qa = random.choice(qac) 
  #print(da,qb,qa,t)
  qb1 = -1
  qa1 = -1
  for i in range(da-1,-1,-1):
    if t[i] == qb:
      qb1 = i
      break
  for i in range(da-1,-1,-1):
    if t[i] == qa:
      qa1 = i
      break
  qb2 = d
  qa2 = d
  for i in range(da+1,d):
    if t[i] == qb:
      qb2 = i
      break
  for i in range(da+1,d):
    if t[i] == qa:
      qa2 = i
      break
  delta = -s[da][qb]+s[da][qa]-c[qb]*(qb2-da)*(da-qb1)+c[qa]*(qa2-da)*(da-qa1)
  if delta > -10000:
    t[da] = qa
    ans += delta
    if ans > mxans:
      mxans = ans
      mxt = copy.deepcopy(t)
  #print(mxans)
for ansd in mxt:
  print(ansd+1)

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

int main()
{
	int N;
	cin >> N;
	vector<int> D( N );
	for( int i = 0; i < N; i++ ) {
		cin >> D[i];
	}
 
	vector<int> d( N );
	int ma = 0;
	for( int i = 0; i < N; i++ ) {
		d[ D[i] ]++;
		if( D[i] > ma ) ma = D[i];
	}
	if( d[0] > 1 || D[0] != 0 ) {
		cout << 0 << endl;
		return 0;
	}
	for( int i = 0; i <= ma; i++ ) {
		if( d[i] == 0 ) {
			cout << 0 << endl;
			return 0;
		}
	}
 
	const long long MOD = 998244353;
	auto power = [&]( long long x, long long n )
	{
		long long res = 1;
		while( n > 0 ) {
			if( n % 2 ) res = res * x % MOD;
			x = x * x % MOD;
			n /= 2;
		}
		return res;
	};
	long long ans = 1;
	for( int i = 1; i < ma; i++ ) {
		ans *= power( d[i], d[i + 1] );
		ans %= MOD;
	}
 
	cout << ans << endl;
}


Measured memory_bytes: 4040
N, Y = list(map(int, input().split()))
can = False
for x in range(N + 1):
    for y in range(N + 1 - x):
        z = N - x - y
        tot = 10000 * x + 5000 * y + 1000 * z
        if tot == Y:
            print(' '.join(list(map(str, [x, y, z]))))
            can = True
            break
    else:
        continue
    break

if not can:
    print('-1 -1 -1')

Measured memory_bytes: 40428
#include"bits/stdc++.h"
//#include<boost/multi_array.hpp>
//#include<boost/optional.hpp>
//#include<boost/range/irange.hpp>
//#include<boost/range/algorithm.hpp>
//#include<boost/range/adaptors.hpp>

using namespace std;
//namespace adaptor = boost::adaptors;

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

void Main()
{
    ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if(a < b){
		if(a + t*v >= b + t*w){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}else{
		if(a - t*v <= b - t*w){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main()
{
  int s;
  cin >> s;
  s %= 10;
  if (s == 2 || s == 4 || s == 5 || s == 7 || s == 9)
  {
    cout << "hon";
  }
  if (s == 0 || s == 1 || s == 6 || s == 8)
  {
    cout << "pon";
  }
  if (s == 3)
  {
    cout << "bon";
  }
}


Measured memory_bytes: 3556
#include<iostream>
using namespace std;
int h,w,t,ans,gx,gy,map[10][10],dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
void DFS(int x,int y,int len){for(int i=0;i<4;i++){int xx=x+dx[i],yy=y+dy[i];while(true){if(xx>=0&&xx<w&&yy>=0&&yy<h){if(map[yy][xx]==1){map[yy][xx]=0;DFS(xx,yy,len+1);map[yy][xx]=1;break;}if(map[yy][xx]==2&&len==t){ans++;break;}}else break;xx+=dx[i],yy+=dy[i];}}}
int main(){while(true){cin>>w>>h;if(w==0&&h==0)break;t=0;for(int i=0;i<h;i++){for(int j=0;j<w;j++){cin>>map[i][j];if(map[i][j]==2)gy=i,gx=j;if(map[i][j]==1)t++;}}ans=0;DFS(gx,gy,0);cout<<ans<<endl;}return 0;}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	int all = 1;
	int odd = 1;
	for (int i = 0; i < N; i++)
	{
		int v;
		cin >> v;

		all *= 3;
		if (v % 2 == 0) odd *= 2;
	}

	cout << all - odd;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) a.begin(), a.end()
#define gr greater<LL>()

using namespace std;

// O(log(n))
map<LL, LL> find_factors(LL num){
    map<LL, LL> cnts;
    LL tmp=num, j=2;
    while(j<=sqrt(num)){
        while(tmp%j==0){
            tmp/=j;
            cnts[j]++;
        }
        j++;
    }
    if(tmp>1)cnts[tmp]++;
    return cnts;
}

long long gcd(long long a, long long b) {
  long long _max = a > b ? a : b;
  long long _min = a > b ? b : a;
  if (!(_max%_min)) return _min;
  else return gcd(_min, _max%_min);
}
 
long long lcm(long long a, long long b) {
  return a/gcd(a,b)*b;
}


void solve(long long A, long long B){
    auto N = gcd(A,B);
    auto cnts = find_factors(N);
    cout << cnts.size()+1 << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
N = int(input())

base = ["3", "5", "7"]
nums = ["3", "5", "7"]
temp = []
x = 0

while 1:
    for num in nums[(3**x)-1:]:
        for b in base:
            temp.append(b + num)
    nums.extend(temp)
    
    x += 1
    if int(temp[-1]) > 10**9:
        break
    temp = []

target = []
for n in set(nums):
    if "7" in n and "5" in n and "3" in n:
        target.append(int(n))

count = 0
for n in target:
    if n <= N:
        count += 1

print(count)

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

int main()
{
	int i;

	std::string A, B;
	std::cin >> A;
	std::cin >> B;

	int a[100], b[100];
	for ( i = 0; i < 100; i++ ){
		a[i] = 0;
		b[i] = 0;
	}
	for ( i = 0; i < 100; i++ ){
		a[i] = A[i] - '0';
		b[i] = B[i] - '0';
	}



	if ( A.length() > B.length() ){
		std::cout << "GREATER" <<std::endl;
	}else if ( A.length() < B.length() ){
		std::cout << "LESS" <<std::endl;
	}else{
		int i;
		for ( i = 0; i < A.length(); i++ ){
			if( a[i] > b[i] ){
				std::cout << "GREATER" << std::endl;
				break;
			}else if ( a[i] < b[i] ){
				std::cout << "LESS" <<std::endl;
				break;
			}
			
			if ( i == A.length() - 1 ){
				std::cout << "EQUAL" << std::endl;
			}
		}		
	}		

	return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int count = 1;
  
  for (int i = 0; i < N - 1; i++) {
    if (S.at(i) != S.at(i + 1)) {
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 1000000000000000000
#define Rep(i, a, n) for (ll i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define MAX 1000000000000000000
#define ll long long
#define P pair<int,int>
#define cout_set(n) cout << setprecision(10) << (n) << endl; 
const double PI=3.14159265358979323846;
using namespace std;
const int mod = 1000000007; 
int vy[4] ={1,-1,0,0}, vx[4] = {0,0,-1,1}; //up,down,left,right 

int main(){
    ll n; cin >> n;
    ll a[100000]; rep(i,n) cin >> a[i];
    rep(i,n){
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans=1;
    rep(i,n){
        if(a[i] <= MAX/ans){
            ans *= a[i];
        } else {
            ans = -1;
            break;
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4372
n = int(input())
a = list(map(int,input().split()))
from fractions import gcd
l,r = [0]*(n+1),[0]*(n+1)
for i in range(n):
    l[i+1] = gcd(l[i],a[i])
for i in range(n,0,-1):
    r[i-1]= gcd(r[i],a[i-1])
ans = 0
for i in range(n):
    ans = max(ans,gcd(l[i],r[i+1]))
print(ans)

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

using namespace std;

#define X first
#define Y second
#define ll long long
#define inf (ll)1e18
#define all(x) x.begin(), x.end()

const int MX = 200020;
const int N = 1000060;
const int mod = (int)1e9 + 7;

int n, m;
int in[555];
std::vector<int> g[555];
std::vector<int> topo_res;

void topo(){

	queue<int> q;
	for(int i = 1; i <= n; ++i){
		if(in[i] == 0){
			q.push(i);
		}
	}

	while(q.size()){
		int x = q.front(); q.pop();
		topo_res.push_back(x);
		for(auto y : g[x]){
			in[y]--;
			if(in[y] == 0)
				q.push(y);
		}
	}

}

bool test(int x){

	std::vector<int> res;
	queue<int> q;

	int inx[555];
	memcpy(inx, in, sizeof(in));

	if(inx[x] == 1){ // if it is part of one cycle, remove that cycle
		inx[x]--;
		q.push(x);
	}

	while(q.size()){
		int v = q.front(); q.pop();
		res.push_back(v);
		for(auto u : g[v]){
			if(u != x){ // ignore that edge that caused this cycle
				inx[u]--;
				if(inx[u] == 0)
					q.push(u);
			}
		}	
	}

	return (int) res.size() + (int) topo_res.size() == n;
}

int main(){
/*
     ___     ___
    (^_^)   (^_^)
   /( | )\ /( | )\
     | |     | |
*/
    cin.tie(0);
    cin.sync_with_stdio(0);

    #ifdef Cyborg101
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

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

    if(a > b) swap(a, b);

    int alice = b - a - 1;

    puts(alice & 1 ? "Alice" : "Borys");

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(0, b + c - a) << endl;  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

long long cnt[3001][3001];

int main() {
	int N, S;
	int A[3000];
	cin >> N >> S;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	for (int i = 1; i < 3001; i++) {
		cnt[0][i] = 0;
	}

	cnt[0][0] = 1;

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 3001; j++) {
			cnt[i][j] = cnt[i - 1][j];
			if (j == A[i-1]) {
				cnt[i][j] += i;
			}
			else if (j > A[i - 1]) {
				cnt[i][j] = (cnt[i][j] + cnt[i - 1][j - A[i - 1]]) % 998244353;
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i < N + 1; i++) {
		ans += cnt[i][S];
		ans = ans % 998244353;
	}

	cout << ans;
}

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

struct UnionFind {
	vector<int> d;
	// コンストラクタ　親は-頂点数を保管
	UnionFind(int N) : d(N, -1) {}
	
	int find(int x) {
		if (d[x] < 0) {
			return x;
		}
		return d[x] = find(d[x]);
	}

	bool unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) {
			return false;
		}
		if (d[x] > d[y]) {
			swap(x, y);
		}
		d[x] += d[y];
		d[y] = x;
		return true;
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	int size(int x) {
		return -d[find(x)];
	}
};

int deg[100005]; // 友達の人数
vector<int> to[100005]; // ブロックリスト

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	UnionFind uf(N);

	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		deg[a]++;
		deg[b]++;
		uf.unite(a, b);
	}

	for (int i = 0; i < K; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	for (int i = 0; i < N; i++) {
		int ans = uf.size(i) - 1 - deg[i];
		for (int u : to[i]) {
			if (uf.same(i, u)) {
				ans--;
				// 同じグループのブロックしている人は引く
				// ブロックしている友達はいない
			}
		}
		cout << ans;
		if (i == N - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}

}

Measured memory_bytes: 6784
# B

inp = input().split(' ')
N, K = int(inp[0]), int(inp[1])

sunuke = [1] * N

for i in range(K):
    di = int(input())
    tmp = map(int, input().split())
    for t in tmp:
        sunuke[t-1] = 0
print(sum(sunuke))

Measured memory_bytes: 9192
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int n, k;
signed main() {
	cin >> n >> k;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i <= k)continue;
		else if (n % i < k)ans += (i - k) * (n / i);
		else ans += (i - k) * (n / i) + (n % i - k + 1);
	}
	cout << min(ans, n * n) << endl;
	ggr
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define LL long long 
#define ULL unsigned long long 
#define LD long double 

const int N = 2e5 + 4;
vector<int> V[N];
bool odw[N];
int va[N];
int value = 0;

void DFS(int v) {
	odw[v] = 1;
	int n = V[v].size();
	int stv = va[v];
	int stva = value;
	va[v]+=value;
	value+=stv;
	//cout<<v<<" "<<value<<" "<<va[v]<<endl;
	for(int i=0; i<n; i++) {
		int u = V[v][i];
		if(!odw[u])
			DFS(u);
	}
	value = stva;
	//cout<<"#"<<v<<" "<<value<<endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, q;
	cin>>n>>q;
	int a, b;
	for(int i=1; i<n; i++) {
		cin>>a>>b;
		V[a].push_back(b);
		V[b].push_back(a);
	}
	for(int i=0; i<q; i++) {
		cin>>a>>b;
		va[a]+=b;
	}
	DFS(1);
	for(int i=1; i<=n; i++) {
		cout<<va[i]<<" ";
	}
}


Measured memory_bytes: 23680
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in(),Q=in();
	vector<stack<int>> S(N);
	REP(i,Q){
		int q=in();
		int t=in();
		if(!q){
			S[t].push(in());
		}
		else if(q==1){
			if(!S[t].empty()) out(S[t].top());
		}
		else{
			if(!S[t].empty()) S[t].pop();
		}
	}

	return 0;
}


Measured memory_bytes: 4152
#include<bits/stdc++.h>
using namespace std;
int main(){
  set<long>a;
  int n;
  cin >> n;
  long aa;
  for(int i=0;i<n;i++){
    cin >> aa;
    a.insert(aa);
  }
  if(a.size()==n)cout <<"YES"<<endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 9600
#include<iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio == false;
	int h, w;
	while (1)
	{
	cin >> h >> w;
	if (h == 0 && w == 0)break;
	for (int i = 0; i < h; i++)
	{
			if (i == 0 || i == h - 1)
			{
				for (int k = 0; k < w; k++)
				{
					if (k == w - 1)cout << "#" << endl;
					else cout << "#";
				}
			}
			else
			{
		for (int j = 0; j < w; j++)
		{
			if (!i == 0 || !i == h - 1)
			{
			if (j == 0) cout << "#";
			else if (j == w - 1)cout << "#" << endl;
			else cout << ".";
			}
		}
			}
	}
	cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <cstdio>
#include <cstring>
#include <algorithm>

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

using namespace std;

int n, m;
char s[1001];
char t[1001];
int dp[1001][1001];

int main(){
	int q;
	scanf("%d", &q);
	rep(z, q){
		scanf("%s%s", s, t);
		n = strlen(s);
		m = strlen(t);

		rep(i, n + 1){
			dp[i][0] = 0;
		}
		rep(i, m + 1){
			dp[0][i] = 0;
		}
		for(int i = 1; i <= n; ++i){
			for(int j = 1; j <= m ; ++j){
				dp[i][j] = max(dp[i - 1][j - 1] + (s[i - 1] == t[j - 1]), max(dp[i][j - 1], dp[i - 1][j]));
			}
		}
		printf("%d\n", dp[n][m]);
	}
	return 0;
}

Measured memory_bytes: 4944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define ff first
#define ss second
int main()
{
    int n,d,a;
    cin>>n>>d>>a;
    vector<pair<int,int>>v;
    for(int i=0;i<n;i++)
    {
        int x,h;
        cin>>x>>h;
        v.pb({x,h});
    }
    sort(v.begin(),v.end());
    ll ans=0;
    ll arr[n]={0};
    for(int i=0;i<n;i++)
    {
        if(i!=0)
        arr[i]+=arr[i-1];
        if(v[i].ss-arr[i]*a>=0)
        {
            int extra=(v[i].ss-arr[i]*a+a-1)/a;
            arr[i]+=extra;
            ans+=extra;
            auto it=upper_bound(v.begin(),v.end(),make_pair(v[i].ff+2*d+1,0));
            if(it!=v.end())
            {
                int minus=it-v.begin();
                arr[minus]-=extra;
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3440
A, B, X = map(int, input().split())
k = (X // 1000)
ans = k * min(A, 2*B)
r = X - 1000*k
if 0 < r <= 500:
    ans += min(A, B)
elif 500 < r:
    ans += min(A, 2*B)
print(ans)


Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <stack>
using namespace std;


int main() {
    string l;
    int a, b;
    stack <int> S;
    while(cin >> l) {
        if(l[0] == '+') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a+b);
        }
        else if (l[0] == '-') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(b-a);
        }
        else if (l[0] == '*') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a*b);
        }
        else {
            S.push(atoi(l.c_str()));
        }
    }
    cout << S.top() << endl;
    return 0;
}


Measured memory_bytes: 3216
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long lint;
//typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
const int    dx[]={-1,0,0,1};
const int    dy[]={0,-1,1,0};
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

int N,M;
int P[100010],Y[100010];
vector<int>ran[100010];

signed main(){
  cin>>N>>M;
  for(int i=1;i<=M;i++){
    cin>>P[i]>>Y[i];
    ran[P[i]].push_back(Y[i]);
  }
  for(int i=1;i<=N;i++)sort(ran[i].begin(),ran[i].end());

  for(int i=1;i<=M;i++){
    int temp=(int)(lower_bound(ran[P[i]].begin(),ran[P[i]].end(),Y[i])-ran[P[i]].begin())+1;
    cout<<setw(12)<<setfill('0')<<P[i]*1000000+temp<<endl;
  }
  return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

/***** type *****/
using namespace std;
using ll = long long;
using ld = long double;
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
template <class T> using vvvt = vector<vector<vector<T>>>;
using ml = boost::multiprecision::cpp_int;

/***** define *****/
#define all(c) (c).begin(), (c).end()            // begin to end
#define rep(i, b, e) for (ll i = b; i < e; i++)  // repeat
#define repr(i, b, e) for (ll i = b; e < i; i--) // repeat reverse
#define val(itr) *(itr)                          // get value
/***** const value *****/
#define llong_max 9223372036854775807            // 9 * 10^18
#define ldbl_max 1.79769e+308                    // 1.7 * 10^308
#define mod 1000000007                           // 1e9 + 7
#define pi 3.14159265                            // 3.14 ...
/***** for each macro *****/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, c) fori(i, auto e = c.begin(); e != c.end(); ++e)
#define forir(i, v, ...) if(ll i = Size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, c) forir(i, auto e = c.rbegin(); e != c.rend(); ++e)

/***** lambda *****/
auto Count = [] // long long count value
(auto b, auto e, auto x) { return (ll)count(b, e, x); };
auto CtoN = [] // char to number
(auto c) { return (ll)(c - '0'); };
auto DivC = [] // long double div ceiling
(auto a, auto b) { return ceil((ld)a / (ld)b); };
auto Fix = [] // fix value
(auto b, auto e, auto fix)
{ for (auto it = b; it != e; ++it)*it += fix; };
auto Pow = [] // long long pow
(auto a, auto b) { return (ll)pow(a, b); };
auto Pow2 = [] // long long pow2
(auto n) { return (1LL << n); };
auto Pow10 = [] // long long pow10
(auto n) { return (ll)pow(10, n); };
auto Size = []  // long long collection size
(auto& c) { return (ll)(c).size(); };
auto Sum = [] // long long accumulate
(auto b, auto e) { return accumulate(b, e, 0LL); };

/***** template *****/
template <class T> vvt<T> VVT
(ll ys, ll xs, T fill = T())
{	// vector<vector<T>> resize + fill
	vvt<T> v(ys);
	each(i, y, v) { y->resize(xs, fill); } return v;
}
template <class T> vvvt<T> VVVT
(ll zs, ll ys, ll xs, T fill = T())
{	// vector<vector<vector<T>>> resize + fill
	vvvt<T> v(zs);
	each(i, z, v) { val(z) = VVT(ys, xs, fill); } return v;
}
template <class T> vt<T> InputVT
(ll size, T fix = T())
{	// input vector<T> (T != struct) + fix
	vt<T> v(size);
	each(i, e, v) { cin >> val(e); val(e) += fix; } return v;
}
template <class T> vvt<T> InputVVT
(ll ys, ll xs, T fix = T())
{	// input vector<vector<T>> (T != struct) + fix
	vvt<T> v(ys); each(i, y, v) val(y).resize(xs);
	each(i, y, v) each(j, x, val(y)) { cin >> val(x); val(x) += fix; } return v;
}
template <class T> vvvt<T> InputVVVT
(ll zs, ll ys, ll xs, T fix = T())
{	// input vector<vector<vector<T>>> (T != struct) + fix
	vvvt<T> v(zs);
	each(i, z, v) { val(z) = InputVVT<T>(ys, xs, fix); } return v;
}

//using namespace NyaGadget;
//using mll = ModLL<1000000007>;

int main()
{
	ll H, A; cin >> H >> A;
	if (H % A == 0) cout << H / A;
	else cout << H / A + 1;
	return 0;
}

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

void inp_str(int*);


int main(void) {

int input1[100];
inp_str(input1);
int input2[100];
inp_str(input2);
int input3[100];
inp_str(input3);

int N;
N=input1[0];

int ans=0;

int i;
for(i=0;i<N;i=i+1){
	if(input2[i]>=input3[i]){
		ans=ans+(input2[i]-input3[i]);
	}else{
	}
}

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


void inp_str(int instr[]){
char *ptr;
int z,i,count;
char str[100]={'\0'};
char *ln;

fgets(str, 100, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       z = getchar();
      if (z == '\n' || z == EOF) break;
   }
}
	count=0;
    ptr = strtok(str, " ");
    i = atoi(ptr);
    instr[count]=i;
    count=count+1;
    // 2回目以降
    while(ptr != NULL) {
        // strtok関数により変更されたNULLのポインタが先頭
        ptr = strtok(NULL, " ");
        // ptrがNULLの場合エラーが発生するので対処
        if(ptr != NULL) {
		    i = atoi(ptr);
    instr[count]=i;
    		count=count+1;
        }
    }
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,a,b) for (int i=(a); i<(b);i++)
#define frr(i,a,b) for(int i=(a-1);i>=(b);i--)
#define vi vector<int>
#define de deque<int>
#define del deque<ll>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define mp map<ll,ll>
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define ln(a) a.length()
#define sz(a) a.size()
ll M=1000000000000007;

int a[100005][3];
int dp[100005][3];
int n;

int mx(int a,int b,int c)
{
if(a>=b && a>=c)return a;
if(b>=a && b>=c)return b;

return c;

}

int fun(int i,int j)
{
   
if(dp[i][j]!=-1)return dp[i][j];

int k;

if(j==0)
k= a[i][j]+max(fun(i-1,1),fun(i-1,2));
else if(j==1)
k= a[i][j]+max(fun(i-1,0),fun(i-1,2));
else 
k= a[i][j]+max(fun(i-1,1),fun(i-1,0));
dp[i][j]=k;
return k;

}

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

	cin>>n;
	
	fr(i,0,n)fr(j,0,3)cin>>a[i][j];
    memset(dp,-1,sizeof dp);
    dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
  
  cout<<mx(fun(n-1,0),fun(n-1,1),fun(n-1,2))<<endl;





}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long

ll mod = 1e9+7;

ll power(ll n, ll x)
{
	if(x==0) return 1ll;
	ll p = 1;
	for(ll i=0;i<x;i++)
	{
		p = (p*n)%mod;
	}
	return p;
}

int main()
{
	ll i,j,n;
	cin>>n;
	if(n==1) {cout<<0;return 0;}
	ll ch = power(10,n);
    ch -= 2*power(9,n);
    ch += power(8,n);
    ch%=mod;
	ch = ch+mod;
	ch%=mod;
	cout<<ch<<"\n";
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <tuple>

using namespace std;

int main(int, char**) {
    string str;
    cin >> str;
    bool a=0, b=0;
    for(int i(0); i< str.length(); ++i){
      if(str[i]=='C'){ a= true; }
      if(a&&str[i]=='F') {b=true;}

    }
    if (b) { cout << "Yes" <<endl; }
    else {  cout << "No" <<endl; }
    return 0;
}



Measured memory_bytes: 256
ref = {"1":[".",",","!","?"," "],
	   "2":["a","b","c"],
	   "3":["d","e","f"],
	   "4":["g","h","i"],
	   "5":["j","k","l"],
	   "6":["m","n","o"],
	   "7":["p","q","r","s"],
	   "8":["t","u","v"],
	   "9":["w","x","y","z"]}
for _ in range(input()):
	inputs = map(str,raw_input().split("0"))
	ans = ""
	for input in inputs:
		if len(input) > 0:
			ans += ref[input[0]][(len(input)-1)%len(ref[input[0]])]
	print ans

Measured memory_bytes: 4260
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

#define FOR(i,n) for(int i=0;i<n;i++)
#define PRINT(a) cout<<a<<"\n"
 
int main(){

	int a,b,c,t=1;

	cin>>a>>b>>c;

	if(a-b!=0)t++;
	if((a-c)*(b-c)!=0)t++;

	PRINT(t);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	string s, t;
	cin >> s >> t;

	vector<vi> v(26);
	rep(i, s.size()) v[s[i] - 'a'].push_back(i);

	const int smax = s.size() + 10;
	rep(i, 26) v[i].push_back(smax);
	ll cycle = 0, cur = -1, i = 0;

	while(i < t.size()) {
		vi& v2 = v[t[i] - 'a'];
		if(v2.size() == 1) {
			cycle = -1;
			break;
		}
		cur = *upper_bound(v2.begin(), v2.end(), cur);
		if(cur == smax) {
			cycle++;
			cur = -1;
		}
		else i++;
	}
	if(cycle == -1) cout << -1 << endl;
	else cout << cycle * s.size() + cur + 1 << endl;
}


Measured memory_bytes: 1344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

int H, W,N;
int field[305][305];
int field2[305][305];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};


void dfs(int x, int y, int h) {
    field[x][y] = 0;
    rep(i,4){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(0 <= nx and nx < H and 0 <= ny and ny < W and field[nx][ny] > h) dfs(nx, ny, h);
    }
    return ;
}

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

    int h, w;
    while(cin >> h >> w) {
        if(h == 0 and w == 0) return 0;
        rep(i,h) {
            rep(j,w) {
                if((i+j)%2 == 0) cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

int main(){
  int n;
  cin >> n;
  string s = "";
  while(n!=0){
    if(n%2){
      s = '1'+s;
      n--;
    }
    else s = '0'+s;
    n /= -2;
  }
  if(s=="") s='0';
  cout << s << endl;
}

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

int main(){
  vector<int> v(5);
  int k;
  for(auto& x:v)
    cin >> x;
  cin >> k;
  string ans = "Yay!";
  if(v.at(4)-v.at(0) > k)
    ans = ":(";
  cout << ans << endl;
}

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


int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> vec(H+2, vector<char>(W+2));
  
  rep(i, W+2) {
    vec[0][i] = '#';
    vec[H+1][i] = '#';
  }
  
  for(int i=1; i<H+1; i++) {
    for(int j=1; j<W+1; j++) {
      cin >> vec[i][j];
    }
    vec[i][0] = '#';
    vec[i][W+1] = '#';
  }
  
  rep(i, H+2) {
    rep(j, W+2) {
      cout << vec[i][j];
    }
    cout << endl;
  }
  
}


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

int main() {
	int n; cin >> n;
	int cnt = 0;
	bool ok = false;
	REP(i, n) {
		int l, r; cin >> l >> r;
		if (l == r)
			cnt++;
		else
			cnt = 0;
		if (cnt == 3) {
			ok = true;
		}
	}
	if (ok) cout << "Yes" << '\n';
	else cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 3628