akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main(){
	int n,m;
	char target[1000][100];
	int money[100];
	char str[100];
	while(scanf("%d %d",&n,&m), n){
		REP(i,n){
			scanf("%s %d",target[i],&money[i]);
		}
		int sum=0;
		while(m--){
			scanf("%s",str);
			for(int i=0;i<n;i++){
				for(int j=0;j<8;j++){
					if(target[i][j]!='*'&&target[i][j]!=str[j]){goto next;}
			
				}
				sum+=money[i];
				break;
				next:;
			}
		}
			printf("%d\n",sum);
	}
}

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

int counter[5] = {-1,-1,-1,-1,-1};
int number[10] = {0,1,2,3,4,5,6,7,8,9};

int trancerate(int base){
    int sum = 0;
    int k = 1;
    REP1(i,5){
        if (counter[i] != -1){
            sum += number[counter[i]]*k;
        }
        k *= 10;
    }
    return sum;
}

int uper(int base,int N,int keta){
    if(N <= trancerate(base)) return trancerate(base);
    
    if(counter[keta] < base-1){
        counter[keta]++;
        return uper(base,N,0);
    }else{
        counter[keta] = 0;
        return uper(base,N,keta+1);
    }
}

int main(){
    INT(N);INT(K);
    REP1(i,K){
        INT(D);
        number[D] = 10;
    }
    sort(number,number+10);
    
    cout << uper(10-K,N,0) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

int a[maxn],n,k,mn;
int p[maxn],cnt;

int main(){
	scanf("%d %d",&n,&k);
	mn = inf;
	rep(i,1,n) scanf("%d",&a[i]) , mn = min(mn,a[i]);
	rep(i,1,n) if ( a[i] == mn ) p[++cnt] = i;
	int r = 0 , ans = 0;
	rep(i,1,cnt){
		int x = p[i];
		if ( r + 1 >= x ){ r = max(r,x); continue; }
		int cur = ceil((double)(x - r) / (k - 1));
		r = cur * (k - 1) + r + 1;
		ans += cur;
	}
	int d = n - r;
	ans += ceil((double)d / (k - 1));
	printf("%d\n",ans);
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
  int i,n,x,y,z,max,ans;
  char str[1000];

  while(1){
    fgets(str,sizeof(str),stdin);
    sscanf(str,"%d",&n);
    if(n==0) break; 
    max=-1;
    for(i=0;i<n;i++){
      fgets(str,sizeof(str),stdin);
      sscanf(str,"%d %d %d",&z,&x,&y);
      if(x+y>max){
      max=x+y;
      ans=z;
      }
    }
    printf("%d %d\n",ans,max);
  }
  return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int n;
int dp[1010][20];
int index[1010];
string str;
int dfs(int now,int bit);


int main(){
	cin >> n >> str;
	for(int i=0;i<n;i++){
		if(str[i]=='J') index[i]=0;
		else if(str[i]=='O') index[i]=1;
		else index[i]=2;
		for(int j=0;j<20;j++){
			dp[i][j] = -1;
		}
	}
	cout << dfs(0,1) << endl;
}

int dfs(int now,int bit){
	if(now==n) return 1;
	if(dp[now][bit] != -1) return dp[now][bit];
	int ret = 0;
	for(int i=0;i<8;i++){
		if( (bit&i) && (i&(1<<index[now]))){
			ret += dfs(now+1,i);
		}
	}
	return dp[now][bit] = ret % 10007;
}

Measured memory_bytes: 1348
S = input()
digits = list(map(int, S))
divisor = 2019

rem_count = [0] * divisor
rem_count[0] = 1
num = 0
pow10 = 1
total = 0

for digit in reversed(digits):
    num = digit * pow10 + num
    num %= divisor
    total += rem_count[num % divisor]
    pow10 *= 10
    pow10 %= divisor
    rem_count[num % divisor] += 1

print(total)


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

int X, Y;
int sum = 0;

int main(){
  cin >> X >> Y;

  if(X + Y == 2) cout << 1000000 << endl;
  else{
    if(X == 1) sum += 300000;
    else if(X == 2) sum += 200000;
    else if(X == 3) sum += 100000;

    if(Y == 1) sum += 300000;
    else if(Y == 2) sum += 200000;
    else if(Y == 3) sum += 100000;

    cout << sum << endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string S; cin >> S;
    bool f=false;
    if(S[0]==S[1] && S[1]==S[2]) f=true;
    if(S[1]==S[2] && S[2]==S[3]) f=true;
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3536
<?php

$a = (int)trim(fgets(STDIN));

$ans = 'No';
for ($i = 1; $i < 10; $i++) {
    for ($j = 1; $j < 10; $j++) {
        if ($i * $j === $a) {
            $ans = 'Yes';
            break;
        }
    }
}

echo $ans;

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

bool IsPrime(long long n){
  if(n == 1) return false;
  for(long long i = 2; i * i < n; i++){
    if(n%i == 0) return false;
  }
  return true;
}

vector<pair<long long, long long>> PrimeFactorize(long long n){
  vector<pair<long long, long long>> res;

  long long a = 0;

  for(long long i = 2; i * i <= n; i++){
    a = 0;
    if(n%i == 0){
      if(IsPrime(i)){
        while(n % i == 0){
          n /= i;
          a++;
        }
        res.push_back(make_pair(i, a));
      }
    }
  }

  if(n!= 1) res.push_back(make_pair(n, 1));
  return res;
}

int NumOfDivisor(long long n){
  vector<pair<long long, long long>> res;
  res = PrimeFactorize(n);

  int num = 1;
  for(int i = 0; i < res.size(); i++){
    num *= (1 + res[i].second);
  }

  return num;

}

int main(){
  const int mod = 1e9 + 7;
  int n;
  const int max_n = 1e3;
  cin >> n;

  long long ans = 1;
  long long ex[max_n + 2]  = {};
  
  for(int i = 1; i <= n; i++){
    vector<pair<long long, long long>> res;
    res = PrimeFactorize(i);
    for(int j = 0; j < res.size(); j++){
      ex[res[j].first - 1] += res[j].second;
    }
  }

  for(int i = 0; i < n; i++){
    ans *= (ex[i] + 1);
    ans %= mod;
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n,t;
	cin>>n>>t;
	int cost=INF;
	rep(i,n){
	    int c,tm;
	    cin>>c>>tm;
	    if(tm<=t){
	        cost=min(cost,c);
	    }
	}
	if(cost==INF)cout<<"TLE"<<endl;
	else cout<<cost<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF=1<<29;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,M,Ans=0,tmp=0;
	cin>>N>>M;
	vector<ll> A(N);
	for(int i=0;i<N;i++) cin>>A[i];
	//sort(A.begin(),A.end());
	vector<pair<ll,ll>> B(M);
	for(int i=0;i<M;i++){
		cin>>B[i].first>>B[i].second;
		swap(B[i].first,B[i].second);
	}
	for(int i=0;i<N;i++){
		B.push_back(make_pair(A[i],1LL));
	}
	sort(B.begin(),B.end(),greater<pair<ll,ll>>());
	for(int i=0;i<B.size();i++){
		for(int j=0;j<B[i].second;j++){
			Ans+=B[i].first;
			tmp++;
			if(tmp==N){
				cout<<Ans<<endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 7428
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
    return a == 0 ? b : gcd(b%a,a);
}
int main(){
    int n;
    scanf("%d",&n);
    long long ans = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            for (int k = 1; k <= n; k++){
                ans += gcd(i,gcd(j,k));
            }
        }
    }
    printf("%lld",ans);
}


Measured memory_bytes: 3756
def x_base(n, x):
  j = []
  while(1):
    if(n < x):
      j.append(n)
      break
    else:
      j.append(n % x)
      n //= x
  return j


n = [int(i) for i in input().split()]
print(len(x_base(n[0], n[1])))


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, C;
  cin >> N >> C;

  vector<ll> X(N + 2), V(N + 2), D(N + 2), E(N + 2);
  for (ll i = 1; i <= N; i++) {
    cin >> X[i] >> V[i];
    V[i] += V[i - 1];
    D[i] = max(D[i - 1], V[i] - X[i]);
  }

  for (int i = N; i >= 1; i--)
    E[i] = max(E[i + 1], (V[N] - V[i - 1]) - (C - X[i]));
  ll ret = max(D[N], E[1]);
  for (int i = 1; i <= N; i++)
    ret = max(ret, D[i] + E[i + 1] - X[i]);
  for (int i = N; i > 1; i--)
    ret = max(ret, E[i] + D[i - 1] - (C - X[i]));
  cout << ret << '\n';
  return 0;
}


Measured memory_bytes: 3456
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            int a,b;
            String line = reader.readLine();
            StringTokenizer token = new StringTokenizer(line," ");
            a = Integer.parseInt(token.nextToken());
            b = Integer.parseInt(token.nextToken());
            System.out.println((a*b)+" "+(a*2+b*2));
        }catch(IOException e){
            System.out.println(e);
        }catch(NumberFormatException e){
System.out.println("The input number was not correct.");
        }
    }
}



Measured memory_bytes: 24088
// finish date: 2018/02/18

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


struct pos {
    int x, y;
};

int main() {
    int H, W;
    cin >> H >> W;
    vs s(H);
    rep(i, H) cin >> s[i];
    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            if (s[i][j] == '.') ans++;
        }
    }
    pos p;
    p.x = 0;
    p.y = 0;
    stack<pos> st;
    st.push(p);
    vvi dis(H, vi(W, INF));
    dis[0][0] = 0;
    while (!st.empty()) {
        p = st.top();
        st.pop();
        for (int i = -1; i <= 1; i += 2) {
            if (0 <= p.x + i && p.x + i < W) {
                if (s[p.y][p.x + i] == '.') {
                    if (dis[p.y][p.x] + 1 < dis[p.y][p.x + i]) {
                        dis[p.y][p.x + i] = dis[p.y][p.x] + 1;
                        p.x = p.x + i;
                        st.push(p);
                        p.x = p.x - i;
                    }
                }
            }
            if (0 <= p.y + i && p.y + i < H) {
                if (s[p.y + i][p.x] == '.') {
                    if (dis[p.y][p.x] + 1 < dis[p.y + i][p.x]) {
                        dis[p.y + i][p.x] = dis[p.y][p.x] + 1;
                        p.y = p.y + i;
                        st.push(p);
                        p.y = p.y - i;
                    }
                }
            }
        }
    }
    if (dis[H - 1][W - 1] == INF) cout << -1 << endl;
    else cout << ans - dis[H - 1][W - 1] - 1 << endl;


    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  int a, b, c, d;
  cin >> a >> b >> c;
  
  d = 100 * a + 10 * b + c;
  
  if (d % 4 == 0) 
  {
    cout << "YES " << endl;
  }else{
    cout << "NO " << endl;
  }
}


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

int main() {
    // Sum_{k=1..n} k/2 * floor(n/k) * floor(1 + n/k).
    int n;
    ll r = 0, h = 0;
    cin >> n;
    for (ll i = 1; i <= n; ++i) {
        if (i % 2 && (n / i) % 2 && (1 + n / i) % 2) ++h;
        r += i * (n / i) * (1 + n / i) / 2;
    }
    cout << r + h / 2 << endl;
}

Measured memory_bytes: 3596
n, k = [int(i) for i in input().split()]
if k > (n - 1)*(n - 2) // 2:
    print(-1)
else:
    ed = []
    for i in range(1, n):
        ed.append(" ".join(map(str, [1, i + 1])))
    kk = (n - 1)*(n - 2)//2 - k
    if not kk:
        print(len(ed))
        print("\n".join(ed))
        exit()
    for i in range(1, n):
        for j in range(i+1, n):
            ed.append(" ".join(map(str, [i + 1, j + 1])))
            kk -= 1
            if not kk:
                print(len(ed))
                print("\n".join(ed))
                exit()


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    double r;cin>>r;

    cout<<2*M_PI*r<<"\n";
    
    return 0;

}

Measured memory_bytes: 3788
import sys
sys.setrecursionlimit(100000000)

N, M = map(int, input().split())

visited = [False for i in range(N)]
v_to = [[] for i in range(N)]

for i in range(M):
  X, Y, Z = map(int, input().split())
  v_to[X - 1].append(Y - 1)
  v_to[Y - 1].append(X - 1)

def dfs(i):
  if visited[i]:
    return 0

  visited[i] = True
  for to in v_to[i]:
    dfs(to)

  return 1

ans = 0
for i in range(N):
  ans += dfs(i)

print(ans)

Measured memory_bytes: 104700
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
string z = "keyence";
int main()
{
	string s;
	cin >> s;
	int c1 = 0;
	for (int i = 0; i < 7; i++)
	{
		if (s[i] == z[i])c1++;
		else break;
	}
	for (int i = 0; i < 7; i++)
	{
		if (s[s.size() - i - 1] == z[6 - i])c1++;
		else break;
	}
	printf((c1 >= 7) ? "YES\n" : "NO\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <queue>
#include <ctime>
#define int long long
using namespace std;
int32_t main(){
	int q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	int two = min(d, min(2*s, min(4*h, 8*q)));
	int one = min(s, min(2*h, 4*q));
	cout << two * (n / 2) + one * (n % 2) << endl;
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b, c, d; cin >> a >> b >> c>> d;
    cout << max({a*c,a*d,b*c,b*d});
}

Measured memory_bytes: 3684
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    ab, bc, ca = map(int, input().split())
    res = (ab * bc) // 2
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextString(scanner)
	ans := "NO"
	if able(s) {
		ans = "YES"
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}

func able(s string) bool {
	if s == "" {
		return true
	}

	ss := map[string]int{
		"dream":   5,
		"dreamer": 7,
		"erase":   5,
		"eraser":  6,
	}

	for sss, l := range ss {
		if len(s) < l {
			continue
		}
		if s[0:l] == sss {
			if able(s[l:]) {
				return true
			}
		}
	}

	return false
}


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

int main(){

   int h,n;
   cin>>h>>n;

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

if(sum>=h) cout<<"Yes"<<endl;
else cout<<"No"<<endl;


return 0;
}

Measured memory_bytes: 640
import Control.Applicative
import Data.List
import Data.Char

readInts :: IO [Integer]
readInts = map read . words <$> getLine

strip :: String -> String
strip = reverse . dropWhile isSpace . reverse . dropWhile isSpace

ints :: String -> [Integer]
ints = map read . words

prn :: Show a => a -> IO ()
prn = putStrLn . show

prns :: Show a => [a] -> IO ()
prns = putStrLn . unwords . map show

calc :: [Integer] -> [Integer]
calc xs = [gcd a b, lcm a b]
  where
    a = xs !! 0
    b = xs !! 1

main :: IO ()
main = do
  s <- getContents
  let xs = map ints $ lines $ strip s :: [[Integer]]
  mapM_ prns $ map calc xs

Measured memory_bytes: 4124
#include <stdio.h>

using namespace std;
typedef long long llong;

#define MAX
const llong mod = 1000000000 + 7;

int main()
{
  int N;
  int flag = 0;
  scanf("%d", &N);
  for (int i = 0; i < 3; i++)
  {
    if (N % 10 == 7)
      flag = 1;
    N /= 10;
  }
  if (flag)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}

Measured memory_bytes: 1664
var
	N,i:Longint;
	p,A,T:int64;
begin
	read(N,p);
	T:=1000;
	for i:=2 to N do begin
		read(A);
		if p<A then begin
			T:=T mod p+T div p*A;
		end;
		p:=A;
	end;
	writeln(T);
end.

Measured memory_bytes: 1388
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll a[Maxn];
map<ll, ll> mp;
ll n, m, v, p;
	
bool check(ll x){
	if(x <= p) return true;
	ll me = a[x - 1] + m;
	ll d = max(0ll, v - (p - 1) - (n - x));
	ll sm = d * m;
	for(int i = p - 1; i < x; i++){
		if(a[i] > me) return false;
		ll del = min(me - a[i], m);
		sm -= del;
	}
	if(sm > 0) return false;
	return true;
}
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> v >> p;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	
	ll L = 0, R = n + 1;
	ll mid;// = (L + R) >> 1;
	while(L + 1 < R){
		mid = (L + R) >> 1;
		if(check(mid)) L = mid;
		else R = mid;
	}
	cout << L;
	return 0;
}




Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (auto&& e : a) cin >> e;
  for (int i = n - 2; i >= 0; --i) {
    if (a[i] > a[i + 1] + 1) return cout << "No" << '\n', 0;
    if (a[i] == a[i + 1] + 1) --a[i];
  }
  cout << "Yes" << '\n';
}


Measured memory_bytes: 3716
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int x, y;
    cin >> x >> y;
    int ans = 2e9;
    if (y >= x) ans = min(ans, y-x);
    if (y >= -x) ans = min(ans, y+x+1);
    if (-y >= x) ans = min(ans, -y-x+1);
    if (-y >= -x) ans = min(ans, -y+x+2);
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N;
    long long x, y;
    cin >> N;
    vector<long long> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    sort(A.begin(),A.end());

    int i = N - 1;
    x = -1;
    y = -1;
    while(y < 0){
        if(A[i] == A[i - 1]){
            if(x < 0){
                x = A[i];
                i = i - 2;
            }
            else{
                y = A[i];
            }
        }
        else i--;
        if(i < 0){
            y = 0;
            break;
        }
    }
    cout << x * y << endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Main m = new Main();
    m.exec();
  }

  private void exec() {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    int result = (n + 1) * (m + 1) - (2 * (m + 1) + 2 * (n - 1));
    System.out.println(result);
  }
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

const long long MOD = 998244353;

ll fastpow(ll _x,ll _n){
   int ret = 1;
   while(0<_n){
       if((_n%2) == 0){
           _x = (_x*_x)%MOD;
           _n >>= 1;
       }else{
           ret = (ret*_x)%MOD;
           --_n;
       }
   }
   return ret;
}

void solve(long long n, std::vector<long long> D){
    REP(i,0,n){
        if(i==0 && D[i]!=0){cout<<0<<endl;return;}
        if(i>0 && D[i]==0){cout<<0<<endl;return;}
    }
    int now=1,ans=1;
    int maxD=*max_element(ALL(D))+1;
    Vi a(n);
    REP(i,0,n){
        a[D[i]]++;
    }
    REP(i,1,maxD){
        if(a[i]==0){cout<<0<<endl;return;}
//        REP(j,0,a[i]) ans = (ans*a[i-1])%MOD;
        ans = (ans * fastpow(a[i-1],a[i]))%MOD;
    }
    cout<<ans<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> D(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&D[i]);
    }
    solve(N, std::move(D));
    return 0;
}


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

int main () {
  long long N,K;
  cin >> N >> K;
  vector<long long>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  vector<long long>counta(N,0);
  vector<long long>countb(N,0);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (A.at(i) < A.at(j)){
        if (i > j){
          counta.at(i)++;
        }
        countb.at(i)++;
      }
    }
  }
  
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += counta.at(i);
  }
  
  long long mod = 1000000007;
  
  long long dis = 0;
  for (int i = 0; i < N; i++) {
    dis += countb.at(i);
    dis %= mod;
  }
  
  long long kaijo = (K * (K-1)/2) % mod;
  
  ans *= K;
  ans %= mod;
  ans += kaijo*dis;
  ans %= mod;
  cout << ans << endl;
}
  
  

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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){
    os << "(" << p.first << "," << p.second << ")";
}

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

ll n,m;

struct edge{
    pii to;
    int cost;
    edge(){}
    edge(pii _to,int _cost){
        to = _to;
        cost = _cost;
    }
};


map<pii,vector<edge>> g;

int dijkstr(pii s,pii t){
    using P = pair<int,pair<int,int>>;
    priority_queue<P,vector<P>,greater<P>> que;
    map<pii,int> d;
    for(auto p : g){
        d[p.first]=INF;
    }
    d[t] = INF;
    d[s] = 0;
    que.push(MP(0,s));

    while(!que.empty()){
        int cost;
        pii v;
        tie(cost,v) = que.top();
        que.pop();
        if(v==t) break;
        if(d[v] < cost) continue;

        for(auto e : g[v]){
            if(d[e.to] > d[v]+e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(MP(d[e.to],e.to));
            }
        }
    }

    return d[t];
}

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

    vector<set<int>> vecset(n);
    vi P(m),Q(m),C(m);

    for(int i=0;i<m;i++){
        int p,q,c;cin>>p>>q>>c;
        p--;
        q--;
        P[i]=p;
        Q[i]=q;
        C[i]=c;
        vecset[p].insert(c);
        vecset[q].insert(c);
    }


    for(int i=0;i<n;i++){
        for(int c: vecset[i]){
            g[pii(i,0)].PB(edge(pii(i,c),1));
            g[pii(i,c)].PB(edge(pii(i,0),0));
        }
    }

    for(int i=0;i<m;i++){
        int p=P[i],q=Q[i],c=C[i];
        g[pii(p,c)].PB(edge(pii(q,c),0));
        g[pii(q,c)].PB(edge(pii(p,c),0));
    }

    int d = dijkstr(pii(0,0),pii(n-1,0));
    if(d==INF){
        cout << -1 << endl;
        return 0;
    }
    cout << d << endl;
}


Measured memory_bytes: 119512
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
bool ng[19];
bool check(int a){
	while(a>0){
		if(ng[a%10]) return false;
		a/=10;
	}
	return true;
}
int main()
{
	int n,k,a;
	cin>>n>>k;
	memset(ng,false,sizeof(ng));
	rep(i,k){
		cin>>a;ng[a]=true;
	}
	while(1){
		if(check(n)){
			cout<<n<<endl;break;
		}
		n++;
	}
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
ll a, b, c, k;

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

    ll ans = 0;
    if (k >= a)
    {
        ans += a;
        k -= a;
    }
    else
    {
        ans += k;
        k = 0;
    }

    // cout << k << endl;
    if (k >= b)
    {
        k -= b;
    }
    else
    {
        k = 0;
    }
    // cout << k << endl;
    if (k >= c)
    {
        ans -= c;
    }
    else
    {
        ans -= k;
        k = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
/*  ex5_3 Grid Compression
    pandacodeb  */

#include <stdio.h>

int main(void){
    int height, width;
    int i, j;
    scanf("%d %d", &height, &width);
    char a[height][width];
    
    //各行・列には最終的に消すかを表す配列；最初の値は 0 (false)
    int rowDel[height], colDel[width];
    for (i = 0; i < height; i++){
        rowDel[i] = 0;
    }
    for (j = 0; j < width; j++){
        colDel[j] = 0;
    }

    //入力（行ごと）
    for (i = 0; i < height; i++){
        for (j = 0; j < width; j++){
            scanf(" %c", &a[i][j]);
        }
    }

    //どの行が # を持たないのかをチェックする
    for (i = 0; i < height; i++){
        for (j = 0; j < width; j++){
            //最初の # 見つければ、残りを無視して次の行にチェックする
            if (a[i][j] == '#'){
                break;
            }
            //最後まで # を持たない場合 -> その行を消すか=true
            else if (a[i][j] == '.' && j == width - 1){
                rowDel[i] = 1;
            }
        }
    }
    //どの列が # を持たないのかをチェックする
    for (j = 0; j < width; j++){
        for (i = 0; i < height; i++){
            //最初の # 見つければ、残りを無視して次の列にチェックする
            if (a[i][j] == '#'){
                break;
            }
            //最後まで # を持たない場合 -> その列を消すか=true
            else if (a[i][j] == '.' && i == height - 1){
                colDel[j] = 1;
            }
        }
    }

    //出力(行ごと)
    for (i = 0; i < height; i++){
        //その行は消す予定だったら、何も実行せずに次の行に考える
        if (rowDel[i] == 1)
            continue;
        for (j = 0; j < width; j++){
            //その列は消す予定だったら、何も実行せずに次の行に考える
            if (colDel[j] == 1){
                continue;
            }
            printf("%c", a[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 128
def main():
    input()
    a_list = list(set((map(int, input().split(' ')))))
    a_list.sort()
    small_a = a_list[0]
    for a in a_list:
        surplus = a % small_a
        if surplus != 0:
            while small_a - surplus >= 1:
                small_a = small_a - surplus
                if small_a < surplus:
                    small_a, surplus = surplus, small_a
            if small_a == 1:
                break
    print(small_a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20012
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

const char *t="AKIHABARA";
void main() {
    char s[55];
    R(s);
    int n=strlen(s),p=0;
    REP(i,n) {
        if ( t[p]=='A' && s[i]!=t[p] ) p++;
        if ( s[i]==t[p] ) p++;
        else {
            W("NO");
            return;
        }
    }
    if ( t[p]=='A' ) p++;
    W(t[p]=='\0' ? "YES" : "NO");
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<n-k;i++)
int main(){
  long long n,k,s;
  cin>>n>>k>>s;
  if(s<1000000000){
  for(long long i=0;i<n-k;i++) cout<<s+1<<" ";
  for(long long i=0;i<k;i++) cout<<s<<" ";
  }
  
  else{
  for(long long i=0;i<n-k;i++) cout<<s-1<<" ";
  for(long long i=0;i<k;i++) cout<<s<<" ";
  }
}

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

int main(void){
    int n, m;
    cin >> n >> m;
    const int inf = 1e9;
    vector<pair<int,int>> edge(m);
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        edge.at(i).first = a-1;
        edge.at(i).second = b-1;
    }

    int ans = 0;

    for(int i=0; i<m; i++){
        vector<vector<bool>> graph(n, vector<bool>(n, false));
        for(int j=0; j<m; j++){
            if(i != j){
                graph[edge.at(j).first][edge.at(j).second] = true;
                graph[edge.at(j).second][edge.at(j).first] = true;
            }
        }
        for(int k=0; k<n; k++){
            for(int j=0; j<n; j++){
                for(int l=0; l<n; l++){
                    if(graph[j][k] == true && graph[k][l] == true){
                        graph[j][l] = true;
                    }
                }
            }
        }

        bool bridge = false;
        for(int j=0; j<n-1; j++){
            for(int k=j+1; k<n; k++){
                if(graph[j][k] == false){
                    bridge = true;
                    break;
                }
            }
        }
        if(bridge){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
string st;
int a,b,w;
int main()
{
	cin>>a>>b;
	cin>>st;
	for (int i=0;i<st.size();i++)
	{
		if (i!=a)
		{
			if (st[i]<'0' || st[i]>'9') 
			{
				w=1;
				break;
			}
		}
	}
	if (w==1 || st[a]!='-') cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long int64;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int n;
    cin >> n;
    while(n != 0){
        vector<int> s(n);
        REP(i, n) cin >> s[i];
        int sum = accumulate(All(s), 0);
        sum -= *max_element(All(s)) + *min_element(All(s));
        sum /= (n-2);
        cout << sum << "\n";

        cin >> n;
    }
    return 0;
}


Measured memory_bytes: 3148
n = int(input())
if (n <= 111):
    print(111)
elif (n <= 222):
    print(222)
elif (n <= 333):
    print(333)
elif (n <= 444):
    print(444)
elif (n <= 555):
    print(555)
elif (n <= 666):
    print(666)
elif (n <= 777):
    print(777)
elif (n <= 888):
    print(888)
elif (n <= 999):
    print(999)

Measured memory_bytes: 3064
/*	ex4_3
	suzuto	*/

#include <stdio.h>
int snow_height(int len_1, int len_2); /*プロトタイプ宣言*/

int main(void) {
  int west, east, height; /*変数の宣言*/
  scanf("%d %d", &west, &east); /*塔の露出部分の長さを出力*/
  height = snow_height(west, east);
  printf("%d\n", height);
  return 0;
}

int snow_height(int len_1, int len_2){
  int count, dif, west_num, west_height, res; /*変数の宣言*/
  dif = len_2 - len_1; /*difは東側の塔が西から何番目かを表す数と等しい*/
  west_num = dif - 1; /*西側の塔の位置*/
  west_height = 0; /*west_heightの初期化*/
  for(count = 1; count <= west_num; count++){ /*西側の塔の高さを算出する*/
    west_height = west_height + count;
  }
  res = west_height - len_1; /*雪からの露出分の高さを引く（これが雪の積雪の高さ）*/
  return res;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>

using namespace std;

void solve(string n) {
  string ans = "";
  for (int i = 0; i < n.length(); i++) {
    if (n[i] == '1') {
      ans += "9";
    } else {
      ans += "1";
    }
  }
  printf("%s\n", ans.c_str());
}

int main() {
  string n;
  cin >> n;
  solve(n);
  return 0;
}

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

int main() {

    int k;
    scanf("%d", &k);
    
    int arr[32]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    printf("%d",arr[k-1]);


    return 0;

}

Measured memory_bytes: 1728
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;
 
using namespace std;
 
//[p,r)
int partition(vector<int>& A,int p,int r){
    int x = A[r-1];//partition
    int i = p-1;
    REP(j,r){
        if(A[j] <= x)    swap(A[j],A[++i]);
    }
    return i;
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> A(n);REP(i,n)cin>>A[i];
    int standard =  partition(A,0,n);
    REP(i,n){
        if(i)cout << ' ';
        if(standard == i)cout << '[';
        cout << A[i];
        if(standard == i)cout << ']';
    }
    cout << endl;
  return 0;
}

Measured memory_bytes: 3224
from sys import stdin

N = int(stdin.readline())
Job = [None]*N
for i in range(N):
    Job[i] = tuple(map(int, stdin.readline().split()))[::-1]

Job.sort()

Now = 0
for i in range(N):
    Deadline = Job[i][0]
    Now += Job[i][1]
    if Now > Deadline:
        print("No")
        quit()

else:
    print("Yes") 

Measured memory_bytes: 50396
#include <iostream>
#include <algorithm>
#define rep(i, a, n) for(int i = a;i < n;i++)
#define repr(i, a, n) for(int i = a;i > n;i--)
using namespace std;


int main(){
	char c[3][3];

	rep(i, 0, 3)
		rep(j, 0, 3) cin >> c[i][j];

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

	return 0;
}

Measured memory_bytes: 256
k = int(input())
s = input()
n = len(s)

mod = 10**9 + 7

## nCkのmodを求める関数
# テーブルを作る(前処理)
max = 2 * 10**6 + 100
fac, finv, inv = [0]*max, [0]*max, [0]*max

def comInit(max):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( (n<0) | (k < 0)):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

ans = 0
ex25 = [1] * (k+1)
ex26 = [1] * (k+1)
for i in range(1,k+1):
    ex25[i] = (ex25[i-1] * 25)%mod
    ex26[i] = (ex26[i-1] * 26)%mod

for i in range(k+1):
    j = k-i
    tmp = ex25[i] * com(n+i-1,i) * ex26[j]
    ans = (ans+tmp)%mod

print(ans)

Measured memory_bytes: 133256
from collections import defaultdict

MOD = 998244353


def main():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
#    dp = [defaultdict(int) for _ in range(S)]
    dp = [0] * S
    ans = 0
    for right in range(N):
        num = A[right]
        if num > S:
            continue
        elif num == S:
            ans = (ans + (right+1) * (N-right)) % MOD
            continue
        # for left in dp[S-num]:
        #     cnt = dp[S-num][left]
        #     ans = (ans + (left+1) * (N-right) * cnt) % MOD
        # for i in range(S-num-1, -1, -1):
        #     for left in dp[i]:
        #         dp[i+num][left] += dp[i][left]
        # dp[num][right] = 1
        ans = (ans + dp[S-num] * (N-right)) % MOD
        for i in range(S-num-1, -1, -1):
            dp[i+num] += dp[i]
        dp[num] += right + 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 91828
from collections import defaultdict

x, n = map(int, input().split())

plist = map(int, input().split())

pdict = defaultdict(int)

for p in plist:
    pdict[p] = 1



if pdict[x] == 0:
    print(x)
    exit(0)

z = 1


while True:
    if pdict[x - z] == 0:
        print(x - z)
        exit(0)
    if pdict[x + z] == 0:
        print(x + z)
        exit(0)
    z += 1





Measured memory_bytes: 9468
#include <stdio.h>

int f;
void judge(int x, int y, int z)
{    
    if (x * x + y * y == z * z){
        f = 1;
    }  
}


int main(void)
{
    int n, a, b, c;
    scanf("%d", &n);
    for (int i = 0; i < n ; ++i){
        f = 0;
        scanf("%d %d %d", &a, &b, &c); 
        judge (a, b, c); 
        judge (b, c, a); 
        judge (c, a, b);  
        if (f == 1){    
            printf("YES\n");
        }else{	
            printf("NO\n");
        }
    }
    return 0;        
}

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

int n;
vector<int> a;

int solve(bool smaller, int i, int used) {
  if(i == a.size()) {
    return ((used & 0b111) == 0b111);
  }

  int res = 0;
  if(smaller || a[i] >= 7) res += solve(smaller || a[i] > 7, i+1, used | (1<<2));
  if(smaller || a[i] >= 5) res += solve(smaller || a[i] > 5, i+1, used | (1<<1));
  if(smaller || a[i] >= 3) res += solve(smaller || a[i] > 3, i+1, used | 1);
  return res;
}

int main () {
  cin >> n;

  int m = n;
  rep(i, 10) {
    int d = m % 10;
    a.insert(a.begin(), d);
    m /= 10;
    if(m == 0) break;
  }

  int ans = 0;
  rep(i,a.size()) ans += solve(i!=0, i, 0);
  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){

    string s, t;
    cin >> s >> t;
    int n = sz(s);
    int m = sz(t);

    int ans = inf;
    for(int i = 0; i <= n-m; i++) {
        int tmp = 0;
        rep(j,m) {
            if(s[i+j] != t[j]) tmp++;
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624