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

using namespace std;

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

	vector<int>A(N), B(N), C(N);
	vector<int>D(M), E(M), F(M);

	std::set<int>x_org = {0};
	std::set<int>y_org = {0};

	struct pair3 {
		int a, b, c;
		pair3(int a = 0, int b = 0, int c = 0) : a(a), b(b), c(c) {}
	};
	std::vector<pair3>Xpair;//N ko
	std::vector<pair3>Ypair;//M ko


	for (int n = 0; n < N ; ++n) {
		cin >> A[n]>> B[n]>>C[n];
		Xpair.emplace_back(A[n], B[n], C[n]);
		x_org.insert(A[n]); 
		x_org.insert(B[n]); 
		y_org.insert(C[n]);
	}

	for (int m = 0; m < M ; ++m) {
		cin >> D[m] >> E[m] >> F[m]; 
		Ypair.emplace_back(D[m], E[m], F[m]);
		x_org.insert(D[m]);
		y_org.insert(E[m]);
		y_org.insert(F[m]); 
	}

	vector<int>X, Y;//縮小から元
	std::map<int, int>mx;//元から縮小
	std::map<int, int>my;//元から縮小
	for (auto itr = x_org.begin(); itr != x_org.end(); ++itr) {
		mx[*itr] = X.size();
		X.push_back(*itr);
	}

	for (auto itr = y_org.begin(); itr != y_org.end(); ++itr) {
		my[*itr] = Y.size();
		Y.push_back(*itr);
	}
	int x = 2 * X.size() + 1;
	int y = 2 * Y.size() + 1;

	vector<vector<int>>XY(x,vector<int>(y));//all 0
	
	for (int n = 0 ;n < (int)Xpair.size() ; ++n) {
		for (int m = mx[Xpair[n].a] * 2 + 1; m <= mx[Xpair[n].b] * 2 + 1;++m) {
			XY[m][my[Xpair[n].c]*2+1] = -1;
		}
	}

	for (int n = 0; n < (int)Ypair.size(); ++n) {
		for (int m = my[Ypair[n].b] * 2 + 1; m <= my[Ypair[n].c] * 2 + 1; ++m) {
			XY[mx[Ypair[n].a] * 2 + 1][m] = -1;
		}
	}


	queue<pair<int,int>> q; 
	XY[mx[0] * 2 + 1][my[0] * 2 + 1] = 1;
	q.emplace(mx[0] * 2 + 1, my[0] * 2 + 1);
	while (!q.empty()) {
		int x0 = q.front().first; 
		int y0 = q.front().second;
		q.pop();
		//範囲内かつ0を4セット
		{
			int x1 = x0 + 1;
			int y1 = y0;
			if ((0 <= x1) && (x > x1) && (0 <= y1)&&(y > y1)&&(0 == XY[x1][y1])) {
				XY[x1][y1] = 1;
				q.emplace(x1,y1);
			}
		}
		{
			int x1 = x0 - 1;
			int y1 = y0;
			if ((0 <= x1) && (x > x1) && (0 <= y1) && (y > y1) && (0 == XY[x1][y1])) {
				XY[x1][y1] = 1;
				q.emplace(x1, y1);
			}
		} 
		{
			int x1 = x0;
			int y1 = y0 +1;
			if ((0 <= x1) && (x > x1) && (0 <= y1) && (y > y1) && (0 == XY[x1][y1])) {
				XY[x1][y1] = 1;
				q.emplace(x1, y1);
			}
		} 
		{
			int x1 = x0;
			int y1 = y0 - 1;
			if ((0 <= x1) && (x > x1) && (0 <= y1) && (y > y1) && (0 == XY[x1][y1])) {
				XY[x1][y1] = 1;
				q.emplace(x1, y1);
			}
		}
	}

	long long nAns = 0;
	for (int a = 0;a <= (int)X.size();++a ) {//どっちかが奇数out
		for (int b = 0; b <= (int)Y.size(); ++b) {
			if (1 != XY[2*a][2*b]) {
				continue;
			}
			if ((a == 0) || (a == (int)X.size()) || (b == 0) || (b == (int)Y.size())) {
				cout << "INF" << endl;
				return 0;
			}
			long a1 = (X[a] - X[a - 1]);
			long a2 = (Y[b] - Y[b - 1]);
			nAns += a1 * a2;
		}
	}
	cout << nAns << endl;
	return 0;
}

Measured memory_bytes: 144944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300005,p=1000000007;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,ans,f[3][2][3],g[3][2][3];
char ch[N];
void check(int &x,int y){x=(x+y<p) ? (x+y) : (x+y-p);}
void trans(int x,int y,int z,int fl){
	if (fl==0) check(g[x][y][(z==0) ? 1 : (3-z)],f[x][y][z]);
	else if (z!=1) check(g[x+((x==y)&&(!z))][y^1][0],f[x][y][z]);
	else check(g[x][y][0],f[x][y][z]);
}
int main(){
	scanf(" %s",ch+1);
	n=strlen(ch+1);
	f[0][0][0]=1;
	for (int i=1;i<=n;i++){
		memset(g,0,sizeof(g));
		for (int x=0;x<3;x++)
		for (int y=0;y<2;y++)
		for (int z=0;z<3;z++)
		if (ch[i]=='0') trans(x,y,z,0);
		else if (ch[i]=='1') trans(x,y,z,1);
		else{trans(x,y,z,0);trans(x,y,z,1);}
		memcpy(f,g,sizeof(f));
	}
	memset(g,0,sizeof(g));
	for (int x=0;x<3;x++)
	for (int y=0;y<2;y++)
	for (int z=0;z<3;z++) trans(x,y,z,1);
	check(ans,g[2][0][0]);
	check(ans,g[2][1][0]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
X = int(input())

X_half = X // 2
max_ans = 1
tmp_max = 0

for i in range(1,X_half+10):
    for j in range(2,X_half+10):
        tmp = i ** j
        if tmp<=X:
            tmp_max = tmp
    max_ans = max(max_ans, tmp_max)

print(max_ans)


Measured memory_bytes: 40668
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

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

using ll = long long;
using namespace std;

//  -d
int main() {
    // int n;
    string str;
    // cin >> n;
    cin >> str;
    if (str == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;

    return 0;
}



Measured memory_bytes: 3624
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  string A[3];
  REP(i,3)cin>>A[i];
  bool f=true;
  FOR(i,1,3)if(A[i-1].back()!=A[i].front())f=false;
  cout<<(f?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    int h[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    sort(h + 1, h + n + 1);
    /*
    for (int i = 1; i <= n; i++) {
        cout << h[i] << " ";
    }
    cout << endl;*/
    int Min = 1000000000;
    int tmp = 0;
    for (int i = 1; i <= n - k + 1; i++) {
        tmp = h[i + k - 1] - h[i];
        Min = Min > tmp ? tmp : Min;
    }
    cout << Min << endl;
}



Measured memory_bytes: 640
n, m = map(int, input().split())

a = []
b = []

for i in range(n):
    a.append(list(input()))
for i in range(m):
    b.append(list(input()))



for s_h in range(n - m + 1):
    for s_w in range(n - m + 1):
        flag = True
        for i in range(m):
            for j in range(m):
                if a[s_h + i][s_w + j] != b[i][j]:
                    flag = False
                    break
            if not flag:
                break
        if flag:
            print("Yes")
            break
    if flag:
        break
if not flag:
    print("No")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

void a()
{
	int ab, bc, ca;
	cin >> ab >> bc >> ca;
	cout << (ab * bc) / 2 << endl;
}

int f(int n) {
	return n % 2 == 0 ? n / 2 : 3 * n + 1;
}

void b()
{
	int s;
	cin >> s;
	int *a;
	a = (int*)malloc(sizeof(int) * 1000001);
	a[1] = s;
	for (int i = 2; i <= 1000000; i++) {
		a[i] = f(a[i-1]);
		for (int j = 1; j < i; j++) {
			if (a[j] == a[i]) {
				cout << i << endl;
				return;
			}
		}
	}
}

int main()
{
	b();
}

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

int n, w;
int arr[105][2];
unsigned long long dp[100005][105];
int main() {
    cin >> n >> w;
    for(int i = 1; i <= n; i++) {
        cin >> arr[i][0] >> arr[i][1];
    }
    for(int i = 1; i <= w; i++) {
        for(int j = 1; j <= n; j++) {
            dp[i][j] = dp[i][j-1];
            if(i >= arr[j][0]) {

                dp[i][j] = max(dp[i][j], (dp[i - arr[j][0]][j-1] + arr[j][1]));
            }
        }
    }

    cout << dp[w][n] << endl;
    return 0;
}


Measured memory_bytes: 82304
n = int(input())
s = list(input())
for i in range(len(s)):
    if s[i] == 'o':
        s[i] = True
    else:
        s[i] = False

state = [None]*n
state[0] = 1
state[1] = 1


def next_predict(before_state,current_state,output):#i+1の動物を出力する
    if current_state == 1:
        if output == True:
            if before_state == 1:
                return 1
            else:
                return 0
        else:
            if before_state == 1:
                return 0
            else:
                return 1
    else:
        return next_predict(before_state,1,not(output))

isFound = -1
for i in range(4):
    for j in range(1,n-1):
        state[j+1] = next_predict(state[j-1],state[j],s[j])
    tmp0 = next_predict(state[n-2],state[n-1],s[n-1])
    tmp1 = next_predict(state[n-1],state[0],s[0])
    if tmp0 == state[0] and tmp1 == state[1] :
        isFound = 1
        ans = []
        for k in range(n):
            if state[k] == 0:
                ans.append('W')
            else:
                ans.append('S')
        print("".join(ans))
        break
    else:
        if i == 0:
            state[1] = 0
        elif i == 1:
            state[0] = 0
        else:
            state[1] = 1

if isFound == -1:
    print(-1)


Measured memory_bytes: 5676
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

H, W = getNM()
Ch, Cw = getNM()
Dh, Dw = getNM()
maze = [input() for i in range(H)]
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

# 二次元ダイクストラ
def Dijkstra(start, goal, size):
    sy, sx = start
    gy, gx = goal
    dist = [[float('inf')] * W for i in range(H)]
    pos = [(0, sy, sx)]
    heapify(pos)
    dist[sy][sx] = 0

    while len(pos):
        cost, y, x = heappop(pos)

        if y == gy and x == gx:
            return cost
        if dist[y][x] < cost:
            continue
        # エッジは探索のたびに生成していく
        # walking
        for i in range(4):
            ny = y + dy[i]
            nx = x + dx[i]
            if 0 <= ny < H and 0 <= nx < W and maze[ny][nx] == '.':
                if dist[ny][nx] > cost:
                    dist[ny][nx] = cost
                    heappush(pos, (cost, ny, nx))
        # warp
        for w_y in range(-2, 3):
            for w_x in range(-2, 3):
                wy = y + w_y
                wx = x + w_x
                if 0 <= wy < H and 0 <= wx < W and maze[wy][wx] == '.':
                    if dist[wy][wx] > cost + 1:
                        dist[wy][wx] = cost + 1
                        heappush(pos, (cost + 1, wy, wx))
    return dist[gy][gx]

ans = Dijkstra((Ch, Cw), (Dh, Dw), H * W)
if ans == float('inf'):
    print(-1)
else:
    print(ans)

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

#define A first
#define B second

const ll MAXN = 1e5+5;

ll n, ans, m;
vector<pii> g[MAXN];

ll ct[5];
bool y = 0;
ll vis[MAXN];
ll edges = 0, vtx = 0;

void dfs(ll v, ll col) {
	ct[col]++;
	vis[v] = col;
	edges += g[v].size();
	vtx++;

	for (pii t : g[v]) {
		ll x = t.B;
		ll colnext = col;
		if (x == -1) {
			colnext--;
			if (colnext == 0)
				colnext = 3;
		} else {
			colnext++;
			if (colnext == 4)
				colnext = 1;
		}

		if (vis[t.A] != 0) {
			if (vis[t.A] != colnext)
				y = 1;
		} else
			dfs(t.A, colnext);
	}
}

int main() {
	cin >> n >> m;
	for (ll i = 0; i < m; ++i) {
		ll a, b;
		cin >> a >> b;
		a--; b--;

		g[a].push_back(pii(b, 1));
		g[b].push_back(pii(a, -1));
	}

	for (ll i = 0; i < n; ++i) {
		if (vis[i] != 0)
			continue;
		edges = vtx = y = 0;
		ct[1] = ct[2] = ct[3] = 0;
		dfs(i, 1);
		edges /= 2;

		if (y == 1) {
			ans += vtx*vtx;
		} else {
			if (ct[1] == 0 || ct[2] == 0 || ct[3] == 0)
				ans += edges;
			else
				ans += (ct[1] * ct[2] + ct[2] * ct[3] + ct[3] * ct[1]);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 12800
n = gets.to_s.to_i
rr = ll = 0
ary = []

n.times do
  s = gets.to_s.chomp.bytes
  
  l = r = 0
  s.each do |c|
    if c == 40 # p '('.ord #=> 40
      l += 1
    elsif l == 0
      r += 1
    else
      l -= 1
    end
  end
  
  if l == 0
    rr += r
  elsif r == 0
    ll += l
  else
    ary << [r, l]
  end
end

ary.sort_by{|(r,l)| r - l }.each do |(r,l)|
  ll -= r
  break if ll < 0
  ll += l
end

puts ll == rr ? "Yes" : "No"

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

int main(void)
{
    int N;
    string S;
    cin >> N >> S;

    int ans = 0;
    
    for (int i = 0; i < 1000; i++)
    {
        int d1 = i/100;
        int d2 = (i%100)/10;
        int d3 = i%10;

        int sel = 0;
        for (int i = 0; i < N; i++)
        {
            if(sel == 0){
                if(d1 == (S[i] - '0')) sel++;
            } else if(sel == 1){
                if(d2 == (S[i] - '0')) sel++;
            } else if(sel == 2){
                if(d3 == (S[i] - '0')) sel++;
            } else if(sel == 3){
                break;
            }
        }

        if(sel == 3) {
            ans++;
        }
    }

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


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)

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

	vector<string> pic(H);
	rep(i, H) cin >> pic.at(i);
	rep(i, H){
		cout << pic.at(i) << endl;
		cout << pic.at(i) << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int w=sc.nextInt();
		int h=sc.nextInt();
		long min=Integer.MAX_VALUE;
		if(w%3==0||h%3==0){
			System.out.println("0");
		}else{
			//System.out.println(a);
			min=Math.min(c(w,h),t(w,h));
			min=Math.min(Math.min(c(h,w),t(h,w)),min);
			System.out.println(min);
			
		}
		
	}
	public static long c(long w,long h){
		long a=h/2;
		long b=h/2+h%2;
		long min=Integer.MAX_VALUE;
		//System.out.println(w+" "+h+" "+a+" "+b);
		long d[]=new long[3];
		for(int i=1;i<=w;i++){	
			long p=i;long q=w-i;
			//System.out.println(p+q);
			d[0]=(q*a);
			d[1]=(q*b);
			d[2]=p*h;
			//System.out.println(d[0]+d[1]+d[2]);
			//System.out.println(sum1+" "+sum2+" "+sum3 );
			Arrays.sort(d);
			long sum=d[2]-d[0];
			if(sum<min){
				//System.out.println(p+" "+q+" "+(p*h)+" "+s1);
				min=(long)sum;
		
			}
			
		}
		return min;
	}
	public static long t(long w,long h){
		
		long min=Integer.MAX_VALUE;
		//System.out.println(w+" "+h+" "+a+" "+b);
		long d[]=new long[3];
		for(int i=1;i<=w;i++){	
			long p=i;long q=w-i;
			//System.out.println(p+q);
			long a=(q/2);
			long b=q-a;
			d[0]=(h*a);
			d[1]=(h*b);
			d[2]=p*h;
			//System.out.println(a+b+p);
			Arrays.sort(d);
			long sum=d[2]-d[0];
			if(sum<min){
				//System.out.println(p+" "+q+" "+(p*h)+" "+s1);
				min=(long)sum;
		
			}
			
		}
		return min;
	}
 
}

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

#define fastio1 ios_base::sync_with_stdio(false)
#define fastio2 cin.tie(NULL)
#define ll long long
#define MOD 1000000007
using namespace std;

int main(){
    fastio1; fastio2;
	ll n, k; cin >> n >> k;
	vector<ll> a(n);
	int maxBits = 45;
	ll tracker[maxBits];
	for (int i = 0; i < maxBits; i++){
		tracker[i] = 0;
	}
	
	for (int i = 0; i < n; i++){
		cin >> a[i];
		ll temp = a[i];
		int b = 0;
		while(temp > 0){
			tracker[b] += (temp % 2);
			temp /= 2;
			b++;
		}
	}
	
	
	ll x = 0;
	for (int i = maxBits-1; i >= 0; i--){
		if (x + (tracker[i] < n-tracker[i])*(1LL<<i) <= k){
			x += (tracker[i] < n-tracker[i])*(1LL<<i);
		}
	} 
	
	ll total = 0;
	for (int i = 0; i < n; i++){
		total += x^a[i];
	}
	cout << total << endl;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int[,] map = new int[3, 3];
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                map[i, j] = sc.NextInt();
            }
        }

        for (int i = 0; i < 2; i++)
        {
            int diff = map[i + 1, 0] - map[i, 0];
            for (int j = 1; j < 3; j++)
            {
                if (diff != map[i + 1, j] - map[i, j])
                {
                    Console.WriteLine("No");
                    return;
                }
            }
        }

        for (int j = 0; j < 2; j++)
        {
            int diff = map[0, j + 1] - map[0, j];
            for (int i = 1; i < 3; i++)
            {
                if (diff != map[i, j + 1] - map[i, j])
                {
                    Console.WriteLine("No");
                    return;
                }
            }
        }

        Console.WriteLine("Yes");
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
void solve() {
    ll h, w;
    cin >> h >> w;
    ll res = w * h - (w * h) / 2;
    if (w == 1 || h == 1) res = 1ll;
    cout << res << endl;
}

int main() {
	header();
	solve();
	return 0;
}


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

using namespace std;

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

using llong = long long;
using ld = long double;
using ii = pair<int, int>;
using ull = unsigned long long;
using pll = pair<llong, llong>;
using vi = vector<int>;


#define endl "\n"
#define fi first
#define se second
#define left LEVO
#define right PRAVO
#define time CHAS
#define all(a) (a).begin(), (a).end()
#define prev PAPEREDNIKXD
#define next NASTUPNIKXD
#define pb push_back
#define deb cout<<"CHECK\n";
#define last(a) (a)[(a).size()-1]

#define elif else if
#define cclear cout<<flush;
#define fclear fflush(stdout);
#define x_files freopen("exam.in","r",stdin);freopen("exam.out","w",stdout);
#define kchay ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
const llong over999 = 1e14;
const ld eps = 1e-9;
const int base = 1000*1000;
const ld Pi = acos(-1);
const llong md = 1e9+7;
const llong ya = 0;

/*.st*/


int n, m, q, a[10100], c[200][200];

void dfs(int x, int y, int it)
{
    if(!a[it])it++;
    a[it]--;
    c[x][y] = it;
    if(x+1 <= n && !c[x+1][y])dfs(x+1, y, it);
        elif(y+1 <= m && !c[x][y+1])dfs(x, y+1, it);
            elif(x-1 >= 1 && !c[x-1][y])dfs(x-1, y, it);
                elif(y-1 >=1 && !c[x][y-1])dfs(x, y-1, it);
    return;
}

int main() {
    kchay;   
    //x_files;
    
    cin >> n >> m;
    
    cin >> q;
    
    for(int i = 1; i <= q; i++)
    {
        cin >> a[i];
    }
    
    dfs(1, 1, 1);
    
    
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=1;i<n+1;i++)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
#define stringc(s) string s; cin >> s;
using namespace std;
int main() {
  unsigned ll x,a=100,b=0;
  cin >> x;
  while(a<x) {
    a=a+a/100;
    b++;
  }
  cout << b << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
    return 0;
}

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

using namespace std;

int main(void){
    long long n;
    cin >> n;
    long long ans = n+1;
    for(long long i = 1; i <= sqrt(n); i++){
        if(n % i == 0){
            if(i == 1){
                ans = min(ans, n-1);
            }else{
                ans = min(ans, n/i + i - 2);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int asc(const void *a, const void *b) {
	return *(int *)a - *(int *)b;
}

int find(int x, int par[]){
	if (par[x] == x)return x;
	else return par[x] = find(par[x], par);
}

void unite(int x, int y, int par[]){
	int rx = find(x, par);
	int ry = find(y, par);
	if (rx != ry)par[ry] = rx;
}

int main(void){
	int n, m;
	scanf("%d %d", &n, &m);
	int par[100001];
	int i;
	for (i = 1; i <= n; i++){
		par[i] = i;
	}
	for (i = 0; i < m; i++){
		int x, y, z;
		scanf("%d %d %d", &x, &y, &z);
		unite(x, y, par);
	}
	for (i = 1; i <= n; i++){
		par[i] = find(i, par);
	}
	qsort(par, n + 1, sizeof(int), asc);
	int now = 0;
	int count = 0;
	for (i = 1; i <= n; i++){
		if (par[i] != now){
			count++;
			now = par[i];
		}
	}
	printf("%d\n", count);
		return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int n;
  cin >> n;
  
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  
  int ans = 0;
  int p = 0;
  
  for(int i=0;i<n;i++){
    if(i < n - 1 && a[i] >= a[i + 1]) p++;
    else{
      if(ans < p) ans = p;
      p = 0;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


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

using ll = long long;
ll a, b, x;

int main()
{
    cin >> a >> b >> x;

    long long  ans = 0;
    if (a == 0)
    {
        ans = (b / x + 1);
    }
    else
    {
        ans = (b / x + 1) - ((a-1)/x + 1);
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int x;
  cin >> x;
  x /= 200;
  cout << 10 - x << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int main(void){
	int A, B, ans = 0;
	string S;
	cin >> A >> B >> S;
	if(S.size() == A + B + 1){
		if(S[A] == '-'){
			for(int i = 0; i < S.size(); i++){
				if(i == A) {
					// do nothing
				} else if (!isdigit(S[i])){
					cout << "No" << endl;
					return 0;
				}
			}
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)




int main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt	
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif	

    FAST
//	PRECISE

ll n,k;
cin>>n>>k;
ve <ll> v(n);
FOR(i,0,n)cin>>v[i];
ll l=1,r=1000000000;
while(l!=r){
	ll mid=(l+r)/2;
	ll rem=k;
	ll ok=1;
	FOR(i,0,n){
		ll y=v[i]/mid;
		ll re=y-1;
		if(v[i]%mid!=0)re++;
		if(rem>=re)rem-=re;
		else ok=0;
	}
	if(ok)r=mid;
	else l=mid+1;
}
cout<<l;

// ll n,q;
// cin>>n>>q;
// ve <ll> v(n);
// FOR(i,0,n)cin>>v[i];




return 0;
 }



Measured memory_bytes: 4776
def f(n)
  return   if n < 0
  return n if n < 2
  a, b = 0, 1
  n.times { a, b = b, a + b }
  a
end

n, m = gets.split.map &:to_i

x = 1
b = 0

m.times do
  e = gets.to_i
  x *= f(e-b)
  b = e+1
end
x *= f(n-b+1)
p x % 1_000_000_007

Measured memory_bytes: 21756
from collections import Counter
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

for cx in range(101):
  for cy in range(101):
    l0 = [abs(cx - x) + abs(cy - y) for x, y, h in L if h == 0]
    m = min(l0) if l0 else float('inf')
    c = Counter(h + abs(cx - x) + abs(cy - y) for x, y, h in L if h != 0)
    if len(c) == 1 and c.most_common()[0][0] <= m:
      print(cx, cy, c.most_common()[0][0])
      exit()

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

using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vb = vector<bool>;
using vs = vector<string>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const ld eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for (ll i=(a); i<(b);i++)
#define FORD(i, a, b) for (ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll weight[101] = {0};
ll value[101] = {0};
ll maximum[105][100005] = {};
ll n, w;

ll knapsack(ll item, ll weightLeft) {
	if (weightLeft == 0) {
		return 0;
	}
	if (weightLeft < 0) {
		return -oo;
	}
	if (item > n) {
		return 0;
	}
	if (maximum[item][weightLeft] != -1) {
		return maximum[item][weightLeft];
	}
	ll res;

	res = max(knapsack(item + 1, weightLeft - weight[item]) + value[item], knapsack(item + 1, weightLeft));

	maximum[item][weightLeft] = res;
	return res;
}

int main() {
	cin.sync_with_stdio(0);

	fill(&maximum[0][0], &maximum[0][0] + sizeof(maximum) / sizeof(maximum[0][0]), -1);

	cin >> n >> w;

	FOR(i, 1, n + 1) {
		ll tw, tv;
		cin >> weight[i] >> value[i];
	}

	cout << knapsack(1, w);
}

Measured memory_bytes: 82304
N = int(input())
X = []
for i in range(N):
    x,l=map(int,input().split())
    X.append([x-l,x+l])

X = sorted(X, key=lambda x:x[1])
a = X[0][0]-1
ans = 0
for i in range(N):
    if X[i][0] >= a:
        a =X[i][1]
        ans +=1
    else:
        continue
print(ans)

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

int main() {
	string str, ans = "";
	stack<char> s;
	cin >> str;
	for (char c : str) {
		if (c == '0') s.push(c);
		else if (c == '1') s.push(c);
		else if (!s.empty()) s.pop();
	}
	while (!s.empty()) {
		ans.push_back(s.top());
		s.pop();
	}
	for (int i = ans.length() - 1; i >= 0; i--) cout << ans[i];
}


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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        p[x - 1] = i;
    }
    set<int> cur;
    ll ans = 0;
    for (int i = n - 1; i >= 0; --i) {
        vector<ll> ml(2, -1), mr(2, n);
        auto itl = cur.lower_bound(p[i]), itr = itl;
        for (int i = 0; i < 2; ++i) {
            if (itl != cur.begin()) {
                --itl;
                ml[i] = *itl;
            }
            if (itr != cur.end()) {
                mr[i] = *itr;
                ++itr;
            }
        }
        ans += 1ll * ((ml[0] - ml[1]) * (mr[0] - p[i]) + (p[i] - ml[0]) * (mr[1] - mr[0])) * (i + 1);
        cur.emplace(p[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5376
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <bits/stdc++.h>
#define   int  long long 
#define   pb   push_back
#define   co(x)  cout << x << '\n' 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
using namespace std;

inline void solve(){
    int n, k, ans = 0 ; 
    cin >> n >> k ; // max(n,k) <= 100 
    vector <int> a(n+5);
    for (int i=0;i<n;i++) 
        cin >> a[i] ; 
    for (int  i=1 ; i <= min(n,k) ; i++) { 
        for (int j=0;j<=i;j++){
            int  l = j, r = i - j, cur = 0 ; 
            vector <int> hand;
            for (int  t = 0 ; t < l ; t++ ) {
                hand.pb( a[t] ) ; 
            }
            for (int  t = 0 ; t < r ; t++ ) { 
                hand.pb( a[n-t-1] ) ; 
            }
            sort(all(hand)) ; 
          	reverse(all(hand));
            for (int  t=1 ; t <= k-i and sz(hand)>0 ; t++) { 
                if (hand.back()<0) hand.pop_back();
                else break;
            }
            for (auto &it: hand) cur += it ; 
            ans = max(ans, cur) ; 
        }
    }
    co (ans) ; 
}

//problem link: https://atcoder.jp/contests/abc128/tasks/abc128_d 

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
long long my_gcd(long long x, long long y){
	while(y!=1){
		if(x%y == 0) return y;
		long long temp = x;
		x = y;
		y = temp%y;
	}
	return 1;
}
	

int main(){
	long long a,b,c,d;
	cin >> a >> b >> c >> d;
	long long gcd = my_gcd(c,d);
	long long scm = c/gcd*d;
	//cout << gcd << " " << scm << endl;
	long long count = 0;
	count += b/c;
	count += b/d;
	count -= b/scm;
	count -= (a-1)/c;
	count -= (a-1)/d;
	count += (a-1)/scm;

	cout << (b-a+1)-count;
	
}
		
		
    
	




Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int b, r, g, c, s, t;

  while(1){
    cin >> b >> r >> g >> c >> s >> t;
    if(b == 0 && r == 0 && g == 0 && c == 0 && s == 0 && t == 0){
      break;
    }
    t -= s;
    int tb = 5*b + 3*r;
    t -= tb;
    int u = tb*13;
    int m = t * 3;

    int v = 100 + u + 15*(b+r) + 7*g + 2*c - m;
    cout << v << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int n, x, y, z;
    cin >> n >> x;
    int a[x];
    for (int i = 0; i < x; i++) cin >> a[i];
    cin >> y;
    int b[y];
    for (int i = 0; i < y; i++) cin >> b[i];
    cin >> z;
    int c[z];
    for (int i = 0; i < z; i++) cin >> c[i];
    sort(a, a + x);
    sort(b, b + y);
    sort(c, c + z);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i == *lower_bound(c, c + z, i)) {
            if (i == *lower_bound(b, b + y, i)) ans++;
            else if (!(i == *lower_bound(a, a + x, i))) ans++;
        }
    }
    cout << ans << endl;
}


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

ll dfs(ll n, ll x){
    if(x == 0) return 0;
    if(n == 0) return 1;
    ll a = pow((ll)2,(ll)(n+1));
    if(x <= a-2) return dfs(n-1,x-1);
    else return a/2 + dfs(n-1,min(a-3,x-a+1));
}

int main(){
    ll n, x;
    cin >> n >> x;
    ll ans = dfs(n,x);
    cout << ans << endl;
   return 0;
}

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

int main(){
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  
  int S1 = A*B;
  int S2 = C*D;
  
  int ans;
  S1>S2 ? ans=S1 : ans=S2;
  
  cout <<ans<<endl;
}

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

using namespace std;

#define REP(i,x) for(int i=0; i<(int)(x); i++)       // 0 <= i < x
#define REPS(i,x) for(int i=1; i<=(int)(x); i++)     // 0 < i <= x
#define RREP(i,x) for(int i=((int)(x)-1); i>=0; i--) // x > i >= 0
#define RREPS(i,x) for(int i=((int)(x)); i>0; i--)   // x >= i > 0
#define INF 100000000

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

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

int main(void){
	int N, K;
    cin >> N >> K;
    int ar[200001] = {0}, temp;
    REP(i, N){
        cin >> temp;
        ar[--temp]++;
    }
    
    sort(ar, ar+N, greater<int>());
    int res = 0;
    for(int i=K; i<N; i++){
        res += ar[i];
    }

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


Measured memory_bytes: 1024
import sys
from collections import defaultdict

# sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


M = 10
inf = 10 ** 20


def solve():
    n, ma, mb = read_int_list()
    p = [read_int_list() for i in range(n)]
    min_c = defaultdict(lambda: inf)
    min_c[(0, 0)] = 0

    for i, (a, b, c) in enumerate(p):
        for u in range(M * i, -1, -1):
            for v in range(M * i, -1, -1):
                if (u, v) in min_c:
                    cost = min_c[(u, v)]
                    if cost + c < min_c[((u + a), (v + b))]:
                        min_c[((u + a), (v + b))] = cost + c

    res = inf
    for u in range(0, M * n + 1):
        for v in range(0, M * n + 1):
            if u == 0 and v == 0:
                continue
            if u * mb == v * ma:
                if (u, v) in min_c:
                    cost = min_c[(u, v)]
                    if cost < res:
                        res = cost
    if res == inf:
        res = -1
    return res


def main():
    res = solve()
    print(res)


main()


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

int main(){
	int n=0;
	int m=0;
	int a[50];
	int b[50];
	int i=0;
	int ans[50];
	for(i=0;i<50;i++){
		ans[i]=0;
	}
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>a[i]>>b[i];
	}
	for(i=0;i<m;i++){
	        
		ans[a[i]-1]=ans[a[i]-1]+1;
		ans[b[i]-1]=ans[b[i]-1]+1;
	
	}
	for(i=0;i<n;i++){
		cout<<ans[i]<<endl;
	}
}

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

namespace ACB61A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (a <= c && c <= b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;
typedef pair<double, double >pd;

const ll mod = 1e4;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const double eps = 1e-10;
const double PI = 3.14159265358979323846;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second






int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0;i < s.size();i++) {
		string ans;
		for (int j = 0;j < s.size();j++) {
			ans += s[(i + j) % (int)s.size()];
		}
		if (ans == t) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

ll dp[100005];

int main()
{
    string s;
    int k;
    cin >> s >> k;
    vector<string> v;

    rep(i, s.size()){
        reps(j, k){
            string tmp = s.substr(i, j);
            if(tmp != "") v.push_back(tmp);
        }
    }

    sort(all(v));
    v.erase(unique(all(v)), v.end());
    cout << v[k-1];

}

Measured memory_bytes: 1660
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

Measured memory_bytes: 9096
package main

import (
	"fmt"
)

type Book struct {
	cost int
	values []int
}

func main() {
	var n, m, x int
	// var result int = 0
	fmt.Scanf("%d %d %d", &n, &m, &x)

	books := make([]Book, n)

	for i := 0; i < n; i++ {
		var cost int
		fmt.Scan(&cost)
		values := make([]int, m)
		for j := 0; j < m; j++ {
			fmt.Scan(&values[j])
		}
		books[i] = Book{ cost, values }
	}

	fmt.Printf("%d", backtrack(books, x, m));
}

func countFulfill(expect int, curSkill []int) int {
	count := 0
	for i := 0; i < len(curSkill); i++ {
		if curSkill[i] >= expect {
			count++
		}
	}
	return count
}

func addArray(a []int, b[]int) []int {
	c := make([]int, len(a))
	for i := 0; i < len(a); i++ {
		c[i] = a[i] + b[i]
	}
	return c
}

func backtrack(books []Book, expect int, skillNum int) int {
	return loop(books, expect, make([]int, skillNum), 0)
}

func loop(books []Book, expect int, curSkill []int, curCost int) int {
	// 既に満たしている場合をチェック
	var fullfillNum = countFulfill(expect, curSkill)
	if (fullfillNum == len(curSkill)) {
		return curCost
	}

	// 次の本がない場合
	if len(books) == 0 {
		return -1
	}

	cost1 := loop(books[1:], expect, addArray(curSkill, books[0].values), curCost + books[0].cost)
	cost2 := loop(books[1:], expect, curSkill, curCost);

	if cost1 == -1 {
		return cost2
	} else if cost2 ==  -1 {
		return cost1
	} else {
		if cost1 < cost2 {
			return cost1
		} else {
			return cost2
		}
	}
}


Measured memory_bytes: 2216
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MXX = 50 + 5;

string s[5];
int cnt = -1;
void go(int curr)
{

 //  cout<<curr<<endl;
   cnt = curr;
   if(s[curr].size() == 0)
   {
       if(curr == 0)
       {
           return;
           cout<<"A"<<endl;
           exit(0);
       }
       else if(curr = 1)
       {
          return;
           cout<<"B"<<endl;
          // cout<<curr<<endl;
           exit(0);
       }
       else
       {
           return;
           cout<<"C"<<endl;
           exit(0);
       }

   }
   char turn = s[curr][0];
   s[curr].erase(0, 1);
   int pep = turn - 'a';
   go(pep);
}

int main()
{
    cin>>s[0]>>s[1]>>s[2];
    go(0);
    //cout<<cnt<<endl;
    //return 0;
    if(cnt == 0)cout<<"A"<<endl;
    else if(cnt == 1)cout<<"B"<<endl;
    else cout<<"C"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  int W, H, x, y; cin >> W >> H >> x >> y;
  
  cout << fixed << setprecision(11);
  cout << double(W)*double(H)/2.0 << endl;
  cout << (2*x==W && 2*y==H ? 1 : 0) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> values(M);
    vector<vector<int>> openLists(M);
    for (int i = 0; i < M; ++i)
    {
        int bi; cin >> values[i] >> bi;
        for (int j = 0; j < bi; ++j)
        {
            int cj; cin >> cj; --cj;
            openLists[i].push_back(cj);
        }
    }
    // dp[bit] : 鍵の開閉状態がbitとなる場合の最小費用
    // bit は最大で 2^12 = 4,096通り
    const int INF = 1e9;
    vector<int> dp(1 << N, INF);
    dp[0] = 0;
    for (int i = 1; i <= M; ++i)
    {
        const int value = values[i - 1];
        const auto openList = openLists[i - 1];
        // 鍵を使うことで開く宝箱を数値に変換
        int now = 0;
        for (const int box : openList)
        {
            now += (1 << box);
        }
        for (int bit = 0; bit < (1 << N); ++bit)
        {
            dp[bit | now] = min(dp[bit | now], dp[bit] + value);
        }
    }
    int ans = dp[(1 << N) - 1];
    cout << (ans == INF ? -1 : ans) << endl;
}


Measured memory_bytes: 384
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}
fn main() {
    let N: usize = read();
    let S: String = read();
    if N % 2 != 0 {
        println!("No");
        return;
    }
    let (first, last) = S.split_at(N / 2);
    if first == last {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <unordered_set>
#include <set>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

using ll = long long;
const ll INF = 1e18 + 1;


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

    ll n;
    cin >> n;

    string str;

    while(n != 0) {
        n--;
        str = (char)('a' + n%26) + str;
        n /= 26;
    }

    cout << str << endl;


}

Measured memory_bytes: 3132
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_Q 101

using namespace std;

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

int main() {
    int Q;
    ll A[MAX_Q], B[MAX_Q];
    cin >> Q;
    for (int i = 0; i < Q; ++i) {
        cin >> A[i] >> B[i];
    }
    
    for (int i = 0; i < Q; ++i) {
        ll ans = 0;
        ll mul = A[i] * B[i];
        ll m = (ll)sqrt((double)mul);
        if (m * m == mul) {
            --m;
        }
        // m: sqrt(mul)より真に小さい整数
        
        if (m * (m + 1) < mul) {
            ans = 2 * m;
        } else {
            ans = 2 * m - 1;
        }
        
        if (m >= A[i]) {
            --ans;
        }
        if (m >= B[i]) {
            --ans;
        }
        
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	mp := make(map[int]struct{})
	rec(0, mp)

	if _, e := mp[N]; e {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

func rec(n int, mp map[int]struct{}) {
	if n > 100 {
		return
	}
	if _, e := mp[n]; e {
		return
	}
	mp[n] = struct{}{}
	rec(n+4, mp)
	rec(n+7, mp)
}


Measured memory_bytes: 640