akhauriyash/Code-Regression huggingface dataset:
import numpy as np

N,M = map(int,input().split())
A = np.array([list(input()) for _ in range(N)])
B = np.array([list(input()) for _ in range(M)])

bl = False
for i in range(N-M+1):
  for j in range(N-M+1):
    if (A[i:i+M,j:j+M] == B).all():
      bl = True

answer = 'Yes' if bl else 'No'
print(answer)


Measured memory_bytes: 21212
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    double pi = 3.141592;
    double num;
    cin >> num;
    cout << setprecision(20) << pi*2*num << endl;
    return 0;
}

Measured memory_bytes: 3256
import sys
s=input()
a=int(s[0]);b=int(s[1]);c=int(s[2]);d=int(s[3])
if a+b+c+d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a+b+c-d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a+b-c+d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a+b-c-d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a-b+c+d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a-b+c-d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a-b-c+d==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a-b-c-d==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
  sys.exit()


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

int main(void) {
  int n; float m; cin >> n >> m;
  vector<float> a(n);
  for (int i=0; i<n; i++) cin >> a[i];
  
  float sum; int count=0;
  sum = accumulate(a.begin(), a.end(), 0);
  for (int i=0; i<n; i++) {
    if (a[i] >= sum / (4 * m)) count++;
  }
  
  if (count >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;

int N,T;

struct Edge{
	int a,b;
	long long t,m,v;
	Edge(){}
	Edge(int a,int b,long long t,long long m,long long v) : a(a), b(b), t(t), m(m), v(v) {}
};
vector<Edge> g[310];
vector<int> seg;
vector<int> rev;
int gen_seg(int x,int p){
	seg.push_back(x);
	rev.push_back(0);
	for(int i = 0 ; i < g[x].size() ; i++){
		if( g[x][i].b != p ) gen_seg(g[x][i].b,x);
	}
	if( p != -1 ) seg.push_back(p) , rev.push_back(1);
}
vector<int> pos[310];

vector<Edge> G[310];

long long dp[610][10010] = {};
long long dp2[10010] = {};

map< pair<int,int> , Edge > info;



int main(){
	for(int i = 0 ; i < 610 ; i++)
		for(int j = 0 ; j < 10010 ; j++)
			dp[i][j] = -1e12;
	
	cin >> N >> T;
	for(int i = 0; i < N-1 ; i++){
		int a,b,t,m,v;
		cin >> a >> b >> t >> m >> v;
		a--,b--;
		g[a].push_back(Edge(a,b,t,m,v));
		g[b].push_back(Edge(b,a,t,m,v));
		info[make_pair(a,b)] = info[make_pair(b,a)] = Edge(a,b,t,m,v);
	}
	gen_seg(0,-1);
	/*for(int i = 0 ; i < seg.size() ; i++)
		cout << seg[i] << " ";
	cout << endl;
	for(int i = 0 ; i < rev.size() ; i++)
		cout << rev[i] << " ";
	cout << endl;
	*/
	for(int i = 0 ; i < seg.size() ; i++)
		pos[seg[i]].push_back(i);
	dp[0][0] = 0;
	for(int i = 0 ; i+1 < seg.size() ; i++){
		Edge e = info[make_pair(seg[i],seg[i+1])];
		/*for(int j = 0 ; j <= T ; j++){
			if( dp[i][j] >= 0 ) cout << "[" << i << "][" << j << "] = " << dp[i][j] << endl;
		}*/
		if( rev[i+1] ){
			for(int j = 0 ; j <= T ; j++){
				dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
			}
		}else{
			// use
			long long m = e.m / 2, v = e.v * 2, t = e.t * 2;
			for(int j = 0 ; j <= T ; j++) dp2[j] = -1e12;
			if( m > 0 ){
				//ikkai ugoku
				m--;
				for(int j = t ; j <= T ; j++) dp2[j] = dp[i][j-t]+v;
				if(e.m%2){
					for(int j = T ; j >= 2*e.t ; j--){
						dp2[j] = max(dp2[j],dp2[j-2*e.t]+e.v);
					}
				}
			}else{
				// ikkai ugoku
				if(e.m%2)
					for(int j = 2*e.t ; j <= T ; j++) dp2[j] = dp[i][j-2*e.t]+e.v;
			}
			// muda ni move
			for(int j = t ; j <= T ; j++)
				dp2[j] = max(dp2[j],dp[i][j-t]);
				
			for(long long k = 1; m > 0 ; k *= 2 ){
				long long wei = min(m,k);
				long long VV = v * wei;
				long long TT = t * wei;
				for(int j = T ; j >= TT ; j--){
					dp2[j] = max(dp2[j],dp2[j-TT]+VV);
				}
				m -= wei;
			}
			
			for(int j = 0 ; j <= T ; j++)
				dp[i+1][j] = max(dp[i+1][j],dp2[j]);
			
			// unuse
			int next = *upper_bound(pos[seg[i]].begin(),pos[seg[i]].end(),i);
			for(int j = 0 ; j <= T ; j++){
				dp[next][j] = max(dp[next][j],dp[i][j]);
			}
		}
	}
	cout << *max_element(dp[seg.size()-1],dp[seg.size()-1]+T+1) << endl;
	
	
	
	
}

Measured memory_bytes: 49116
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N, X, T;
  cin >> N >> X >> T;
  if(N % X == 0) {
    cout << (N / X) * T << endl;
  }
  else {
    cout << (N / X) * T + T << endl;
  }
}


Measured memory_bytes: 3632
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mini(vec) return *std::min_element(vec.begin(), vec.end());
#define maxi(vec) return *std::max_element(vec.begin(), vec.end());

int main() {
    double a,b,res;
    cin>>a>>b;
    res=(a+b)/2;
    cout<<int(res+0.9)<<endl;
}



Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
s = []
for i in range(h):
	t = input()
	s.append(t)

res = 0
dx = [1,0,-1,0]
dy = [0,1,0,-1]
for i in range(h):
	for j in range(w):
		if s[i][j] == "#":
			continue
		queue = deque([[i,j]])
		visited = [[0 for ii in range(w)] for jj in range(h)]
		visited[i][j] = 1
		while queue:
			l,m = queue.popleft()
			for k in range(4):
				x = l + dx[k]
				y = m + dy[k]
				if x < 0 or y < 0 or x >= h or y >= w or visited[x][y] != 0 or s[x][y] == "#":
					continue
				visited[x][y] = visited[l][m] + 1
				queue.append([x,y])
		for ii in range(h):
			for jj in range(w):
				res = max(res,visited[ii][jj])
print (res-1)

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll n, k, s;cin >> n >> k >> s;
	REP(i, n){
		if(i < k)cout << s << " ";
		else cout << (s <= 2 ? INF : s - 1) << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 1280
n, m = map(int, input().split())
edge = [[0]*n for _ in range(n)]
a = []
b = []
for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    a.append(x)
    b.append(y)
    edge[x][y] = 1
    edge[y][x] = 1

def bfs():
    q = [0]
    visit = [False]*n
    visit[0] = True
    while q:
        x = q[0]
        q.pop(0)
        for i in range(n):
            if not visit[i] and edge[x][i] == 1:
                q.append(i)
                visit[i] = True
    return len(list(filter(lambda x:x, visit)))

ans = 0
for i in range(m):
    edge[a[i]][b[i]] = 0
    edge[b[i]][a[i]] = 0
    if bfs() < n:
        ans += 1
    edge[a[i]][b[i]] = 1
    edge[b[i]][a[i]] = 1

print(ans)


Measured memory_bytes: 3064
N,K=map(int,input().split())
if K>(N+1)//2:
    print(-1)
else:
    used={i:False for i in range(K+2*N,K+3*N)}
    ans=[]
    for i in range(K):
        print(K+i,2*N+i,2*N+K+2*i)
        ans.append((K+i,2*N+i,2*N+K+2*i))
        used[2*N+K+2*i]=True

    pos=2*N+K+1
    count=0
    while N-K>count:
        if not used[pos]:
            print(2*K+count,2*K+count+N-K,pos)
            ans.append((2*K+count,2*K+count+N-K,pos))
            used[pos]=True
            count+=1
            pos+=1
        else:
            pos+=1

    #test=[]
    #for a,b,c in ans:
        #if a+b>c:
            #print("WA")
        #else:
            #test.append(a)
            #test.append(b)
            #test.append(c)

    #test.sort()
    #check=[i for i in range(K,K+3*N)]
    #if test==check:
        #print("AC")
    #else:
        #print("WA")

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    int a,b,c;
    cin >> a >> b >> c;
    
    ll ans = 0;
    
    if (a+b > c) ans = b+c;
    else if (a+b < c) ans = a+b*2+1;
    else if (a+b == c) ans = a+b*2;
    
    cout << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 888
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] s = new String[h];
		char[][] c = new char[h+2][w+2];
		for(int i=0; i<w+2; i++){
        		c[0][i] = '.';
    		      	c[h+1][i] = '.';
		}
		for(int i=0; i<h+2; i++){
          		c[i][0] = '.';
          		c[i][w+1] = '.';
        	}
		for(int i=0; i<h; i++){
			s[i] = sc.next();
			for(int j=0; j<w; j++){
				c[i+1][j+1] = s[i].charAt(j);
			}
		}
		boolean bl = true;
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
					if(c[i][j]=='#' && c[i-1][j]!='#' && c[i+1][j]!='#' && c[i][j-1]!='#' && c[i][j+1]!='#'){
						bl=false;
						break;
					}
			}
			if(bl==false)break;
		}
		System.out.println(bl==true? "Yes" : "No");
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}

int main() {
  string s; cin>>s;
  string t="YAKI";
  if (s.size() <= 3 || s.substr(0,4) != t) {
    cout<<"No"<<endl;
  } else {
    cout<<"Yes"<<endl;
  }
}

// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int maxx=-1,n,ans=1;
	scanf("%d%d",&n,&maxx);
	for(int i=1,x;i<n;i++)
	{
		scanf("%d",&x);
		if(x>=maxx)ans++,maxx=x;
	}
	printf("%d",ans);
	return 0;
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;

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

  ld a, b;
  cin >> a >> b;
  ld res = a * b;
  ll ans = res;
  cout << ans << '\n';
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 21000;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct TwoSat {
    int N;
    vector<vi> gr;
    vi values; // 0 = false, 1 = true
 
    TwoSat(int n = 0) : N(n), gr(2*n) {}
 
    int add_var() { // (optional)
        gr.emplace_back();
        gr.emplace_back();
        return N++;
    }
 
    void either(int f, int j) {
        f = max(2*f, -1-2*f);
        j = max(2*j, -1-2*j);
        gr[f^1].push_back(j);
        gr[j^1].push_back(f);
    }
    void set_value(int x) { either(x, x); }
 
    void at_most_one(const vi& li) { // (optional)
        if (sz(li) <= 1) return;
        int cur = ~li[0];
        rep(i,2,sz(li)) {
            int next = add_var();
            either(cur, ~li[i]);
            either(cur, next);
            either(~li[i], next);
            cur = ~next;
        }
        either(cur, ~li[1]);
    }
 
    vi val, comp, z; int time = 0;
    int dfs(int i) {
        int low = val[i] = ++time, x; z.push_back(i);
        trav(e, gr[i]) if (!comp[e])
            low = min(low, val[e] ?: dfs(e));
        ++time;
        if (low == val[i]) do {
            x = z.back(); z.pop_back();
            comp[x] = time;
            if (values[x>>1] == -1)
                values[x>>1] = !(x&1);
        } while (x != i);
        return val[i] = low;
    }
 
    bool solve() {
        values.assign(N, -1);
        val.assign(2*N, 0); comp = val;
        rep(i,0,2*N) if (!comp[i]) dfs(i);
        rep(i,0,N) if (comp[2*i] == comp[2*i+1]) return 0;
        return 1;
    }
};

int N;
pair <int, int> pp[MAXN];

bool works (int d)
{
    TwoSat sat(2*N);
    for (int i = 0; i < N; i++)
    {
        int cv = pp[i].second;
        sat.either(~cv, i + N);
        if (i > 0 && pp[i-1].first / d == pp[i].first / d)
        {
            sat.either(~(i-1+N), i + N);
            sat.either(~(i-1+N), ~cv);
        }
    }

    int hi = N - 1;
    for (int i = N - 1; i >= 0; i--)
    {
        int cv = pp[i].second;
        while (hi > i && pp[hi].first >= pp[i].first + d)
            hi--;
        if (pp[hi].first / d > pp[i].first / d)
        {
            sat.either(~(hi+N), ~cv);
        }
    }
    return sat.solve();
}

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int x, y;
        cin >> x >> y;
        pp[2*i] = make_pair (x, i);
        pp[2*i+1] = make_pair (y, ~i);
    }
    N *= 2;

    sort (pp, pp + N);
    int lo = 0, hi = 1e9;
    while (lo < hi)
    {
        int mid = (lo + hi + 1) / 2;
        if (works (mid))
            lo = mid;
        else
            hi = mid - 1;
    }
    cout << lo << "\n";
}

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

#include <iostream>
#include <vector>
// #include <map>
#include <string>
#include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	string s, p;
	bool flag = false;
	getline(cin, s);
	getline(cin, p);
	for (unsigned int i = 0; i < s.size(); i++) {
		for (unsigned int j = 0; j < p.size(); j++) {
			if (i + j >= s.size()) {
				if (s[i + j - s.size()] != p[j]) {
					break;
				}
			} else {
				if (s[i + j] != p[j]) {
					break;
				}
			}
			if (j == p.size() - 1) {
				flag = true;
			}
		}
		if (flag) {
			break;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 3240
#include<stdio.h>

int main(){
	int i,j,n,x,flag,ans=0;
	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d",&x);
		flag=1;
		for(j=2; j*j<=x; j++){
			if(x%j==0){
				flag=0;
				break;
			}
		}
		ans+=flag;
	}

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 2688
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#define LL long long
using namespace std;

const int MOD = 1e9+7;
const int MAX = 1e6+10;
const int INF = 0x3fffffff;

int main(){
	int a,b,x,y;
	while (scanf("%d%d%d%d",&a,&b,&x,&y)!=EOF){
		int t1 = y-b;
		if(t1>0){
			for(int i=0;i<abs(t1);i++) printf("U"); 
		}
		else {
			for(int i=0;i<abs(t1);i++) printf("D"); 
		}
		int t2 = x-a;
		if(t2>0){
			for(int i=0;i<abs(t2);i++) printf("R"); 
		}
		else {
			for(int i=0;i<abs(t2);i++) printf("L"); 
		}
		if(t1>0){
			for(int i=0;i<abs(t1);i++) printf("D"); 
		}
		else {
			for(int i=0;i<abs(t1);i++) printf("U"); 
		}
		if(t2>0){
			for(int i=0;i<abs(t2);i++) printf("L"); 
		}
		else {
			for(int i=0;i<abs(t2);i++) printf("R"); 
		}
		if(t2>0){
			printf("L");
			if(t1>0){
				for(int i=0;i<abs(t1+1);i++)	printf("U");
			}
			else {
				for(int i=0;i<abs(t1+1);i++)	printf("D");
			}
		} 
		else {
			printf("R");
			if(t1>0){
				for(int i=0;i<abs(t1+1);i++)	printf("U");
			}
			else {
				for(int i=0;i<abs(t1+1);i++)	printf("D");
			}
		}
		if(t2>0){
			for(int i=0;i<abs(t2+1);i++)	printf("R");
		}
		else {
			for(int i=0;i<abs(t2+1);i++)	printf("L");
		}
		if(t1>0){
			printf("D");
		}
		else printf("U");
		if(t2>0)	printf("R");
		else printf("L");
		if(t1>0){
			for(int i=0;i<abs(t1+1);i++)	printf("D");
		}
		else {
			for(int i=0;i<abs(t1+1);i++)	printf("U");
		}
		if(t2>0){
			for(int i=0;i<abs(t2+1);i++)	printf("L");
		}
		else {
			for(int i=0;i<abs(t2+1);i++)	printf("R");
		}
		if(t1>0)	printf("U\n");
		else printf("D\n");
	}
	return 0;
}

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

int N;
int s[101010];

// 左から順に辿り着く座標
// 0, A, A-B, 2A-B, 2A-2B, 3A-2B, 3A-3B, 4A-3B ...
// C = A - Bとすると
// 0, A, C, A + C, 2C, 2C + A, 3C, ...
// xC + AがN-1になる必要がある。-> A, A+C, ... はN-1 - C, N-1 - 2C ...と書ける。
// xとCを決め打ちしたときに正数AとB(A > B)が定まればよい。

int main(){
  cin >> N;
  for(int i=0; i < N; ++i) cin >> s[i];
  
  long ans = 0;
  for(int C = 1; C < N; ++C) {
    long sum = 0;
    vector<bool> used(N);
    for(int x = 0; x * C < N; ++x) {
      long A = N-1 - x * C;
      long B = A - C;
      if(A <= 0 || B <= 0 || A < B) break;
      
      if(used[x * C]) break;
      sum += s[x * C];
      used[x * C] = true;
      
      if(used[N-1 - x * C]) break;
      sum += s[N-1 - x * C];
      used[N-1 - x * C] = true;
      
      ans = max(ans, sum);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdio>

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define vec vector
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef long long ll;

ll N, M;
ll L;
string S, T;

ll gcd(ll a, ll b) {
   if (b == 0) return a;
   return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
   return ( a * b / gcd(a, b));
}

#define min(a, b) ((a < b) ? a : b)

int main() {
   cin >> N >> M;
   cin >> S;
   cin >> T;
   L = lcm(N, M);
//for (int i=0;i<min(N,M);i++) {
   for (ll i=0;;i++) {
      if (i*L/M>=N || i*L/N>=M) {
         break;
      }
      if (S[i*L/M] != T[i*L/N]) {
         cout << -1 << endl;
         return 0;
      }
   }
   cout << L << endl;
   return 0;
}


Measured memory_bytes: 512
n,m=map(int,input().split())
A=[[i,list(map(int,input().split()))] for i in range(m)]
A.sort(key=lambda x:x[1][1])
B={}
for x,y in A:
    if y[0] not in B:
        B[y[0]]=1
        y[1]=1
    else:
        B[y[0]] +=1
        y[1]=B[y[0]]

for i in sorted(A,key=lambda x:x[0]):
    print(str(i[1][0]).zfill(6)+str(i[1][1]).zfill(6))

Measured memory_bytes: 47200
#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() {
  double X, Y, Z;
  cin >> X >> Y >> Z;

  // 最初に左端を切り捨てる
  // あとは Y + Z で割る
  int ans = (X - Z) / (Y + Z);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3700
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0


[N, X] = inpl()
listL = inpl()
nlistD = np.array([0]*(N+1))

for i in range(len(nlistD)-1):
    nlistD[i+1] = nlistD[i]+listL[i]

ans = (nlistD<=X).sum()


print(ans)

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll k, a, b;

int main(){
    cin >> k >> a >> b;
    k -= a;
    ll ans = 1;
    if (k <= 0) {
        cout << ans << endl;
        return 0;
    }
    if (a <= b) {
        cout << -1 << endl;
        return 0;
    }
    cout << 1 + 2 * (k/(a-b) + (k%(a-b)>0)) << endl;
}
































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

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

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

int D, G;
vector<int> p(111), c(111);
int mi=1e9;

void bit_search(int i, int g, int cnt, vector<bool> f){
    //cout << i <<" "<< g <<" "<< cnt << endl;
    if(i==D){
        if(g>=G){
            mi = min(mi, cnt);
            return;
        }
        else {
            for(int j=f.size()-1; j>=0; j--){
                //cout << f[j] <<" ";
                if(f[j]==false){
                    int c=0;
                    while(g<G && p[j]>c){
                        g += (j+1)*100;
                        cnt++;
                        c++;
                    }
                }
            }
            //puts("");
            mi = min(mi, cnt);
            return;
        }
    }
    
    f.push_back(true);
    bit_search(i+1, g+((i+1)*p[i]*100+c[i]), cnt+p[i], f);
    f.pop_back();
    
    f.push_back(false);
    bit_search(i+1, g, cnt, f);
    f.pop_back();
}


int main(){
    cin >> D >> G;
    for(int i=0; i<D; i++) cin >> p[i] >> c[i];
    vector<bool> f;
    
    bit_search(0, 0, 0, f);
    
    cout << mi << endl;
}


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

typedef long long ll;
typedef complex<double> Vec;

ll N;
const ll MOD = 998244353;
vector<ll> Pow;
vector<ll> Y;
vector<pair<ll, ll>> XY;
map<ll, ll> IY;
ll R;

void prepare() {
  Pow.push_back(0);
  for (ll i = 1; i <= N; ++i) {
    Pow.push_back((Pow.back() * 2 + 1) % MOD);
  }
}

vector<ll> BIT;
void add(ll i, ll x) {
  for (; i <= N; i += i & -i) BIT[i] += x;
}
ll sum(ll i) {
  ll res = 0;
  for (; i > 0; i -= i & -i) res += BIT[i];
  return res;
}
void solve() {
  R = N * Pow[N] % MOD;
  for (ll i = 0; i < N; ++i) {
    (R += MOD - 2 * (Pow[i] + Pow[N - 1 - i]) % MOD) %= MOD;
  }
  BIT.resize(N + 1);
  for (ll cnt = 0; cnt < N; ++cnt) {
    ll y = XY[cnt].second;
    ll i = IY.at(y) + 1;
    ll left = sum(i);
    ll right = cnt - left;
    assert(left >= 0 && right >= 0);
    (R += Pow[left]) %= MOD;
    (R += Pow[right]) %= MOD;
    add(i, 1);
  }
  BIT.clear();
  BIT.resize(N + 1);
  for (ll cnt = 0; cnt < N; ++cnt) {
    ll y = XY[N - 1 - cnt].second;
    ll i = IY.at(y) + 1;
    ll left = sum(i);
    ll right = cnt - left;
    assert(left >= 0 && right >= 0);
    (R += Pow[left]) %= MOD;
    (R += Pow[right]) %= MOD;
    add(i, 1);
  }
}

int main() {
  cin >> N;
  prepare();
  for (ll i = 0; i < N; ++i) {
    ll x, y;
    cin >> x >> y;
    Y.push_back(y);
    XY.push_back(make_pair(x, y));
  }
  sort(Y.begin(), Y.end());
  for (ll i = 0; i < N; ++i) {
    IY[Y[i]] = i;
  }
  sort(XY.begin(), XY.end());
  solve();
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 21996
#include<stdio.h>

int main() {
    //変数の宣言
    int x,y; //入力
    int i, j, k, total;
    int count; //カウンター
    
    while (1) {
        scanf("%d %d", &x, &y);
        
        count = 0; //空にする
        
        //ループ終了
        if (x==0 && y==0) {
            break;
        }
        
        for (i=1; i<=x; i++) {
            for (j=1; j<=x; j++) {
                for (k=1; k<=x; k++) {
                    if (i == j || j == k || k == i) {
                        //１つも被ったらダメ
                    }else{
                        total = i + j + k;
                        if (total == y) {
                            count++;
                        }
                    }
                }
            }
        }
        
        printf("%d\n", count/6); //3のバラバラのものを並べるとき、その数の組み合わせがかぶるのは６通り
        
    }
    
    
    
    return 0;
}



Measured memory_bytes: 2048
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
int n,flg=1;
string upp[4]={".",".","#","#"}, dwn[4]={".","#","#","."}, lst[2],nw[2];
char ss[4];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
int main()
{
	//freopen("Long Blackboard.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n);
	while( true )
	{
		for(RG int i=0;i<4;i++)
		{
			nw[0]= flg ? lst[0]+upp[i] : upp[i]+lst[0];
			nw[1]= flg ? lst[1]+dwn[i] : dwn[i]+lst[1];
			cout<<nw[0]<<endl<<nw[1]<<endl;
			scanf("%s",ss);
			if(ss[0]=='T')
			{
				lst[0]=nw[0];
				lst[1]=nw[1];
				if(lst[0].size()==n) return 0;
				break;
			}
			if(i==3) flg=0;
		}
	}
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 724
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define mod 998244353
#define pi 3.1415926535
#define fi first
#define se second
#define vll vector<ll>
#define vpll vector<pair <ll,ll> >
#define vvll vector< vll >
#define str string
#define umap unordered_map
#define uset unordered_set
#define rep(i,n) for(ll i=0;i<n;i++)
#define repA(i,s,n) for(ll i=s;i<=n;i++)
#define repD(i,s,n) for(ll i=s;i>=n;i--)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define elif else if
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ALL(v) v.begin(),v.end()
#define sortA(v) sort(ALL(v))
#define sortD(v) sort(ALL(v),greater <ll> ())
#define print(v) for(auto itr:v) cout<<*itr<<" ";
#define sz size()
#define nl cout<<"\n";
using namespace std;
ll factorial(ll n){return (n==1||n==0)?1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll powerMod(ll x,ll y,ll m){if(y==0)return 1;ll p=powerMod(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll modInverse(ll a,ll m){return powerMod(a,m-2,m);}
ll gcd(ll a,ll b){if(a==0){return b;}else if(b==0){return a;}else{if(a>b){return gcd(a%b,b);}else{return gcd(b%a,a);}}}

int main(){
    fast
    ll n=0,k=0;
    cin>>n>>k;
    vll v;
    rep(i,n){
        ll x=0;
        cin>>x;
        v.pb(x);
    }
    sortA(v);
    ll sum=0;
    rep(i,k){
        sum+=v[i];
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3620
fun main(args: Array<String>) {

    val k = readLine()!!.toInt()

    var ans = 0

    for (a in 1..k) {
        for (b in 1..k) {
            for (c in 1..k) {
                ans += gcd(a, b, c)
            }
        }
    }

    println(ans)
}

fun gcd(a: Int, b: Int, c: Int): Int {

    val d = if (a > b) {
        gcd(a, b)
    } else {
        gcd(b, a)
    }

    val ans = if (c > d) {
        gcd(c, d)
    } else {
        gcd(d, c)
    }

    return ans
}

fun gcd(a: Int, b: Int): Int {

    val r = a % b
    if (r == 0) {
        return b
    }

    return gcd(b, r)
}

Measured memory_bytes: 35108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+100;
ll x,d,ans; int n;
struct Node{
    ll p,l,r;
}a[N];
bool cmp(Node &a,Node &b){
    if(a.p!=b.p) return a.p<b.p;
    else return a.l<b.l;
}
int main(){
    scanf("%d %lld %lld",&n,&x,&d);
    if(d==0){
        printf("%d\n",x==0?1:n+1);
        return 0;
    }
    if(d<0) x=-x,d=-d;
    for(int i=0;i<=n;++i){
        a[i].p=i*x%d;
        a[i].l=1LL*i*(i-1)/2+i*x/d;
        a[i].r=1LL*(n*2-1-i)*i/2+i*x/d;
    }
    sort(a,a+n+1,cmp);
    for(int i=0,j=0;i<=n;i=j){
        ll l=a[i].l,r=a[i].r;
        while(j<=n&&a[j].p==a[i].p&&a[j].l<=r){
            r=max(r,a[j].r); j++;
        }
        ans+=r-l+1;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int m[50];
int n[50];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l=0;
    while(true){
        cin >> m[l] >> n[l] ;
        if(m[l]==0)break;
        l++;
    }
    for(int i=0;i<l;i++){
    bool c[7368792];
    for(int j=m[i];j<=7368792;j++){
        c[j]=false;
    }
    for(int k=m[i];k<=7368792;k++){
        if(c[k]==false){
            if(n[i]==0){
            cout<<k<<"\n";
            break;
        }
            n[i]--;
            for(int h=k;h<=7368792;h+=k){
                c[h]=true;
            }
        }
        else{
        }
    }
    }
}


Measured memory_bytes: 10372
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    string S(100030,'A');
    cin>>S;
    int t=0,fie[100030]={0};
    fie[0]=1;
    for(int i=1;S[i]!='A';i++){
        if(fie[i-1]){
            if(S.substr(i-1,5)=="dream")fie[i+4]=1;
            if(S.substr(i-1,5)=="erase")fie[i+4]=1;
            if(S.substr(i-1,6)=="eraser")fie[i+5]=1;
            if(S.substr(i-1,7)=="dreamer")fie[i+6]=1;
        }
    }
/*
    for(int i=0;i<20;i++){
        cout<<fie[i];
    }
    puts("");
    for(int i=0;i<20;i++){
        cout<<S[i];
    }
    puts("");
*/
    for(int i=100015;;i--){
        if(S[i]!='A'){
//            cout<<i<<endl;
            if(fie[i]==1)puts("YES");
            else puts("NO");
            break;
        }
    }
    return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; cin >> n;
    ll sum = 0;
    map<ll, ll> mp;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        mp[a]++;
        sum += a;
    }
    int q; cin >> q;
    while (q--) {
        ll b, c; cin >> b >> c;
        sum += (c - b) * mp[b];
        cout << sum << '\n';
        mp[c] += mp[b];
        mp.erase(b);
    }
    return 0;
}


Measured memory_bytes: 7568
#include <iostream>
using namespace std;
typedef long long ll;

ll M;
ll N;
static const ll mod = 1000000007;

ll pow(ll n, ll p, ll mod){
    if(p==0) return 1;
    ll res = pow(n * n % mod, p /2, mod);
    if(p % 2 == 1) res = res * n % mod;
    return res;
}

int main(void){
    cin >> M >> N;
    cout << pow(M, N, mod) << endl;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string s;
    cin >> s;
    lint k;
    cin >> k;

    if (s[0] == '1') {
        int c = 0;
        rep(i, s.size()) {
            if (s[i] == '1') c++;
            else break;
        }
        if (k <= c) cout << '1' << endl;
        else cout << s[c] << endl;
    }
    else {
        cout << s[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
n,m=map(int,input().split())
tmp=[-1]*n
for _ in range(m):
    s,c=map(int,input().split())
    s-=1
    if tmp[s]<0:
        tmp[s]=c
    if tmp[s]!=c:
        print(-1)
        sys.exit()
if tmp[0]==0 and n>1:
    print(-1)
    sys.exit()
if tmp[0]<0 and n>1:
    tmp[0]=1
if n==1 and tmp[0]==-1:
    tmp[0]=0
for i in range(1,n):
    if tmp[i]<0:
        tmp[i]=0
for i in tmp:
    print(i,end='')

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

bool is_valid(int k, int N, int M, const vector<vector<int>> &A){
    vector<int> idx(N, 0);
    vector<bool> used(M + 1, true);
    used[0] = false;
    int n_used = M;
    while (true){
        vector<int> freq(M + 1, 0);
        for (int i = 0; i != N; ++i){
            while (idx[i] < M and not used[A[i][idx[i]]]){
                ++idx[i];
                if (idx[i] == M) return false;
            }
            ++freq[A[i][idx[i]]];
        }
        bool ok = true;
        for (int m = 1; m <= M; ++m){
            if (freq[m] > k){
                used[m] = false;
                --n_used;
                ok = false;
            }
        }
        if (ok) return true;
        if (n_used * k < N) return false;
    }
}


int solve(int N, int M, const vector<vector<int>> &A){
    for (int k = 1; k <= N; ++k){
        if (is_valid(k, N, M, A)){
            return k;
        }
    }
    return N;
}


int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> A(N, vector<int>(M));
    for (auto & row : A){
        for (auto &cell : row) cin >> cell;
    }
    cout << solve(N, M, A) << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
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 long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 998244353
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}

int main(){
    ll n;
    cin >> n;
    vector<ll> s;
    for (ll i=0;i<n;i++){
        ll a;
        cin >> a;
        s.push_back(a);
    }
    sort(s.begin(),s.end());
    ll q;
    cin >> q;
    ll t[q];
    for (ll i=0;i<q;i++){
        cin >> t[i];
    }
    ll ans=0;
    for (ll i=0;i<q;i++){
        auto x=lower_bound(s.begin(),s.end(),t[i]),y=upper_bound(s.begin(),s.end(),t[i]);
        if (y-x){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}    



Measured memory_bytes: 4120
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r; cin >> r;
  if(r < 1200) cout << "ABC" << endl;
  else if(r < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const ll MOD = 1000000007LL;
/*メモ XOR問題のまとめ
性質 1「交換則、結合則が成り立つ」
　　 2「a xor a = 0」
　　 3「ある数xのb番目のビットが1である <=> x mod 2^(b+1) ≧ 2^b」
　　 4「0≦aのとき、4a, 4a+1, 4a+2, 4a+3のxor和は0」
方針 
!!!!!1「xor計算は各ビットで独立なので別々に計算」
　　 2「trieを使ったxorの最大最小探索がある解説」
・しゃくとり法は[ｌ,r)で考えるとわかりやすいよ！
*/
int main(){
    string s;
    std::cin >> s;
    if(s[0]==s[1]||s[3]==s[2]||s[2]==s[1])std::cout << "Bad" << std::endl;
    else std::cout << "Good" << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    ll n;
    cin>>n;
    ll a[100002];
    ll b[100001];
    rep(i,n+1)cin>>a[i];
    rep(i,n)cin>>b[i];
    ll sum=0;
    rep(i,n+1)sum+=a[i];
    ll ans=0;
    rep(i,n){
        int x=a[i];
        a[i]=(a[i]>=b[i])?a[i]-b[i]:0;
        b[i]=max(b[i]-x,(ll)0);

        x=a[i+1];
        a[i+1]=(a[i+1]>=b[i])?a[i+1]-b[i]:0;
        b[i]=max(b[i]-x,(ll)0); 
        
    }

    ll xx=0;
    rep(i,n+1)xx+=a[i];
    ans=sum-xx;

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

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

using ll = long long;

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

    ll q,h,s,d;
    cin>>q>>h>>s>>d;
    ll n;
    cin>>n;

    ll ans=0;

    if(n>=2)
    {
        ll p=min(min(q*8,h*4),min(s*2,d));
        ans=(n/2)*p;
    }

    if(n%2==1)
    {
        ll p=min(min(q*4,h*2),s);
        ans+=p;
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
using namespace std;

using ll = long long;

#define rep_init(i, init, n) for(ll i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

int log10(ll B)
{
	int count = 0;
	while (true)
	{
		B /= 10;
		if (B == 0) break;
		++count;
	}

	return count;
}

int main()
{
	ll N;
	cin >> N;

	vector<ll> A(N);
	rep(i, N)
	{
		cin >> A[i];
		if (A[i] == 0)
		{
			cout << 0 << endl;
			return 0;
		}
	}

	ll mul = 1;
	rep(i, N)
	{
		if (log10(mul) + log10(A[i]) >= 18 && mul * A[i] != 1000000000000000000)
		{
			mul = -1;
			break;
		}

		mul *= A[i];
		if (mul > 1000000000000000000)
		{
			mul = -1;
			break;
		}
	}

	cout << mul << endl;

	return 0;
}

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

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

    vector<int> A(n - 1);
    REP(i, n - 1) A[i] = i + 1;

    bool G[n][n] = {};
    REP(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a][b] = true;
        G[b][a] = true;
    }

    int cnt = 0;
    do{
        int s = 0, e;
        bool f = true;
        REP(i, A.size()){
            e = A[i];
            if(G[s][e]);
            else{
                f = false; break;
            }
            if(G[e][s]);
            else{
                f = false; break;
            }
            s = A[i];
        }
        if(f) cnt++;
    }while(next_permutation(A.begin(), A.end()));

    cout << cnt << endl;

    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end



int main(){
   int n; cin>>n;
   ll res=0,sum=0;
   rep(i,0,n){
      int x; cin>>x;
      sum+=x;
      if(x==0){
         res+=sum/2;
         sum=0;
      }
   }
   if(sum)res+=sum/2;
   cout<<res<<endl;
   return 0;
}

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


def solve(N: int, X: int, T: int):
    for i in range(10000):
        if X * i >= N:
            return T * i
    raise

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    print(solve(N, X, T))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9180
#include <stdio.h>
#include <stdlib.h>


int main(void) 
{
    int a,b,c,d;
  
    scanf("%d%d%d%d", &a, &b, &c, &d);
    
    if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
      printf("Yes\n");
    }
    else {
      printf("No\n");
    }
    
    return(0);
}      

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

#define MOD 1000000007

int main()
{
  ll n, m, k;
  cin >> n >> m >> k;

  vi a, b;
  rep(i, n)
  {
    ll _a;
    cin >> _a;
    a.push_back(_a);
  }

  rep(i, m)
  {
    ll _b;
    cin >> _b;
    b.push_back(_b);
  }

  int ans = 0;

  ll a_k = 0;
  int a_index = -1;

  ll b_k = 0;
  int b_index = -1;

  // b読める分だけ読む
  while(b_index + 1 < b.size() && b_k + b[b_index + 1] <= k) {
    b_index++;
    b_k += b[b_index];
  }

  for (int i = 0; i <= n; i++)
  {
    if (i > 0)
    {
      a_index++;
      a_k += a[a_index];
    }

    // bを減らす
    while (a_k + b_k > k && b_index >= 0)
    {
      b_k -= b[b_index];
      b_index--;
    }

    if (a_k + b_k <= k)
    {
      ans = max(ans, a_index + b_index + 2);
    }
  }

  cout << ans << endl;
}


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

int n, MAX = 100000;
int h[100010], dp[100010];

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> h[i];
		dp[i] = 1e9 + 7;
	}
	dp[1] = 0;
	for (int i = 1; i <= n; i++)
	{
		dp[i + 1] = min(abs(h[i] - h[i + 1]) + dp[i], dp[i + 1]);
		dp[i + 2] = min(abs(h[i] - h[i + 2]) + dp[i], dp[i + 2]);
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

Int par[200001];
Int sz[200001];
bool used[200001];

Int root(Int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
}

void unite(Int x, Int y) {
    Int rx = root(x);
    Int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
}

int main() {
    ios::sync_with_stdio(false);
    Int n;
    cin >> n;
    vector<Int> a(n + 1);
    for (Int i = 1; i <= n; i++) {
        Int x;
        cin >> x;
        a[x] = i;
        par[i] = i;
        sz[i] = 1;
    }
    Int res = 0;
    for (Int i = n; i >= 1; i--) {
        Int l, r;
        l = r = 1;
        Int index = a[i];
        if (index > 1) {
            if (used[index - 1]) {
                Int rindex = root(index - 1);
                l += sz[rindex];
                sz[index] += sz[rindex];
                unite(rindex, index);
            }
        }
        if (index < n) {
            if (used[index + 1]) {                
                Int rindex = root(index + 1);
                r += sz[rindex];
                sz[index] += sz[rindex];
                unite(rindex, index);                
            }            
        }
        used[index] = true;
        /* for (Int i = 1; i <= n; i++) cout << par[i] << " ";
        cout << endl;
        for (Int i = 1; i <= n; i++) cout << sz[i] << " ";
        cout << endl;
        dump(l * r * i); */
        res += l * r * i;
    }
    dump(res);
    return 0;
}

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

using namespace std;

#define pb            push_back
#define mp            make_pair
#define po            pop_back
#define fi            first
#define se            second
#define mxn           100005
#define ll            long long int
#define ldb           long double
#define fr(i,a,b,k)   for(int i=a ; i<b ; i+=k)
#define frr(i,a,b,k)  for(int i=a ; i>b ; i-=k)
#define all(v)        v.begin(),v.end()
#define endl          "\n"
#define deg(x)        cout<<endl<<#x<<" = "<<(x)<<endl;
#define casep(x)      cout<<"Case #"<<(x)<<": ";
#define fast          ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

typedef pair<int,int> pp;
typedef vector<int> vi;
typedef vector<pp> vpp;
typedef vector<vi> vvi;

const int inf = INT_MAX;

ll power(int a, int n, int mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
int gcd(int a,int b){ return __gcd(a,b);}
int lcm(int a,int b){return a*b/__gcd(a,b);}
vector<vector<int>> adj;
bool visited[mxn];


void solve(ll test){

    ll n;
    cin >> n;

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

    ll ans = 0;
    for(int i=1 ; i<n ; i++) {
        if(a[i] < a[i-1]) {
            ans += abs(a[i-1]-a[i]);
            a[i] = a[i-1];
        }
    }

    cout << ans;

}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve(i);
        cout << endl;
    }
    return 0;
}


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

int main()
{
	set<long long>s;
	int n; cin>>n;
	long long a;
	for(int i=0; i<n; i++)
	{
		cin>>a;
		s.insert(a);
	}
	if(n==s.size()) cout<<"YES"<<endl;
	else cout<<"NO\n";
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int mod=1000000007;
  int N;
  cin>>N;
  string s,t;
  cin>>s>>t;
  if(N==1){
    cout<<3<<endl;
  }
  else if(N==2){
    cout<<6<<endl;
  }
  else{
  vector<long> dp(N);
  dp.at(0)=3;
  dp.at(1)=6;
  for (int i = 2; i < N; i++) {
    if(s.at(i)==t.at(i)){
      if(s.at(i-1)==t.at(i-1)){
        dp.at(i)=2*dp.at(i-1)%mod;
      }
      else{
        dp.at(i)=dp.at(i-1);
      }
    }
    else{
      if(s.at(i-2)==t.at(i-2)){
        dp.at(i)=2*dp.at(i-2)%mod;
      }
      else{
        dp.at(i)=3*dp.at(i-2)%mod;
      }
    }
  }
    cout<<dp.at(N-1)<<endl;
  }

}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
main(){
  int z=0,zero,n=1,x,ans[100000],frg=0;
  while(n!=0){
    cin>>n;
    frg=0;
    zero=-1;
    for(int i=0;i<n;i++){
      cin>>x;
      if(x>=2){
	frg=1;
      }else if(x==0){
	zero++;
      }
    }
    if(frg==1){
      ans[z]=n-zero;
    }else{
      ans[z]=-1;
    }
    z++;
  }
  for(int i=0;i<z-1;i++){
    if(ans[i]>=0){
      cout<<ans[i]<<endl;
    }else{
      cout<<"NA"<<endl;
    }
  }
  return(0);
}



Measured memory_bytes: 3116