akhauriyash/Code-Regression huggingface dataset:
class Dice():
    def __init__(self,ary):
        self.top = ary[0]
        self.south = ary[1]
        self.east = ary[2]
        self.west = ary[3]
        self.north = ary[4]
        self.bottom = ary[5]

    def get_top(self):
        return self.top

    def rotate_north(self):
        self.top,self.south,self.north,self.bottom = self.south,self.bottom,self.top,self.north
    
    def rotate_south(self):
        self.top,self.south,self.north,self.bottom = self.north,self.top,self.bottom,self.south

    def rotate_west(self):
        self.top,self.west,self.bottom,self.east = self.east,self.top,self.west,self.bottom

    def rotate_east(self):
        self.top,self.west,self.bottom,self.east = self.west,self.bottom,self.east,self.top

    def rotate_horizon(self):
        self.south,self.east,self.north,self.west = self.west,self.south,self.east,self.north

    def get_east(self):
        return self.east
        
dice1 = Dice(list(map(int,input().split())))
dice2 = Dice(list(map(int,input().split())))

h=""

for i in range(4):
    dice2.rotate_west()
    if dice1.top == dice2.top:
        for _ in range(4):
            dice2.rotate_horizon()
            if dice1.south == dice2.south:
                if dice1.east == dice2.east and dice1.west == dice2.west:
                    h = "Yes"
for _ in range(4):
    dice2.rotate_north()
    if dice1.top == dice2.top:
        for m in range(4):
            dice2.rotate_horizon()
            if dice1.south == dice2.south:
                if dice1.east == dice2.east and dice1.west == dice2.west:
                    h = "Yes"
if h:
    print(h)
else:
    print("No")

Measured memory_bytes: 7852
/*B - Bingo*/

#include <bits/stdc++.h>

using namespace std;

int main(){

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

	map <int, pair<int, int> > have;
	vector <int> rows(3);
	vector <int> col(3);
	
	bool can = false;
	
	int mat[3][3];
	
	int dig, r, c;
	int nums;

	for (int i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cin >> mat[i][j];
			have[mat[i][j]] = {i,j};
		}
	}


	cin >> nums;


	for (int i = 0; i < nums; ++i)
	{
		cin >> dig;

		if(have.count(dig)){

			r = have[dig].first;
			c = have[dig].second;

			col[c]++;
			rows[r]++;
			mat[r][c] = 0;
			if(col[c] == 3 or rows[r] == 3){
				can = true;
				break;
			}
		}
	}

	int aux = 0;
	if(can == false){

		for (int i = 0; i < 3; ++i)
		{
			if(mat[i][i] == 0)
				aux++;
		}

		if(aux == 3)
			can = true;
		else
			aux = 0;

		if(mat[0][2] == 0 and mat[1][1] == 0 and mat[2][0] == 0)
			can = true;

	}

	if(can)
		cout << "Yes";
	else
		cout <<"No";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int H,W;
cin >> H >> W;
vector<vector<char>> vec(H+2,vector<char>(W+2));
for (int i = 1;i < H+1;i++) {
  for (int j = 1;j < W+1;j++) {
    cin >> vec.at(i).at(j);
  }
}
for (int i = 1;i < H+1;i++) {
  for (int j = 1;j < W+1;j++) {
    if (vec.at(i).at(j) == '#') cout << '#';
    else {
      int ans = 0;
      for (int k = i-1;k <= i+1;k++) {
        if (vec.at(k).at(j-1) == '#') ans++;
        if (vec.at(k).at(j) == '#') ans++;
        if (vec.at(k).at(j+1) == '#') ans++;

      }
      cout << ans;
    }
  }
  cout << endl;
}



return 0;
}

Measured memory_bytes: 256
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int d=n%10;
    if(d==0||d==1||d==6||d==8)
    cout<<"pon";
    else if(d==3)
    cout<<"bon";
    else
    cout<<"hon";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b == c) cout << "No";
  else if (a != b && a != c && b != c) cout << "No";
  else cout << "Yes";
  
  return 0;
}



Measured memory_bytes: 256
n = int(input())

def f(a, b):
  a_digit = len(str(a))
  b_digit = len(str(b))
  
  return max(a_digit, b_digit)

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n // i)
  divisors.sort()
  return divisors

ans = 10000000007
divs = make_divisors(n)
#print(divs)
for i in range(len(divs)):
  a = divs[i]
  b = divs[-(i+1)]
  digit = f(a, b)
  # print('{} : {} : {}'.format(a, b, digit))
  ans = min(ans, digit)
print(ans)

Measured memory_bytes: 39920
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bfs():
    from collections import deque

    que = deque()
    cnt = 1
    memo = {}
    for i in range(1, 10):
        que.append(str(i))
        memo[cnt] = str(i)
        cnt += 1
    while que:
        x = que.popleft()
        last = int(x[-1])
        if last != 0:
            que.append(x+str(last-1))
            memo[cnt] = x + str(last-1)
            cnt += 1
        que.append(x+str(last))
        memo[cnt] = x+str(last)
        cnt += 1
        if last != 9:
            que.append(x+str(last+1))
            memo[cnt] = x + str(last+1)
            cnt += 1
        if cnt > K:
            return memo

K = INT()

res = bfs()
print(res[K])


Measured memory_bytes: 67164
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef long int li;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<float, float> ff;
typedef pair<double, double> dd;
typedef unsigned int ui;
typedef vector<ii> vii;
typedef vector<ff> vff;
typedef set<int> si;
typedef set<lli> slli;
typedef vector<lli> vlli;
typedef long long ll;
typedef long long ll;
typedef vector<ll> vll;
typedef unsigned long long int ulli;
#define MOD 1000000007
#define INF (unsigned)(~0)>>1
typedef pair<int, ii> iii;
void arr_int(int* given_arr, int n){
  for(int i=0;i<n;i++)
    scanf("%d", &given_arr[i]);
}
void solve();
int main(int argc, char const *argv[]){
  solve();
  return 0;
}
void solve(){
  lli N, A, B;
  cin>>N>>A>>B;
  if(N<A)
    cout<<N<<endl;
  else{
    if(N<A+B)
      cout<<A<<endl;
    else{
      lli temp = N/(A+B) * A;
      if((N - (N/(A+B))*(A+B))>A)
        temp += A;
      else{
        temp += N-(N/(A+B))*(A+B);
      }
      cout<<temp<<endl;
    }
  }
}


Measured memory_bytes: 256
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;

int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a+b>=c) puts("Yes"); else puts("No");
	return 0;
}




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

#define LL long long int

#define rep(p,q) for(int i = p; i < q;i++)

template
<
	typename TYPE,
	std::size_t SIZE
>
std::size_t array_length(const TYPE(&)[SIZE])
{
	return SIZE;
}

class Algo {

public:
	static int gcd(LL a, LL b) {
		if (a < b) {
			LL swap = a;
			a = b;
			b = swap;
		}
		int c = a % b;
		if (c == 0) return b;
		else gcd(b, c);
	}

	//エラトステネスの篩　lengthにarray size指定
	static void eratos(bool isPrime[],LL length) {
		rep(0, length)isPrime[i] = true;
		// nが合成数なら素因数にsqrt{ n }以上の物を持つのでsqrt{ n }まで見れば良い
		int route = sqrt(length);
		rep(2, route) {
			if (!isPrime[i])continue;
			else {			
				for (int j = i * 2; j < length; j += i) {
					isPrime[j] = false;
				}
			}
		}
	}

	//素数個別判定
	static bool checkPrime(LL n) {
		if (n == 2) return true;
		else if (n < 2 || n % 2 == 0) return false;
		else {
			LL route = sqrt(n);
			for (int i = 3; i <= route; i += 2) {
				if (n % i == 0)return false;
			}
		}
		return true;
	}

};

bool isPrime[10000000];

int main(void) {
	int n;
	cin >> n;
	int count = 0;
	rep(0, n) {
		int a;
		cin >> a;
		if (Algo::checkPrime(a))count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 3076
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int i, n,m;
    for(i = 0; i < 3000; i++){
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        if(n > m)
        cout << m << " " << n << endl;
        else
        cout << n << " " << m << endl;
    }
    return 0;
}



Measured memory_bytes: 2984
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x <<endl;
using namespace std; 

//int _; 

const double pi=3.14159265358979323846; 

int a,b,h,m;

int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> a >> b >> h >> m;
	double l=sqrt(a*a+b*b-2*a*b*cos(abs(h*60-m*11)*1.0*pi/360.0));
	printf("%.20lf\n",l);
	return 0;
}

Measured memory_bytes: 4192
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
struct Node
{
    int x,y;
};
struct Edge
{
    int to,next;
}e[5000005];
vector<Node>a[1000005];
int f[100005],rt[100005],d[400005],h[400005],cnt;
inline void Addedge(int x,int y)
{
    e[++cnt]=(Edge){y,h[x]};h[x]=cnt;
}
inline int GetFather(int x)
{
    if(f[x]==x)return x;
    return f[x]=GetFather(f[x]);
}
inline void Merge(int x,int y)
{
    x=GetFather(x);
    y=GetFather(y);
    if(x!=y)f[x]=y;
}
queue<int>q;
int main(void)
{
    int i,j,x,y,n,m,c,id;
    while(scanf("%d%d",&n,&m)==2)
    {
        cnt=0;
        for(i=1;i<=1000000;++i)a[i].clear();
        memset(d,0,sizeof(d));
        memset(h,0,sizeof(h));
        for(i=1;i<=m;++i)
        {
            scanf("%d%d%d",&x,&y,&c);
            a[c].push_back((Node){x,y});
        }
        id=n;
        for(i=1;i<=1000000;++i)
        {
            for(j=0;j<a[i].size();++j)
            {
                x=a[i][j].x;y=a[i][j].y;
                f[x]=x;f[y]=y;
                rt[x]=rt[y]=0;
            }
            for(j=0;j<a[i].size();++j)Merge(a[i][j].x,a[i][j].y);
            for(j=0;j<a[i].size();++j)
            {
                x=a[i][j].x;y=a[i][j].y;
                if(!rt[GetFather(x)])rt[GetFather(x)]=++id;
                Addedge(x,rt[GetFather(x)]);
                Addedge(rt[GetFather(x)],x);
                Addedge(y,rt[GetFather(y)]);
                Addedge(rt[GetFather(y)],y);
            }
        }
        q.push(1);
        while(!q.empty())
        {
            x=q.front();q.pop();
            for(i=h[x];i;i=e[i].next)
            {
                y=e[i].to;
                if(!d[y]){d[y]=d[x]+1;q.push(y);}
            }
        }
        if(d[n])printf("%d\n",d[n]/2);
        else printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 41088
#!/mnt/c/Users/moiki/bash/env/bin/python
H,W = list(map(int, input().split()))
a = [list(input()) for _ in range(H)]
c = [[0 for _ in range(W)] for _ in range(H)]
# print(a)
mod = int(1e9 + 7)
c[0][0] = 1

for y in range(H):
    for x in range(W):
        if a[y][x] == "#":
            continue
        # print("x,y:",x,y)
        if x+1 < W and a[y][x+1] != "#":
            c[y][x+1] = c[y][x+1] + c[y][x]  % mod # right
        if y+1 < H and a[y+1][x] != "#":
            c[y+1][x] = c[y+1][x] + c[y][x]  % mod # right
        
        

# for i in range(H):
#     print(c[i])
print(c[H-1][W-1] % int(1e9+7))

Measured memory_bytes: 52380
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int a = Integer.parseInt(tokens[0]);
		int b = Integer.parseInt(tokens[1]);
		if (a <= 8 && b <= 8) {
			System.out.println("Yay!");
		} else {
			System.out.println(":(");
		}
		in.close();
	}

}

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

const int mod = 2019;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main() {
  string S;
  cin >> S;
  map<ll, ll> mp;
  ll N = S.size();

  mint t = mint('0');
  mp[t.x]++;

  mint d = mint(1);
  rep(i, N) {
    t = mint((S[N - 1 - i] - '0') * d.x + t.x);
    d *= 10;
    mp[t.x]++;
  }

  ll ans = 0;
  auto begin = mp.begin(), end = mp.end();
  for (auto iter = begin; iter != end; iter++) {
    // cout << iter->first << ' ' << iter->second << endl; 
    ll m = iter->second;
    ans += m * (m - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int N;
  cin >> N;
  cout << 0.5 * (N) * (N + 1) << endl;
}

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

int s[5], dx[]{ 1,-1,0,0, }, dy[]{ 0,0,1,-1 };
vector<vector<int>>a(5, vector<int>(5));
int Max;
void dfs(int x, int y, int c) {
	vector<vector<P>>b(5, vector<P>(5));
	rep(i, 5)rep(j, 5)b[i][j].first = a[i][j];
	bool update = true;
	int p = 0;
	for (int v = 1; update; v++) {
		update = false;
		rep(i, 5) {
			int back = 0, cnt = 0;
			rep(j, b[i].size()) {
				if (back != b[i][j].first) {
					if (cnt >= 3) {
						for (int k = 1; k <= cnt; k++)
							b[i][j - k].second = 1;
					}
					cnt = 0;
				}
				back = b[i][j].first; cnt++;
			}
			if (cnt >= 3) {
				for (int k = 1; k <= cnt; k++)
					b[i][b[i].size() - k].second = 1;
			}
		}
		rep(i, 5) {
			int back = 0, cnt = 0;
			rep(j, 5) {
				if (b[j].size() <= i || back != b[j][i].first) {
					if (cnt >= 3) {
						for (int k = 1; k <= cnt; k++)
							b[j - k][i].second = 1;
					}
					cnt = 0;
				}
				if (i < b[j].size()) {
					back = b[j][i].first; cnt++;
				}
			}
			if (cnt >= 3) {
				for (int k = 1; k <= cnt; k++)b[5 - k][i].second = 1;
			}
		}
		rep(i, 5)rep(j, b[i].size()) {
			if (b[i][j].second == 1) {
				p += v*s[b[i][j].first];
				b[i].erase(b[i].begin() + j); update = true; j--;
			}
		}
	}
	Max = max(Max, p);
	if (c == 0)return;
	rep(i, 4) {
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx&&nx < 5 && 0 <= ny&&ny < 5) {
			swap(a[x][y], a[nx][ny]);
			dfs(nx, ny, c - 1);
			swap(a[x][y], a[nx][ny]);
		}
	}
}
int main() {
	int n;
	while (scanf("%d", &n), ~n) {
		Max = 0;
		rep(i, 5)rep(j, 5)scanf("%d", &a[j][i]), a[j][i]--;
		rep(i, 5)reverse(a[i].begin(), a[i].end());
		rep(i, 5)scanf("%d", &s[i]);
		rep(i, 5)rep(j, 5)dfs(i, j, n);
		printf("%d\n", Max);
	}
}

Measured memory_bytes: 3288
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=1000005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
template<class T> inline void read(T &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
template<class T> inline void print(T x){
	if(!x){puts("0");return;}
	if(x<0){putchar('-');x=-x;}
	int a[20],m=0;
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');puts("");
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,a[N];
ll sum;

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
	srand(time(0));
#endif
	ios::sync_with_stdio(0);
	read(n);
	for(int i=1;i<=n;i++) read(a[i]),sum+=a[i];
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		sum-=a[i];
		if(a[i]>sum*2){printf("%d\n",i);return 0;}
	}
#ifdef rqgao2014
	time_tester(1);
#endif
	return 0;
}


Measured memory_bytes: 640
n = int(input())
h = list(map(int,input().split()))
tmp = [0 for i in range(n)]
ans = 0
right = 0
left = n-1

while tmp != h:
    for i in range(n):
        if tmp[i] != h[i]:
            right = i
            left = i
            break
    for i in range(i+1,n):
        if tmp[i] == h[i]:
            left = i-1
            break
        elif i == n-1 and tmp[n-1] != h[n-1]:
            left = n-1
            break
    for i in range(right,left+1):
        tmp[i] += 1
    ans += 1
#    print(right,left,ans)
#    print(tmp)

print(ans)


Measured memory_bytes: 73848
import java.util.*;
 
class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int rows = scanner.nextInt();
    int cols = scanner.nextInt();
    int constant = scanner.nextInt();
    
    int[] code = new int[cols];
    for (int ix = 0; ix < cols; ix++) {
      code[ix] = scanner.nextInt();
    }
    
    int matches = 0;
    for (int row = 0; row < rows; row++) {
      int result = 0;
      for (int col = 0; col < cols; col++) {
        result += scanner.nextInt() * code[col];
      }
      
      if (result + constant > 0) matches++;
    }
    
    System.out.println(matches);
  }
}

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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

/*const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}*/

/*vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/

vector<int> a;
int f(const ll m) {
    int ans = 0;
    for (auto & i : a) {
        if (i <= m) continue;
        ans += (i - m + m - 1) / m;
    }
    return ans;
}

void solve() {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.pb(x);
    }

    ll l = 0, r = 1e18;
    while (l + 1 < r) {
        ll m = l + (r - l) / 2;
        if (f(m) <= k) r = m;
        else l = m;
    }
    cout << r << endl;
}

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

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 4256
#include<iostream>
#include<vector>

using namespace std;

int huda[3];

bool calc(int Y) {
    int sum = 0;

    sum += huda[0]*10;
    sum += huda[1]*5;
    sum += huda[2]*1;

    return sum == Y ? true:false;
}

int main(void) {
    int N,Y;

    cin>>N>>Y;
    Y /= 1000;
    
    for(int i = 0;i <= N;i++) {
        for(int j = N-i;j >= 0;j--) {
                huda[0] = i;
                huda[1] = j;
                huda[2] = N - i - j;
                if(calc(Y)) {
                    cout<<i<<" "<<j<<" "<<N-i-j<<endl;

                    return 0;
                }
            
        }
    }

    cout<<-1<<" "<<-1<<" "<<-1<<endl;

    return 0;
}


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

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

    int n;
    cin >> n;
    ll h[n];
    rep(i,n) cin >> h[i];
    
    int diff[n-1];
    rep(i,n-1){
        if(h[i+1] <= h[i]){
            diff[i] = true;
        }else{
            diff[i] = false;
        }
    }
    
    int count = 0;
    int ans = 0;
    rep(i,n-1){
        if(diff[i]){
            count++;
            ans = max(ans, count);
        }else{
            count = 0;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
#include <string> 
#include <cctype>

int main()
{
	std::string input;
	while(std::getline(std::cin, input))
	{
	    if(input=="0") break;
	    int sum=0;
	    for (int i = 0; i < input.length(); i++)
	    {
	    	char c = input[i];
		    std::string str = { c };
	    	sum += atoi(str.c_str());
    	}
    	std::cout<<sum<<std::endl;
	}
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
const ll MOD = 1000000007LL;

void _main()
{
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    rep(i, 0, H) cin >> a[i];

    vector<vector<ll>> dp(H + 1, vector<ll>(W + 1, 0));
    dp[1][1] = 1;
    rep(i, 0, H) rep(j, 0, W)
    {
        if (a[i][j] == '#')
        {
            continue;
        }
        if (i == 0 && j == 0)
        {
            continue;
        }
        dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j]) % MOD;
    }

    cout << dp[H][W] << endl;
}


Measured memory_bytes: 9216
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l[] = new int[n];
        
        for(int i=0;i<n;i++){
            l[i]=sc.nextInt();
        }
        
        
        Arrays.sort(l);
        
        int count = 0;
        int min;
        int max;
        
        for(int i=0;i<n-2;i++){
            for(int j=i+1;j<n-1;j++){
                max=l[i]+l[j];
                min=Math.abs(l[i]-l[j]);
                
                int a=0;
                int b=0;
                
                for(a=j+1;a<n;a++){
                    if(l[a]>min){
                        break;
                    }
                }
                
                for(b=n-1;b>a;b--){
                    if(l[b]<max){
                        break;
                    } 
                    
                }
                
                count+=b-a+1;
                if(l[a]<=min||l[b]>=max){
                    count--;
                }
                
                
            }
        }
        
        System.out.println(count);
        
    }
}


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

int main(){
    int K; cin >> K;
    int a[K];
    for(int i=0;i<K;i++) cin >> a[i];
    reverse(a,a+K);
    long long a_max=2;
    long long a_min=2;
    for(int i=0;i<K;i++){
        a_max=(a_max/a[i]+1)*a[i]-1;
        a_min=((a_min+a[i]-1)/a[i])*a[i];
        if(a_min>a_max){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << a_min << " " << a_max << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define DIM 107
#define DIMM 100007
#define INF 1000000009.0
#define X 500007
#define epc 0.0000001
#define pi 3.14159265358979323846
#define MAX 25
#define MODULO 10009
const long double gr=(1+sqrt(5))/2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

typedef tree<
I,
null_type,
less<I>,
rb_tree_tag,
tree_order_statistics_node_update> mset;

ll n,W,w[DIM],v[DIM],d[DIM][DIMM],maxv;

int main()
{
    //freopen("suffarray.in", "r", stdin);
    //freopen("suffarray.out", "w", stdout);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cout<<"ops"<<endl;

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

    //ll x1,y1,xs,ys,y1,y2,x3,x4,y3,y4;

    cin>>n>>W;
    for(int i=1;i<=n;i++)cin>>w[i]>>v[i];

    for(int j=1;j<=W;j++)d[0][j]=(-INF);

    for(int i=1;i<=n;i++){
     for(int j=0;j<=W;j++){
      d[i][j]=d[i-1][j];
      if(j>=w[i] && d[i-1][j-w[i]]!=(-INF))d[i][j]=max(d[i-1][j-w[i]]+v[i],d[i][j]);
     }
    }
    for(int j=0;j<=W;j++)maxv=max(maxv,d[n][j]);
    cout<<maxv<<endl;
}


Measured memory_bytes: 80128
import Control.Applicative
import Data.Function
import Control.Monad
import Data.List

f [] _ = []
f (a:as) (bs) = map (zipWith (*) a) bs : f as bs

g a b = foldr (\x acc -> (map sum x) : acc) [] $ f a (transpose b)

main = do
    [n,m,l] <- map read . words <$> getLine
    a <- replicateM n $ map read . words <$> getLine
    b <- replicateM m $ map read . words <$> getLine
    mapM_ (putStrLn <$> unwords . map show) $ g a b


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

int main() {
  int Q; cin >> Q;
  int primeset[100001];
  primeset[0]=primeset[1]=0;
  primeset[2]=1;
  for(int i=3; i<=100000; i++){
    primeset[i]=i%2;
  }
  for(int i=2; i<=1000; i++){
    if(primeset[i]==1){
      for(int j=i*3; j<=100000; j+=(i*2)){
        primeset[j]=0;
      }
    }
  }
  int likeset[100001]={};
  for(int i=3; i<100000; i+=2){
    if(primeset[i]==1&&primeset[(i+1)/2]==1){
      likeset[i]=1;
    }
  }
  for(int i=1;i<=100000; i++){
    likeset[i]+=likeset[i-1];
  }
  int l,r;
  for(int i=0; i<Q; i++){
    cin >> l >> r;
    cout << likeset[r]-likeset[l-1] << endl;
  }
}

Measured memory_bytes: 1408
#moderate differences
n,a,b,c,d=map(int,input().split())
flag=False
for i in range(n):
    if (d+c)*i-(n-1)*d<=b-a<=(d+c)*i-(n-1)*c:
        flag=True
        break
if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include<iostream>
int main()
{
	int H_W[10000][2];
	int number;
	for(int i = 0;; i++)
	{
		for(int j = 0; j < 2; j++)
		{
			std::cin >> H_W[i][j];
		}
		if(H_W[i][0] == 0 && H_W[i][1] == 0)
		{
			number = i;
			break;
		}
	}
	for(int i = 0; i < number; i++)
	{
		for(int h = 0; h < H_W[i][0]; h++)
		{
			for(int w = 0; w < H_W[i][1]; w++)
			{
				std::cout << (h == 0 || w == 0 || h == H_W[i][0] - 1 || w == H_W[i][1] - 1 ? '#' : '.');
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3040
using System;
using System.Collections.Generic;

namespace ABC109B
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            string[] input1 = Console.ReadLine().Split(' ');
            int N = int.Parse(input1[0]);

            string[] W = new String[N];
            for (int i = 0; i < N;i++){
                W[i] = Console.ReadLine();
            }


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

                for (int j = 0; j < i; j++)
                {
                    if (W[j] == W[i])
                    {
                        Console.WriteLine("No");
                        return;
                    }
                    if (i != 0)
                    {

                        if (!W[i].StartsWith(W[i - 1].Substring(W[i - 1].Length-1)))   
                        {
                            Console.WriteLine("No");
                            return;
                        }
                    }
                }
            }

            Console.WriteLine("Yes");
        }
    }
}




Measured memory_bytes: 13280
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int n,d,m[110],s[110],x;

int main(){
	while(cin>>n>>d&&n){
		vi c[110];
		fill(s,s+n,0);
		rep(i,n){
			cin>>m[i];
			rep(j,m[i])cin>>x,c[i].pb(x),s[i]+=x;
		}
		int f;
		while(1){
			f=0;
			rep(i,n)if(m[i]){
				s[i]-=c[i][m[i]-1];
				if(*max_element(s,s+n)-*min_element(s,s+n)<=d){
					c[i].erase(c[i].end()-1),m[i]--,f=1;
				}else s[i]+=c[i][m[i]-1];
			}
			if(!f||!accumulate(m,m+n,0))break;
		}
		cout<<(f?"Yes":"No")<<endl;
	}
}

Measured memory_bytes: 940
import scala.io.{StdIn => in}

object Main extends App {
  val ref = "KIHBR"
  val s = in.readLine

  val check = (s:String) =>
    !s.contains("AA") &&
    !s.contains("KA") &&
    !s.contains("IA") &&
    s.replace("A","") == ref

  val ans = if(check(s)) "YES" else "NO"
  println(ans)
}

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

int main()
{
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  for(int i=0;i<2*n;i++)
  {
    if(i%2==0)
      cout<<s.at(i/2);
    else
      cout<<t.at((i-1)/2);
    
    if(i==2*n-1)
      cout<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <time.h>
#define _USE_MATH_DEFINES
#define LL long long
#define UN unsigned
using namespace std;
const double PI = acos(-1.0);

int max_num(int ary[], int length) {
	int max = ary[0];
	for (int i = 1; i < length; i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int max_ord(int ary[], int length) {
	int max;
	max = max_num(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == max) return i;
	}
	return -1;
}

int min_num(int ary[], int length) {
	int min = ary[0];
	for (int i = 1; i < length; i++)
		if (min > ary[i]) min = ary[i];
	return min;
}

int min_ord(int ary[], int length) {
	int min;
	min = min_num(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == min) return i;
	}
	return -1;
}

int main() {
	int n, l[200], ans = 0;
	cin >> n;
	for (int i = 0; i < n * 2; i++) cin >> l[i];
	sort(l, l + n * 2);
	for (int i = 0; i < n * 2; i += 2) {
		ans += min(l[i], l[i + 1]);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    string a;
    for(int i = 0;i < n;i ++){
        cin >> a;
        if(a == "Y"){
            cout << "Four" << endl;
            break;
        }else if(i == n-1){
            cout << "Three" << endl;
        }else{
            continue;
        }
    }
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp20
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] array = line.Split(' ');

            int n = int.Parse(array[0]);
            int m = int.Parse(array[1]);

            if (n == m)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

int main() {

	int A, B;
	cin >> A >> B;

	int Add = A + B;
	int Sub = A - B;
	int Mul = A * B;

	int ans = max({ Add, Sub, Mul });

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  int n ;
  cin >> n ;
  vector<int> poi(n) ;
  int count = 0 ;
  REP(i,n){
    cin >> poi.at(i) ;
  }
  sort(ALL(poi)) ;
  
  REP(i,n-1){
    count += poi.at(i+1)-poi.at(i) ;
  }
  
  cout << count <<endl ;
    

  return 0 ;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  int l = 0;
  int r = 1e8;
  rep(i, M)
  {
    int L, R, t = 0;
    cin >> L >> R;
    l = max(l, L);
    r = min(r, R);
  }
  if (l <= r)
  {
    cout << r - l + 1 << endl;
  }
  else
  {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
struct Node{
	char name[12];
	int time;
	struct Node *last;
	struct Node *next;
};
int n,q;
struct Node *head = NULL;
struct Node *tail = NULL;
int globalTime;
int main(){
	scanf("%d %d",&n,&q);
	int i;
	struct Node *node;
	for(i=0;i<n;i++){
		node = (struct Node *)malloc(sizeof(struct Node));
		scanf("%s %d",node->name,&(node->time));
		if(head==NULL){
			head = node;
			tail = node;
		}else{
			tail->next = node;
			node->last = tail;
			tail = node;
		}
	}
	tail->next = head;
	head->last = tail;
	
//	while(head!=tail){
//		printf("%s %d\n",head->name,head->time);
//		head = head->next; 
//	}
//	printf("%s %d\n",head->name,head->time);
//	head = head->next; 

	
	while(1){
//		printf("###%s %d\n",head->name,head->time);
		int time = head->time;
		if(time > q){
			head->time -= q;
			globalTime += q;
			head = head->next;
		}else{
			globalTime += time;
			printf("%s %d\n",head->name,globalTime);
			head = head->next;
			if(head == head->next){
				break;
			}
			removeNode(head->last);
		}
		
	}
}
void removeNode(struct Node *node){
	node->last->next = node->next;
	node->next->last = node->last;
	free(node);
}


Measured memory_bytes: 4088
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    int[][] d = new int[10][10];

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        for (int i = 0; i <= 9; i++) {
            for (int j = 0; j <= 9; j++) {
                d[i][j] = sc.nextInt();
            }
        }
        int[][] a = new int[H][W];
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        washall_floyd();
        long ans = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (a[i][j] != -1) {
                    ans += d[a[i][j]][1];
                }
            }
            System.out.println();
        }
        System.out.println(ans);
    }

    void washall_floyd() {
        for (int k = 0; k < 10; k++) {
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 10; j++) {
                    d[i][j] = Math.min((int) d[i][j], (int) d[i][k] + (int) d[k][j]);
                }
            }
        }
    }
}

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

int main() {
  int n,k;
  cin>>n;
  k=n/100;
  if(100*k+10*k+k < n)
    cout<<100*(k+1)+10*(k+1)+k+1;
  else cout<<100*k+10*k+k;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<ll> V(N);
    rep(i,0,N)cin >> V[i];
    ll idx, maxi = 0;
    rep(i,0,N){
        if(maxi < abs(V[i])){
            maxi = abs(V[i]);
            idx = i;
        }
    }
    if(maxi == 0){
        cout << 0 << endl;
        return 0;
    }
    vector<P> vec;
    if(V[idx] > 0){
        rep(i,0,N){
            if(V[i] < 0){
                vec.emplace_back(idx+1, i+1);
                V[i] += V[idx];
            }
        }
        vec.emplace_back(idx+1, 1);
        rep(i,1,N){
            vec.emplace_back(i, i+1);
        }
    }else{
        rep(i,0,N){
            if(V[i] > 0){
                vec.emplace_back(idx+1, i+1);
                V[i] += V[idx];
            }
        }
        vec.emplace_back(idx+1, N);
        for(int i = N;i > 1;i--){
            vec.emplace_back(i, i-1);
        }
    }

    cout << vec.size() << endl;
    for(auto p:vec){
        cout << p.first << " " << p.second << endl;
    }
}

Measured memory_bytes: 256
a_1=int(input())
a=[a_1]
for i in range(1000000):
    if a[-1]%2==0:
        a_next=a[-1]//2
    else:
        a_next=3*a[-1]+1
    if a_next in a:
        print(i+2)
        break

    a.append(a_next)

Measured memory_bytes: 3060
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
int n;
int num[66][30];
char str[66];
int main()
{
    //std::ios::sync_with_stdio(false);
    scanf("%d", &n);
    for(int i=0;i<n;i++)
    {   
        scanf("%s", str);
        for(int j=0;j<strlen(str);j++)
        {
            num[i][str[j]-'a']++;
        }
    }

    for(int i=0;i<26;i++)
    {
        int cnt = 66;
        for(int j=0;j<n;j++)
        {
            cnt = min(num[j][i],cnt);
        }
        while(cnt--)
        {
            putchar((char)('a'+i));
        }
    }
    puts("");
    //system("pause");
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n,m = map(int,input().split())

edges = [[] for _ in range(n)]

for _ in range(m):
    a,b = map(int,input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

q = [0]

ans = [-1]*n
ans[0] = 0
count = 1

while q:
    l = q.pop(0)
    for i in edges[l]:
        if ans[i] == -1:
            ans[i] = l
            count += 1
            q.append(i)
    if count == n:
        break

if count == n:
    print('Yes')
    for i in ans[1:]:
        print(i+1)
else:
    print('No')


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

using namespace std;

int a[100000];
int b[100000];

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

  int ret=0;
  int at=0;
  int am=0;
  for(int i=0;i<N;i++)am=max(am,a[i]);
  sort(b,b+N,greater<int>());
  for(int i=0;i<N;i++)
  {
    if(am<=b[i])
    {
      ret++;
      at+=b[i];
    }
    else break;
    if(at>=H)break;
  }
  if(at<H)ret+=(H-at)/am+((H-at)%am?1:0);
  cout<< ret<< endl;

  return 0;
}


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

public static class Program
{
    public static void Main(string[] args)
    {
        var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(s[0] > s[1] * 2 ? s[0] - s[1] * 2 : 0);
    }
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

int n, k, s;

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k >> s;

    for(int i = 0; i < k; ++i) {
        cout << s << ' ';
    }

    for(int i = 0; i < n-k; ++i) {
        int other = s+1;
        if(other > 1000000000) {
            other -= 2;
        }
        cout << other << ' ';
    }

    cout << '\n';
    
    return 0;
}


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

int main () {
    int H, W;
    cin >> H >> W;
    while (H > 0 || W > 0) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (j == 0 || j == W-1 || i == 0 || i == H-1) {
                    printf("#");
                }
                else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
        cin >> H >> W;
    }
}


Measured memory_bytes: 3096
s=input()
fin=False
if len(s)==2:
    if s[0]==s[1]:
        print(1,2)
    else:
        print(-1,-1)
    fin=True
else:
    for i in range(0,len(s)-2):
        if s[i]==s[i+1]:
            print(i+1,i+2)
            fin=True
            break
        elif s[i+1]==s[i+2]:
            print(i+2,i+3)
            fin=True
            break
        elif s[i]==s[i+2]:
            print(i+1,i+3)
            fin=True
            break
    if not fin:
        print(-1,-1)

Measured memory_bytes: 3188
// acdart C++
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <bitset>
#include <cctype>
#include <fstream>
#include <numeric>
#include <utility>
#include <iomanip>
#include <complex>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned long long ULL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector< vi > vvi;
typedef vector< vd > vvd;
typedef vector< vll > vvll;
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define PI 3.1415926535897932384626433832795
#define mod9 1000000009ll
#define mod7 1000000007ll
#define inf 0x3f3f3f3f
#define inf8  1023456789ll
#define inf16 10000000000000000ll
#define SZ(x) ((int)(x).size())
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define rep(i, v) for(int i=0;i<sz(v);++i)
#define lp(i, n) for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n) for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n) for(int i=(j);i>=(int)(n);--i)
#define gcd(x, y) __gcd(x, y)
#define lson (id << 1)
#define rson (id << 1 | 1)
#define lowb(x) (x & (-x))
#define eps 1e-7
/*********default*********/
#define maxm
#define maxn
char a[100010];
int main()
{
	// ios::sync_with_stdio(false);
	int p = 0, fg = 1;
	
	scanf("%s", a);
	int x = strlen(a);
	int l = 0, r = x - 1;
	while (l < r) {
		if (a[l] == a[r]) {
			l++, r--;
		} else if (a[l] == 'x') {
			p++, l++;
		} else if (a[r] == 'x') {
			p++, r--;
		} else {
			fg = 0;
			break;
		}
	}
	if (fg) printf("%d\n", p);
	else puts("-1");
}


Measured memory_bytes: 384
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll n, k, l;
ll p[200005];

int main() {
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'o' || c == 'e') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
	return 0;
}

Measured memory_bytes: 3568
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m,x = map(int, input().split())
a = list( map(int, input().split()))
aa = [0]*(n+1)
for i in a:
    aa[i] = 1

sumn = sum(aa[x+1:])
sum0 = sum(aa[:x])

print(min(sumn,sum0))


Measured memory_bytes: 3060