akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SMI(): return input().split()
def SLI(): return list(input())

def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')

# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N, Y = MI()

    for i in range(N+1):
        for j in range(N+1):
            if N - i - j < 0:
                continue
            k = N - i - j
            ans = 10000 * i + 5000 * j + 1000 * k
            if ans == Y:
                print(i, j, k)
                return
    print(-1, -1, -1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
/*  ex3_2
    pptenshi  */

#include<stdio.h>

int main(void) {
    int num;
    int num_1;  // nの1の位

    // input
    scanf("%d", &num);

    num_1 = num % 10;

    //output
    switch (num_1) {
        case 2: case 4: case 5: case 7: case 9:
            printf("hon\n");
            break;
        case 0: case 1: case 6:  case 8:
            printf("pon\n");
            break;
        case 3:
            printf("bon\n");
            break;
    }

    return 0;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, z = 32, a;
    cin >> n;
    while (n--) {
        cin >> a;
        int b = 0;
        while (a % 2 == 0) a /= 2, b++;
        z = min(z, b);
    }
    cout << z;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define INF 0x3f3f3f3f
//#define Local
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5 + 5, MOD = 1e9 + 7;

int n, m;
int x[N], y[N], d[N];
struct Point{
    int a, b;
    bool operator < (const Point& A) const {
        if(a == A.a) return b > A.b;
        return a < A.a;
    }
}p[N];

int c[N];
int lowbit(int x) {return x & (-x);}

void add(int x, int v) {
    for(; x < N; x += lowbit(x)) c[x] = (c[x] + v) % MOD;
}

int query(int x) {
    int ans = 0;
    for(; x > 0; x -= lowbit(x)) ans = (ans + c[x]) % MOD;
    return ans;
}

void run() {
    d[0] = 0;
    memset(c, 0, sizeof(c));
    for(int i = 1; i <= n; i++) cin >> x[i];
    for(int i = 1; i <= m; i++) cin >> y[i];
    int cnt = 0;
    for(int i = 1; i <= n; i++) {
        if(x[i] > y[1] && x[i] < y[m]) {
            int left = lower_bound(y + 1, y + m + 1, x[i]) - y - 1;
            int right = left + 1;
            int l = x[i] - y[left], r = y[right] - x[i];
            p[++cnt] = {l, r};
            d[++d[0]] = r;
        }
    }
    sort(d + 1, d + d[0] + 1);
    d[0] = unique(d + 1, d + d[0] + 1) - d - 1;
    for(int i = 1; i <= cnt; i++) {
        p[i].b = lower_bound(d + 1, d + d[0] + 1, p[i].b) - d;
    }
    sort(p + 1, p + cnt + 1);
    int ans = 1;
    for(int i = 1; i <= cnt; i++) {
        if(p[i].a == p[i - 1].a && p[i].b == p[i - 1].b) continue;
        int res = query(p[i].b - 1) + 1;
        if(res >= MOD) res -= MOD;
        add(p[i].b, res);
        ans = (ans + res) % MOD;
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
#ifdef Local
    freopen("../input.in", "r", stdin);
    freopen("../output.out", "w", stdout);
#endif
    while(cin >> n >> m) run();
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	string s;
	while(cin>>s,s!="#"){
		vi f(2,-1);
		vi r,l;
		bool b=true;
		int lt=0,rt=1,a1=0,a2=0;;
		for(auto c:s){
		    int p=c-'1';
		    if(b){
    		    if(f[0]==-1||f[0]%3==p%3){
    		        f[0]=p;
    		    }else{
    		        f[1]=p;
    		        if(f[0]%3>f[1]%3){
    		            swap(lt,rt);
    		            swap(f[0],f[1]);
    		        }
    		        b=false;
    		        r=l=f;
    		    }
		    }else{
		        if(rt%2==0){
		            if(r[0]%3>p%3){
		                r[0]=p;
		                a1++;
		            }else{
		                rt++;
		                r[1]=p;
		            }
		        }else{
		            if(r[1]%3<p%3){
		                r[1]=p;
		                a1++;
		            }else{
		                rt++;
		                r[0]=p;
		            }
		        }
		        if(lt%2==0){
		            if(l[1]%3<p%3){
		                l[1]=p;
		                a2++;
		            }else{
		                lt++;
		                l[0]=p;
		            }
		        }else{
		            if(l[0]%3>p%3){
		                l[0]=p;
		                a2++;
		            }else{
		                lt++;
		                l[1]=p;
		            }
		        }
		    }
		}
		cout<<min(a1,a2)<<endl;
	}
	return 0;
}



Measured memory_bytes: 3140
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(1, len(p)-1):
    if p[i - 1] < p[i] < p[i + 1] or p[i - 1] > p[i] > p[i + 1]:
        cnt += 1
print(cnt)


Measured memory_bytes: 2940
N = int(input())
H = [int(i) for i in input().split()]
m_max = 0
count = 0
for j in range(1, N):
  if H[j] <= H[j-1]:
    count += 1
    if j == N-1:
      if count > m_max:
        m_max = count
  else:
    if count > m_max:
      m_max = count
    count = 0
print(m_max)

Measured memory_bytes: 14252
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()
#define pb push_back

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 1e5 + 20 , MX = 400 + 20 ;
int n , H , a[N] , b[N] , c[N] , d[N] ;

vector <int> g[MX] , h[MX] ;

bool vis[MX] , c1 , c2 ;

inline void err () {
	cout << "NO\n" ;
	exit(0) ;
}

void dfs (int v) {
	vis[v] = 1 ;
	if (v < MX / 2 && _sz(h[v]) > _sz(g[v])) c1 = 1 ;
	if (v > MX / 2 && _sz(h[v]) < _sz(g[v])) c2 = 1 ;

	for (int u : g[v]) {
		if (!vis[u]) dfs(u) ;
	}
	for (int u : h[v]) {
		if (!vis[u]) dfs(u) ;
	}
}

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

	cin >> n >> H ;
	for (int i = 0 ; i < n ; i ++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i] ;
	
		int l , r ;

		if (c[i]) l = -c[i] ;
		else l = a[i] ;

		if (d[i]) r = d[i] ;
		else r = -b[i] ;
	
		l += MX / 2 , r += MX / 2 ;

		g[l].pb(r) ;
		h[r].pb(l) ;
	}

	for (int i = 0 ; i < MX ; i ++) {
		if (i < MX / 2 && _sz(g[i]) > _sz(h[i])) err() ;
		if (i > MX / 2 && _sz(g[i]) < _sz(h[i])) err() ;
	}

	for (int i = 0 ; i < MX ; i ++) {
		if (_sz(g[i]) + _sz(h[i]) && !vis[i]) {
			c1 = 0 ;
			c2 = 0 ;
			dfs(i) ;

			if (!c1 || !c2) err() ;
		}
	}
	
	cout << "YES\n" ;
}


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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    long long int a[n];
    int d = 1e9;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if((i != 0 && a[i - 1] < 0 && a[i] >= 0) || (a[i] >= 0 && d == 1e9)){
            d = i;
        }
    }
    long long int ans = 1e18;
    if(d == 0){
        cout << a[k - 1]; return 0;
    }
    if(d >= 1e9){
        cout << -a[n - k]; return 0;
    }
    for(int i = d; i < n; i++){
        int mosbat = i - d + 1;
        if(d - (k - mosbat) >= 0){
            ans = min(ans, 2 * a[i] - a[d - (k - mosbat)]);
        }
    }
    for(int i = d - 1; i >= 0; i--){
        int manfy = d - i;
        if(d + (k - manfy - 1) < n){
            ans = min(ans, (-1) * 2 * a[i] + a[d + (k - manfy - 1)]);
        }
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
   cin >> A>>B>>C>>D;
  if(A+B == C+D)
    cout << "Balanced" << endl;
  else
    cout <<(A+B<C+D ? "Right" : "Left")<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		String[] list = {"a","b","c","d","e","f","g","h","i","j",
						"k","l","m","n","o","p","q","r","s","t",
						"u","v","w","x","y","z"};
		int exp = 0;
		String name = "";
		
		long pow = 0;
		for(int i=1;i<=12;i++) {
			if(pow < n) {
				pow = (long) (pow + Math.pow(26, i));
			}else {
				exp = i-1;
				break;
			}
		}
		
		long s = 0;
		String[] namelist = new String[exp];
		for(int j=0;j<exp;j++) {
			if(n > 26) {
				s = n % 26;
				n = n / 26;
				if(s == 0) {
					s = 26;
					n = n - 1;
				}
				namelist[j] = list[(int) (s-1)];
			}else {
				namelist[j] = list[(int) (n-1)];
			}
		}
		for(int k=exp-1;k>=0;k--) {
			name = name + namelist[k];
		}
		System.out.println(name);
	}

}

Measured memory_bytes: 39476
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 32;

int main() {
  int A, B;
  cin >> A >> B;
  int ans = 6 - A - B;
  cout << ans << endl;

  return 0;
}

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

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll h;
	cin >> h;
	
	ll n = 1;
	ll ans = 0;
	while(h > 0){
		ans += n;
		h /= 2;
		n *= 2;
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>
#include <queue>

typedef long long ll;

using namespace std;

static int ca[2 * 100000];

int main(){
    int n;
    cin >> n;
    vector<int> v;

    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        v.push_back(x);
        ca[x - 1]++;
    }

    map<int, ll> ans;
    ll sum = 0;
    for(int i = 1; i <= n; i++){
        ll a, b;
        if(ca[i - 1] == 0) continue;
        a = (ll)ca[i - 1] * (ca[i - 1] - 1) / 2;
        if(ca[i - 1] >= 2) {
            b = (ll)(ca[i - 1] - 1) * (ca[i - 1] - 2) / 2;
        } else {
            b = 0;
        }
        sum += a;
        ans.insert(make_pair(i, a - b));
    }

    for(int i = 0; i < n; i++){
        cout << sum - ans[v[i]] << endl;
    }
}


Measured memory_bytes: 11124
#include <stdio.h>
int BubbleSort(int a[],int n)
{
    int flag = 1,count = 0;
    int k = 0;
    
    while(flag)
    {   flag = 0;
        for(int i = n-1;i>k;i--)
        {
            if(a[i]<a[i-1])
            {
                int j = a[i];
                a[i] = a[i-1];
                a[i-1] = j;
                count++;
                flag = 1;
                
                            }
            
        }
        k++;
    }
    return count;
}




int main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    int count = 0;
    
    for(int i = 0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    
    count = BubbleSort(a,n);
    
    
    for(int i = 0;i<n;i++)
    {
        if(0<i&&i<n)
            printf(" ");
        printf("%d",a[i]);
    }
    puts("");
    printf("%d\n",count);
    
    return 0;
    
}




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

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

  int a[1000];
  for(int i=0;i<n;i++) cin>>a[i];
  
    
  for(int i=0;i < n-1-i;i++) swap(a[i], a[n-1-i]);

  for(int i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<a[i];
  }
  cout<<endl;

  return 0;
}



Measured memory_bytes: 3116
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	if (a[0] + a[1] + a[2] >= 22)
		printf("bust");
	else
		printf("win");
 	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>

using namespace std;

string solve(string s){
	char buf;
	string ans ="";
	buf = s[0];
	int count = 1;
	for(int i=1;i<s.length();i++){
		if(buf == s[i]){
			count++;
		}else{
			stringstream ss;
			ss << count;
			ans += ss.str();
			ans += buf;
			buf = s[i];
			count = 1;
		}
	}
	stringstream ss;
	ss << count;
	ans += ss.str();
	ans += buf;

	return ans;
}

int main(){
	int n;
	string s;
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		cin >> s;
		for(int i=0;i<n;i++){
			s = solve(s);
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1116
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	LL n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	vector<int> first(200002, -1), next(200002, -1), vis(n, -1);
	for (int i = n - 1; i >= 0; --i) {
		next[i] = first[a[i]];
		first[a[i]] = i;
	}
	bool skipped = false;
	int pos = 0;
	vector<int> ans;
	for (LL i = 0; i < k; ++i) {
		while (pos < n) {
			if (!skipped && vis[pos] >= 0) {
				skipped = true;
				LL t = i - vis[pos];
				i += (max(0LL, (k - i - 3) / t)) * t;
			} else {
				vis[pos] = i;
			}
			int next_pos = next[pos];
			if (next_pos < 0) {
				if (i == k - 1) {
					ans.push_back(a[pos++]);
				} else {
					pos = first[a[pos]] + n + 1;
				}
			} else {
				pos = next_pos + 1;
			}
		}
		pos -= n;
	}
	for (auto x : ans) {
		cout << " " << x;
	}
	cout << endl;
	return 0;
}


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

int main(){

	int n,m;
	cin >> n >> m ;
	
	vector<int> a(1000),b(55),ans(10000,0);
	
	for(int i=0;i<m;i++)
		cin >> a.at(i) >> b.at(i);
	
	for(int i=0;i<m;i++){
	
		for(int j=0;j<n;j++){
		
			if(j+1==a.at(i))ans.at(j)++;
			if(j+1==b.at(i))ans.at(j)++;
			
		}
	}
	
	for(int i=0;i<n;i++)cout << ans.at(i) <<endl;

}

Measured memory_bytes: 256
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define    x            real()
#define    y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     point        complex<double>
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
vector< pair<int,int> > v;
int fact(ll no){
   int res=0;
   for(ll i=2;i*i<=no;i++){
    ll cnt=0;
    while(no%i==0){
        no/=i;
        cnt++;
    }
    if(cnt>0)
        res++;
   }
   if(no>1){
    res++;
   }
   return res+1;
}
int main(){
    GO();
    ll a,b;
    cin>>a>>b;
    ll g=__gcd(a,b);
    cout<<fact(g)<<"\n";
}


Measured memory_bytes: 256
# encoding: utf-8
import itertools


n = int(input())
xlist = []
ylist = []
hlist = []
for i in range(n):
	xtmp, ytmp, htmp = map(int, input().split())
	xlist.append(xtmp)
	ylist.append(ytmp)
	hlist.append(htmp)
h = max(hlist)
end_flag = False
while True:
	for cx, cy in itertools.product(range(101), range(101)):
		if all([hlist[i] == max(h - abs(xlist[i] - cx) - abs(ylist[i] - cy), 0) for i in range(n)]):
			print('{} {} {}'.format(cx, cy, h))
			end_flag = True
			break
	if end_flag:
		break
	h += 1


Measured memory_bytes: 59356
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long ret = r[0];
            for (int i = 0; i < N - 1; i++)
            {
                if (i == N - 2)
                {
                    ret += r[i];
                }
                else
                {
                    ret += Math.Min(r[i], r[i + 1]);
                }
            }
            Console.WriteLine(ret);
        }

    }
}

Measured memory_bytes: 13268
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline T int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
// sort(ALL(v), [](auto const& lhs, auto const& rhs) { return lhs > rhs; /* 左の方が大きい...というイメージ。*/ });
// --------------------------------------------------------------------------------------------- //

static const int MAX = 100001;
static const ll MOD = 1000000007;


int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int K; cin >> K;
	rep(i, K){
		cout << "ACL";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>
int main(void)
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(((r<=x)&&(x<=(W-r)))&&((r<=y)&&(y<=H-r)))
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 2664
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;


int main(){
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++){
        int a = i, cnt = 0;
        while(a){
            cnt++;
            a /= 10;
        }
        if(cnt&1)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    ll n;
    cin>>n;
    ll m=sqrt(n);
    cout<<(m*m)<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#define yes(n) std::cout << ((n) ? "Yes" : "No") << std::endl
int main()
{
    std::string S,T;
    std::cin >> S >> T;
    int n,m;
    std::cin >> n >> m;
    std::string U;
    std::cin >> U;
    if(S == U)
        std::cout << (n - 1) <<" " << m      << std::endl;
    else
    {
        std::cout <<  n      <<" "<< (m - 1) << std::endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for(int i = 0; i < m; ++i)  cin >> a[i];
    sort(a.begin(), a.end());
    vector<int> dist;
    for(int i = 0; i + 1 < m; ++i)  dist.push_back(a[i + 1] - a[i]);
    sort(dist.begin(), dist.end());
    ll ans = 0;
    for(int i = 0; i < m - n; ++i)  ans += dist[i];
    cout << ans << endl;
}

Measured memory_bytes: 1276
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main()
{
	auto ab = readln.split.to!( int[] );
	writeln( solve( ab[ 0 ], ab[ 1 ] ) );
}

auto solve( in int a, in int b )
{
	auto d = b - a;
	auto h = iota( 1, d ).sum;
	
	return h - a;
}

unittest
{
	assert( solve( 8, 13 ) == 2 );
	assert( solve( 54, 65 ) == 1 );
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int i,j,n,m;
    int top,front,top_num,front_num;
    int num[6];
    for(i=0;i<6;i++){
        scanf("%d",&num[i]);
    }
    scanf("%c %d",&i,&i);
    for(j=0;j<i;j++){
        scanf("%d %d",&top,&front);
        for(n=1;num[0]!=top;n++){
            if(n%4==0){
                m=num[3];
                num[3]=num[4];
                num[4]=num[2];
                num[2]=num[1];
                num[1]=m;
            }
            m=num[4];
            num[4]=num[0];
            num[0]=num[1];
            num[1]=num[5];
            num[5]=m;
        }
        for(n=1;num[1]!=front;n++){
            m=num[3];
            num[3]=num[4];
            num[4]=num[2];
            num[2]=num[1];
            num[1]=m;
        }
        printf("%d\n",num[2]);
    }
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int N; cin >> N;

    bool ans = false;
    while (N > 0) {
        if (N%10 == 9) {
            ans = true;
            break;
        }

        N /= 10;
    }

    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int A,B;
       cin >> A>>B;
      
      if(A<=8&&B<=8) cout << "Yay!";
     else cout << ":(";
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int k,n;
	scanf("%d %d",&k,&n);
	for(int i=n-k+1;i<=n+k-1;i++)
	{
		if(i!=n-k+1)
		printf(" ");
		printf("%d",i);
	}
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
input()
b = list(map(int,input().split()))
t = b[0]
a = b[1]
c = list(map(int,input().split()))
c_temp = [abs(a-(t-i*0.006)) for i in c]
print(c_temp.index(min(c_temp))+1)


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
  int ar[200],br[200];
  int n,ans=0,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&ar[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&br[i]);
  }
   for(i=0;i<n;i++){
    if(ar[i]>br[i]){
      ans=ans+(ar[i]-br[i]);
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    a=parseMap(split(readline()))
    s=sum(a)
    ans=[0 for i in 1:n]
    ans[1]=s-2*sum(a[2:2:n-1])
    for i in 2:n
        # ans[i]+ans[i+1]=2*A[i]より
        # ans[i+1]=2*A[i]-ans[i]
        ans[i]=2*a[i-1]-ans[i-1]
    end
    println(join(ans," "))
end
main()

Measured memory_bytes: 172336
#include <bits/stdc++.h>
using namespace std;
int r,g,b;
void solve()
{
    if ((100*r+10*g+b)%4==0) cout<<"YES";
    else cout<<"NO";
    cout<<endl;
}
int main()
{
    while(cin>>r>>g>>b)
        solve();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String nextLine = sc.nextLine();
		int N = Integer.valueOf(nextLine.split("\\s+")[0]);
		int K = Integer.valueOf(nextLine.split("\\s+")[1]);
		nextLine = sc.nextLine();
		System.out.println(cal(nextLine.split("\\s+"), K));
	}

	private static int cal(String[] strings, int k) {
		int size = strings.length;
		int min = Integer.valueOf(strings[0]);
		int max = Integer.valueOf(strings[size - 1]);
		if (max <= 0) {
			return -Integer.valueOf(strings[size - k]);
		} else if (min >= 0) {
			return Integer.valueOf(strings[k - 1]);
		}
		int result = Integer.MAX_VALUE;
		for (int i = 0; i + k - 1 < size; i++) {
			int j = i + k - 1;
			min = Integer.valueOf(strings[i]);
			max = Integer.valueOf(strings[j]);
			int temp = countResult(min, max);
			if (result > temp)
				result = temp;
			if (min > 0)
				break;
		}
		return result;
	}

	private static int countResult(int min, int max) {
		if (max <= 0) {
			return -min;
		} else if (min >= 0) {
			return max;
		} else {
			return Math.min(-2 * min + max, -min + 2 * max);
		}
	}
}


Measured memory_bytes: 50060
#include<stdio.h>
int main(void)
{
	int A[101][101], b[101][1], c[101][1], n, m, i, j;
	scanf("%d %d", &n, &m);
	for(i = 0; i < n; ++i) {
		for(j = 0; j < m; ++j) {
			scanf("%d", &A[i][j]);
		}
	}
	for(j = 0; j < m; ++j) {
		scanf("%d", &b[j][0]);
	}
	for(i = 0; i < n; ++i) {
		c[i][0] = 0;
	}
	for(i = 0; i < n; ++i) {	
		for(j = 0; j < m; ++j) {
			c[i][0] += A[i][j]*b[j][0];
		}
		printf("%d\n", c[i][0]);
	}
	return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin>>N;
if(N==1)cout<<"Hello World"<<endl;
else{
    int A,B;
    cin>>A>>B;
    cout<<A+B<<endl;

}
//system("pause");
return 0;
}

Measured memory_bytes: 256
open Base
open Stdio

(* Core.read_line is deprecated *)
let read_line () =
    (* Out_channel.(flush stdout); *)
    In_channel.(input_line_exn stdin)

let mapt2 ~f (a, b) = (f a, f b)

let n = Int.of_string @@ read_line ()

let sums = Array.create ~len:(n+1) 0
let neg_res = Array.create ~len:(n+1) 0L
let g_hd = Array.create ~len:(n+1) 0
let g_nx = Array.create ~len:(2*n) 0
let g_to = Array.create ~len:(2*n) 0
let g_len = ref 0
let g_add u v =
    g_len := !g_len + 1;
    g_nx.(!g_len) <- g_hd.(u);
    g_to.(!g_len) <- v;
    g_hd.(u) <- !g_len

let colors = read_line () |> String.split ~on:' ' |> List.map ~f:Int.of_string
    |> List.cons 0 |> Array.of_list

let rec dfs ?(cur=1) ?(par=0) () =
    let memo = sums.(colors.(par)) in
    let rec loop e acc = if e = 0 then acc else
        let ch = g_to.(e) in
        let ret = if ch = par then 0 else dfs ~cur:ch ~par:cur () in
        loop g_nx.(e) (ret + acc)
    in
    let tree_size = loop (g_hd.(cur)) 1 in

    sums.(colors.(cur)) <- sums.(colors.(cur)) + 1;
    let component_size = Int64.of_int @@ tree_size - (sums.(colors.(par)) - memo) in
    neg_res.(colors.(par)) <- Int64.(neg_res.(colors.(par)) + component_size * (component_size + 1L) / 2L);
    sums.(colors.(par)) <- tree_size + memo;
    tree_size

let _ =
    for i = 0 to n - 2 do
        let a, b = read_line () |> String.lsplit2_exn ~on:' ' |> mapt2 ~f:Int.of_string in
        g_add a b;
        g_add b a
    done

let _ =
    ignore (dfs ());
    for i = 1 to n do
        let component_size = Int64.of_int @@ n - sums.(i) in
        let n64 = Int64.of_int n in
        let res = Int64.(n64 * (n64 + 1L) / 2L - component_size * (component_size + 1L) / 2L - neg_res.(i)) in
        printf "%Ld\n" res
    done


Measured memory_bytes: 53396
#include <stdio.h>

int main(void){
    int num,x,y,b,p,sum,sum1;
    scanf("%d",&num);
    while(num--){
        scanf("%d %d %d %d",&x,&y,&b,&p);
        if(b>=5&&p>=2)
            printf("%d\n",(x*b+y*p)*8/10);
        else{
            sum=x*b+y*p;
            sum1=(x*(b>=5?b:5)+y*(p>=2?p:2))*0.8;
            printf("%d\n",sum>sum1?sum1:sum);
        }
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vll = vector<ll>;
using vdouble = vector<double>;
using vstr = vector<string>;
typedef pair<int,int> P;
int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
template<class T> inline bool chmax(T& a, T b){if(a<b) {a=b; return 1;} return 0; }
template<class T> inline bool chmin(T& a, T b){if(a>b) {a=b; return 1;} return 0; }
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const ll MAX_N = 100100;

ll dp[MAX_N];//dp[i]がiについての答え

int main(){
    ll N; cin>>N;
	
    rep(i,MAX_N) dp[i]=N;
    dp[0]=0;
	
	for(int n=0; n<N; n++){
		for(int j=1; n+j<=N; j*=6){
			dp[n+j]=min(dp[n]+1, dp[n+j]);
		}
		for(int j=1; n+j<=N; j*=9){
			dp[n+j]=min(dp[n]+1, dp[n+j]);
		}
		
	}
	
	cout<<dp[N]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>
#include <numeric>
#include <iomanip>

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

using namespace std;

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    vector<int> vec = {a, b, c, d, e};

    for (int i = 0; i < 5; i++)
    {
        for (int j = i; j < 5; j++)
        {
            if (vec[j] - vec[i] > k)
            {
                cout << ":(" << endl;
                return 0;
            }
            
        }
    }

    cout << "Yay!" << endl;
    
}

Measured memory_bytes: 256
def Main():
  a, b = map(int, input().split())
  if a > 1 and b > 1:
    if a < b:
      print("Bob")
    elif a > b:
      print("Alice")
    elif a == b:
      print('Draw')

  elif a == 1:
    # if b > a:
    #   print('Bob')
    if b == a:
      print('Draw')
    else:
      print('Alice')
  elif b == 1:
    # if a > b:
    #   print('Alice')
    if b == a:
      print("Draw")
    else:
      print('Bob')


if __name__ == '__main__':
  Main()

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

int main(int argc, char const *argv[]) {
  int a, b;
  std::cin >> a >> b;

  int sum = 0;
  
  for (size_t i = 0; i < 2; i++) {
    if (a > b) {
      sum += a;
      a--;
    } else {
      sum += b;
      b--;
    }
  }
  
  std::cout << sum << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int k,a,b;
    cin>>k>>a>>b;
    int value=a/k;
    int value1=value+1;
    if(a%k==0||b%k==0)
    {
        cout<<"OK";
    }
    else if (value1*k<=b)
    {
   
        cout<<"OK";
    }
    else
    {
        cout<<"NG";
    }
    
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll MOD = 1e9 +7;
const ll MAXN = 1e6 + 5;

inline ll quickpow(ll a, ll b){
	ll ans = 1;
	ll base = a % MOD;
	while(b){
		if(b & 1){
			ans = (ans % MOD * base % MOD) % MOD;
		}
		base = (base % MOD * base % MOD) % MOD;
		b = b >> 1;
	}
	ans %= MOD;
	return  ans;
}

ll p=MOD;

inline ll qpow(ll a,ll b){
    if(b==1) return a;
    ll t=qpow(a,b/2);
    t=t*t%p;
    if(b&1) t=t*a%p;
    return t;
}
inline ll C(ll n,ll m){
    if(n<m) return 0;
    if(m>n-m) m=n-m;
    ll a=1,b=1;
    for(int i=0;i<m;i++){
        a=(a*(n-i))%p;
        b=(b*(i+1))%p;
    }
    return a*qpow(b,p-2)%p;
}
inline ll Lucas(ll n,ll m){
    if(m==0) return 1;
    return Lucas(n/p,m/p)*C(n%p,m%p)%p;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,x,y;
	cin>>n>>x>>y;
	ll u=quickpow(2,n);
	ll v=Lucas(n,x);
	ll w=Lucas(n,y);
	ll t=(v+w)%MOD;
	if(n==2){
		cout<<0;
		return 0;
	}
	else cout<<(MOD+u-1-t)%MOD;
	return 0;
}


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll A, B;
ll tmp;
ll ret = 0;

void input() {
  IN(A);
  IN(B);
}

void solve() {
  ll i = 1;
  ll toA;
  ll toB;
  for(; i <= B; i = i<<1) {
    toA = A/(i<<1)*i + max(0ll, A%(i<<1)-i);
    toB = (B+1)/(i<<1)*i + max(0ll, (B+1)%(i<<1)-i);
    ret += ((toB-toA)&1)?i:0;
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fr(i,n,x) for(int i=0;i<n;i+=x)
#define pb push_back
int main(){
	int n,h,w;
	cin>>n>>h>>w;
	int ans=(n-(h-1))*(n-(w-1));
	cout<<ans;
}

Measured memory_bytes: 3488
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b

def main():
    N = int(input())
    for i in range(N, 10000):
        if len(set(str(i))) == 1:
            print(i)
            return 


if __name__ == '__main__':
    main()


Measured memory_bytes: 4456
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"1 3
" => r"2",

r"7 4
" => r"6",

r"5 5
" => r"5"
}

use std::cmp;
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i32,
        b: i32,
    }

    ((a + b + 1) / 2).to_string()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define scn(n) scanf("%d", &n)
#define scns(s) scanf("%s", &s)
#define pri(n) printf("%d", n)
#define priln(n) printf("%d\n", n)
#define pris(s) printf("%s", s)
#define prisln(s) printf("%s\n", s)
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; }

int main()
{
  long n;
  int k;
  scn(n);
  scn(k);

  int ans = 0;
  while (n >= k) {
    n = n / k;
    ans++;
  }

  pri(ans + 1);
  return 0;
}


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

int func(int choco, int d){
  int ret=1;
  for(int i = 1; i < d; i++){
	if(i * choco + 1 <= d){
      ret++;
    }
  }
  return ret;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int r,m,d;
  cin>>r>>m>>d;
  int R[r], M[m];
  int min_r = INF;
  for(int i=1;i<=r;i++) {
    cin >> R[i];
	min_r = min(min_r, R[i]);
  }
  int min_m = INF;
  for(int i = 1;i<=m;i++) {
    cin >> M[i];
    min_m = min(min_m, M[i]);
  }
  int x, y, c;
  int discountedSum = min_r + min_m;
  rep(i, d){
    cin >> x >> y >> c;
    if(discountedSum > R[x]+M[y]-c)
      discountedSum = R[x]+M[y]-c;
  }
  cout << discountedSum << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
template<class T>
void input(vector<T>& vec,int n){
	vec.resize(n);
	for(int i=0;i<n;i++){
		cin >> vec[i];
	}
}
ll dp[55][2];
int N,p;
int A[55];
int main(){
	cin >> N >> p;
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	dp[0][0] = 1ll;
	for(int i=0;i<N;i++){
		for(int j=0;j<2;j++){
		 dp[i+1][(j+A[i])%2]+=dp[i][j];
		 dp[i+1][j] += dp[i][j];
		}
	}	
	cout << dp[N][p] << endl;
	return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
s = [input() for _ in range(h)]

dp = [[h * w] * w for _ in range(h)]
dp[0][0] = int(s[0][0] == '#')
for i in range(h):
    for j in range(w):
        if i + 1 < h:
            dp[i + 1][j] = min(dp[i + 1][j],
                               dp[i][j] + int(s[i + 1][j] != s[i][j]))
        if j + 1 < w:
            dp[i][j + 1] = min(dp[i][j + 1],
                               dp[i][j] + int(s[i][j + 1] != s[i][j]))
print((dp[-1][-1] + 1) // 2)


Measured memory_bytes: 74212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A, B) << " ";
  if (A + B - N > 0)  {
    cout << A + B - N << endl;
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
typedef long long ll;
typedef unsigned un;
typedef std::string str;
typedef std::pair<ll,ll> pll;
ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return f*x;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
void umax(ll& a,ll t){if(t>a)a=t;}
void umin(ll& a,ll t){if(t<a)a=t;}
const ll INF=1ll<<58;
#define MAXN 200011
ll a[MAXN],w[MAXN];
int main()
{
	ll n=read(),l=read(),t=read(),rk=0;
	for(ll i=0;i<n;++i)
	{
		ll x=read(),dir=read();
		if(dir==1)
		{
			x+=t;
			rk=(rk+x/l)%n;
			a[i]=x%l;
		}
		else
		{
			x-=t;
			rk=(rk-(-x+l-1)/l)%n;
			a[i]=(x%l+l)%l;
		}
	}
	rk=(rk+n)%n;
	std::sort(a,a+n);
	for(ll i=rk;i<n;++i)printf("%lld\n",a[i]);
	for(ll i=0;i<rk;++i)printf("%lld\n",a[i]);
	return 0;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if(a>b && b!=1){
    cout<<"Alice"<<endl;
  }else if(a>b && b==1){
    cout<<"Bob"<<endl;
  }else if(a<b && a!=1){
    cout<<"Bob"<<endl;
  }else if(a<b && a==1){
    cout<<"Alice"<<endl;
  }else if(a==b){
    cout<<"Draw"<<endl;
  }
}


Measured memory_bytes: 384
#include <stdio.h>

#define max(a,b) (((a)>(b)) ? (a):(b))
#define min(a,b) (((a)<(b)) ? (a):(b))
#define rep(i,s,n) for(int i=(int)s;i<(int)(n);i++)
#define MAX 1000000000
#define MIN -1000000000

void swap(int *a,int *b){
    int tmp=*b;
    *b=*a;
    *a=tmp;
}

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

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

int abs(int n){
    if(n<0)n=-n;
    return n;
}

int main(void){
    int n,k,h[101000];
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++)scanf("%d",&h[i]);
    int dp[101000];
    dp[0]=0;
    for(int i=1;i<n;i++) dp[i]=MAX;
    for(int i=1;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i-j<0) break;
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    printf("%d",dp[n-1]);
    return 0;
}


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

int n;

#define MAX 100002

int a[MAX];

map<int, vector<int> > mp;

long long int cnt[MAX];


int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		mp[-a[i]].push_back(i);
	}
	int mint = INT_MAX;
	long long int ava = 0;
	for (auto it = mp.begin(); it != mp.end(); it++){
		auto nex = it;
		nex++;
		vector<int> &v = (*it).second;
		for (int i = 0; i < v.size(); i++){
			mint = min(mint, v[i]);
		}
		ava += v.size();
		if (nex != mp.end()){
			int cur = -(*it).first;
			int go = -(*nex).first;
			long long int dif = (cur - go);
			dif *= ava;
			cnt[mint] += dif;
		}
		else{
			cnt[mint] += ava*(-(*it).first);
		}
	}
	for (int i = 0; i < n; i++){
		printf("%lld\n", cnt[i]);
	}
	return 0;
}

Measured memory_bytes: 13184
#設定
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)

#ライブラリインポート
from collections import defaultdict
import queue

#入力受け取り
def getlist():
	return list(map(int, input().split()))

INF = float("inf")

class Graph(object):
	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b):
		self.graph[a].append(b)

	def get_nodes(self):
		return self.graph.keys()

def DFS(G, W, Wlist, visit, node):
	for i in G.graph[node]:
		if visit[i] != "Yes":
			visit[i] = "Yes"
			DFS(G, W, Wlist, visit, i)
			W[node] += W[i]
			Wlist[node].append(W[i])
	W[node] += 1

class BFS(object):
	def __init__(self, graph, s, N):
		self.g = graph.graph
		self.Q = queue.Queue()
		self.Q.put(s)
		self.dist = [INF] * N
		self.dist[s] = 0
		self.visit = ["No"] * N
		self.visit[s] = "Yes"
		while not self.Q.empty():
			v = self.Q.get()
			for i in self.g[v]:
				if self.visit[i] == "No":
					self.dist[i] = self.dist[v] + 1
					self.Q.put(i)
					self.visit[i] = "Yes"

#処理内容
def main():
	N = int(input())
	G = Graph()
	for i in range(N - 1):
		a, b = getlist()
		a -= 1; b -= 1
		G.add_edge(a, b)
		G.add_edge(b, a)
	#例外処理
	if N == 2:
		print("Second")
		return

	judge = "Second"
	#DFS 判定
	#1回目
	W = [0] * N
	visit = ["No"] * N
	visit[0] = "Yes"
	Wlist = [[] for i in range(N)]
	DFS(G, W, Wlist, visit, 0)
	# print(Wlist)
	for i in range(N):
		cnt = 0
		jud = "Yes"
		for j in Wlist[i]:
			if j % 2 == 1:
				cnt += 1
		if cnt >= 2:
			judge = "First"
			break

	#2回目
	W = [0] * N
	visit = ["No"] * N
	visit[1] = "Yes"
	Wlist = [[] for i in range(N)]
	DFS(G, W, Wlist, visit, 1)
	for i in range(N):
		cnt = 0
		jud = "Yes"
		for j in Wlist[i]:
			if j % 2 == 1:
				cnt += 1
		if cnt >= 2:
			judge = "First"
			break

	#3回目
	W = [0] * N
	visit = ["No"] * N
	visit[2] = "Yes"
	Wlist = [[] for i in range(N)]
	DFS(G, W, Wlist, visit, 2)
	for i in range(N):
		cnt = 0
		jud = "Yes"
		for j in Wlist[i]:
			if j % 2 == 1:
				cnt += 1
		if cnt >= 2:
			judge = "First"
			break

	if N % 2 == 1:
		judge = "First"

	print(judge)

if __name__ == '__main__':
	main()

Measured memory_bytes: 49616
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%s %s", $s,$t);
$array = str_split($s);
$array2 = str_split($t);
for($i = 0; $i < $n; $i++){
   $array3[] = $array[$i];
   $array3[] = $array2[$i];
}
$str = implode('', $array3);
print($str);
?>

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

int main() {
    int n, k;
    cin >> n >> k;
    map<int, int> m;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        m[a]++;
    }
    
    vector<int> v(m.size());
    int index = 0;
    for (auto i = m.begin(); i != m.end(); i++)
    {
        v.at(index) = i -> second;
        index++;
    }
    sort(v.begin(), v.end());

    int cnt = 0;
    int i = 0;
    int kind = (int)m.size();
    while (kind > k) {
        kind--;
        cnt += v.at(i);
        i++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 10368