akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int n = 0, need[550], mid[550], ans[250500];
bool comp(int x, int y) { return need[x] < need[y];}
int tot[550];
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> need[i], mid[i] = i, ans[need[i]] = i, tot[i] = 1;
	sort(mid + 1, mid + n + 1, comp);
	int p = 1;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j < mid[i]; j++)
		{
			while(ans[p]) p++;
			if(p > n * n) { cout << "No" << endl; return 0; }
			ans[p] = mid[i], tot[mid[i]]++;
		}
	}
	int q = 1;
	while(p <= n * n)
	{
		while(q < n and tot[mid[q]] == n) q++;
		if(not ans[p]) ans[p] = mid[q], tot[mid[q]]++;
		p++;
	}
	p = 1, memset(tot, 0, sizeof tot);
	for(int i = 1; i <= n * n; i++)
	{
		tot[ans[i]]++;
		if(p <= n and i == need[mid[p]])
		{
			if(tot[mid[p]] != mid[p]) { cout << "No" << endl; return 0; }
			p++;
		}
	}
	for(int i = 1; i <= n; i++)
		if(tot[i] != n) { cout << "No" << endl; return 0; }
	cout << "Yes" << endl;
	for(int i = 1; i <= n * n; i++)
		cout << ans[i] << " ";
	cout << endl;
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> b(n + 1); b[0] = b[n] = 1001001001;
  for (int i = 1; i < n; i++) cin >> b[i]; 
  vector<int> a(n);
  for (int i = 0; i < n; i++) a[i] = min(b[i], b[i+1]);
  int s = 0;
  for (auto &x : a) s += x;
  cout << s << '\n';
  return 0;
}

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

int main() {
  int N, X, m[100];
  cin >> N >> X;
  rep(i, N) cin >> m[i];

  int moto = X;
  rep(i, N) moto -= m[i];

  int ans = N;

  sort(m, m + N);

  ans = ans + moto / m[0];

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
typedef complex<double> P;
double dot(P a, P b){ //内積
    return (a.real() * b.real() + a.imag() * b.imag());
}

double cross(P a, P b){ //外積
    return (a.real() * b.imag() - a.imag() * b.real());
}

bool is_orth(P a1, P a2, P b1, P b2){ //垂直か
    return EQ(dot(a1 - a2, b1 - b2), 0.0);
}

bool is_para(P a1, P a2, P b1, P b2){ //平行か
    return EQ(cross(a1 - a2, b1 - b2), 0.0);
}

bool is_online(P a, P b, P c){ //cが線分上か
    return (abs(a-c) + abs(c-b) < abs(a-b) + EPS);
}

bool distance_lp(P a, P b, P c){ //直線abと点cの距離
    return abs(cross(b-a, c-a)) / abs(b-a);
}

double norm(P a){
  return a.real() * a.real() +a.imag() *a.imag();
}

ll ccw(P p0,P p1,P p2){
  P a = p1-p0;
  P b = p2-p0;
  if(cross(a,b) > EPS) return 1;
  if(cross(a,b) < -EPS) return -1;
  if(dot(a,b) < -EPS) return 2;
  if(abs(a) < abs(b)) return -2;
  return 0;
}

bool is_intersect(P p1, P p2, P p3, P p4){
  return (ccw(p1,p2,p3) * ccw(p1,p2,p4) <= 0 &&
      ccw(p3,p4,p1) * ccw(p3,p4,p2) <= 0 );
}

P intersect_pos(P a1, P a2, P b1, P b2){ //直線同士の交点
    P a = a2 - a1;
    P b = b2 - b1;
    return a1 + a * cross(b, b1 - a1) / cross(b, a);
}

double getDistanceLP(P a1, P a2, P b){
    return abs(cross(a2-a1, b-a1) / abs(a2 - a1));
}

double getDistanceSP(P a1, P a2, P b){
    if(dot(a2 - a1, b - a1) < EPS) return abs(b - a1);
    if(dot(a1 - a2, b - a2) < EPS) return abs(b - a2);
    return getDistanceLP(a1, a2, b);
}
double getDistance(P a1, P a2, P b1, P b2){
    if(is_intersect(a1, a2, b1, b2)) return 0.0;
    double v1 = min(getDistanceSP(a1, a2, b1), getDistanceSP(a1, a2, b2));
    double v2 = min(getDistanceSP(b1, b2, a1), getDistanceSP(b1, b2, a2));
    return min(v1,v2);
}

#define printP(P) cout << "(" << P.real() << ", " << P.imag() << ")" << endl;




int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    double x[110], y[110];
    vector<P> p;
    rep(i,0,N){
        cin >> x[i] >> y[i];
        P t(x[i], y[i]);
        p.push_back(t);
    }
    rep(i,0,N){
        double sin = cross(p[(i-1+N)%N] - p[i], p[(i+1)%N] - p[i]) * -1;
        if(sin < 0){
            print(0);
            return 0;
        }
    }
    print(1);


}


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

int main() {

	ll n; cin >> n;
	const ll p = 26;
	ll tmp = n;
	tmp--;
	string ans = "";
	while (true) {
		if (tmp / p != 0) {
			ll tmpMod = tmp % p;
			char tmpChar = (char)('a' + tmpMod);
			string tmpChar_s{ tmpChar };
			ans += tmpChar_s;			
		}
		else {
			ll tmpMod = tmp % p;
			char tmpChar = (char)('a' + tmpMod);
			string tmpChar_s{ tmpChar };
			ans += tmpChar_s;
			break;
		}
		tmp /= p;
		tmp--;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#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():
    n,k = mi()
    cnt = 0
    while n:
        n//=k
        cnt+=1
    print(cnt)



main()



Measured memory_bytes: 5716
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			h = scanner.nextInt();
			w = scanner.nextInt();
			if ((h | w) == 0)
				break;
			char[][] map = new char[h][w];
			for (int i = 0; i < h; i++) {
				map[i] = scanner.next().toCharArray();
				for (int j = 0; j < w; j++) {
					if (map[i][j] == 'A') {
						ay = i;
						ax = j;
					} else if (map[i][j] == 'B') {
						by = i;
						bx = j;
					}
				}
			}
			int[][] dp = new int[h][w];
			for (int[] dp1 : dp)
				Arrays.fill(dp1, 1 << 30);
			Deque<Point> deque = new ArrayDeque<Main.Point>();
			deque.push(new Point(ay, ax, 0));
			dp[ay][ax] = 0;
			while (!deque.isEmpty()) {
				Point p = deque.poll();
				int y = p.y;
				int x = p.x;
				int step = p.step;

				for (int[] m : move) {
					int ny = y + m[0];
					int nx = x + m[1];
					if (!isOK(ny, nx))
						continue;
					if (map[ny][nx] == '#')
						continue;
					if (dp[ny][nx] <= step + 1)
						continue;
					dp[ny][nx] = step + 1;
					deque.offer(new Point(ny, nx, step + 1));
				}

			}
			char[] p = scanner.next().toCharArray();
			int e;
			for (e = 0; e < 500; e++) {
				if (dp[by][bx] <= e)
					break;
				char o = p[e % p.length];
				int ny = by + (o == '2' ? 1 : 0) - (o == '8' ? 1 : 0);
				int nx = bx + (o == '6' ? 1 : 0) - (o == '4' ? 1 : 0);
				if (!isOK(ny, nx))
					continue;
				by = ny;
				bx = nx;
			}
			System.out.println(e < 500 ? e + " " + by + " " + bx
					: "impossible");
		}
	}

	private boolean isOK(int ny, int nx) {
		return 0 <= ny && ny < h && 0 <= nx && nx < w;
	}

	int ay, ax, by, bx, h, w;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

	class Point {
		int y, x, step;

		public Point(int y, int x, int step) {
			super();
			this.y = y;
			this.x = x;
			this.step = step;
		}

		@Override
		public String toString() {
			return "Point [y=" + y + ", x=" + x + ", step=" + step + "]";
		}

	}
}

Measured memory_bytes: 24336
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	static long[] list = new long[10001];
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()) {
			int[] data = new int[5];
			String[] tmp = stdIn.next().split(",");
			for(int i = 0; i < 5; i++) {
				
				data[i] = Integer.parseInt(tmp[i]);
			}
			solv(data);
		}
	}
	public static void solv(int[] a) {
		Arrays.sort(a);
		if((a[0] == a[1] && a[1] == a[2] && a[2] == a[3]) || (a[1] == a[2] && a[2] == a[3] && a[3] == a[4])) {
			System.out.println("four card");
			return;
		}
		if((a[0] == a[1] && a[1] == a[2] && a[3] == a[4]) || (a[0] == a[1] && a[2] == a[3] && a[3] == a[4])) {
			System.out.println("full house");
			return;
		}
		if((a[0] == 1 && a[1] == 2 && a[2] == 3 && a[3] == 4 && a[4] == 5) || a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 && a[4] == 13) {
			System.out.println("straight");
			return;
		}
		for(int i = 1; i < 5; i++) {
			if(a[i-1]+1 != a[i]) {
				break;
			}
			if(a[i] == 1) {
				break;
			}
			if(i == 4) {
				System.out.println("straight");
				return;
			}
		}
		for(int i = 2; i < 5; i++) {
			if(a[i-2] == a[i-1] && a[i-1] == a[i]) {
				System.out.println("three card");
				return;
			}
		}
		int count = 0;
		for(int i = 1; i < 5; i++) {
			if(a[i-1] == a[i]) {
				count++;
			}
		}
		if(count == 2) {
			System.out.println("two pair");
		}
		if(count == 1) {
			System.out.println("one pair");
		}
		if(count == 0) {
			System.out.println("null");
		}
		
	}
}

Measured memory_bytes: 15404
n,k = map(int,input().split())

mod = 10**9 + 7
# k個選ぶときからn-1個選ぶとき
ans = 0
for i in range(k, n+1):
  min = 1/2 * (i-1) * i
  max = 1/2 * (n-i+1+n) * (n-(n-i+1)+1)
  ans += (max - min + 1) % mod
print(int(ans + 1)% mod)



Measured memory_bytes: 72824
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder (1000000007)
#define pie acos(-1)
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0;
using namespace std;
int h,w,g;
int dp[110][10];
signed main(){
	cin>>h>>w>>g;
	dp[0][0]=1;
	rep(i,h){
		rep(j,w)dp[i][j]%=moder;
		rep(j,((ll)1<<(w-1))){
			for(int k=0;k<w-2;k++){
				if(((j>>k)&1)&&((j>>(k+1))&1))goto kaage;
			}
			rep(k,w){
				if(k!=0&&((j>>(k-1))&1))dp[i+1][k-1]+=dp[i][k];
				else if(k!=w-1&&((j>>k)&1))dp[i+1][k+1]+=dp[i][k];
				else dp[i+1][k]+=dp[i][k];
			}
			kaage:;
		}
	}
	cout<<dp[h][g-1]%moder<<endl;
	ggr;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
A=list(map(int,input().split()))
k=1/(4*M)
t=0
S=0
for i in range(N):
  S=S+A[i]
for i in range(N):
  if A[i]>=S*k:
    t=t+1
  else:
    continue
if t>=M:
  print ('Yes')
else:
  print ('No')

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String []args){
		//????????£????????????
		Scanner sc = new Scanner(System.in);
		while(true){
			//??????m
			int m = sc.nextInt();
			//??????f
			int f = sc.nextInt();
			//???????¨? r
			int r = sc.nextInt();
			//??¨??????-1?????£????????????
			if(m == -1 && f == -1 && f == -1){
				break;
			}
			//??????
			//??????????¨???¨??????????¨?????????????????¬???? ????????????30?????\???
			if(m == -1 || f == -1){
				System.out.println("F");
			//???????????????80?????\???
			}else if((m + f)>=80){
				System.out.println("A");
			//???????????????80?????????????????????65?????\???
			}else if(80>(m+f)&&(m+f)>=65){
				System.out.println("B");
			//???????????????65?????????????????????50?????\???
			}else if(65>(m+f)&&(m+f)>=50){
				System.out.println("C");
			//???????????????50??????????????????30?????\??? 
			}else if(50>(m+f)&&(m+f)>=30){
				//???????¨????50?????\???
				if(r >=50){
					System.out.println("C");
				}else{
					System.out.println("D");
				}
			}else if((m+f)<30){
				System.out.println("F");
			}
		}
    }
}

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

int main()
{
	int N, K, ans = 1;
	cin >> N >> K;

	for (int i = 0; i < N; i++) {

		if ((ans * 2) >(ans + K)) {
			ans += K;
			//cout << ans << endl;
		}

		else if ((ans * 2) < (ans + K)) {
			ans *= 2;
			//cout << ans << endl;
		}

		else if ((ans * 2) == (ans + K)) {
			ans += K;
		}

		else {
			ans += 2;
			//cout << ans << endl;
		}
	}

	cout << ans << endl;
}


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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n;
int dp[55];

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>n;
    dp[0]=1;
    dp[1]=1;
    rep(i,2,n+1){
        dp[i]=dp[i-1]+dp[i-2];
    }
    cout<<dp[n]<<endl;
    
    
    
    
    
    
    return 0;
}


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

int main () {

  int M,D,ans = 0;

  scanf("%d %d", &M, &D);

  for(int m =1;m<=M;++m) {
    
    for(int d=1;d<=D;++d) {
      if (d%10 >= 2 && d/10 >=2 && ((d%10) * (d/10)) == m) 
        ans++;
    }
    
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls p<<1
#define rs p<<1|1 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<endl;
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
#define all(v) v.begin(),v.end() 
#define mem(x,i) memset(x,i,sizeof(x)) 
#define eps 1e-8 
#define ull unsigned long long
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
const int maxn=1e5+100;
ll a,b;
int main()
{
	cin>>a>>b;
	ll k=(a+b)/2;
	if(abs(a-k)==abs(b-k)) cout<<k<<endl;
	else cout<<"IMPOSSIBLE\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX = 100010;
typedef vector<vector<int>> Graph;
int n;
bool seenF[MAX], seenS[MAX];
int distF[MAX], distS[MAX];

void bfs(const Graph g, int u, int *dist) {
    rep(i, n) dist[i] = INF;
    dist[u] = 0;
    queue<int> q;
    q.push(u);
    while (q.size()) {
        int v = q.front(); q.pop();
        for (auto nv: g[v]) {
            if (dist[nv] == INF) {
                q.push(nv);
                dist[nv] = dist[v] + 1;
            }
        }
    }
}

int main() {
    cin >> n;
    Graph g(n);
    rep(i, n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    bfs(g, 0, distF);
    bfs(g, n-1, distS);

    int nf = 0, ns = 0;
    rep(i, n) {
        if (distF[i] <= distS[i]) nf++;
        else ns++;
    }
    if (nf > ns) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}


Measured memory_bytes: 11992
#include <queue>
#include <cstdio>

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

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<int> G[5000];
	int deg[5000]={};
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		G[u].push_back(v);
		deg[v]++;
	}

	bool ambig=false;
	vector<int> ans;

	queue<int> Q;
	rep(u,n) if(deg[u]==0) Q.push(u);
	while(!Q.empty()){
		if(Q.size()>=2) ambig=true;
		int u=Q.front(); Q.pop();
		ans.push_back(u);
		rep(i,G[u].size()){
			int v=G[u][i];
			deg[v]--;
			if(deg[v]==0) Q.push(v);
		}
	}

	rep(i,n) printf("%d\n",ans[i]+1);
	printf("%d\n",ambig?1:0);

	return 0;
}

Measured memory_bytes: 1884
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
    int H;
    cin >> H;

    int N;
    cin >> N;

    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    int sum = 0;
    for (int i = 0; i < N; i++)
        sum += A[i];

    if (sum < H)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  
  if (N < 500){
    if (N <= A){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    if ((N % 500) <= A) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;


void main() {
    auto K = readln.chomp.to!long;

    int N = 50;
    auto A = new long[](N);

    auto X = K / 50;
    auto Y = K % 50;

    foreach (i; 0..N) {
        A[i] = 49 + X;
    }

    foreach (i; 0..Y) {
        A[i] += N;
        foreach (j; 0..N) if (j != i) A[j] -= 1;
    }

    N.writeln;
    A.map!(a => a.to!string).join(" ").writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a); i>=(b);i--) 

const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;



int main()
{
   ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
   int n,d;
   cin >> n >> d;
   d *= 2;d++;
   if(n % d) cout << n / d + 1;
   else cout << n / d;
   return 0;
}

Measured memory_bytes: 256
// atcoder/abc115/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    cout << "Christmas" << flush;
    for (int i = 0; i < 25 - n; ++i) {
      cout << " Eve";
    }
    cout << endl;
  }

  return 0;
}


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

// Union-Find
struct UnionFind {
    vector<int> par;
    vector<int> scale1;
    vector<int> rank;
    int size1;
    // par[i]はiの親の番号
    // scale[i]はiが親の時にのみ意味を持ち, その木の要素の数
    // rank[i]はiが親の時にのみ意味を持ち, その木のrank(union操作に使う)
    // sizeは木の数

    //最初は全てが根であるとして初期化
    UnionFind(int N) : par(N), scale1(N,1), rank(N,0){
        for(int i = 0; i < N; i++) par[i] = i;
        size1 = N;
    }

    // データxが属する木の根を再帰で得る
    int root(int x){
        if (par[x] == x) return x;
        par[x] = root(par[x]); // 親を根にする付け替えによって次回以降の参照を高速化
        return par[x];
    }

    // xの属する木の要素の数を返す関数
    int scale(int x){
        return scale1[root(x)];
    }

    // 木の数を返す関数
    int size(){
        return size1;
    }

    // xとyの木を併合
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if(rank[rx] > rank[ry]){
            par[ry] = rx;
            scale1[rx] += scale1[ry];
        }else if(rank[rx] < rank[ry]){
            par[rx] = ry;
            scale1[ry] += scale1[rx];
        }else{
            par[ry] = rx;
            scale1[rx] += scale1[ry];
            rank[rx]++;
        }
        size1--;
    }

    // 2つのデータx, yが属する木が同じならtrueを返す関数
    bool same(int x, int y){
        return root(x) == root(y);
    }
};


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

    UnionFind tree(N);
    vector<ll>ans(M);
    ll temp = N;
    temp = (temp * (temp-1)) / 2; // このオーバーフローのせいで30分溶かした
    for(int i = M - 1; i >= 0; --i){
        ans[i] = temp;
        if(! tree.same(A[i]-1, B[i]-1)){
            ll aS = tree.scale(A[i]-1);
            ll bS = tree.scale(B[i]-1);
            temp = temp - aS * bS;
            tree.unite(A[i]-1, B[i]-1);
        }
    }

    for (int i = 0; i < M; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int hash( string s, int a );

int main()
{
    string s;
    int t;

    while( cin >> s )
    {
        if( s == "." )
            break;

        cin >> t;

        int res = hash( s, t );
        int cnt = 0;
        for( int i = 0; i <= 9999; i++ )
            if( hash( s, i ) == res )
                cnt++;
        
        cout << res << " " << cnt << endl;
    }
    return 0;
}

int hash( string s, int a )
{
    char b[4];
    stack<char> st;

    for( int i = 0; i < 4; i++ )
    {
        b[3-i] = a % 10 + '0';
        a /= 10;
    }

    for( int j = 0; j < s.size(); j++ )
    {
        if( s[j] == 'a' )
            s[j] = b[0];
        else if( s[j] == 'b' )
            s[j] = b[1];
        else if( s[j] == 'c' )
            s[j] = b[2];
        else if( s[j] == 'd' )
            s[j] = b[3];
        else;
    }

    for( int i = 0; i < s.size(); i++ )
    {
        if( s[i] == ']' )
        {
            int x = st.top() - '0';
            st.pop();
            int y = st.top() - '0';
            st.pop();
            char c = st.top();
            if( c == '+' )
                x = x | y;
            else if( c == '*' )
                x = x & y;
            else
                x = x ^ y;
            st.pop();
            st.pop();
            st.push( x + '0' );
        }
        else
            st.push(s[i]);
    }
    return st.top() - '0';
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y;
vector<int> ft[100100];
int dp[100100];
int f(int u){
	if(dp[u]!=-1)
		return dp[u];
	dp[u]=0;
	for(int i=0;i<ft[u].size();i++){
		int v=ft[u][i];
		dp[u]=max(dp[u],f(v)+1);
	}
	return dp[u];
}
int main(){
	//freopen("longestpath.in","r",stdin);
	//freopen("longestpath.out","w",stdout);
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>x>>y;
		ft[y].push_back(x);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=max(ans,f(i));
	}
	cout<<ans<<endl;
	return 0;
}

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

int n;
ll k, s[200010], xx[200010], ans;

struct BIT{
	int dat[200010];
	void upd(int x){
		for(; x <= n + 1; x += x & -x) dat[x]++;
	}
	int get(int x){
		int ret = 0;
		for(; x; x -= x & -x) ret += dat[x];
		return ret;
	}
} B;

int wh(ll x){ return (int)(lower_bound(xx + 1, xx + n + 2, x) - xx); }

int main(){
	scanf("%d%lld", &n, &k);
	for(int i = 1; i <= n; i++){
		scanf("%lld", s + i);
		s[i] -= k;
		s[i] += s[i - 1];
		xx[i] = s[i];
	}
	sort(xx + 1, xx + n + 2);
	B.upd(wh(0));
	for(int i = 1; i <= n; i++){
		ans += B.get(wh(s[i]));
		B.upd(wh(s[i]));
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 4096
#include <math.h>
#include <iostream>
using namespace std;

/** Problem0045 : Sum and Average **/
int main()
{
	unsigned inputNum=0, soldNum=0, value=0;
	unsigned tValue=0, tNum=0, out;
	char camma;
	
	while (cin >> tValue >> camma >> tNum) {
		inputNum++;
		soldNum += tNum;
		value += tValue*tNum;
	}
	
	out = (round)((double)soldNum/inputNum);
	
	cout << value << endl;
	cout << out << endl;
	
	return 0;
}

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

using namespace std;

int mod = 1e9 + 7;

int find(int a, vector<int>& group) {
    while (a != group[a]) {
        a = group[a];
    }
    return a;
}

void unite(int group_a, int group_b, vector<int>& group, vector<int>& rank) {
    if (rank[group_a] < rank[group_b]) swap(group_a, group_b);
    group[group_b] = group_a;
    rank[group_a] += rank[group_b];
    return;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // N-1 -(built edges)
    int N, M, a, b;
    cin >> N >> M;
    vector<int> group(N + 1);
    for (int i = 0; i <= N; i++) {
        group[i] = i;
    }
    vector<int> rank(N + 1, 1);
    int ans = N - 1;
    for (int j = 0; j < M; j++) {
        cin >> a >> b;
        int group_a = find(a, group), group_b = find(b, group);
        if (group_a != group_b) {
            ans--;
            if (ans == 0) {
                cout << 0;
                return 0;
            }
            unite(group_a, group_b, group, rank);
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3992
#include<stdio.h>
#include<algorithm>
int main() {
	
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int N, M;

	scanf("%d %d", &N, &M);
	if (M%N == 0) {
		printf("%d", N + M);
	}
	else {
		printf("%d", M - N);
	}
}

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

int n;
int64_t v[1 << 18], w[1 << 18];
int64_t val[1 << 9][100010];

int main() {
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> v[i] >> w[i];
	}
	for(int i = 1; i < (1 << 9); ++i) {
		for(int j = 0; j < 100010; ++j) {
			val[i][j] = val[i / 2][j];
			if(j - 1 >= 0) val[i][j] = max(val[i][j], val[i][j - 1]);
			if(j - w[i - 1] >= 0) {
				val[i][j] = max(val[i][j], val[i / 2][j - w[i - 1]] + v[i - 1]);
			}
		}
	}
	int q; cin >> q;
	while(q--) {
		int vv, l; cin >> vv >> l;
		if(vv < (1 << 9)) {
			cout << val[vv][l] << '\n';
			continue;
		}
		vector<int> vec;
		while(vv >= (1 << 9)) {
			vec.push_back(vv - 1);
			vv >>= 1;
		}
		int64_t ans = 0;
		int vn = vec.size();
		for(int mask = 0; mask < (1 << vn); ++mask) {
			int64_t W = 0;
			int64_t V = 0;
			for(int i = 0; i < vn; ++i) {
				if(mask >> i & 1) {
					W += w[vec[i]];
					V += v[vec[i]];
				}
			}
			if(l - W >= 0) {
				ans = max(ans, val[vv][l - W] + V);
			}
		}
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 406880
import sys
sys.setrecursionlimit(10 ** 9)
n,m = map(int, input().split())
ab = []
c = [set() for i in range(n)]

for i in range(m):
  a = list(map(int, input().split()))
  a.sort()
  x,y = a[0]-1,a[1]-1
  c[x].add(y)
  c[y].add(x)

def dfs(s):
  if vis[s] == False:
    ary.append(s)
    vis[s] = True
    for j in c[s]:
      dfs(j)

vis = [False for i in range(n)]

ans= []

for i in range(n):
  ary = []
  dfs(i)
  if len(ary) == 0:
    continue
  ans.append(len(ary))

print (len(ans)-1)

Measured memory_bytes: 65380
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
const int maxn=5e5+5;
int n,c[maxn],last[maxn];
vector<pair<int,int> > queries[maxn];
int sum[maxn];
void add(int pos,int val)
{
    while(pos<=n)
    {
        sum[pos]+=val;
        pos+=pos&(-pos);
    }
    return;
}
int query(int pos)
{
    int res=0;
    while(pos)
    {
        res+=sum[pos];
        pos-=pos&(-pos);
    }
    return res;
}
int ans[maxn];
int main()
{
    int m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&c[i]);
    for(int i=1;i<=m;i++)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        queries[r].push_back(make_pair(l,i));
    }
    memset(last,-1,sizeof(last));
    for(int i=1;i<=n;i++)
    {
        if(~last[c[i]])
            add(last[c[i]],-1);
        last[c[i]]=i;
        add(i,1);
        for(int j=0;j<(int)queries[i].size();j++)
        {
            int s=queries[i][j].first;
            ans[queries[i][j].second]=query(i)-query(s-1);
        }
    }
    for(int i=1;i<=m;i++)
        printf("%d\n",ans[i]);
    return 0;
}
/*
4 3
1 2 1 3
1 3
2 4
3 3
 
10 10
2 5 6 5 2 1 7 9 7 2
5 5
2 4
6 7
2 2
7 8
7 9
1 8
6 9
8 10
6 8
 */


Measured memory_bytes: 33240
s = input()
q = s.count("?")
ans = [0] * 13
ans[0] = 1

for v in s:
    dp = [0] * 13
    for j in range(13):
        dp[(j * 10) % 13] = ans[j] % 1000000007
    dp += dp
    for j in range(13):
        if v == '?':
            ans[j] = sum(dp[j+4:j+14])
        else:
            ans[j] = dp[j - int(v)]

print(ans[5] % 1000000007)


Measured memory_bytes: 3188
#include<cstdio>
#include<algorithm>
#define f(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;i=-(~i))
const int neko=100010;
using namespace std;
int n,ans,a[neko];
int main()
{
	scanf("%d",&n);
	f(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(register int i=1,j;i<=n;i=j)
	{
		j=i;while(j<=n&&a[i]==a[j])++j;
		if(j-i>=a[i])ans+=j-i-a[i];
		else ans+=j-i;
	}return printf("%d\n",ans),0;
}

Measured memory_bytes: 512
# coding: utf-8
n, m = map(int, input().split())
a = list(int(i) for i in input().split())
s = sum(a)
a.sort(reverse=True)
c = 0

for i in range(n):
    if 4 * m * a[i] >= s:
        c += 1

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


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int x; cin >> x;
    ll ans = x / 500 * 1000;
    x -= x / 500 * 500;
    ans += x / 5 * 5;
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  int N, a;
  cin >> N;
  int ans = 0;
  vector<int> vec(N);

  for (int i = 0; i < N; i++){
    cin >> a;
    vec.at(i) = a;
  }

  vector<P> p(9);
  p[0].first = 399;
  p[0].second = 0;
  p[1].first = 799;
  p[1].second = 0;
  p[2].first = 1199;
  p[2].second = 0;
  p[3].first = 1599;
  p[3].second = 0;
  p[4].first = 1999;
  p[4].second = 0;
  p[5].first = 2399;
  p[5].second = 0;
  p[6].first = 2799;
  p[6].second = 0;
  p[7].first = 3199;
  p[7].second = 0;
  p[8].first = 4801;
  p[8].second = 0;

  for (int i = 0; i < N; i++){
    for (int j = 0; j < 9; j++) {
      if(vec.at(i) <= p[j].first){
        p[j].second++;
        break;
      }
    }
  }

  for (int i = 0; i < 8; i++) {
    // cout << p[i].first << " -> "<< p[i].second << endl;
    if(p[i].second > 0) ans++;
  }

  if(ans != 0){
    cout << ans << " " << ans + p[8].second << endl;
  }else{
    cout << 1 << " " << ans + p[8].second << endl;
  }

  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
#define int long long
vector<int> graph[110000];
int visited[110000];
int ans [110000];
signed main()
{
    int n,m;cin >> n >> m;
    rep(i,m){
        int a,b;cin >>a >> b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    queue<int> q;
    q.push(0);
    visited[0] = 1;
    while(q.size()){
        auto now = q.front();q.pop();
        
        for(auto next:graph[now]){
            if(visited[next])continue;
            ans[next] = now;
            q.push(next);
            visited[next] = 1;
            

        }

    }
    cout << "Yes" << endl;
    for(int i = 1;i < n ;i++){
        cout << ans[i]+1 << endl;
    }
    
    return 0;
}

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

string S[30];
int pos, n;
int Rank[30];

int Add(int);
int Multi(int);

int main(){
	int ans;
	while(cin>>n && n){
		for(int i=0;i<n;i++){
			cin>>S[i];
			Rank[i]=S[i].length()-1;
		}

		if('0'<=S[0][0] && S[0][0]<='9'){
			cout<<S[0][0]<<endl;
			continue;
		}else{
			pos=1;
			if(S[0][0]=='+'){
				ans=Add(0);
			}else if(S[0][0]=='*'){
				ans=Multi(0);
			}

			cout<<ans<<endl;
		}

	}

	return 0;
}

int Add(int R){
	int ret=0;
	while(pos<n){
		if(Rank[pos]<=R)break;

		char ch=S[pos][ Rank[pos] ];
		if('0'<=ch && ch<='9'){
			ret+=(ch-'0');
			pos++;
		}else{
			pos++;
			if(ch=='+'){
				ret+=Add(Rank[pos-1]);
			}else if(ch=='*'){
				ret+=Multi(Rank[pos-1]);
			}
		}
	}

	return ret;
}

int Multi(int R){
	int ret=1;
	while(pos<n){
		if(Rank[pos]<=R)break;

		char ch=S[pos][ Rank[pos] ];
		if('0'<=ch && ch<='9'){
			ret*=(ch-'0');
			pos++;
		}else{
			pos++;
			if(ch=='+'){
				ret*=Add(Rank[pos-1]);
			}else if(ch=='*'){
				ret*=Multi(Rank[pos-1]);
			}
		}
	}

	return ret;
}



Measured memory_bytes: 3168
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
 
int main(void){
    string s;
    cin>>s;
    if(s=="hi")cout<<"Yes";
    else{
        if(s=="hihi")cout<<"Yes";
        else{
            if(s=="hihihi")cout<<"Yes";
            else{
                if(s=="hihihihi")cout<<"Yes";
                else{
                    if(s=="hihihihihi")cout<<"Yes";
                    else cout<<"No";
                }
            }
        }
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		
		//p(n)=2,3,5の時は個別に考える必要があるが、
		//その他のケースでは、式変形により答えは0
		
		if(n==0) {
			System.out.println(1);
			return;
		}
		if(n==1) {
			System.out.println(2);
			return;
		}
		if(n==2) {
			System.out.println(1);
			return;
		}
		System.out.println(0);
		
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


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

int main()
{
  int A,B;
  
  cin >>A>>B;
  
  int a=(A*100/8),b=(B*10);
  int i=0;
  for(i=a-10;i<1010;i++){
  if((int)(i*0.08)==A && (int)(i*0.10)==B ){cout << i <<endl; break;}
  }
  
  if(i>=1010)cout << -1 <<endl;
  
}

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

int main() {
	map<string, int> m;
	string s;
	cin >> N;
	int _max = 0;
	vector<string> vec;
	rep(i, N) {
		cin >> s;
		if (m.count(s) == 0) {
			m[s] = 1;
		}
		else {
			m[s]++;
		}
		_max = max(_max, m[s]);
	}
	for (auto itr = m.begin(); itr != m.end(); ++itr) {
		if (itr->second == _max) vec.push_back(itr->first);
	}

	sort(vec.begin(), vec.end());
	rep(i, vec.size()) {
		cout << vec[i] << endl;
	}
}



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

int main() {
    int M, K;
    cin >> M >> K;

    if(M == 0) {
        if(K == 0) cout << "0 0" << endl;
        else cout << -1 << endl;
    } else if(M == 1) {
        if(K == 0) cout << "0 0 1 1" << endl;
        else cout << -1 << endl;
    } else {
        if(K >= (1 << M)) cout << -1 << endl;
        else {
            for(int i=0; i<(1<<M); ++i) {
                if(i != K) cout << i << ' ';
            }
            cout << K << ' ';
            for(int i=(1<<M)-1; i>=0; --i) {
                if(i != K) cout << i << ' ';
            }
            cout << K << endl;
        }
    }
}

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

int main() {
  int N, H, W;
  cin >> N >> H >> W;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    if (A >= H && B >= W) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
n ,k = map(int,input().split())
a = list(map(int,input().split()))

max_d = sum(a[0:k])
max_i = 0
total = sum(a[0:k])


for i in range(1,n - k + 1):
    total = total - a[i - 1] + a[i + k - 1]

    if total > max_d:
        max_d = total
        max_i = i

ans = 0
for i in range(max_i,max_i + k):
    ans += (1 + a[i])/2
print("{:7f}".format(ans))       

Measured memory_bytes: 25060
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005
ll dp[105][100005];
void solve()
{
	ll n,w;
	cin>>n>>w;
	vii v(n);
	rep(i,0,n)
	{
		cin>>v[i].F>>v[i].S;
	}
	rep(i,0,1)
	{
		rep(j,0,100001)
		dp[i][j]=1000000000000;
	}
	dp[0][0]=0;
	dp[0][v[0].S]=v[0].F;
	rep(i,1,n)
	{
		rep(j,0,v[i].S)
		dp[i][j]=dp[i-1][j];
		rep(j,v[i].S,100001)
		{
			dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i].S]+v[i].F);
		}
	}
	// rep(i,0,n)
	// {
	// 	rep(j,0,20)
	// 		cout<<(dp[i][j]>1000000?-1:dp[i][j])<<" ";
	// 	cout<<endl;
	// }
	repr(i,0,100001)
	{
		if(dp[n-1][i]<=w)
		{
			cout<<i<<endl;
			return;
		}
	}
	return;
}
int main()
{
	#ifndef ONLINE_JUDGE
	// freopen ("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	#endif
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 80128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[][] board = new char[n + 1][];
		for(int i = 0; i < n + 1; i++) {
			board[i] = sc.next().toCharArray();
		}
		int sum = 0; //print
		for(int i = 1; i <= n; i++) {//?????????????????£????????????
			out: for(int j = 0; j < board[i].length; j++) {//1??????????????¢?´¢
				if(board[i][j] == board[0][0]) {
					for(int k = j + 1; k < board[i].length; k++) {//2??????????????¢?´¢
						if(board[i][k] == board[0][1]) {
							int interval = k - j;//1???????????¨2??????????????????
							int cnt = 2;//?????????????????¢?´¢???????????????
							for(int m = k + interval; m < board[i].length; m = m + interval) {//3???????????\????????¢?´¢
								if(board[i][m] == board[0][cnt]) {
									cnt = cnt + 1;
									if(cnt == board[0].length) {
										sum = sum + 1;
										break out;
									}
								} else {
									break;
								}
							}
						}
					}
				}
			}
		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 27632
object Main extends App {
  val n = scala.io.StdIn.readLine.toInt
  val s = scala.io.StdIn.readLine
  var arr1 = Array.fill[Int](n)(0)
  var arr2 = Array.fill[Int](n)(0)
  var cnt = n

  arr1(0) = 0

  // 0人目をリーダーに
  cnt = s.takeRight(n - 1).count(_ == 'E')
  arr2(0) = cnt

  (1 until n).foreach { x =>
    if (s.charAt(x - 1) == 'W') {
      arr1(x) = arr1(x - 1) + 1
    } else {
      arr1(x) = arr1(x - 1)
    }

    if (s.charAt(x) == 'E') {
      arr2(x) = arr2(x - 1) - 1
    } else {
      arr2(x) = arr2(x - 1)
    }
    /*
    println("====A")

    println(cnt)
    println(arr1(x))
    println(arr2(x - 1))
    println(arr1(x) + arr2(x - 1) - 1)
    println("====B")
    */
    cnt = List(cnt, arr1(x) + arr2(x)).min
  }

/*
  arr1.foreach(print)
  println()

  arr2.foreach(print)
  println()
  */
  println(cnt)

}


Measured memory_bytes: 49164
// ABC128 B GuideBook  https://atcoder.jp/contests/abc128/tasks/abc128_b
// map使ってみた
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int N;
    cin >> N;
    vector<string> city;
    map<string, int> dic;
    for(int i = 0; i < N; i++) {
        string tempstr;
        int temppoint;
        cin >> tempstr;
        cin >> temppoint;
        city.push_back(tempstr + to_string(999 - temppoint));
        dic[tempstr + to_string(999 - temppoint)] = i + 1;
    }
    sort(city.begin(), city.end()); //昇順ソート
    for(int i = 0; i < N; i++) {
        cout << dic[city[i]] << endl;
    }
    cout << "";
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = Console.ReadLine();
			var sLength = s.Length;

			long pow = (long)Math.Pow(2, sLength - 1);
			long sum = 0;

			for(long i = 1; i < pow; i++)
			{
				var dividedList = new List<string>();
				var bitString = Convert.ToString(i, 2);
				var plusLength = bitString.Length;

				var startIndex = 0;

				for(int j = 0; j < plusLength; j++)
				{
					if(bitString[plusLength - j - 1] == '1')
					{
						dividedList.Add(s.Substring(startIndex, j + 1 - startIndex));
						startIndex = j + 1;
					}
				}

				long number;
				var isDigit = long.TryParse(s.Substring(startIndex), out number);
				number = isDigit ? number : 0;

				sum += dividedList.Sum(value => long.Parse(value)) + number;
			}

			Console.WriteLine(sum + long.Parse(s));
		}
	}
}


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

int main()
{
	cin.sync_with_stdio(false);
	int n, k;
	while (cin >> n >> k, n | k) {
		bool e = false;
		vector<int> a(k);
		for (int i = 0; i < k; i++) {
			cin >> a[i];
			if (a[i] == 0) {
				e = true;
				a[i] = -10;
			}
		}
		sort(a.begin(), a.end());
		int t1 = 1, t2 = 1, res = 1;
		for (int i = 1; i < k; i++) {
			if (a[i] - a[i - 1] == 1) {
				t1++;
				t2++;
			}
			else if (a[i] - a[i - 1] == 2) {
				t2 = t1 + 2;
				t1 = 1;
			}
			else {
				t1 = t2 = 1;
			}
			res = max(res, e ? t2 : t1);
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3136
#!/usr/bin/env python3
import sys


N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]

for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47284
#include<bits/stdc++.h>
using namespace std;
int p[100005];
int main()
{
	int n,b,ans=0,x;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		p[x]=i;
	}
	for(int i=1;i<=n;i++)
	{
		printf("%d ",p[i]);
	}
	
}


Measured memory_bytes: 1152
N, K = map(int, input().split())
A = list(map(int, input().split()))

AA = A + A

AA_re = list(reversed(AA))
A_re = list(reversed(A))

ans0 = 0
for i in range(N):
    a = A_re[i]
    for j in range(i + 1, N):
        b = A_re[j]
        if a < b:
            ans0 += 1


ans1 = 0
for i in range(N):
    a = AA_re[i]
    for j in range(i + 1, 2 * N):
        b = AA_re[j]
        if a < b:
            ans1 += 1


sa = ans1 - ans0
m = 10 ** 9 + 7


matu = ans0 + sa * (K - 1)
c = ans0 + matu

ans = c * K // 2

if K == 0:
    print(int(ans0))
    exit()

ans = ans % m


print(int(ans))


Measured memory_bytes: 41692