akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;

using graph = vector<vector<int>>;

bool check(vector<int> vec) {
	for (auto a : vec) {
		if (a == -1) {
			return false;
		}
	}
 return true;
}
void Main() {
	int N, M, a, b;
	cin >> N >> M;
	graph G(N);
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	vector<int> dist(N, -1); 
	vector<int> from(N, -1);
	queue<int> q;

	dist[0] = 0;
	q.push(0);
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (int nv : G[v]) {
			if (dist[nv] != -1) continue;
			dist[nv] = dist[v] + 1;
			if (from[nv] == -1) from[nv] =  v + 1;
			q.push(nv);
		}
	}
	
	if (check(dist)) {
		cout << "Yes" << endl;
		for (int i = 1; i < N; i++) {
			cout << from[i] << endl;
		}
	}
	else {
		cout << "No" << endl;
	}

	


}
int main() {
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 10872
s = input()
t = input()
moji = list(set(s))
if all([k in moji for k in set(t)]) is not True:
  print(-1)
else:
  a = 0
  l = len(s)
  seq = s
  for k in t: 
    p = seq.find(k) + 1
    if p == 0:
      p = s.find(k) + 1
      a += p + len(seq)
      seq = s
    else:
      a += p
    seq = seq[p:]
  print(a)

Measured memory_bytes: 3448
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	int cost = 999999999;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			if (i * 1000 + j * 500 < x) continue;
			cost = min(cost, a*i + b * j);
		}
	}
	cout << cost << endl;
	return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main() {
	int n;
	cin>>n;
	cout<<n*n*3<<endl;
	return 0;
}


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

int f[2333][2333],n,k;
const int mod =1e9+7;
int main()
{
	scanf("%d%d",&n,&k);
	f[1][n-k]=1;for (int i=1;i<n-k;++i) f[1][n-k]=(f[1][n-k]<<1)%mod;
	for (int i=2;i<=n;++i)
	{
		f[i][0]=(f[i-1][0]+f[i-1][1])%mod;
		for (int j=1;j<=n+1;++j)
	         f[i][j]=(f[i][j-1]+f[i-1][j+1])%mod;
	}
	printf("%d",f[n][0]);
	return 0;
}

Measured memory_bytes: 18688
import java.util.*;

// ARC 106-D
// https://beta.atcoder.jp/contests/abc106/tasks/abc106_d

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

		int N = in.nextInt();
		int K = in.nextInt();
		
		ArrayList<Long> left = new ArrayList<Long>();
		ArrayList<Long> right = new ArrayList<Long>();
		
		for (int i = 0; i < N; i++) {
			long temp = in.nextLong();
			// Include 0 in left
			if (temp <= 0) {
				left.add(temp);
			} else {
				right.add(temp);
			}
		}
		
		long temp = 0;
		long answer = Long.MAX_VALUE;

		// 左へ行く
		for (int i = left.size() - 1; i >= 0; i--) {
			int count = left.size() - i;
			temp = Math.abs(left.get(i));
			
			if (count < K && count + right.size() >= K) {
				int rightIndex = K - count - 1;
				temp *= 2;
//				System.out.printf("i: %d, left count: %d, right index: %d\n", i, count, rightIndex, temp);
				temp += right.get(rightIndex);
				answer = Math.min(answer, temp);
			} else if (count == K) {
				answer = Math.min(answer, temp);
			}
		}
		
		// 右へ行く
		for (int i = 0; i < right.size(); i++) {
			int count = i + 1;
			temp = right.get(i);
			
			if (count < K && count + left.size() >= K) {
				int leftIndex = left.size() - (K - count);
				temp *= 2;
//				System.out.printf("i: %d, right count: %d, left index: %d\n", i, count, leftIndex, temp);
				temp += Math.abs(left.get(leftIndex));
				answer = Math.min(answer, temp);
			} else if (count == K) {
				answer = Math.min(answer, temp);
			}
		}
		
		System.out.println(answer);
    }
}


Measured memory_bytes: 62312
N = input()
H = map(int, raw_input().split())
H[0] -= 1
ok = True
for i in range(1, N):
  if H[i-1]<H[i]:
    H[i] -= 1
  if H[i-1]>H[i]:
    ok = False
print "Yes" if ok else "No"


Measured memory_bytes: 11340
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_CHAR_MAX		1000005									// 最大文字数

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Str[D_CHAR_MAX];									// 文字列
static int siCCnt;												// 文字数
static int si2Cnt[D_CHAR_MAX][2];								// 枚数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 改行カット
// 戻り値：文字数
int
fCutCrLf(
	char *pcpStr				// <I> 文字列
)
{
	int i;

	for (i = 0; pcpStr[i] != '\0'; i++) {
		if (pcpStr[i] == '\n') {
			pcpStr[i] = '\0';
			break;
		}
	}

	return i;
}

// 最小値 - 取得
int
fGetMin(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	if (piVal1 < piVal2) {
		return piVal1;
	}
	else {
		return piVal2;
	}
}

// 実行メイン
int
fMain(
)
{
	int i;

	// 文字列 - 取得
	sc1Str[0] = '0';
	fgets(&sc1Str[1], sizeof(sc1Str) - 1, szpFpI);
	siCCnt = fCutCrLf(sc1Str);

	// 数値化
	for (i = 0; i < siCCnt; i++) {
		sc1Str[i] -= '0';
	}

	// 枚数 - 初期化
	for (i = 0; i < siCCnt; i++) {
		si2Cnt[i][0] = INT_MAX;
		si2Cnt[i][1] = INT_MAX;
	}
	si2Cnt[siCCnt][0] = 0;
	si2Cnt[siCCnt][1] = 1;

	// 枚数 - セット
	for (i = siCCnt - 1; i >= 0; i--) {

		// 釣りなし + 釣りなし
		si2Cnt[i][0] = fGetMin(si2Cnt[i][0], si2Cnt[i + 1][0] + sc1Str[i]);

		// 釣りあり + 釣りなし
		si2Cnt[i][0] = fGetMin(si2Cnt[i][0], si2Cnt[i + 1][1] + sc1Str[i] + 1);

		// 釣りなし + 釣りあり
		si2Cnt[i][1] = fGetMin(si2Cnt[i][1], si2Cnt[i + 1][0] + 10 - sc1Str[i]);

		// 釣りあり + 釣りあり
		si2Cnt[i][1] = fGetMin(si2Cnt[i][1], si2Cnt[i + 1][1] + 10 - sc1Str[i] - 1);
	}

	return si2Cnt[0][0];
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
const int N=6005,mod=1000000007;
inline void add(int &a,int b){a+=b;if(a>=mod)a-=mod;}
int n,m,dp[2][N][2];
int main()
{
	scanf("%d%d",&n,&m);
	dp[0][0][1]=1;
	for(int i=1;i<=n;i++)
		dp[0][i][0]=1;
	int p=0;
	for(int i=0;i<2*m;i++)
	{
		memset(dp[p^1],0,sizeof(dp[p^1]));
		for(int j=0;j<=n;j++)
		{
			for(int s=0;s<2;s++)
			{
				int x=j,y=n-j+(i%2);
				if(!dp[p][j][s])
					continue;
				if(x) add(dp[p^1][j-1+(i+1)%2][s|(j==1)],dp[p][j][s]);
				if(y) add(dp[p^1][j+(i+1)%2][s],dp[p][j][s]);
			}
		}
		p^=1;
	}
	int ans=0;
	for(int i=0;i<=n;i++)
		add(ans,dp[p][i][1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3856
from collections import deque
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]

graph = [[] for _ in range(N)]
for x, y in edges:
    graph[x - 1].append(y - 1)
    graph[y - 1].append(x - 1)

def dfs(s, c):
    q = deque()
    q.append(s)
    visited[s] = True
    color[s] = c
    
    while len(q) > 0:
        v = q.pop()
        for i in graph[v]:
            if visited[i] and color[i] == color[v]:
                return False
            
            if not visited[i]:
                visited[i] = True
                color[i] = -color[v]
                q.append(i)
                
    return True

visited = [False] * N
color = [0] * N

if dfs(0, 1):
    x = sum(v + 1 for v in color) // 2
    print(x * (N - x) - M)
else:
    print(N * (N - 1) // 2 - M)
    
    

Measured memory_bytes: 76248
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
ll n,i,sum=1;
cin>>n;
string s[n];
for(i=0;i<n;i++)
cin>>s[i];
sort(s,s+n);
for(i=1;i<n;i++)
{
if(s[i]!=s[i-1])
sum++;
}
cout<<sum<<endl;


return 0;
}


Measured memory_bytes: 9848
N = int(input())
song_title = []
song_len = []
for i in range(N):
    t, l = input().split()
    song_title.append(t)
    song_len.append(int(l))


X = input()
last = 0
for i in range(N):
    if song_title[i] == X:
        last = i
        break

ans = 0
for i in range(last + 1, N):
    ans += int(song_len[i])
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#define MAX_N 2000001
#define MAX_V 10001
 
unsigned short A[MAX_N];
unsigned short B[MAX_N];
int C[MAX_V];
 
void countingSort(int n) {
    int i, j;
    for (i = 0; i < MAX_V; i++) {
        C[i] = 0;
    }
 
    for (j = 1; j <= n; j++) {
        C[A[j]]++;
    }
    for (i = 1; i < MAX_V; i++) {
        C[i] = C[i] + C[i-1];
    }
 
    for (j = n; j >= 1; j--) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
}
 
 
int main(void) {
    int i, n;
 
    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        scanf("%hd", &A[i]);
    }
 
    countingSort(n);
 
    for (i = 1; i <= n; i++) {
        if (i > 1) printf(" ");
        printf("%d", B[i]);
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 9576
#include <bits/stdc++.h>
#define PI                acos(-1)
#define pb                emplace_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second

using namespace std;

typedef int       ll;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const ll INF = ll(1e9 + 7);

const ll tam = 330;

ll dp[330][330][330];
vector< ii > rangs[330];

bool OK(ll i, ll j, ll k, ll l, ll r, ll x)
{
	ll diff = 0;
	if ( l <= i && i <= r ) diff++;
	if ( l <= j && j <= r ) diff++;
	if ( l <= k && k <= r ) diff++;
	return diff == x;
}

ll mod = 1e9+7;

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    ll n, m;
    cin >> n >> m;
    for (ll i = 0; i < m; i++)
    {
    	ll l, r, x;
    	cin >> l >> r >> x;
    	rangs[r].pb( mp(l, x) );
    }
    clr(dp, 0);
    dp[0][0][0] = 1;
    for (ll i = 0; i <= n; i++)
    {
    	for (ll j = 0; j <= n; j++)
    	{
    		if (i > 0 && i == j) continue;
    		for (ll k = 0; k <= n; k++)
    		{
    			if (k > 0 && (i == k || j == k)) continue;
    			ll nxt = max(i, max(j, k)) + 1;

    			//cout << "Para " << i << ", " << j << ", " << k << ": ";

    			dp[nxt][j][k] = (dp[nxt][j][k] + dp[i][j][k]) % mod;
    			dp[i][nxt][k] = (dp[i][nxt][k] + dp[i][j][k]) % mod;
    			dp[i][j][nxt] = (dp[i][j][nxt] + dp[i][j][k]) % mod;

    			for (ii seg : rangs[nxt])
    			{
    				ll l = seg.F;
    				ll r = nxt;
    				ll x = seg.S;
    				if ( !OK(nxt, j, k, l, r, x) ) dp[nxt][j][k] = 0;
    				if ( !OK(i, nxt, k, l, r, x) ) dp[i][nxt][k] = 0;
    				if ( !OK(i, j, nxt, l, r, x) ) dp[i][j][nxt] = 0;
    			}
    			//cout << dp[i][j][k] << endl;
    		}
    	}
    }
    long long res = 0;
    for (ll i = 0; i < n; i++)
    {
    	for (ll j = 0; j < n; j++)
    	{
    		if (i > 0 && i == j) continue;
    		res = ( res + dp[i][j][n] ) % mod;
    		res = ( res + dp[i][n][j] ) % mod;
    		res = ( res + dp[n][i][j] ) % mod;
    	}
    }
    cout << res << '\n';
    return 0;
}
// PLUS ULTRA!

Measured memory_bytes: 140672
#include <iostream>
#include <algorithm>

using namespace std;
const long long int Mod = 1000000007;

long long int fact(long long int n){
    long long int p = 1;
    while (n != 1){
        p = (p * n) % Mod;
        n--;
    }
    return p;
}

int main(int argc, char** argv){
    long long int N, M;
    cin >> N >> M;
    long long int ans = (fact(N) * fact(M)) % Mod;
    switch (N-M) {
        case 0:
            ans = (2*ans)%Mod;
            break;
        case 1:
            break;
        case -1:
            break;
        default:
            ans = 0;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;


int main(){
	int h,w;
	cin >> h >> w;
	char cells[h][w];
	int memo[h][w] = {0};
	
	rep(i,0,h){
		rep(j,0,w){
			cin >> cells[i][j];
			memo[i][j] = 0;
		}
	}
	
	rep(i,0,h){
		rep(j,0,w){
			if(cells[i][j] == '#'){
				if(i != 0){
					if(cells[i-1][j] == '#'){
						memo[i][j]++;
					}
				}
				if(i != h-1){
					if(cells[i+1][j] == '#'){
						memo[i][j]++;
					}
				}
				if(j != 0){
					if(cells[i][j-1] == '#'){
						memo[i][j]++;
					}
				}
				if(j != w-1){
					if(cells[i][j+1] == '#'){
						memo[i][j]++;
					}
				}
				
				if(!memo[i][j]){
					cout << "No" << endl;
					return 0;
				}
			}
			
			
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import bisect
s = input()
t = input()
d = {}
for i in range(len(s)):
  if s[i] in d:
    d[s[i]] += [i]
  else:
    d[s[i]] = [i]
c = 0
cur = -1
for i in t:
  if i not in d:
    print(-1)
    exit()
  if cur < d[i][-1]:
    cur = d[i][bisect.bisect_right(d[i],cur)]
    continue
  else:
    cur = d[i][0]
    c += 1
print(c*len(s)+cur+1)

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

int main() {
  ll H, W;
  cin >> H >> W;

  ll ans = H * W;
  ll s[3];

  rep(i, 0, 2) {
    rep(h, 1, H) {
      // まずは縦割り
      s[0] = h * W;
      s[1] = (H - h) * (W / 2);
      s[2] = H * W - (s[0] + s[1]);
      sort(s, s + 3);
      ans = min(ans, s[2] - s[0]);

      // 次いで横割り
      s[0] = h * W;
      s[1] = ((H - h) / 2) * W;
      s[2] = H * W - (s[0] + s[1]);
      sort(s, s + 3);
      ans = min(ans, s[2] - s[0]);
    }
    // 板チョコを90度回す
    swap(H, W);
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double EPS = 1e-6;
const int MAX_H = 1e5 + 5;
const int MAX_N = 3e3 + 5;

ll fastExpo(int base, int e) {
    ll ans = 1;
    while(e != 0) {
        if(e % 2 == 1) ans = (ll) ans * base % MOD;
        base = (ll) base * base % MOD;
        e /= 2;
    }
    return ans;
}

namespace modOp {
    int add(int a, int b, int mod = MOD) { return (a + b) % mod; }
    int sub(int a, int b, int mod = MOD) { return (a - b + mod) % mod; }
    int mul(int a, int b, int mod = MOD) { return (ll)a * b % mod; }
    int divide(int a, int b, int mod = MOD) { return (ll)a * fastExpo(b, mod - 2) % mod; }
}
using namespace modOp;

int H, W, N;
pi walls[MAX_N];
int dp[MAX_N];
ll fac[2 * MAX_H], inv[2 * MAX_H];

int f(int a, int b) {
	a += b;
	if (a < 0 || b < 0 || b > a) return 0;
	return mul(fac[a], mul(inv[b], inv[a - b]));
}

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

	fac[0] = inv[0] = 1;
	for (int i = 1; i < 2 * MAX_H; ++i) {
		fac[i] = mul(fac[i - 1], i);
		inv[i] = divide(1, fac[i]);
	}

	cin >> H >> W >> N;
	for (int i = 0; i < N; ++i) {
		cin >> walls[i].ff >> walls[i].ss;
	}
	walls[N] = {H, W};

	sort(walls, walls + N + 1, [](pi a, pi b) {return a.ff + a.ss < b.ff + b.ss;});

	for (int i = 0; i <= N; ++i) {
		dp[i] = f(walls[i].ff - 1, walls[i].ss - 1);
		for (int j = 0; j < i; ++j) {
			if (walls[i].ff >= walls[j].ff && walls[i].ss >= walls[j].ss) {
				dp[i] = sub(dp[i], mul(dp[j], f(walls[i].ff - walls[j].ff, walls[i].ss - walls[j].ss)));
			}
		}
	}

	cout << dp[N] << '\n';

	return 0;
}

Measured memory_bytes: 3456
x,y = input().split()
import math
a = math.floor((2 * int(x)) - (int(y)/2))
b = math.floor((int(y)/2) - int(x))

if (a + b) == int(x) and ((2*a) + (4*b) == int(y)) and a>=0 and b>=0:
    print("Yes") 
else:
    print("No")

Measured memory_bytes: 9112
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int ans=0,bns=0,cns=0,dns=0;
    string s;
    cin>>s;
    for(int i=0;i<1000;i++)
    {
        if(s[i]=='W')ans++;
        if(s[i]=='E')bns++;
        if(s[i]=='N')cns++;
        if(s[i]=='S')dns++;
    }
    if((ans!=0&&bns!=0||ans==0&&bns==0)&&(cns!=0&&dns!=0||cns==0&&dns==0))printf("Yes\n");
        else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
A,B,C,X,Y = map(int,input().split())

cost = A*X + B*Y
a = X
b = Y
c  = 0
N = max(X,Y)

for i in range(N):
  c += 2
  if a > 0:
    a -= 1
  if b > 0:
    b -= 1
  cost = min(cost,A*a + B*b + c*C)
print(cost)

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

using namespace std;

int main()
{
  int i,j,k,s;
  cin>>k>>s;
  int ans=0;
  for(i=0;i<=k;++i)
  {
    for(j=0;j<=k;++j)
    {
      if(s-(i+j)>=0 && s-(i+j)<=k)
        ++ans;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = []
for i in range(0, n):
    s.append(input())

final_list = [0 for i in range(26)]
for i, si in enumerate(s):
    char_list = [0 for i in range(26)]
    for char in si:
        char_list[ord(char)-97] += 1
    if i == 0:
        final_list = char_list
    else:
        final_list = [min(char_list[i], final_list[i]) for i in range(26)]

result = ''
for i in range(26):
    if final_list[i] != 0:
        for j in range(final_list[i]):
            result += chr(97+i)

print(result)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**6)

n = int(input())
h = list(map(int, input().split()))
# dp = [[None] * 10**6 for _ in range(n)]
dp = [None] * (n+1)

# Return the smallest cost to reach the idx
def solve(idx):
    if dp[idx] is not None:
        return dp[idx]

    if idx == 1:
        dp[idx] = abs(h[idx] - h[idx - 1])
    elif idx == 0:
        dp[idx] = 0
    else:
        # jump from idx - 1
        c1 = solve(idx - 1) + abs(h[idx] - h[idx - 1])

        # jump from idx - 2
        c2 = solve(idx - 2) + abs(h[idx] - h[idx - 2])

        dp[idx] = min(c1, c2)

    return dp[idx]

ans = solve(n-1)

print(ans)

Measured memory_bytes: 122872
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define double long double
#define x first
#define y second
#define long long long
#define int long 



           //       |----|       /\      |    |   -----   |
           //       |   /       /  \     |    |     |     |
           //       |--/       /----\    |----|     |     |
           //       |   \     /      \   |    |     |     |
           //       |    \   /        \  |    |   -----   -------

int n,m;
vector<int> v[100002];
int cache[100002];
int dp(int i)
{
	if(cache[i]!=-1)
		return cache[i];
	int ans=0;
	for(auto j:v[i])
		ans=max(ans,1+dp(j));
	return cache[i]=ans;

}
int32_t main()
{
    IOS
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
    	int a,b;
    	cin>>a>>b;
    	v[a].push_back(b);
    }
   	memset(cache,-1,sizeof(cache));
   	int ans=0;
   	for(int i=1;i<=n;i++)
   		ans=max(ans,dp(i));
    cout<<ans;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int sum=0;
void S(int n){
	while(true){
		sum+=n%10;
		n/=10;
		if(n==0)break;
	}
}
int main(){
	int n;
	cin>>n;
	S(n);
	if(n%sum==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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

int main(){
  int a1, a2, a3, sum;
  cin >> a1 >> a2 >> a3;
  sum = a1 + a2 + a3;
  if(sum>=22){
    cout << "bust";
  }
  else{
    cout << "win";
  }
}


Measured memory_bytes: 256
D,G=map(int, input().split())
PC=[0]+[list(map(int,input().split())) for _ in range(D)]
PC

def dfs(i,g):
    if i ==0:
        return 1e9
    m =min(g//(i*100),PC[i][0])
    s=100*i*m
    if m ==PC[i][0]:
        s+=PC[i][1]
    if s<g:
        m+=dfs(i-1,g-s)
    return min(m, dfs(i-1,g))
print(dfs(D,G))

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

static const int N = 10000;

int isPrime(int x){
  int i;
  if(x == 2) return 1;

  if(x < 2 || x % 2 ==0) return 0;

  i =3;
  while(i <= sqrt(x)){
    if(x % i == 0) return 0;
    i = i+2;
  }
  return 1;
}

int main(){
  int i,n,cnt=0,t;
  int A[N+1];

  scanf("%d",&n);
  for(i=0;i<n;i++){
      scanf("%d",&A[i]);
  }
    for(i=0;i<n;i++){
      t = isPrime(A[i]);
      if(t == 1) cnt++;
  }
    printf("%d\n",cnt);
    
    return 0;
}

Measured memory_bytes: 628
#include <stdio.h>
#define sqr(x) ((x)*(x))
#define swap(x,y) ((x)^=(y)^=(x)^=(y))
int main(){
  int n,a,b,c;
  scanf("%d",&n);
  while(n){
    scanf("%d%d%d",&a,&b,&c);
    if(a>c) swap(a,c);
    if(b>c) swap(b,c);
    puts((sqr(a)+sqr(b)==sqr(c))?"YES":"NO");
    n--;
  }
}

Measured memory_bytes: 580
N = int(input())#整数
A = list(map(int, input().split()))#配列Int型

ans = 0
max_val = A[0]

for i in range(1, N):
    if max_val > A[i]:
        ans += max_val - A[i]
    else:
        max_val = A[i]
print(ans)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PPI;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

struct UnionFind{
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  void init(){ for(int i = 0;i < v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};

ll n,m;
P x[111111],y[111111];
PPI es[222222];

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  rep(i,n){
    cin>>x[i].fi>>y[i].fi;
    x[i].se=i; y[i].se=i;
  }
  sort(x,x+n); sort(y,y+n);
  rep(i,n-1){
    es[m++]=PPI(x[i+1].fi-x[i].fi,P(x[i+1].se,x[i].se));
    es[m++]=PPI(y[i+1].fi-y[i].fi,P(y[i+1].se,y[i].se));
  }
  sort(es,es+m);
  UnionFind uf(n);
  ll res=0;
  rep(i,m){
    if(!uf.same(es[i].se.fi,es[i].se.se)){
      uf.unite(es[i].se.fi,es[i].se.se);
      res+=es[i].fi;
    }
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 9216
#include <stdio.h>
#define MAX 400010

int A[MAX];

int main(void)
{
	int q, com, x, y, s = 0, t = 0;
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d", &com, &x);
		if (com == 0) {
			scanf("%d", &y);
			if (x == 0) {
				--s;
				if (s < 0) s += MAX;
				A[s] = y;
			}
			else {
				A[t++] = y;
				if (t >= MAX) t -= MAX;
			}
		}
		else if (com == 1) {
			printf("%d\n", A[(s + x) % MAX]);
		}
		else {
			if (x == 0) {
				++s;
				if (s >= MAX) s -= MAX;
			}
			else {
				--t;
				if (t < 0) t += MAX;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3416
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
#define rep(i,N) for (int i = 0; i < N; i++)

int N;
long double dp[310][310][310];
int one = 0, two = 0, three = 0;

double rec(int i, int j, int k) {
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;

    double temp = 0.0;
    if (i > 0) temp += i*rec(i-1,j,k);
    if (j > 0) temp += j*rec(i+1,j-1,k);
    if (k > 0) temp += k*rec(i,j+1,k-1);

    temp += N;
    temp *= 1.0/(i+j+k);

    return dp[i][j][k] = temp;
}

int main() {
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        int temp; scanf("%d", &temp);
        if      (temp == 1) one++;
        else if (temp == 2) two++;
        else                three++;
    }

    memset(dp, -1, sizeof(dp));

    long double ans = rec(one, two, three);
    printf("%.10Lf\n", ans);
    return 0;
}

Measured memory_bytes: 465920
n=int(input())
a=[]
for i in range(n):
	a.append(int(input()))
a.sort()

now=a[0]
odd=False
ans=0
for i in range(n):
	#前の文字と一緒の時
	if a[i]==now:
		odd=not odd
	#前の文字と違う時
	else:
		#前の文字の個数の偶奇を判定し、奇数ならansをインクリメント
		ans+=odd
		#注目する文字を今の文字にする
		now=a[i]
		odd=True
#最後の文字をきちんと処理するためにoddを加える
print(ans+odd)

Measured memory_bytes: 7492
N = int(input())
As = list(map(int, input().split()))

As.sort()
def main():
  if N%3 == 0:
    a, b, c = As[0], As[N//3], As[2*N//3]
    for i in range(0, N//3):
      if a != As[i]:
        return "No"
    for i in range(N//3, 2*N//3):
      if b != As[i]:
        return "No"
    for i in range(2*N//3, N):
      if c != As[i]:
        return "No"
    if a^b == c and b^c == a and c^a == b:
      return "Yes"
    else:
      return "No"
  else:
    if As[0] != As[N-1]:
      return "No"
    else:
      if As[0] == 0:
        return "Yes"
      else:
        return "No"
print(main())


Measured memory_bytes: 14120
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,ans;
    cin>>n;
    if(n%2)
    n*=2;
    cout<<n<<endl;


    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(void)
{
    int x, y;
    while(1) {
        scanf("%d %d", &x, &y);

        if (x == 0 && y == 0) {
            break;
        }else if ( x < y) {
            printf("%d %d\n", x, y);
        }else {
            printf("%d %d\n", y, x);
        }
    }
}

Measured memory_bytes: 1028
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;


ll N, K;
string S;
int  ans;
vint B;


int main() {

	cin >> N >> K;
	cin >> S;

	vint A;
	char mae = '1';
	int cnt = 0;
	FOR(i, 0, N) {
		if (S[i] != mae) {
			A.push_back(cnt);
			cnt = 1;
			mae = S[i];
		}
		else cnt++;
	}
	if (cnt != 0)A.push_back(cnt);
	if (A.size() % 2 == 0)A.push_back(0);
	
	int Add = 2 * K + 1;
	vint sum(A.size() + 1);

	for (int i = 0; i < A.size();i++) {
		sum[i + 1] = sum[i] + A[i];
	}

	
	for (int i = 0; i < A.size();i+=2) {
		int left = i;
		int right = min(i + Add, (int)A.size());
		int tmp = sum[right] - sum[left];

		ans = max(tmp, ans);
	}

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

Measured memory_bytes: 1272
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

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

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

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
int main() {

  int a,b,c,d;
  cin >> a >> b >> c >> d;

  while(true) {
    c -= b;
    if(c<=0) {
      yes();
      break;
    }
    a -= d;
    if(a<=0) {
      no();
      break;
    }
  }

  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int hug=0;
  for(int i=0;i<s.size()/2;i++){
    if(s.at(i)!=s.at(s.size()-i-1)) hug++;
  }
  cout << hug;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n;
    cin >> n;
    for(int i = 1; i < 10; i++) {
        for(int j = 1; j < 10; j++) {
            if(i*j == n) {
                cout << "Yes" << endl;
                return 0;
            } 
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3644
S = input()
remaining = set("abcdefghijklmnopqrstuvwxyz") - set(S)
if remaining:
    print(S + min(remaining))
else:
    prev = S[25]
    for i in range(24, -1, -1):
        c = S[i]
        if c < prev:
            print(S[:i] + min(c for c in S[i + 1 :] if c > S[i]))
            break
        prev = c
    else:
        print(-1)


Measured memory_bytes: 3060
import random
import time

t1=time.time()
d=int(input())
c=input()
cl=[int(n) for n in c.split()]
sl=list()
for i in range(d):
    s=input()
    sl=sl+[int(n) for n in s.split()]
tl=list()
for i in range(d):
    tl.append(random.randint(1,26))
sat=0
for i in range(d):
    sat+=sl[i*26+tl[i]-1]

def decr(tl,cl):
    dec=0
    for i in range(26):
        last=[a for a, x in enumerate(tl) if x==i+1]
        if last==list():
            dec+=(d*(d+1)/2)*cl[i]
        else:
            for v in range(len(last)):
                if v!=len(last)-1:    
                    dec+=cl[i]*(last[v+1]-last[v]-1)*(last[v+1]-last[v])/2
                else:
                    dec+=cl[i]*(d-last[v]-1)*(d-last[v])/2
            dec+=cl[i]*(last[0])*(last[0]+1)/2
    return(int(dec))

oldscore=sat
oldans=oldscore-decr(tl,cl)
oldtl=[int(x) for x in tl]
t2=time.time()
while t2-t1<1.85:
    if round(t2)/2==0:
        d1=random.randint(1,d)
        d2=random.randint(1,d)
        q1=tl[d2-1]
        q2=tl[d1-1]
        cha=sl[(d1-1)*26+q1-1]-sl[(d1-1)*26+tl[d1-1]-1]+sl[(d2-1)*26+q2-1]-sl[(d2-1)*26+tl[d2-1]-1]
        tl[d2-1]=q1
        tl[d1-1]=q2
        newscore=oldscore+cha
        newans=newscore-decr(tl,cl)
        if newans<oldans:
            tl=[int(x) for x in oldtl]
        else:
            oldans=newans
            oldtl=[int(x) for x in tl]
            oldscore=newscore
    else:
        da=random.randint(1,d)
        q=random.randint(1,26)
        cha=sl[(da-1)*26+q-1]-sl[(da-1)*26+tl[da-1]-1]
        tl[da-1]=q
        newscore=oldscore+cha
        newans=newscore-decr(tl,cl)
        if newans<oldans:
            tl=[int(x) for x in oldtl]
        else:
            oldans=newans
            oldtl=[int(x) for x in tl]
            oldscore=newscore
    t2=time.time()
for i in range(d):
    print(tl[i])
        


Measured memory_bytes: 89644
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

// 154-d
int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, 0, n) { cin >> p[i]; }

    int cnt   = 1;
    int mnval = p[0];
    rep(i, 1, n) {
        if (p[i] < mnval) {
            cnt++;
            mnval = p[i];
        }
    }
    cout << cnt << endl;
    return 0;
}


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

bool an = true;
int n;
int x;
list<int> b, ans;

int main()
{
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		cin >> x;
		b.push_back(x);
	}
	for (size_t i = n; i > 0; i--)
	{
		decltype(b)::iterator it = b.end();
		for (int j = i; j >= 0; j--)
		{
			it--;
			if (*it == j)
			{
				ans.push_front(j);
				b.erase(it);
				break;
			}
			if (j == 0)
			{
				an = false;
			}
		}
	}
	if (an)
	{
		while (!ans.empty())
		{
			cout << ans.front() << ' ';
			ans.pop_front();
		}
		cout << endl;
	}
	else
	{
		cout << -1 << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,k,l,c;
    scanf("%d",&n);
    int a[n+3];
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    sort(a,a+n);
    c=0;
    for(i=0;i<(n-2);i++){
        for(j=i+1;j<(n-1);j++){
            for(k=j+1;k<n;k++){
                if(a[i]==a[j]||a[j]==a[k])
                  continue;
                else if(a[i]+a[j]>a[k])
                   c++;
            }
        }
    }
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 3828
N,M=gets.chomp.split.map(&:to_i)
e1 = Array.new(N+1).map{Array.new}
M.times do
  u,v=gets.chomp.split.map(&:to_i)
  e1[u] << v
end
s,t=gets.chomp.split.map(&:to_i)
e2 = Array.new(N*3+1).map{Array.new}
1.upto(N) do |i|
  e1[i].each do |j|
    e2[i] << N+j
    e2[N+i] << 2*N+j
    e2[2*N+i] << j
  end
end

d = Array.new(3*N+1,10**10)

def bfs(s, t, e, d, depth)
  que = []
  que.push(s)
  d[s] = depth

  while(que.size != 0)
    n = que.shift
    e[n].each do |v|
      next if d[v] <= d[n] + 1
      d[v] = d[n] + 1
      que.push(v)
    end
  end

end

bfs(s,t,e2,d,0)

if d[t] != 10**10 && d[t] % 3 == 0
  puts d[t] / 3
else
  puts -1
end


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

int main()
{
    int a, b, c;
    bool tf;
    cin >> a >> b >> c;
    if(a == 5){
        if(b == 7){
            if(c == 5){
                tf = true;
            } else {
                tf = false;
            }
        } else if(b == 5){
            if (c == 7){
                tf = true;
            } else {
                tf = false;
            } 
        } else{
            tf = false;
        }
    } else if(a == 7){
        if(b == 5 && c == 5){
            tf = true;
        } else {
            tf = false;
        }
    } else {
        tf = false;
    }

    if(tf){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
#define push_back pb;
#define INF (int)(1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()

/*--------------------------------------------*/
/*
int dx[4]={-1,0,1,0};//四方に移動
int dy[4]={0,-1,0,1};
*/
/*--------------------------------------------*/
/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}
ll lcm(ll A, ll B) {//最小公倍数
    ll a=A;
    ll b=B;
    if (a==0 || b==0) {return 0;}
    if (a<0) {a=-a;}
    if (b<0) {b=-b;}
    while(b>0) {
        ll c=a%b;
        a=b;
        b=c;
    }
    return A/a*B;
}

ll gcd(ll a,ll b){
    while(b!=0) {
        int t=b;
        b=a%b;
        a=t;
    }
    return a;
}

//入力はすべて正とする
bool is_prime(int n) {//素数判定o(√n)
    for (int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return n!=1;//1の場合は例外
}

vector<ll> divisor(ll n){//約数の列挙o(√n)
    vector<ll> res;
    for(ll i=1;i*i<=n;i++) {
        if(n%i == 0){
        res.push_back(i);
        if(i!=n/i)res.push_back(n/i);
        }
    }
    return res;
}//vector<ll>k=divisor(n);rep(i,k.size())cout<<k[i]<<endl;//のように使う

map<ll,ll> prime_factor(ll n){//素因数分解o(√n)
    map<ll,ll>res;    
    for(ll i=2;i*i<=n;i++) {
        while (n%i==0) { 
            ++res[i];
            n/=i;
        }
    }
    if (n!=1)res[n]=1;
    return res;
}//map<ll,ll> k=prime_factor(n);for(auto i=k.begin();i!=k.end();i++){cout<<i->first<<" "<<i->second<<endl;}//みたいに使う

vector<ll> prime_list(ll n){//n以下の素数を全て見つける
    vector<ll> is_prime(n);//is_prime[i]が1ならiは素数
    for(ll i=2;i<=n;i++)is_prime[i]=1;//最初はみんな素数かも
    for(ll i=2;i*i<=n;i++){//素数の整数倍を消していく(√nまで)
        if(is_prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    is_prime[j]=0;                
                }
            }
        }
    }return is_prime;
}vector<ll>k=prime_list(n);REP(i,n){if(k[i])cout<<i<<endl;}のように使う
*/
/*--------------------------------------------*/


int main(){
    int n,d,x;cin>>n>>d>>x;
    V A(n);rep(i,n)cin>>A[i];
    int cnt=0;
    rep(i,n){
        int now=1;
        while(now*A[i]+1<=d){now++;cnt++;}
        cnt++;
    }
    cout<<cnt+x<<endl;
}




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

constexpr int MAX = 4e5;

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

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

    vector<int> c(n + 1, 0);
    for(int i = 0; i < n; i++) c[a[i]]++;

    vector<int> d(n + 1, 0);
    for(int i = 1; i < n + 1; i++) d[c[i]]++;

    vector< pair<int64_t, int64_t> > max_len(n + 2, {0, 0});
    max_len[n + 1].first = MAX;
    max_len[n + 1].second = n + 1;
    vector<int64_t> sum_k(n + 1, 0);
    vector<int64_t> sum(n + 1, 0);
    for(int i = 1; i < n + 1; i++) sum[0] += d[i];
    for(int i = 1; i < n + 1; i++) {
        sum_k[i] = sum_k[i - 1] + i * d[i];
        sum[i] = sum[i - 1] - d[i];
    }

    for(int i = 1; i < n + 1; i++) {
        max_len[i].first = (sum_k[i] + i * sum[i]) / i;
        max_len[i].second = i;
    }
    sort(max_len.begin(), max_len.end());

    int point = 1;
    for(int i = 1; i < n + 1; i++) {
        int p = point;
        for(int j = p; j < n + 2; j++) {
            if(max_len[j].first <= i) {
                point++;
            } else {
                if(max_len[j - 1].first >= i) {
                    cout << max_len[j - 1].second << endl;
                } else if(j != n + 1) {
                    cout << max_len[j].second << endl;
                } else {
                    cout << 0 << endl;
                }
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;

ll fast(ll n,ll k)
    {
        ll res = 1;
        n%=MOD;
        while(k>0)
        {
            if ((k&1) == 1)
                res = (res * n)%MOD;
            k = k>>1;
            n = (n * n)%MOD;
        }
        return res;
    }

int main()
{
    f_io;
    ll n;
    cin >> n;
    if(n==1)
        cout << "0";
    else
    {
        ll ans = (fast(10,n)-2*fast(9,n))%MOD;
        ans = (ans+fast(8,n)+MOD)%MOD;
        cout << ans << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int i,t,n,s,a[10000001];
int main(){
    cin>>n;
	for(i=1;i<=n;i++){
    a[i]=i;
    s+=i;
    if(s>n){
    break;
    }}
    t=s-n;
    for(i=1;i<=n;i++){
    if(a[i]){
    if(a[i]!=t){
    cout<<a[i]<<endl;
    }}}
    return 0;
}

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(){
  int n;
  cin >>n;
  vector<int> p(n);
  rep(i,n) cin >>p[i];
  int ans = 0;
  for(int i = 1; i<n-1; i++){
    if(p[i-1]<p[i] && p[i]<p[i+1]) ans++;
    else if(p[i-1]>p[i] && p[i]>p[i+1]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 10000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector

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

char C; cin>> C;

cout << ++C << "\n";



}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	int l[N];
	int total = 0;
	int max = 0;
	rep(i, N)
	{
		cin >> l[i];
		if (max < l[i])
		{
			max = l[i];
		}
		total += l[i];
	}

	if (total > 2*max)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	
	return 0;
}


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

int main() {
	int a[4];
	string input; cin >> input;
	for (int i = 0; i < 4; i++) a[i] = input[i] - '0';
	

	for (int x = 0; x < 8; x++) {
		int sum = a[0];
		string s;
		s += (char)('0' + a[0]);
		for (int i = 0; i < 3; i++) {
			if (x & (1 << i)) {
				sum += a[i + 1];
				s += '+';
				s += (char)('0' + a[i + 1]);
			}
			else {
				sum -= a[i + 1];
				s += '-';
				s += (char)('0' + a[i + 1]);
			}
		}
		if (sum == 7) {
			cout << s + "=7" << endl;
			return 0;
		}
	}
	return 0;
}


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

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> ziku(n);
	for(int i = 0; i < n; i++){
		ziku.at(i) = i+1;
	}

for(int l = 0; l < k; l++){

	int d;
	cin >> d;
	vector<int> han(d);
	for(int i = 0; i < d; i++){
		cin >> han.at(i);
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < d; j++){
			if(ziku.at(i) == han.at(j)){
				ziku.at(i) = 0;
			}
		}
	}
}


	int count = 0;

	for(int i = 0; i < n; i++){
		if(ziku.at(i) != 0){
			count++;
		}
	}

	cout << count <<endl;
}


Measured memory_bytes: 3588
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int a = sc.nextInt();
                int b = sc.nextInt();
                int c = sc.nextInt();
                boolean ebishu = true;
                if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
                        ebishu = false;
                        System.out.println(0);
                }
                int d = 0 , e = 0 , f = 0;
                for(int i = 1 ; i < 1000000000 && ebishu ; i++){
                        d = (a + b) / 2;
                        e = (b + c) / 2;
                        f = (c + a) / 2;
                        a = d;
                        b = e;
                        c = f;
                        if(a == b && b == c){
                                System.out.println(-1);
                                ebishu = false;
                        }
                        if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
                                ebishu = false;
                                System.out.println(i);
                        }
                }
                if(ebishu) System.out.println(-1);
        }
}
//初期値が奇数の場合をミスっていました
//計算量やばそうだけどまあいいや！TLE出ないことを祈ります！

Measured memory_bytes: 35588