akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

const int INF = 1000000000;

int main() {
    int N;
    cin >> N;
    vector<int> G[N];
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<int> que_1;
    vector<int> dist_1(N, INF);
    que_1.push(0);
    dist_1[0] = 0;
    while (!que_1.empty()) {
        int u = que_1.front(); que_1.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (dist_1[v] != INF) continue;
            que_1.push(v);
            dist_1[v] = dist_1[u] + 1;
        }
    }

    queue<int> que_n;
    vector<int> dist_n(N, INF);
    que_n.push(N - 1);
    dist_n[N - 1] = 0;
    while (!que_n.empty()) {
        int u = que_n.front(); que_n.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (dist_n[v] != INF) continue;
            que_n.push(v);
            dist_n[v] = dist_n[u] + 1;
        }
    }

    int white = 0, black = 0;
    for (int i = 0; i < N; i++) {
        if (dist_1[i] <= dist_n[i]) {
            black++;
        } else {
            white++;
        }
    }

    if (black > white) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }

    return 0;
}

Measured memory_bytes: 6528
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int x = sc.intarr[0];
            int a = sc.intarr[0];
            int b = sc.intarr[0];

            int ans = (x - a) % b;

            wr.wri(ans);
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13268
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

d,g = li()
pc = []
for _ in range(d):
    pc.append(tuple(li()))
    
ans = 10**10
for bit in range(1<<d):
    point = 0
    probs = 0
    for b in range(d):
        if bit & (1<<b):
            point += (100*(b+1)*pc[b][0] + pc[b][1])
            probs += pc[b][0]
            
    if point >= g:
        ans = min(ans, probs)
           
    else:

        res = g-point
        for q in range(d-1, -1, -1):
            if bit & (1<<q):
                continue
            
            if 100*(q+1)*(pc[q][0]-1) >= res:
                probs += -(-res // (100*(q+1)))
                res = 0
                
            else:
                res -= 100*(q+1)*(pc[q][0]-1)
                probs += pc[q][0]
        
        if res == 0:        
            ans = min(ans,probs)

            
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>

using namespace std;

int main(void){
	
	int n;
	double x[3]={0},y[3]={0},r,a,b,c,d[2]={0},e[2]={0},f[2]={0},l,m;

	scanf("%d",&n);

	for(int i=0;i<n;i++){
		
		a=b=c=r=l=m=0;
		for(int i=0;i<2;i++){
			d[i]=e[i]=f[i]=0;
		}
		for(int i=0;i<3;i++){
			x[i]=y[i]=0;
		}

		scanf("%lf %lf %lf %lf %lf %lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2]);

		a=sqrt((x[0]-x[1])*(x[0]-x[1])+(y[0]-y[1])*(y[0]-y[1]));	//ツ各ツ陛督づ個陳キツつウ
		b=sqrt((x[2]-x[1])*(x[2]-x[1])+(y[2]-y[1])*(y[2]-y[1]));
		c=sqrt((x[0]-x[2])*(x[0]-x[2])+(y[0]-y[2])*(y[0]-y[2]));	
	
		r=a*b*c/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));			//ツ外ツ静堋円ツづ個板シツ径
		
		d[0]=2*(x[1]-x[0]);
		e[0]=2*(y[1]-y[0]);
		f[0]=x[0]*x[0]-x[1]*x[1]+y[0]*y[0]-y[1]*y[1];
		d[1]=2*(x[2]-x[0]);
		e[1]=2*(y[2]-y[0]);
		f[1]=x[0]*x[0]-x[2]*x[2]+y[0]*y[0]-y[2]*y[2];

		l=(e[0]*f[1]-e[1]*f[0])/(d[0]*e[1]-d[1]*e[0]);
		m=(f[0]*d[1]-f[1]*d[0])/(d[0]*e[1]-d[1]*e[0]);

		l=round(l*1000)/1000;
		m=round(m*1000)/1000;
		r=round(r*1000)/1000;
		
		printf("%.03lf %.03lf %.03lf\n",l,m,r);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};



int32_t main()
{

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

#ifndef ONLINE_JUDGE
freopen("input.txt","rt",stdin);
freopen("output.txt","wt",stdout);
#endif 


 int n,m,k;
   cin>>n>>m>>k;

   char v[n][m];
   int ans=0;


   for(int i = 0; i < n; i++)
   	 for(int j = 0; j < m; j++)
   	 	cin>>v[i][j];

   int ar = (1LL << n) - 1;
   int a = (1LL << m) - 1;

   for(int x = 0; x <= ar; x++){
   	for(int y = 0; y <= a; y++){
   		vector<int> Rows, Cols;

   		for(int i = 0; i < n; i++)
   			if((x >> i) & 1)
   				Rows.push_back(i);

   		for(int i = 0; i < m; i++)
   			if((y >> i) & 1)
   				Cols.push_back(i);
   	

   		for(int i = 0; i < Rows.size(); i++){
   			for(int j = 0; j < m; j++){
   				if(v[Rows[i]][j] == '.')
   					v[Rows[i]][j] = 'x';
   				else if(v[Rows[i]][j] == '#')
   					v[Rows[i]][j] = '$';
   			}
   		}

   		for(int i = 0; i < Cols.size(); i++){
   			for(int j = 0; j < n; j++){
   				if(v[j][Cols[i]] == '.')
   					v[j][Cols[i]] = 'x';
   				else if(v[j][Cols[i]] == '#')
   					v[j][Cols[i]] = '$';
   			}
   		}

   		int cnt = 0;
   		for(int i = 0; i < n; i++){
   			for(int j = 0; j < m; j++){
   				if(v[i][j] == '#')
   					cnt++;
   			}
   		}

   		if(cnt == k)
   			ans++;
		
		for(int i = 0; i < Rows.size(); i++){
   			for(int j = 0; j < m; j++){
   				if(v[Rows[i]][j] == 'x')
   					v[Rows[i]][j] = '.';
				else if(v[Rows[i]][j] == '$')
					v[Rows[i]][j] = '#';
   			}
   		}

   		for(int i = 0; i < Cols.size(); i++){
   			for(int j = 0; j < n; j++){
   				if(v[j][Cols[i]] == 'x')
   					v[j][Cols[i]] = '.';
   				else if(v[j][Cols[i]] == '$')
   					v[j][Cols[i]] = '#';
   			}
   		}   		
   	}
   }

   cout<<ans;
   return 0;

}


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

int main(){
	int angle = 90;
	char a[8][8],b[8][8],c[8][8],d[8][8];
	for(int i = 0;i < 8;++i){
		for(int j = 0;j < 8;++j){
			cin >> a[i][j];
		}
	}
	for(int i = 0;i < 8;++i){
		for(int j = 0;j < 8;++j){
			b[i][j] = a[7 - j][i];
		}
	}
	cout << angle << endl;
	for(int i = 0;i < 8;++i){
		for(int j = 0;j < 8;++j){
			cout << b[i][j];
		}
		cout << endl;
	}
	for(int i = 0;i < 8;++i){
		for(int j = 0;j < 8;++j){
			c[i][j] = b[7 - j][i];
		}
	}
	cout << angle * 2 << endl;
	for(int i = 0;i < 8;++i){
		for(int j = 0;j < 8;++j){
			cout << c[i][j];
		}
		cout << endl;
	}
	for(int i = 0;i < 8;++i){
		for(int j = 0;j < 8;++j){
			d[i][j] = c[7 - j][i];
		}
	}
	cout << angle * 3 << endl;
	for(int i = 0;i < 8;++i){
		for(int j = 0;j < 8;++j){
			cout << d[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, atan2
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**8)

INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()

ans = INF
for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
        ans = min(ans, n // i + i - 2)


print(ans)


Measured memory_bytes: 41836
#include<iostream>
using namespace std;
int main(){
    char S[4];
    bool res = false;
    for(int i = 0;i < 4;i++)cin>>S[i];
    
    for(int i = 0;i < 3;i++){
        if(S[i] == S[i+1])res = true;
    }
    if(res){
    cout<<"Bad";
    }else{
    cout<<"Good";    
    }
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
L = []
R = []
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

a = 1
b = N

for i in range(M):
    if(L[i] >= a and R[i] >= b):
        a = L[i]
    if(L[i] <= a and R[i] <= b):
        b = R[i]
    if(L[i] >= a and R[i] <= b):
        a = L[i]
        b = R[i]
    if(R[i] < a or L[i] > b):
        print(0)
        exit()


print(b-a+1)

Measured memory_bytes: 16896
h, w = map(int, input().split())
ans = 0
if (h % 2 == 0) or (w % 2 == 0):
    ans = (h * w) // 2
else:
    ans = (h * w) // 2 + 1

if h == 1 or w == 1:
    ans = 1
print(ans)

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;++i) {
    cin >> h[i];
  }
  int cnt = 0;
  int ma = 0;
  for(int i=0;i<n;++i) {
    if(h[i] < ma) continue;
    cnt++;
    ma = max(ma, h[i]);
  }
  cout << cnt << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

struct edge
{
	int u, v, id;
};

int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m;
	cin >> n >> m;
	vector<bool> deg(n);
	vector<vector<edge>> adj(n);
	vector<pair<int, int>> how(m);
	for (int i = 0, u, v; i < m; ++i)
	{
		cin >> u >> v;
		--u, --v;
		adj[u].push_back({ u, v, i });
		adj[v].push_back({ v, u, i });
		how[i] = { u, v };
		deg[u] = deg[u]^true;
	}

	vector<bool> mark(n);
	function<void(int, int, int)> dfs = [&](int u, int p, int id)
	{
		mark[u] = true;
		for (auto v : adj[u])
			if (!mark[v.v])
				dfs(v.v, u, v.id);
		if (deg[u] && p != -1)
		{
			swap(how[id].F, how[id].S);
			deg[p] = deg[p]^true;
		}
	};

	dfs(0, -1, -1);
	if (!deg[0])
	{
		for (auto i : how)
			cout << i.F+1 << " " << i.S+1 << "\n";
	}
	else
		cout << "-1\n";

	return 0;
}


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

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define CLOSEALL() fclose(stdin), fclose(stdout)

const int MAXN = 1e5 + 10;
typedef long long i64;

i64 K;
i64 N, M;
i64 answer[MAXN];
i64 a[MAXN], idx[MAXN];

i64 stk[MAXN], top;

bool vis[MAXN];

int main()
{
	//REDIRECT("rabbit");
	
	scanf("%lld", &N);
	for(int i = 1; i <= N; i++)
		scanf("%lld", &a[i]), idx[i] = i;
		
	for(int i = N; i >= 1; i--)
		a[i] -= a[i-1];
		
	scanf("%lld%lld", &M, &K);
	for(int i = 1;i <= M; i++)
	{
		int t;
		scanf("%lld", &t);
		std::swap(idx[t], idx[t + 1]);
	}
	
	for(int i = 1; i <= N; i++)
		if(!vis[i])
		{
			int cur = i;
			top = 0;

			while(!vis[cur])
				stk[++top] = cur, vis[cur] = true, cur = idx[cur];

			for(int k = 1; k <= top; k++)
				answer[stk[k]] = a[stk[(K + k - 1) % top + 1]];
		}

	for(int i = 1; i <= N; i++)
		answer[i] += answer[i-1],
		printf("%lld\n", answer[i]);

	CLOSEALL();
	return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(void){
  int n; cin >> n;
  int A[3] = {0, 0, 0};
  REP(i, n){
    int k; cin >> k;
    if(k % 4 == 0) A[0]++;
    else if(k % 2 == 0) A[1]++;
    else A[2]++;
  }
  if(A[1] == 0){
    if(A[2] <= A[0] + 1) cout << "Yes" << BR;
    else cout << "No" << BR;
  }
  else{
    if(A[2] <= A[0]) cout << "Yes" << BR;
    else cout << "No" << BR;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 2005
using namespace std;
int n,m,q,node[li][li],ledge[li][li],uedge[li][li];
char s[li][li];
int get_node(int lx,int ly,int rx,int ry){
	return node[rx][ry]-node[rx][ly-1]-node[lx-1][ry]+node[lx-1][ly-1];
}
int get_edgel(int lx,int ly,int rx,int ry){
	return ledge[rx][ry]-ledge[rx][ly-1]-ledge[lx-1][ry]+ledge[lx-1][ly-1];
}
int get_edgeu(int lx,int ly,int rx,int ry){
	return uedge[rx][ry]-uedge[rx][ly-1]-uedge[lx-1][ry]+uedge[lx-1][ly-1];
}
int get_edge(int lx,int ly,int rx,int ry){
	return get_edgel(lx,ly,rx,ry)+get_edgeu(lx,ly,rx,ry)-get_edgeu(lx,ly,lx,ry)-get_edgel(lx,ly,rx,ly);
}
int main(){
	scanf("%d %d %d",&n,&m,&q);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			scanf(" %c",&s[i][j]);
			node[i][j]=node[i-1][j]+node[i][j-1]-node[i-1][j-1]+(s[i][j]=='1');
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			ledge[i][j]=ledge[i-1][j]+ledge[i][j-1]-ledge[i-1][j-1];
			uedge[i][j]=uedge[i-1][j]+uedge[i][j-1]-uedge[i-1][j-1];
			if(s[i][j]=='1'){
				if(s[i-1][j]=='1') uedge[i][j]+=1;
				if(s[i][j-1]=='1') ledge[i][j]+=1;
			}
		}	
	}
	for(int i=1;i<=q;i++){
		int lx,rx,ly,ry;
		scanf("%d %d %d %d",&lx,&ly,&rx,&ry);
		printf("%d\n",get_node(lx,ly,rx,ry)-get_edge(lx,ly,rx,ry));
	}
	return 0;
}



Measured memory_bytes: 52864
S=input()
N=len(S)+1
A=[0]*(N)
for i in range(N-1):
    if S[i]=="<":
        A[i+1]=A[i]+1
for i in range(len(S)-1,-1,-1):
    if S[i]==">":
        A[i]=max(A[i+1]+1,A[i])
print(sum(A))

Measured memory_bytes: 23336
from sys import stdin, setrecursionlimit
from collections import deque

setrecursionlimit(10 ** 9)

N = int(stdin.readline())
ab = [list(map(int, stdin.readline().split())) for i in range(N - 1)]

# 1 index
graph = [[] for i in range(N + 1)]

for a, b in ab:
    graph[a].append(b)
    graph[b].append(a)

q = deque([])

mod0 = deque([])
mod1 = deque([])
mod2 = deque([])

for k in range(1, N + 1):
    if k % 3 == 0:
        mod0.append(k)
    elif k % 3 == 1:
        mod1.append(k)
    else:
        mod2.append(k)

dist = [-1] * (N + 1)


def bfs(start):
    q.append(start)
    dist[start] = 0

    while q:
        now = q.popleft()

        for node in graph[now]:
            if dist[node] != -1:
                continue
            else:
                dist[node] = dist[now] + 1
                q.append(node)


node_p = [0] * (N + 1)


def modfit(i):
    if even <= N / 3:
        if dist[i] % 2 == 0:
            node_p[i] = mod0.pop()

        else:
            if mod1:
                node_p[i] = mod1.pop()
            elif mod2:
                node_p[i] = mod2.pop()
            else:
                node_p[i] = mod0.pop()

    elif odd <= N / 3:
        if dist[i] % 2 != 0:
            node_p[i] = mod0.pop()

        else:
            if mod1:
                node_p[i] = mod1.pop()
            elif mod2:
                node_p[i] = mod2.pop()
            else:
                node_p[i] = mod0.pop()

    else:
        if dist[i] % 2 == 0:
            if mod1:
                node_p[i] = mod1.pop()
            elif mod0:
                node_p[i] = mod0.pop()
            else:
                print(-1)
                exit(0)
        else:
            if mod2:
                node_p[i] = mod2.pop()
            elif mod0:
                node_p[i] = mod0.pop()
            else:
                print(-1)
                exit(0)

    print(node_p[i], end=" ")


odd = 0
even = 0

bfs(N)

for i in range (1,N + 1):
    if dist[i] % 2 == 0:
        even += 1
    else:
        odd += 1

for k in range(1, N + 1):
    modfit(k)

print()


Measured memory_bytes: 81492
#include <stdio.h>
int main(void)
{
    int r, g, b, a;
    scanf("%d %d %d", &r, &g, &b);
    
    a = 10*g+b;
    
    if(a%4 == 0)
        printf("YES\n");
    else
        printf("NO\n");
    
    return 0;
}

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

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

    ll ans = min(a, k);
    k -= a + b;
    if (k > 0) ans -= k;

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


Measured memory_bytes: 3596
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int i = 0;
    
    while (i >= 0) {
      if ((int)Math.pow(K,i) <= N && (int)Math.pow(K,i+1) > N) {
        break;
      }
      i++;
    }
    
    System.out.println(i+1);
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll dp[55][55][2505];
ll n,a;
ll x[55];
int main()
{
  finp;
  dp[0][0][0]=1;
  cin>>n>>a;
  afor(i,1,n)
  {
    cin>>x[i];
    afor(j,0,n)afor(k,0,2500)dp[i][j][k]=dp[i-1][j][k];

    afor(j,0,n-1)afor(k,0,2500)
    {
      if((k + x[i])>2500)break;
      dp[i][j+1][k+x[i]]+=dp[i-1][j][k];
    }
  }

  ll ans=0;
  afor(j,1,n)afor(k,0,2500)
  {
    if(k%j==0 && (k/j)==a)ans+=dp[n][j][k];
  }
  cout<<ans;
  
return 0;
}

Measured memory_bytes: 50432
#include <iostream>

using namespace std;

int main() {

	int n,m,X,Y,i,j;
	int x,y,xmax=-100,ymin=100,zmin,zmax;
	bool f=false;
	
	cin >> n >> m >> X >> Y;

	for (i = 0; i < n; i++) {
		cin >> x;
		/*if (x >= Y) {
			cout << "War" << endl;
			return 0;
		}*/
		if (x > xmax)xmax = x;

	}
	//cout << xmax << endl;

	for (i = 0; i < m; i++) {
		cin >> y;
		/*if (y <= X) {
			cout << "War" << endl;
			return 0;
		}*/
		if (y < ymin)ymin = y;

	}
	//cout << ymin << endl;
	zmin = xmax + 1;
	zmax = ymin; //z有効範囲

	if(zmax<zmin)cout << "War" << endl;
	else if(zmin<=X || zmax>=Y) cout << "War" << endl;
	else cout << "No War" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
vector<string>str;
string c[103];
int n,w;
int main(){
	cin>>n>>w;
	for(int i=0;i<n;i++){
		cin>>s;
		bool can=0;
		for(int j=0;j<w;j++)
			if(s[j]=='#')
				can=1;
		if(can)str.push_back(s);
	}
	for(int i=0;i<w;i++)
	{
		bool can=0;
		for(int j=0;j<str.size();j++)
			if(str[j][i]=='#')
				can=1;
		if(can)
			for(int j=0;j<str.size();j++)
				c[j]+=str[j][i];
	}
	for(int i=0;i<str.size();i++)
		cout<<c[i]<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(void) {
    int a,b,S;
    std::cin>>a>>b>>S;
    int t=0;
    t=S-a;
    if(t<0){
        std::cout<<"NO";
    }else{
    if(t<=b){
        std::cout<<"YES";
    }else{
        std::cout<<"NO";
    }
    }
    return 0;
}

Measured memory_bytes: 256
def lucas_number(x):
    if x == 0:
        return 2
    if x == 1:
        return 1
    l = 2
    r = 1
    while x - 1 > 0:
        l, r = r, l + r
        x -= 1
    return r

n = int(input())
print(lucas_number(n))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int i;
string a,b;
int main()
{
    cin>>a>>b;
    for(i=0;i<b.size();i++)
    {
    	cout<<a[i]<<b[i];
	}
	if(a.size()!=b.size())
	{
		cout<<a[a.size()-1];
	}
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
N,M=map(int,input().split())
ball = [1 for i in range(N+1)]
ball[0] = 0
red = [0 for i in range(N+1)]
red[1] = 1


for i in range(M):
    x,y=map(int,input().split())
    ball[x]-=1
    ball[y]+=1
    if red[x]:
        red[y]=1
    if ball[x]==0:
        red[x]=0

print(sum(red))



Measured memory_bytes: 4696
#include <bits/stdc++.h>
using namespace std;
int cnt;
int a[1000005];
void is(int n,int g){
	for(int i=g;i<n;i++){
		int v=a[i];
		int j=i-g;
		while(j>=0&&a[j]>v){
			a[j+g]=a[j];
			j=j-g;
			cnt++;
		}
		a[j+g]=v;
	}
}
int g[1000005];
int m;
void ss(int n){
	cnt=0;
	m=1;
	g[0]=1;
	for(;g[m-1]*3+1<=n;m++)
		g[m]=g[m-1]*3+1;
	reverse(g,g+m);
	for(int i=0;i<m;i++){
		is(n,g[i]);
	}
}
int main(){
	int n;cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	ss(n);
	cout<<m<<endl;
	for(int i=0;i<m-1;i++){
		cout<<g[i]<<' ';
	}cout<<g[m-1]<<"\n";
	cout<<cnt<<"\n";
	for(int i=0;i<n;i++){
		cout<<a[i]<<"\n";
	}
	return 0;
}



Measured memory_bytes: 7024
// Aizu Vol-10 1023: Amazing Graze
// 2017.8.20 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define MAX 100000
typedef struct { int x, y, e; } T; 
T a[MAX+5];
int AN, BN, R;

int cmp(T *a, T *b) { return a->x - b->x; }

int bsch(int x)
{
	int m, l = 0, r = AN;
    while (l < r) {
        m = (l + r) >> 1;
        if (a[m].x <= x) l = m + 1; else r = m;
    }
	return l;
}

int main()
{
	int x, y;
	int i, j, r, r2, t;

	while (scanf("%d%d%d", &AN, &BN, &R) && AN) {
		for (i = 0; i < AN; i++) scanf("%d%d", &a[i].x, &a[i].y), a[i].e = 0;
		qsort(a, AN, sizeof(T), cmp);
		r = R << 2, r2 = r*r;
		for (i = 0; i < BN; i++) {
			scanf("%d%d", &x, &y);
			for (j = bsch(x-r-1); j < AN && a[j].x <= x+r; j++) {
				if ((a[j].x-x)*(a[j].x-x) + (a[j].y-y)*(a[j].y-y) <= r2) a[j].e++;
			}
		}
		for (t = i = 0; i < AN; i++) t += a[i].e;
		printf("%d\n", t);
	}
	return 0;
}

Measured memory_bytes: 3388
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    a, b = map(int, input().split())
    x[i]=a+b
    y[i]=a-b
xmax=max(x)
xmin=min(x)
ymax=max(y)
ymin=min(y)
print(max(xmax-xmin,ymax-ymin))

Measured memory_bytes: 73052
import math
M = 256
while 1:
    N = int(raw_input())
    if N == 0: break
    H = 1e10
    I = map(int,raw_input().split())
    for S in range(16):
        for A in range(16):
            for C in range(16):
                R = S
                O = [0]*M
                for i in I:
                    R = (A*R+C)%M
                    O[(i+R)%M] += 1
                tmp = -sum(1.0*x/N*math.log(1.0*x/N,2) for x in O if x > 0)
                if tmp < H:
                    H = tmp
                    ans = [S,A,C]
    print " ".join(map(str,ans))

Measured memory_bytes: 4440
arr=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
arr1=[1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1549,1559,1579]
arr2=arr+arr1
n=int(input())
arrx=[]
i=0
j=0
while(i<n):
	if(arr2[j]%10==9):
		arrx.append(arr2[j])
		i+=1
	j+=1
print(*arrx)


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

double cacu(double x, double y)
{
  double X = x*x;
  //cout << X << endl;
  double Y = y*y;
  //cout << Y << endl;

  double sum = X + Y;

  return sum;
}

int main(int argc, char *argv[])
{
  double D, E;

  while (cin >> D >> E, D) {
    double LowCost = 100;
    double col = D;
    for (int i = 0; i < D; i++) {
      //cout << col << endl;
      //cout << i << endl;
      double x = cacu(col, i);
      //cout << x << endl;
      double z = sqrt(x);
      //cout << x << endl;
      double cost = z - E;
      cost = abs(cost);
      
      if(LowCost>cost) {
	LowCost = cost;
      }
      col--;
    }
    cout << LowCost << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3284
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int X,Y;
    cin >> X >> Y;
    cout << X + Y/2 <<endl;
}


Measured memory_bytes: 256
import sys
n = int(input())
print(0)#, flush=True)
s = input()
if s == "Vacant":
    sys.exit()
l = 0
r = n
ls = s
rs = s

def nibun(l, r, m, ls, rs, s):
    if ((m-l) % 2 == 0 and ls == s) or\
        ((m-l) % 2 == 1 and ls != s):
        return 1
    else:
        return 0

for ii in range(21):
    m = (l+r)//2
    print(m)#, flush=True)
    s = input()
    if s == "Vacant":
        break
    if nibun(l, r, m, ls, rs, s) == 0:
        r = m
        rs = s
    else:
        l = m
        ls = s

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

int main() {
  int n;
  std::cin >> n;
  std::vector<int64_t> as;
  int64_t sum = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    sum += a;
    as.push_back(sum);
  }
  if (as.size() == 2) {
    std::cout << std::abs(sum - 2 * as[0]) << std::endl;
    return 0;
  }
  std::vector<int64_t> diff;
  for (int i = 1; i < n - 1; ++i) {
    diff.push_back(std::abs(sum - 2 * as[i]));
  }
  std::sort(diff.begin(), diff.end());
  std::cout << diff[0] << std::endl;
  return 0;
}


Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
long long ans;
priority_queue<long long> pq;
int main(){
    int n,m;
    long long x;
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;++i){
        scanf("%lld",&x);
        pq.push(x);
    }
    while(m--){
        x=pq.top(); pq.pop();
        x/=2;   pq.push(x);
    }
    ans=0;
    while(!pq.empty()){
        ans+=pq.top();  pq.pop();
    }
    printf("%lld\n",ans);
    return 0;
}


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

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

    int res = 1;
    int ans = 0;

    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if(a == res) res++;
        else ans++;
    }

    if(ans == n) ans = -1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>
#include <map>
#include <utility>
#include <numeric>
#include <set>
#include <map>

#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 _USE_MATH_DEFINES

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

const ll INF = 999999999;
const ll atcoder = 1e9 + 7;
const int dx[4] = { 1 , 0 , -1 ,0 };
const int dy[4] = { 0 , 1 , 0 , -1 };

int main() {

	int n;
	ll ans = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ans += b - a + 1;
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[100005],n,t=0,ans=0;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		t++;
		if(a[i]!=a[i+1])
		{
		if(t>=a[i])
			ans+=(t-a[i]);
			else
			ans+=t;
			t=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	myout(Math.ceil(N / 2));
}


Measured memory_bytes: 7628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll po(ll a, ll b) {
    ll c = 1;
    while (b) {
        if (b % 2) c = c * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return c;
}

int main() {
    ios::sync_with_stdio(false);
    ll f[200005] = {1}, g[200005] = {};
    for (int i = 1; i <= 200000; i++) f[i] = f[i - 1] * i % mod;
    g[200000] = 750007460;
    for (int i = 199999; i >= 0; i--) g[i] = g[i + 1] * (i + 1) % mod;
    ll n, a, b;
    cin >> n >> a >> b;
    ll z = po(2, n) - 1, x = 1, y = 1;
    for (ll i = n - a + 1; i <= n; i++) x = x * i % mod;
    for (ll i = n - b + 1; i <= n; i++) y = y * i % mod;
    x = x * g[a] % mod;
    y = y * g[b] % mod;
    z -= x;
    if (z < 0) z += mod;
    z -= y;
    if (z < 0) z += mod;
    cout << z;
}


Measured memory_bytes: 5196
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, A, B;
    cin >> N;
    cin >> A;
    cin >> B;
    
    if(N == 1){
        cout << "Hello World" << endl;
        exit(0);
    }
    else{
        cout << A + B << endl;
        exit(0);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string n;cin>>n;
    long int count=0;
    for(int i=0;i<n.size();i++){
        if(n[i]=='1') count+=1;
        else if(n[i]=='2') count+=2;
        else if(n[i]=='3') count+=3;
        else if(n[i]=='4') count+=4;
        else if(n[i]=='5') count+=5;
        else if(n[i]=='6') count+=6;
        else if(n[i]=='7') count+=7;
        else if(n[i]=='8') count+=8;
        else if(n[i]=='9') count+=9;
    }
    if(count%9==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
char s[100001],ss[100001];
int main()
{    
	scanf("%s",s+1);
	register int sum=0,ans=0,l=strlen(s+1);
	while(1)
	{
		for(register int i=2;i<l;++i)
		{
			if(s[i]!='\0')
			{
				register int x=i-1;
				while(s[x]=='\0')
					--x;
				if(s[x]!=s[i+1])
					s[i]='\0',++sum;
            }        
		}        
		register int cnt=0;
		for(register int i=1;i<=l;++i)
			if(s[i]!='\0')
				ss[++cnt]=s[i];
		for(register int i=1;i<=l;++i)
			s[i]=ss[i];
		l=cnt;
		if(sum==ans)
			break;
		ans=sum;
	}    
	if(sum%2) return printf("First"),0;
	else return printf("Second"),0;
} 

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
  int a,b,c,d,e,q,aa,bb;
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
  aa=b/d;
  if(b%d!=0)aa++;
  bb=c/e;
  if(c%e!=0)bb++;
  if(aa<bb)aa=bb;
  q=a-aa;
  printf("%d\n",q);
  return 0;
}
 

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

int main() {
  uint64_t A; cin >> A;  // 参加人数Ａ（～100000）
  uint64_t B; cin >> B;  // 参加人数Ｂ（～100000）

  auto p = min(A,B); // ＡとＢの小さいほう
  auto q = max(A,B); // ＡとＢの大きい方

  auto Ans = p*q; // 答え：お菓子の数。q ～ q*p

  for(int i=1; i<=p ; i++ ){
      Ans = q * i;
      if ( Ans % p == 0 ){break;}
  }

  cout << Ans << endl;
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type / Class / Struct Definitions:
using ll = long long;
using ull = unsigned long long;

//Constants:
const int INF = (1ll << 30) - 1;
const ll INFLL = 1ll << 60;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

//================ Main Loop ================
int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }
    //Init DP
    vector<int> dp(n, INF);
    dp[0] = 0;

    rep(i, n) {
        if(i > 0) chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if(i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

template <class T>
inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}


Measured memory_bytes: 1024
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        long G = sc.nextLong() / 100;
        int[] p = new int[d], g = new int[d], max = new int[d];
        int k = (int)Math.pow(2, d);
        for(int i = 0; i < d; i++){
            p[i] = sc.nextInt();
            g[i] = sc.nextInt() / 100;
            max[i] = (i + 1) * p[i] + g[i];
        }
        int ans = Integer.MAX_VALUE;
        for(int i = 0; i < k; i++){
            long gg = G;
            String kk = to2(i, d);
            int tmp = 0;
            int min = -1;
            for(int j = 0; j < d; j++){
                if(kk.charAt(j) == '1'){
                    gg -= max[j];
                    tmp += p[j];
                }else{
                    min = j;
                }
            }
            if(min >= 0){
                if(gg < (min + 1) * p[min]){
                    tmp += Math.min((Math.max(gg, 0) + min) / (min + 1), p[min]);
                }
                else tmp = Integer.MAX_VALUE;
            }
            ans = Math.min(ans, tmp);
        }
        System.out.println(ans);
    }
    static String to2 (int m, int d){
        String ans = "";
        for(int i = 0; i < d; i++){
            if(m % 2 == 0){
                m /= 2;
                ans = "0" + ans;
            }
            else{
                m--;
                m /= 2;
                ans = "1" + ans;
            }
        }
        return ans;
    }
}

Measured memory_bytes: 24276
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

int dfs(int now, VV &g, V& visited) {
	visited[now] = true;
	int sum = 1;
	for (int x : g[now]) if (!visited[x]) {
		sum += dfs(x, g, visited);
	}
	return sum;
}

signed main() {
	int n, m; cin >> n >> m;
	VV g(n);
	V pre(m, -1);
	rep(i, n) {
		int k; cin >> k;
		rep(j, k) {
			int l; cin >> l;
			l--;
			if (pre[l] != -1) {
				g[i].push_back(pre[l]);
				g[pre[l]].push_back(i);
			}
			pre[l] = i;
		}
	}

	V vs(n);
	int ans = dfs(0, g, vs);
	cout << (ans == n ? "YES" : "NO") << endl;

	system("pause");
}

Measured memory_bytes: 12160
#include <iostream>
#include <string>

int main(int argc, char *argv[])
{
  std::string s;
  std::cin >> s;

  if (s.at(s.length() - 1) != 's') {
    std::cout << s << "s" << std::endl;
  } else {
    std::cout << s << "es" << std::endl;
  }
  return 0;
}

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

#define MAX 100001
#define INF 1e+9

int V,E;
vector<pair<int, int>  > adj[MAX];
int color[MAX];
int d[MAX];

void prim(){

/*
	auto compare = [](pair<int, int> a, pair<int, int> b){
		if(a.first == b.first){
			return a.second < b.second;
		}
		else{
			a.first < b.second;
		}
	}
*/	
	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq;
	for(int i = 0;i < MAX;i++){
		color[i] = 0;
		d[i] = INF;
	}

	d[0] = 0;
	pq.push(make_pair(0,0));
	color[0] = 1;

	while(!pq.empty()){
		pair<int, int> f = pq.top();
		pq.pop();
		int u = f.second;
		if(color[u] == 2 || d[u] < f.first)continue;
		color[u] = 2;

		/*
		cout << "color ";
		for(int i = 0;i < V;i++){
			cout << i << ":" << color[i] << " ";
		}
		cout << endl;
		*/
		//if(d[u] < f.first*(-1)) continue;

		for(int i = 0;i < adj[u].size();i++){
			int v = adj[u][i].second;
			if(color[v] == 2)continue;
			if(d[v] > adj[u][i].first){
				d[v] = adj[u][i].first;
				pq.push(make_pair(d[v], v));
				color[v] = 1;
			}
		}
	}
}

int main(){
	int s,t,di;
	cin >> V >> E;
	for(int i = 0;i < E;i++){
		cin >> s >> t >> di;
		adj[s].push_back(make_pair(di,t));
		adj[t].push_back(make_pair(di,s));
	}

	prim();

	int res = 0;
	for(int i = 0;i < V;i++){
		if(d[i] != INF){
			res += d[i];
			//cout << i << ":" << d[i] << endl;
		}
	}

	cout << res << endl;

	/*
	for(int i = 0;i < V;i++){
		if(d[i] == INF){
			cout << "INF" << endl;
		}
		else{
			cout << d[i] << endl;
		}
	}
	*/

	return 0;
}


Measured memory_bytes: 9040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll H, W, K;
	cin >> H >> W >> K;
	vector<string> board(H);
	for (ll i = 0; i < H; i++)
	{
		cin >> board[i];
	}
	ll ans = 0;
	for (ll maskr = 0; maskr < (1 << H); maskr++)
	{
		for (ll maskc = 0; maskc < (1 << W); maskc++)
		{
			ll black = 0;
			for (ll i = 0; i < H; i++)
			{
				for (ll j = 0; j < W; j++)
				{
					if (maskr >> i & 1) continue;
					if (maskc >> j & 1) continue;
					if (board[i][j] == '#') black++;

				}
			}
			if (black == K)
				ans++;
		}
	}
	cout << ans;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    iota(a.begin(), a.end(), 1);
    do {
        for (int i = 0; i < n; i++) cout << a[i] << " \n"[i == n - 1];
    } while (next_permutation(a.begin(), a.end()));
    return 0;
}


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

int f(int n){
    int count = 0;
    while(n % 2 == 0){
        count++;
        n /= 2;
    }
    return count;
}

int main(){
    int N;
    cin >> N;
    int ans = 1;
    int max_f = 0;
    for (int i = 1; i <= N; i++){
        if(max_f < f(i)){
            ans = i;
            max_f = f(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin >> b >> a;
  for(int i=0;i<b*2-1;i++){
    if(i!=b*2-2){
      cout << a-b+1+i<<" ";
    }else{
      cout << a-b+1+i<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int,int);
int main(){
  int x,y;
  scanf("%d %d",&x,&y);
  printf("%d\n",gcd(x,y));

  return 0;
}

int gcd(int x,int y){
  int z,r,i;
  if(x<y){
    r=x;
    x=y;
    y=r;
  }
  r=y;
  for(i=0;i<r;i++){
    z=y;
    y = x%y;
    x=z;
    if(y==0) break;
  }
  return x;

}

Measured memory_bytes: 592
mod = int(1e9+7)
stair = [1]
for i in range(1,2001):
    stair.append(stair[i-1]*i)
def comb(stair,n,r):
    return (stair[n]//(stair[n-r]*stair[r]))%mod

n,k = map(int,input().split())
for i in range(1,k+1):
    ans = comb(stair,n-k+1,i) * comb(stair,k-1,i-1)
    print(ans%mod)

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define loop(a, b, inc) for (int i = a; i <= b; i += inc)
typedef pair<int, int> pii;
typedef pair<int, string> ps;
typedef unsigned long long int llu;
typedef long long int ll;
typedef unsigned u;
const int MOD = 1e7+9, MAXN = 1e6;

vector<int> h;
int n, dp[MAXN];

int solve(int i)
{
	if (i == n-1) return 0;
	if (dp[i] == -1) {
		int w1 = abs(h[i]-h[i+1])+solve(i+1), w2 = -1;
		if (i <= n-3) {
			w2 = abs(h[i]-h[i+2])+solve(i+2);
			dp[i] = min(w1, w2);
		}
		else {
			dp[i] = w1;
		}
	}
	return dp[i];
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int aux;
	cin >> n;
	loop(0, n-1, 1) {
		cin >> aux;
		h.pb(aux);
	}
	memset(dp, -1, sizeof(dp));
	cout << solve(0) << endl;
	
	return 0;
}


Measured memory_bytes: 9336
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 2e5 + 9;
// const ll m = 1e9 + 7;
const ll inf= 1ll<<62;
#define x first
#define y second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;
const ll mod = 1e9;
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
int main()
{                            
     ll T= 1;
     // cin>>T;
     ll ca = 1;
     while(T--){
          ll k,n;cin>>k>>n;
          ll su = 0,a;
          for(int i = 0;i<n;i++){
               cin>>a;
               su+=a;
          }
          if(su>k){
               cout<<-1<<'\n';
          }
          else{
               cout<<(k-su)<<'\n';
          }
     }
    return 0;
}

Measured memory_bytes: 3624