akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char** argv)
{
	int i;

	int n;
	scanf("%d", &n);

	for (i = 1; i <= n; ++i)
	{
		int x = i;
		if (x % 3 == 0)
		{
			printf(" %d", i);
			continue;
		}

		do
		{
			if (x % 10 == 3)
			{
				printf(" %d", i);
				break;
			}

			x /= 10;
		} while (x != 0);
	}

	printf("\n");
	return 0;
}

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

using namespace std;
using ll = long long;

const ll INF = 1e18;

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

	int n;
	cin >> n;
	vector<int> x(n), y(n), p(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> p[i];
	}

	vector<vector<int>> dp_x(n, vector<int>(1 << n, 1e9));
	for (int mask = 1; mask < (1 << n); mask++) {
		int one = __builtin_ctz(mask);
		int pmask = mask - (1 << one);

		for (int i = 0; i < n; i++) {
			dp_x[i][mask] = min(dp_x[i][pmask], abs(x[i] - x[one]));
		}
	}

	vector<vector<int>> dp_y(n, vector<int>(1 << n, 1e9));
	for (int mask = 1; mask < (1 << n); mask++) {
		int one = __builtin_ctz(mask);
		int pmask = mask - (1 << one);

		for (int i = 0; i < n; i++) {
			dp_y[i][mask] = min(dp_y[i][pmask], abs(y[i] - y[one]));
		}
	}

	vector<ll> dp(1 << n, INF);
	for (int mask = 0; mask < (1 << n); mask++) {
		vector<int> ones;
		for (int i = 0; i < n; i++) {
			if ((mask >> i) & 1) {
				ones.push_back(i);
			}
		}

		for (int pmask = 0; pmask < (1 << ones.size()); pmask++) {
			int mask_x = 0, mask_y = 0;
			for (int i = 0; i < ones.size(); i++) {
				(((pmask >> i) & 1) ? mask_x : mask_y) += (1 << ones[i]);
			}

			ll res = 0;
			for (int i = 0; i < n; i++) {
				res += (ll)min({abs(x[i]), abs(y[i]), dp_x[i][mask_x], dp_y[i][mask_y]}) * p[i];
			}

			dp[mask] = min(dp[mask], res);
		}
	}

	vector<ll> ans(n + 1, INF);
	for (int mask = 0; mask < (1 << n); mask++) {
		int cnt = __builtin_popcount(mask);
		ans[cnt] = min(ans[cnt], dp[mask]);
	}

	for (auto el : ans) {
		cout << el << '\n';
	}
}

Measured memory_bytes: 7472
// https://atcoder.jp/contests/abc123/tasks/abc123_a
package main

import "fmt"

func main() {
	var x [5]int
	var k int
	for i := range x {
		fmt.Scanf("%d", &x[i])
	}
	fmt.Scanf("%d", &k)

	ok := true
	for _, x1 := range x {
		for _, x2 := range x {
			d := x1 - x2
			if d < 0 {
				d = -d
			}
			if d > k {
				ok = false
			}
		}
	}
	if ok {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    int times;
    if(n % x == 0) times = n / x;
    else times = n / x + 1;
    cout << times * t << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<math.h>

int max(int*, int);

int main()
{
	int n, i;
	scanf("%d", &n);
	int R[200001];
	for (i = 0; i <= n; i++)
	{
		scanf("%d", &R[i]);
	}
	printf("%d\n", max(R, n));

}


int max(int array[], int n)
{
	int r = 0, i = 0, k, biggest = 1, smallest = 1000000000, champion = -1000000000, challenger;
	while (1)
	{
		i = r;
		while (i <= n - 1)
		{

			if (i == r)
			{
				biggest = 1;
				i = r + 1;
			}
			if (array[i] >= biggest)
			{
				biggest = array[i];
				r = i;
			}
			i++;
		}
		for (k = 0; k <= r - 1; k++)
		{
			if (array[k] <= smallest) smallest = array[k];
		}
		challenger = biggest - smallest;
		if (champion <= challenger) champion = challenger;
		if (r == n - 1) break;
	}
	return champion;
}

Measured memory_bytes: 1804
a = sorted(list(map(int,input().split())))
if a[0]%2 == 0 or a[1]%2 == 0 or a[2]%2 == 0:
    print(0)
else:
    print(a[0]*a[1]*(a[2]//2 + 1) - a[0]*a[1]*(a[2]//2))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int n, k;
    cin >> n >> k;
    vi cnt(26);
    rep(i, n) {
        string s;
        cin >> s;
        cnt[s[0] - 'A']++;
    }

    int ans = 0;
    while (true) {
        sort(rall(cnt));
        rep(i, k) {
            if (cnt[i] == 0) {
                cout << ans << endl;
                return 0;
            }
            cnt[i]--;
        }
        ans++;
    }
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int A, B;
  cin >> A >> B;
  int ans = 0;
  if (B == 1) {
    cout << 0 << endl;
    return 0;
  }
  int total = 0;
  while (B > total) {
    ++ans;
    if (ans == 1) {
      total += A;
    } else {
      total += A - 1;
    }
  }

  cout << ans << endl;

  return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int K, S; cin >> K >> S;
    int ans = 0;
    for(int x = 0; x <= K; x++){
        for(int y = 0; y <= K; y++){
            int z = S-x-y;
            if(0 <= z && z <= K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define sz(a) int((a).size())
//use brackets before operations if taking MOD
//use map only when necessary
//give long long to arrays and variables properly
int mul(int a, int b,int mod = MOD) {
	return int(a * 1ll * b % mod);
}
int norm(int a,int mod = MOD) {
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
	//a = (a%mod+mod)%mod;
	return a;
}
int powmod(int x,int y,int mod = MOD){
	int res = 1;
	while(y>0)
	{
		if(y&1)
			res = mul(res,x,mod);
		x = mul(x,x,mod);
		y=y>>1;
	}
	return res;
}
int inv(int a,int mod = MOD) {
	return powmod(a, mod - 2);
}

int main() {


	fast();
	ll l,r,ans = LLONG_MAX;
	cin>>l>>r;
	for(ll i = l;i<=min(r,l+2025);i++)
	{
		for(ll j = i+1;j<=min(r,l+2025);j++)
		{
			ll res = (i*j)%2019;
			ans = min(ans,res);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC174D
#include <iostream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main(int argc, const char * argv[]) {
    int n;
    cin>>n;
    string c;
    cin >>c;
    int a=0;
    int b=0;
    rep(i,n) if(c[i]=='R') a++; // 赤の数
    int ans=max(a,b);
    rep(i,n){
        if(c[i]=='R'){
            a--;
        }else{
            b++;
        }
        int now=max(a,b);
        ans=min(ans,now);
    }
    cout<<ans<<endl;
    return 0;
}


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

struct Card{char suit,value;};



void bubble(struct Card A[],int N){
    for(int i = 0;i < N;i++){
        for(int j = N - 1;j >= i + 1;j--){
            if(A[j].value < A[j - 1].value){
                Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
            }
        }
    }
}

void selection(struct Card A[],int N){
    for(int i = 0;i < N;i++){
        int minj = i;
        for(int j = i;j < N;j++){
            if(A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[],int N){
    for(int i = 0;i < N;i++){
        if(i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}


bool isStable(struct Card C1[],struct Card C2[],int N){
    for(int i = 0;i < N;i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100],C2[100];
    int N;
    char ch;
    
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for(int i = 0;i < N;i++) C2[i] = C1[i];
    
    bubble(C1,N);
    selection(C2,N);
    
    print(C1,N);
    cout << "Stable" << endl;
    print(C2,N);
    if(isStable(C1,C2,N)){
        cout << "Stable" << endl;
    } else{
        cout << "Not stable" << endl;
    }
    
    return 0;
}



































































Measured memory_bytes: 3092
import math
from functools import reduce

def main():
    K = int(input())
    ans = 0
    for a in range(1, K + 1):
        for b in range(1, K + 1):
            for c in range(1, K + 1):
                ans += reduce(math.gcd, [a, b, c])
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
    int D, G; vector<int> P(15), C(15);

    cin >> D >> G; G /= 100;
    rep1(i, D){
        cin >> P[i] >> C[i];
        C[i] /= 100;
    }

    //どの難易度を全問解くかについて全探索
    int ans = 1e8;
    rep(bits, 1<<D){
        vector<bool> solve(D);
        rep(i, D) solve[i+1] = bits & (1<<i); 
        
        int points = 0, problems = 0;
        rep1(i,D){
            if (solve[i]) {
                points += i*P[i] + C[i];
                problems += P[i];
            }
        }

        if(points >= G){ ans = min(ans, problems); continue; }

        // 残りを点数の高い方から順に解いていく
        for(int i = D; i>=1; i--){
            if(!solve[i]){
                if(G - points <= (P[i]-1)*i){
                    problems += (G - points + (i-1)) / i;
                    ans = min(ans, problems); break;
                } else {
                    points += i*(P[i]-1);
                    problems += P[i]-1;
                }
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;


int main()
{
	long long int s, x[3] = { 0, 1000000000, 0 }, y[3] = { 0, 1, 0 };

	cin >> s;


	y[2] = lldiv(s, x[1]).quot;
	if(lldiv(s, x[1]).rem != 0){
		y[2]++;
		x[2] = x[1] - lldiv(s, x[1]).rem;
    }

	for (int i = 0; i < 3; i++) {
		cout << x[i] << " " << y[i] << " ";
	}

	cout << endl;

	return 0;

}

Measured memory_bytes: 256
s = input()
s += "e"
border = 0
count = 0
flag = ">"
answer = 0

for i in s:
    if i == flag:
        count += 1

    else:
        if flag == ">":
            answer += max(border, count) + (count * (count - 1)) // 2
            border = 0
        else:
            answer += (count * (count - 1)) // 2
            border = count
        flag = i
        count = 1
else:
    answer += border

print(answer)

Measured memory_bytes: 4116
import numpy as np
N = int(input())
A = []*N
B = []*N
C = []*2*N
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(b)
    C.append(a)
D = np.array(C).reshape(N,2).tolist()
D.sort()
time = 0
flag = 1
for i in range(len(D)):
    if time + D[i][1] > D[i][0]:
        flag = 0
        break
    else:
        time += D[i][1]

if flag == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 64436
import sys
nums=input().rstrip().split(" ")
A=int(nums[0])
B=int(nums[1])
answer=0
for i in range(1,1500):
    #print(int(i*0.08))
    #print(int(i*0.1))
    if int(i*0.1)==B and int(i*0.08)==A:
        answer=i
        print(answer)
        sys.exit()
if answer==0:
    answer=-1
print(answer)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int n,a,maxn=-1,minn=1e9;
int main(void){
	cin>>n;
	for(int i=0;i<n;i++){cin>>a;maxn=max(maxn,a);minn=min(minn,a);}
	cout<<maxn-minn;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

int N;
int A[300005];

int main(){
	scanf("%d", &N);
	for(int i=0;i<3*N;i++){
		scanf("%d", &A[i]);
	}
	sort(A, A+3*N);
	long long tot = 0;
	for(int i=N;i<3*N;i+=2){
		tot += (long long)A[i];
	}
	printf("%lld\n", tot);
	return 0;
}

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

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  rep(i, k) {
    vector<ll> b(n + 1, 0);
    rep(j, n) {
      b[max(0LL, j - a[j])]++;
      b[min(n, j + a[j] + 1)]--;
    }
    a[0] = b[0];

    bool all_n = (a[0] >= n);
    rep2(j, 1, n) {
      a[j] = a[j - 1] + b[j];
      all_n &= (a[j] >= n);
    }
    if (all_n) break;
  }

  rep(i, n) cout << a[i] << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 6412
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int n; 
map<int, string> MAP;
vector<int> G[1111];
void dfs(int x, int par, int d) {
  if(x != 0) {
    cout << string(d, '.') << MAP[x] << endl;
  }
  for(auto to : G[x]) {
    if(to != par) {
      dfs(to, x, d + 1);
    }
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  FOR(i,1,n+1) {
    int k;
    string s;
    cin >> k >> s;
    G[k].push_back(i);
    MAP[i] = s;
  }
  dfs(0, -1, -1);
  return 0;
}

Measured memory_bytes: 3488
/*
*	User: Isanchez_Aguilar
*	Problem: AtCoder ABC134B - Golden Apple
*/
#include <bits/stdc++.h>

using namespace std;
using Long = long long;

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

	int k, n;
	int heights[100001];

	k = 2;
	cin >> n;
	
	for (int i = 0; i < n; ++i)
		cin >> heights[i];

	int dp[100001];

	dp[0] = 0;
	for (int i = 1; i < n; ++i)
	{
		dp[i] = INT_MAX;

		for (int j = 1; i - j >= 0 and j <= k; ++j)
			dp[i] = min(dp[i], dp[i - j] + abs(heights[i] - heights[i - j]));
	}

	cout << dp[n - 1];

	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
int main() {
	while (true) {
		int a, b;
		char op;
		std::cin >> a >> op >> b;
		if (op == '?') break;
		if (op == '+') printf("%d\n", a + b);
		else if (op == '-') printf("%d\n", a - b);
		else if (op == '*') printf("%d\n", a * b);
		else if (op == '/') printf("%d\n", a / b);
	}
}


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

int main(){
  int N;  //餅の枚数
  cin >> N;
  
  vector <int> d(N,0); //餅iの直径
  for (int i=0; i<N; i++){
    cin >> d.at(i);
  }

  sort(d.begin(), d.end());
  reverse(d.begin(),d.end());

  int maisu = 1;
  for (int i=1; i<N; i++){
    if ( d.at(i-1) > d.at(i) ){
      maisu +=1;
    }
  }

  cout << maisu << endl;
}


Measured memory_bytes: 256
from collections import deque
import itertools
import copy

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

def solve(s):
    M = copy.deepcopy(S)
    d = ((1, 0), (-1, 0), (0, -1), (0, 1))
    queue = deque([s])
    steps = [[-1 for _ in range(W)] for _ in range(H)]
    steps[s[0]][s[1]] = 0

    while len(queue) > 0:
        current = queue.popleft()
        cy = current[0]
        cx = current[1]
        # M[cy][cx] = '#'
        for i in d:
            ny = cy+i[0]
            nx = cx+i[1]
            # はみ出さないかつ通ってない
            if (0<=ny<H and 0<=nx<W) and M[ny][nx]=='.' and steps[ny][nx] < 0:
            # if (0<=ny<H and 0<=nx<W) and M[ny][nx]!='#':
                queue.append([ny, nx])
                steps[ny][nx] = steps[cy][cx] + 1
        
    return max([max(i) for i in steps])

maxStep = 0
for s in itertools.product(range(H), range(W)):
    if S[s[0]][s[1]] == '.':
        maxStep = max(solve([s[0], s[1]]), maxStep)

print(maxStep)

Measured memory_bytes: 3444
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
//DEBUG 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define all(v) (v).begin(), (v).end()
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
 
int32_t main()
{
    IOS;
    cin>>n>>m;
    if(n%2==1){
      forsn(i,1,m+1){
        cout<<i<<" "<<n-i<<ln;
      }
    }
    else{
      int k=n/2;
      int l=k/2;
      int r=l+1;
      while(l>=1 && m){
        cout<<l<<" "<<r<<ln;
        l--;
        r++;
        m--;
      }
      l=k/2;
      r=l+2;
      while(r<=k && m){
        cout<<k+l<<' '<<k+r<<ln;
        l--;
        r++;
        m--;
      }
    }
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define int unsigned long long
using namespace std;

int n,ans=0;
int a[100005],b[100005],c[100005];

int p[100005][205];

signed main()
{
	cin>>n;
	n++;
	for (int i=1;i<=n;i++)  cin>>a[i];
	
	b[1]=1,c[n]=a[n];
	for (int i=2;i<=n;i++)  b[i]=(b[i-1]-a[i-1])*2;
	for (int i=n-1;i>=1;i--)  c[i]=c[i+1]+a[i];
	for (int i=1;i<=n;i++)  ans+=min(b[i],c[i]);
	for (int i=1;i<=n;i++)
	{
		if (a[i]>b[i])  return cout<<-1<<endl,0;
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 5900
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
uf = UnionFind(n)
for i in range(m):
    x, y = ab[i][0], ab[i][1]
    x -= 1
    y -= 1
    uf.union(x, y)
ans = 0
for i in range(n):
    ans = max(uf.size(i), ans)
print(ans)



Measured memory_bytes: 49980
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "YES"
no = "NO"




def main():
    k = ii()
    a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(a[k-1])



        
    


main()



Measured memory_bytes: 6012
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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; }



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k; cin >> k;
    
    queue<ll> lunlun;
    rep(i,9) lunlun.push(i+1);
    
    
    
    int counter = 0;
    while(1){
        counter++;
        ll front = lunlun.front();
        rep(i,3){
            if((front%10 + (i-1)) < 0 || 9 < (front%10 + (i-1))) continue;
            ll nlunlun = front*10 + (front%10 + (i-1));
            lunlun.push(nlunlun);
        }
        if(counter == k) {
            cout << front << endl;
            break;
        }
        lunlun.pop();
    }
    
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>
 
int main(){
 int x[3];
 int temp;
 
 scanf("%d %d %d\n",&x[0],&x[1],&x[2]);
 if(x[0]>x[1]){
  temp=x[0];
  x[0]=x[1];
  x[1]=temp;
 }
 if(x[1]>x[2]){
  temp=x[1];
  x[1]=x[2];
  x[2]=temp;
 }
 if(x[0]>x[1]){
  temp=x[0];
  x[0]=x[1];
  x[1]=temp;
 }
 
 printf("%d %d %d\n",x[0],x[1],x[2]);
 return 0;
}
  

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int n,d[1000],sum=0;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>d[i];
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		sum+=d[i]*d[j];
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  ll sum=0;
  rep(i,1,n+1){
    if(i%3 && i%5)sum+=i;
  }
  cout<<sum<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

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

int main()
{
    int N, M;
    cin >> N >> M;
    int a[N][M], b[M];
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < M; i++)
    {
        cin >> b[i];
    }

    int c[N];
    for (int i = 0; i < N; i++)
    {
        c[i] = 0;
        for (int j = 0; j < M; j++)
        {
            c[i] += a[i][j] * b[j];
        }
        cout << c[i] << endl;
    }
}



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

int a, b, ch, cw, dh, dw, ans=0, numb=0;
vector< vector<int> > board;
char inc;
//vector< vector<int> > seen;
queue<int> qh, qw;

int imax=2147483647;
int dist[1000009];
vector<pair<int, int>> G[1000009];
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> Q;

map<int, int> m;

void bfs(int h, int w){
	//移動してきた時の処理
	if(board[h][w]!=0) return;
	board[h][w]=numb;
	/*if(seen[h][w]) return;
	seen[h][w]=1;*///一度踏んだらもう踏めなくする（いる？）

	//移動する処理
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			if(i==0 && j==0) continue;
			if(i*j!=0) continue;//8方向にする場合はコメントアウト
			if(-1<h+i && h+i<a && -1<w+j && w+j<b){
				if(board[h+i][w+j]!=0) continue;
				qh.push(h+i);
				qw.push(w+j);
			}
		}
	}
}

int main(){

	cin>> a >> b >> ch >> cw >> dh >> dw;
	ch--;
	cw--;
	dh--;
	dw--;
	board.resize(a);
	//seen.resize(a);
	for(int i=0;i<a;i++) board[i].resize(b);
	//for(int i=0;i<a;i++) seen[i].resize(b, 0);

	//1字ずつ入力する場合
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			cin>> inc;
			if(inc=='.') board[i][j]=0;
			else board[i][j]=-1;
		}
	}
	/*for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			cout<< board[i][j];
		}
		cout<< endl;
	}*/

	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			if(board[i][j]==0){
				numb++;
				qh.push(i);
				qw.push(j);
  				while (!qh.empty()) {
    				bfs(qh.front(), qw.front());
    				qh.pop();
    				qw.pop();
  				}
			}
		}
	}
	/*for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			cout<< board[i][j];
		}
		cout<< endl;
	}*/

	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			if(board[i][j]>0){
				m.clear();
				for(int k=max(0, i-2);k<min(a, i+3);k++){
					for(int l=max(0, j-2);l<min(b, j+3);l++){
						if(board[k][l]==-1) continue;
						if(board[i][j]!=board[k][l] && m[board[k][l]]==0){
							m[board[k][l]]=1;
        					G[board[i][j]].push_back(make_pair(board[k][l], 1));
        					G[board[k][l]].push_back(make_pair(board[i][j], 1));
						}
					}
				}
			}
		}
	}

    for (int i = 1; i <= numb; i++) dist[i] = imax;

    Q.push(make_pair(0, board[ch][cw]));
    dist[board[ch][cw]] = 0;
    while (!Q.empty()) {
        int pos = Q.top().second; Q.pop();
        for (int i = 0; i < G[pos].size(); i++) {
            int to = G[pos][i].first, cost = G[pos][i].second;
            if (dist[to] > dist[pos] + cost) {
                dist[to] = dist[pos] + cost;
                Q.push(make_pair(dist[to], to));
            }
        }
    }
//cout<< "#";
    // 距離を出力する
    /*for (int i = 1; i <= numb; i++){
		if(dist[i]==imax) cout<< "-1" <<endl;
		else cout<< dist[i] <<endl;
    }*/
	if(dist[board[dh][dw]]==imax) cout<< "-1" <<endl;
	else cout<< dist[board[dh][dw]] <<endl;

	return 0;
}

Measured memory_bytes: 53620
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define INF 1000000000000000

using namespace std;

ll get(ll mask, vector<ll> hold[], ll cost[], ll store[])
{
    //cout<<"at mask "<<mask<<"\n";
    if(store[mask]!=INF)
        return store[mask];
    if(mask <= 0)
        return store[mask] = 0;
    if(hold[mask].size() == 1)
        return 0;
    ll ans = -INF;    
    ll lim = (1ll<<(hold[mask].size()));
    for(ll i=1;i<lim;i++)
    {
        ll num = 0;
        for(ll j=0;j<hold[mask].size();j++)
            if((1ll<<j) & i)
                num+=(1ll<<hold[mask][j]);     
        ans = max(ans, cost[num] + get(mask - num, hold, cost, store));        
    }
    
    return store[mask] = ans;
}

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   ll lim = (1ll<<n);
   
   ll mat[n][n];
   for(ll i=0;i<n;i++)
        for(ll j=0;j<n;j++)
            cin>>mat[i][j];
   
   ll cost[lim];
   memset(cost,0,sizeof(cost));
   vector<ll> hold[lim];
   for(ll i=0;i<lim;i++)
   {
       for(ll j=0;j<n;j++)
       if((1ll<<j)&i)
            hold[i].pb(j);
   }
   
   for(ll i=0;i<lim;i++)
   {
       for(ll i1=0;i1<hold[i].size();i1++)
            for(ll j = i1+1;j<hold[i].size();j++)
                cost[i]+=mat[hold[i][i1]][hold[i][j]];
   }
   
   ll store[lim];
   for(ll i=0;i<lim;i++)
        store[i] = INF;
   
   ll ans = get(lim-1,hold,cost,store);
   cout<<ans;
   
   return 0;
}

Measured memory_bytes: 11616
H, W = map(int, input().split())

L, side, ver = [], [], []

for i in range(H):
    a = list(input())
    L.append(a)

for i in range(H):
    if ('#' in L[i]) == True:
        side.append(L[i])

side = list(map(list, zip(*side)))

for i in range(len(side)):
    if ('#' in side[i]) == True:
        ver.append(side[i])

ver = list(map(list, zip(*ver)))

for i in range(len(ver)):
    print(''.join(ver[i]))

Measured memory_bytes: 9388
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	in := func() int {
		sc.Scan()
		i, _ := strconv.Atoi(sc.Text())
		return i
	}

	c := 0
	n := in()

	m := in()

	for i := 1; i < n; i++ {
		v := in()

		if v < m {
			c += (m - v)
		} else {
			m = v
		}
	}

	fmt.Println(c)

}


Measured memory_bytes: 5876
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

string mapp[10];

int xx[12]={1,2,3,-1,-2,-3,0,0,0,0,0,0};
int yy[12]={0,0,0,0,0,0,1,2,3,-1,-2,-3};

void f(int x,int y){
	mapp[y][x]='0';
	int i;
	for(i=0;i<12;i++){
		if(0<=x+xx[i]&&x+xx[i]<8&&0<=y+yy[i]&&y+yy[i]<8&&mapp[y+yy[i]][x+xx[i]]=='1')f(x+xx[i],y+yy[i]);
	}
}

int main() {
	int n=in();
	int i;
	for(i=0;i<n;i++){
		int k;
		for(k=0;k<8;k++){
			cin>>mapp[k];
		}
		int x,y;
		cin>>x>>y;
		f(x-1,y-1);
		cout<<"Data "<<i+1<<":\n";
		for(k=0;k<8;k++){
			cout<<mapp[k]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
      if(A[i]%2==0 && (A[i]%3!=0 && A[i]%5!=0)){
        cout << "DENIED";
        return 0;
      }
    }
   cout << "APPROVED" << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    ll ans=0;
    if(a<=9&&b<=9){
        ans=a*b;
    }else{
        ans=-1;
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

	public static void solve(Scanner s) {
		int n = s.nextInt();
		int k = s.nextInt();
		int[] d = new int[k];

		for (int i = 0; i < k; i++) {
			d[i] = s.nextInt();
		}

		Arrays.sort(d);

		for (int i = 0; i < 100100100; i++) {
			boolean breakFlg = true;

			String nStr = n + "";
			for (int j = 0; j < nStr.length(); j++) {

				for (int l = 0; l < d.length; l++) {
					int num = nStr.charAt(nStr.length() - j - 1) - 48;

					while (num == d[l]) {
						n++;
						breakFlg = false;
						nStr = n + "";
						num = nStr.charAt(nStr.length() - j - 1) - 48;
					}
				}
			}

			if (breakFlg) {
				break;
			}
		}

		System.out.println(n);
	}
}


Measured memory_bytes: 17616
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    p = list(map(int, input().split()))
    q = sorted(p)
    res = 0
    for i in range(n):
        if p[i]!=q[i]:
            res += 1
    if res <=2:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int n;
int arr[100005][3];
long long int rec(long long int a[], long long int b[], long long int c[], long long int index, long long int prev_val){
    long long int x, y, z, ans;
    if(index==0){
        x=a[0]+rec(a, b, c, 1, 0);
        y=b[0]+rec(a, b, c, 1, 1);
        z=c[0]+rec(a, b, c, 1, 2);
        ans = max(x, max(y, z));
        return ans;

    }
    if(index==n){
        return 0;
    }
    if(arr[index][prev_val]!=0)
        return arr[index][prev_val];
    else{
        if(prev_val==0){
            y=b[index]+rec(a, b, c, index+1, 1);
            z=c[index]+rec(a, b, c, index+1, 2);
            ans = max(y, z);
            arr[index][0]=ans;
            return ans;
        }
        if(prev_val==1){
            x=a[index]+rec(a, b, c, index+1, 0);
            z=c[index]+rec(a, b, c, index+1, 2);
            ans = max(x, z);
            arr[index][1]=ans;
            return ans;
        }
        if(prev_val==2){
            x=a[index]+rec(a, b, c, index+1, 0);
            y=b[index]+rec(a, b, c, index+1, 1);
            ans = max(y, x);
            arr[index][2]=ans;
            return ans;
        }
    }
}

int main()
{

    int i;
    cin>>n;
    long long int* a=new long long int[n];
    long long int* b=new long long int[n];
    long long int* c=new long long int[n];
    for(i=0;i<100005;i++){
        arr[i][0]=0;
        arr[i][1]=0;
        arr[i][2]=0;
    }
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    cout<<rec(a, b, c, 0, 3);
    return 0;
}


Measured memory_bytes: 13184
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <iostream>
#include <string>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <math.h>
#include <cmath>
#include <stack>
#include <algorithm>
#include <list>
#include <array>
#include <valarray>
#include <unordered_map>
#include <cassert>
#include <random>

using namespace std;

#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define all(a) a.begin(), a.end()
#define li long long
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

double eps = 1e-9;
const long long INF = 1e9 + 7;
const int MOD = 998244353;

int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	string s;
	cin >> s;

	cout << s.substr(0, s.size() - 8) << endl;
}

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

ll n,a,b;
int h[100000];

bool enough(ll t) {
  ll c = 0;
  rep(i,n) {
    ll rest = h[i] - t*b;
    if(rest > 0) c += rest / (a - b) + (rest % (a - b) != 0);
  }
  return c <= t;
}

int find(ll lb, ll ub) {
  if(lb == ub) return lb;
  ll m = (lb + ub) / 2;
  return enough(m) ? find(lb, m) : find(m + 1, ub);
}

int main () {
  cin >> n >> a >> b;
  rep(i,n) cin >> h[i];

  cout << find(0, 1e9+1) << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long 
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main()
{
    fastio;
    long double a,b,c;
    cin>>a>>b;
    c=a*b;
    cout<<(ll)c<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

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

ll rec(int ix, ll cur, ll sum, vector<int>& digits)
{
  int n = digits.size();
  if (ix == n) {
    return cur + sum;
  }
  return rec(ix + 1, cur * 10 + digits[ix], sum, digits) +
    rec(ix + 1, digits[ix], cur + sum, digits);
}

int main()
{
  string s; cin >> s;
  int n = s.size();
  vector<int> digits(n);
  for (int i = 0; i < n; ++i) {
    digits[i] = s[i] - '0';
  }
  ll ans = rec(1, digits[0], 0, digits);
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	// your code goes here
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		c=c-b;
		if(c<=0){
			cout<<"Yes";
			break;
		}
		a=a-d;
		if(a<=0){
			cout<<"No";
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
#define pri(str) cout << str << endl
using ll = long long;
using P = pair<int, int>;

const ll MX = 1e18;
const long double PI = acos(-1);

int main()
{
    int ans = 0;
    rep(i,5)
    {
        int x;
        cin >> x;
        if(x == 0)
            ans = i+1;
    }
    pri(ans);
    return 0;
}


Measured memory_bytes: 3592
S = input()
K = input()

if not(1 <= len(S) and len(S) <= 100):
    exit()
if not (S.isalpha() and S.islower()):
    exit()
if not float(K).is_integer():
    exit()
if not (1 <= int(K) and int(K) <= 10 ** 9):
    exit()

L = []
tmp = []
pre = ""
for s in S:
    if len(tmp) == 0:
        pre = s
        tmp.append(s)
    elif pre == s:
        tmp.append(s)
    else:
        L.append(tmp)
        pre = s
        tmp = [s]
L.append(tmp)

count = 0
for l in L:
    count += int(len(l) / 2)
    # print(l)
count *= int(K)
if len(L) == 1:
    if len(L[0]) == 1:
        count = int(int(K) / 2)
    elif len(L[0]) % 2 == 1:
        count += int(int(K) / 2)
    
elif L[0][0] == L[len(L)-1][0]:
    if len(L[0]) % 2 == 1 and len(L[len(L)-1]) % 2 == 1:
        count = count + int(K) - 1
print(count)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N, K, S;
  cin >> N >> K;
  S = 0;
  for (int i = 0; i < N; i++) {
      int x;
      cin >> x;
      if ( x <= (K - x) ) {
          S += 2*x;
      } else {
          S += 2*(K - x);
      }
  } 
  cout << S << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int s,w;
    scanf("%d %d", &s, &w);
    if(s > w){
        printf("safe");
    } else {
        printf("unsafe");
    }
    
    return 0;
}


Measured memory_bytes: 1724
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    ll keep = 1;
    int ans = 0;
    int N, K;  cin >> N >> K;
    while(N >= keep){
      keep *= K;
      ans += 1;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>

#define INF INT_MAX>>1

using namespace std;

int main(void){
	while(1){
		int n, m, c, s, g; 
		cin >> n >> m >> c >> s >> g;
		if(!n && !m && !c && !s && !g) break;
		s--; g--;

		static int dist[100][100][20];
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				for(int k=0; k<c; k++){
					if(i==j) dist[i][j][k] = 0;
					else dist[i][j][k] = INF;
				}
			}
		}
		for(int i=0; i<m; i++){
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			x--; y--; c--;
			dist[x][y][c] = dist[y][x][c] = min(dist[x][y][c], d);
		}
		int p[20];
		for(int i=0; i<c; i++) {
			cin >> p[i];
		}
		vector< pair<int, int> > poly[20];
		for(int i=0; i<c; i++){
			poly[i].assign(p[i]+1, make_pair(0, 1));
			for(int j=0; j<p[i]-1; j++){
				int q; cin >> q;
				poly[i][j+1].first = q;
			}
			for(int j=0; j<p[i]; j++){
				int r; cin >> r;
				poly[i][j+1].second = r;
			}
			poly[i].back().first=INF;
		}

		for(int l=0; l<c; l++){
			//ワーシャルフロイド
			for(int k=0; k<n; k++) for(int i=0; i<n; i++) for(int j=0; j<n; j++)dist[i][j][l] = min(dist[i][j][l], dist[i][k][l]+dist[k][j][l]);
		}

		static int cost[100][100][20];
		for(int l=0; l<c; l++){
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					int d = dist[i][j][l];
					if(d == INF){
						cost[i][j][l] = INF;
						continue;
					}
					int tmp=0;
					for(int k=0; k<poly[l].size()-1; k++){
						tmp += poly[l][k+1].second*max(min(poly[l][k+1].first, d)-poly[l][k].first, 0);
					}
					cost[i][j][l] = tmp;
				}
			}
		}

		int ans[100][100];
		fill(ans[0], ans[100], INF);
		for(int i=0; i<n; i++) for(int j=0; j<n; j++) for(int k=0; k<c; k++) ans[i][j] = min(ans[i][j], cost[i][j][k]);
		for(int k=0; k<n; k++) for(int i=0; i<n; i++) for(int j=0; j<n; j++) ans[i][j] = min(ans[i][j], ans[i][k]+ans[k][j]);

		if(ans[s][g] != INF) cout << ans[s][g] << endl;
		else cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 4688