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

//諸機能
#pragma region MACRO 
#define putans(x)  cerr << "answer: " ; cout << (x) << endl
#define dputans(x) cerr << "answer: "; cout << setprecision(10) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define substr(s,i,l) string((s), (i), (l))
#define tos(x) (to_string((x)))
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define input ifs >>
#else //いい感じにやる
#define input cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#ifndef _DEBUG
#define dbg1 {}
#define dbg2 {}
#define dbg3 {}
#define dbgArray {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e9)
#pragma endregion

int main() {
	string s; input s;
	bool x =false, y = false;
	bool a = false, b = false;
	rep(i, s.size()) {
		switch (s[i]) {
		case 'N':
			y = true;
			break;
		case 'W':
			a = true;
			break;
		case 'S':
			b = true;
			break;
		case 'E':
			x = true;
			break;
		default:
			break;
		}
	}
	bool xmove = !a ^ x;
	bool ymove = !b ^ y;
	putans((xmove && ymove) ? "Yes" : "No");
	return 0;
}


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

struct coop {
	double x = 0, y = 0;
};

void rc(int, int, int, int);
static int n, width = 1;
struct coop *p;

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		width *= 4;
	p = new coop[width + 1];
	p[0].x = p[0].y = p[width].y = 0;
	p[width].x = 100;
	
	rc(0, width, 0, 1);
	for (int i = 0; i <= width; i++)
		printf("%lf %lf\n", p[i].x, p[i].y);

	delete[] p;
	return 0;
}

void rc(int left, int right, int direct, int depth)
{
	if (depth == n + 1)
		return;
	int mid, midl, midr;
	double length = 100;
	mid = (left + right) / 2;
	midl = (left + mid) / 2;
	midr = (mid + right) / 2;
	for (int i = 0; i < depth; i++)
		length /= 3;
	p[midl].x = (p[left].x * 2 + p[right].x) / 3;
	p[midr].x = (p[right].x * 2 + p[left].x) / 3;
	p[midl].y = (p[left].y * 2 + p[right].y) / 3;
	p[midr].y = (p[right].y * 2 + p[left].y) / 3;

	p[mid].x = p[midl].x + cos((direct + 1) * M_PI / 3) * length;
	p[mid].y = p[midl].y + sin((direct + 1) * M_PI / 3) * length;

	rc(left, midl, direct, depth + 1);
	rc(midl, mid, direct + 1, depth + 1);
	rc(mid, midr, direct - 1, depth + 1);
	rc(midr, right, direct, depth + 1);
	return;
}


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

int main()
{

    string s;
    cin>>s;
    int d=1000;
    for(int i=0;i<s.length()-2;i++)
    {
        int n=((s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0'));
        d=min(d,abs(n-753));
    }
    cout<<d<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	int d=0;
	if(b-c>=-1){
		d+=b+c;
	}else{
		d+=min(b,c)*2;
		c-=b;
		if(a-c>=-1){
			d+=c;
		}else{
			d+=min(a,c);
			c-=a;
			d+=!!c;
		}
	}
	cout<<d<<endl;
	return 0;
}

Measured memory_bytes: 256
def solve(line):
    
    for array in line:
        
        if array[0] >= array[1]:
            temp = array[0]
            array[0]=array[1]
            array[1] = temp
            print('{0} {1}'.format(array[0],array[1]))
        else:
            print('{0} {1}'.format(array[0],array[1]))

 

def answer():
    line=[]
    while True:
        s = input().split()
        
        if s[0]=='0' and s[1]=='0':
            break
        line.append(list(map(int, s)))
        
        
        
   
    
    solve(line)

if __name__ =='__main__':
    answer()


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

long long koubai(long long c,long long d){
    long long k=c*d;
    long long r;
    if(c<d) swap(c,d);
    while(d>0){
        r=c%d;
        c=d;
        d=r;
    }
    return k/c;
}

int main(){
    long long a,b,c,d,ans=0,q=0,w=0,e=0;
    cin>>a>>b>>c>>d;
    long long x=koubai(c,d),p=a%x;
    ans=(b-a+1)-(b/c+b/d-b/x)+((a-1)/c+(a-1)/d-(a-1)/x);
    cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> data(n);
    vector<int> flags(n, 0);
    for(int i = 0; i < n; ++i){
        cin >> data[i];
    }
    vector<vector<int>> path(m, vector<int>(2));
    for(int i = 0; i < m; ++i){
        cin >> path[i][0] >> path[i][1];
    }
    for(int i = 0; i < m; ++i){
        int a = path[i][0]-1;
        int b = path[i][1]-1;
        // cout << "a: "  << a << " b: " << b << endl;
        if(data[a] > data[b]){
            // data[b] = -1;
            flags[b] = -1;
        } else if(data[a] < data[b]){
            // data[a] = -1;
            flags[a] = -1;
        } else if(data[a] == data[b]){
            // data[a] = -1;
            // data[b] = -1;
            flags[a] = -1;
            flags[b] = -1;
        }
    }
    int count = 0;
    for(int i  = 0; i < n; ++i){
        if(flags[i] != -1){
            count++;
        }
    }
    // for(auto x : flags){
    //     cout << x << " ";
    // }
    // cout << endl;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 9808
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
const int inf = 1e9;

int n, m;
int a[51], b[51];
int asum[51], bsum[51];
int dp[2][2][51][51][51][51];
bool fin[2][2][51][51][51][51];
pair<int,int> stkbtm[2][2][51][51][51][51];

int opt(int a, int b, int t){
    return (t==0)? max(a,b) : min(a,b);
}
int adj(int p, int t, int ab, int at, int bb, int bt){
    pair<int,int> &btm = stkbtm[p][t][ab][at][bb][bt];
    return (asum[at] -asum[btm.first]) -(bsum[bt] -bsum[btm.second]);
}
int solve(int p, int t, int ab, int at, int bb, int bt){
    bool &cfin = fin[p][t][ab][at][bb][bt];
    int &cdp = dp[p][t][ab][at][bb][bt];
    pair<int, int> &cstkbtm = stkbtm[p][t][ab][at][bb][bt];
    if(cfin) return cdp;

    int ret = opt(inf, -inf, 1-t);
    //pass
    if(p==0){
        int np = (ab==at && bb==bt)? 1: 0;
        stkbtm[np][1-t][at][at][bt][bt] = make_pair(at, bt);
        ret = opt(adj(p, t, ab, at, bb, bt) +solve(np, 1-t, at, at, bt, bt), ret, t);
    }else{
        ret = opt(0, ret, t);
    }
    
    if(t==0 && at<n){
        //a:put
        stkbtm[0][1-t][ab][at+1][bb][bt] = cstkbtm;
        if(a[at+1] == -1) stkbtm[0][1-t][ab][at+1][bb][bt].second = bt;
        ret = opt(solve(0, 1-t, ab, at+1, bb, bt), ret, t);
    }
    if(t==1 && bt<m){
        //b:put
        stkbtm[0][1-t][ab][at][bb][bt+1] = cstkbtm;
        if(b[bt+1] == -1) stkbtm[0][1-t][ab][at][bb][bt+1].first = at;
        ret = opt(solve(0, 1-t, ab, at, bb, bt+1), ret, t);
    }

    fin[p][t][ab][at][bb][bt] = true;
    dp[p][t][ab][at][bb][bt] = ret;
    return ret;
}

int main(){
    cin >> n >> m;
    for(int i=1; i<=n; i++) cin >> a[i];
    for(int i=1; i<=m; i++) cin >> b[i];
    REP(p,2) REP(t,2) REP(ab,n+1) REP(at,n+1) REP(bb,m+1) REP(bt,m+1) fin[p][t][ab][at][bb][bt] = false;
    a[0] = b[0] = asum[0] = bsum[0] = 0;
    REP(i, n) asum[i+1] = asum[i] +max(a[i+1], 0); 
    REP(i, m) bsum[i+1] = bsum[i] +max(b[i+1], 0);
    stkbtm[0][0][0][0][0][0] = make_pair(0, 0);
    cout << solve(0, 0, 0, 0, 0, 0) << endl;
    return 0;
}



Measured memory_bytes: 267428
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let k: u64 = read();
    let s: u64 = read();
    let mut ans: u64 = 0;
    for x in 0..(k + 1) {
        for y in 0..(k + 1) {
            if s < x + y {
                continue;
            }
            let z = s - (x + y);
            if z <= k {
                //println!("{}, {}, {}", x, y, z);
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
from itertools import groupby

s = input()
k = int(input())
a = [sum(1 for _ in g) for _, g in groupby(s)]
if len(a) == 1:
    print(len(s) * k // 2)
else:
    r = sum(x // 2 for x in a) * k
    if s[0] == s[-1]:
        x, y = a[0], a[-1]
        r += ((x + y) // 2 - x // 2 - y // 2) * (k - 1)
    print(r)


Measured memory_bytes: 3064
# coding: utf-8
# Your code here!

n, a, b = map(int, input().split())

div, mod = divmod(n, a + b)

# print(div)
# print(mod)

count = 0
count = a * div

# print(count)

if mod >= a:
    count += a
else:
    count += mod
    
print(count)

Measured memory_bytes: 3060
# coding:utf-8
def main():
    #a = int(input())
    #l = list(map(int, input().split()))
    n,r = map(int, input().split())
    if n >= 10:
        print(r)
    else:
        print(r+(100 * (10-n)))


if __name__ == '__main__' :
    main()

Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対グラフ

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

int main(){
    int n;
    cin >>n;
    int h[n];
    int ans=0;
    int p=0;
    rep(i,n){
        cin >>h[i];
    }
    int v[n][100];
    rep(i,100){
        rep(j,n){
            if(h[j]>i){
                v[j][i]=1;
            }else{
                v[j][i]=0;
            }
        }
    }
    rep(i,100){
        rep(j,n){
            if(v[j][i]==1){
                p++;
            }else{
                if(p>0){
                    ans+=1;
                }
                p=0;
            }
        }
        if(p>0){
            ans+=1;
        }
        p=0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>

int main(void){
    int n;
    long long k;
    std::cin >> n >> k;

    std::map<int, long long> map;
    for(int i = 0; i < n; i++){
        int a;
        long long b;
        std::cin >> a >> b;
        map[a] += b;
    }
    
    long long count = 0;

    for (auto p : map) {
        auto key = p.first;
        auto value = p.second;
        count += value;
        if(count >= k){
            std::cout << key << std::endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4224
#include<stdio.h>
#include<math.h>
int main(void)
{
	int a,b,c;
	char op;
	while(1){
	scanf("%d %c %d",&a,&op,&b);
	if(op=='?')break;
	if(op=='+'){
	c=a+b;}
	else if(op=='-'){
	c=a-b;}
	else if(op=='*'){
	c=a*b;}
	else if(op=='/'){
	c=a/b;}
	printf("%d\n",c);
	}
	
	return 0;
}


Measured memory_bytes: 2100
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<string>
#include <stdlib.h>
using namespace std;

#define         rep(i,n)       for ( i=0 ; i<n ; ++i )
#define         rep1(i,n)      for ( i=1 ; i<=n ; ++i )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rev(str)       reverse(str.begin(),str.end())
#define         usajo(str)     sort(str.rbegin(),str.rend())
#define         pi             2*acos(0.0)
#define         nel            printf("\n")
#define         longmx         92233720368547758
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"YES"<<"\n"
#define         no             cout<<"NO"<<"\n"
#define         vcl            vector<ll>
#define         pb             push_back
#define         prl            pair< ll , ll >
#define         mkp(x,y)       make_pair(x,y)
#define         ff             first
#define         sc             second
#define         spc            ' '
#define         nn             '\n'
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef         long long int  lli;
typedef         long long      ll;

int main(){//Faysal

    lli ans,sum,tot,cnt,mx,mn,idx,chk,rem,ret,tmp,mid,lft,rgt,pos;

    ll tc,n,m,a,b,c,d,g,h,l,r,x,y,i,j,k;

    cin>>n>>m;
    ans=0;
    if(n>1)
        ans+=((n*(n-1))/2);
    if(m>1)
        ans+=((m*(m-1))/2);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
     
//#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)
     
     
int main(){

	int n; sd(n);

	int AllSum = 0 , tSum = 0, arr[n] , min = 10000000;

	for(int i = 0; i< n; i++){
		sd(arr[i]);
		AllSum += arr[i];
	}           

	for(int i =0 ; i< n; i++){
		tSum += arr[i] ;
		int temp = AllSum - tSum;

		int diff = temp - tSum;

		if(diff < 0)diff = -1 * diff;

		if(diff < min)min = diff;


	}
           
     
     pd(min);
        
    return 0;
}


Measured memory_bytes: 256
t = input().split()
while t[1] != "?":
	a = int(t[0])
	b = int(t[2])
	if t[1] == "+":
		print(a + b)
	if t[1] == "-":
		print(a - b)
	if t[1] == "*":
		print(a * b)
	if t[1] == "/":
		print(a // b)
	t = input().split()



Measured memory_bytes: 5592
#include <iostream>
using namespace std;
int main() {
    int a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    int k,i;
    cin>>k;
    for(i=0;i<32;i++)
    {
        if(i==k-1)
            cout<<a[i];
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
int main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    cin>>a[i];
    vector<int> dp(k+1,0);
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i>=a[j] && dp[i-a[j]]==0)
            dp[i]=1;
        }
    }
    if(dp[k]==1)
    cout<<"First";
    else 
    cout<<"Second";
    return 0;
}


Measured memory_bytes: 640
N, M = map(int, input().split(" "))
flg = 0
for i in range(N, M+1):
    if M % i == 0:
        print (M//i)
        flg = 1
        break
    if i**2 > M:
        break

if flg == 0:
    for i in range(M//N, 0, -1):
        if M % i == 0:
            print (i)
            break

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define maxn 305
#define mod 1000000007
int n,m;
int rec[maxn][maxn][maxn];
int mem[maxn][maxn][maxn];
vector<pair<int,int> > q[maxn];
bool check(int a,int b,int c)
{
    int i,x = max(a,max(b,c)),now;
    if(rec[a][b][c]==-1) {
        rec[a][b][c] = 1;
        for(i=0;i<q[x].size();i++)
        {
            now = (q[x][i].first<=a) + (q[x][i].first<=b) + (q[x][i].first<=c);
            if(q[x][i].second!=now) rec[a][b][c] = 0;
        }
    }
    return rec[a][b][c];
}
int f(int a,int b,int c)
{
    int x = max(a,max(b,c)) + 1;
    if(x==n+1) return check(a,b,c);
    if(mem[a][b][c]==-1) {
        if(!check(a,b,c)) mem[a][b][c] = 0;
        else mem[a][b][c] = (f(x,b,c) + (f(a,x,c) + f(a,b,x))%mod)%mod;
    }
    return mem[a][b][c];
}
main()
{
    int i,x,y,val;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d%d%d",&x,&y,&val);
        q[y].push_back({x,val});
    }
    memset(rec,-1,sizeof(rec));
    memset(mem,-1,sizeof(mem));
    printf("%d",f(0,0,0));
}


Measured memory_bytes: 221952
n = int(input())
p = list(map(int,input().split()))

def seccheck(i):
    if p[i-1]<p[i]<p[i+1] or p[i-1]>p[i]>p[i+1]:
        return True
    else:
        return False

count = 0
for i in range(1,n-1):
    if seccheck(i):
        count += 1

print(count)

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


typedef long long ll;

using namespace std;


const ll mod=1000000007;



int main(){
    ll N;
    cin>>N;
    ll p=N;
    if(p%2==1){
        cout<<0<<endl;
    }else{
    p/=2;
    ll count=0;
    p=p-p%5;
    while(p>0){
        //cout<<p<<endl;
        p/=5;
        p=p-p%5;
        ++count;
    }
    //cout<<count<<endl;
    N=N/2;
    ll ans=0;
    for(ll i=1;i<=count;++i){
        ans+=N/(ll)pow(5,i);

    }
    cout<<ans<<endl;
    }
   
}



Measured memory_bytes: 4148
#include <iostream>
#define BOARD_SIZE 9
#define CELL_SIZE 3

void init1(int a[BOARD_SIZE])
{
	for (int i=0; i<BOARD_SIZE; i++) a[i] = 0;
}

void init2(bool a[BOARD_SIZE][BOARD_SIZE])
{
	for (int i=0; i<BOARD_SIZE; i++) {
		for (int j=0; j<BOARD_SIZE; j++) a[i][j] = false;
	}
}

void check_vertical(int board[BOARD_SIZE][BOARD_SIZE], bool v[BOARD_SIZE][BOARD_SIZE])
{
	int appeared[BOARD_SIZE];
	
	for (int j=0; j<BOARD_SIZE; j++) {
		init1(appeared);
		for (int i=0; i<BOARD_SIZE; i++) appeared[board[i][j]-1]++;
		for (int i=0; i<BOARD_SIZE; i++) {
			if (appeared[board[i][j]-1] > 1) v[i][j] = true;
		}
	}
}

void check_horizontal(int board[BOARD_SIZE][BOARD_SIZE], bool v[BOARD_SIZE][BOARD_SIZE])
{
	int appeared[BOARD_SIZE];
	
	for (int i=0; i<BOARD_SIZE; i++) {
		init1(appeared);
		for (int j=0; j<BOARD_SIZE; j++) appeared[board[i][j]-1]++;
		for (int j=0; j<BOARD_SIZE; j++) {
			if (appeared[board[i][j]-1] > 1) v[i][j] = true;
		}
	}
}

void check_cell(int board[BOARD_SIZE][BOARD_SIZE], bool v[BOARD_SIZE][BOARD_SIZE])
{
	int appeared[BOARD_SIZE];
	
	for (int c=0; c<BOARD_SIZE; c++) {
		init1(appeared);
		int offseti = (c/CELL_SIZE) * CELL_SIZE;
		int offsetj = (c%CELL_SIZE) * CELL_SIZE;
		for (int i=0; i<CELL_SIZE; i++) {
			for (int j=0; j<CELL_SIZE; j++) appeared[board[offseti + i][offsetj + j]-1]++;
		}
		for (int i=0; i<CELL_SIZE; i++) {
			for (int j=0; j<CELL_SIZE; j++) {
				if (appeared[board[offseti + i][offsetj + j]-1] > 1) v[offseti + i][offsetj + j] = true;
			}
		}
	}
}

int main()
{
	int board[BOARD_SIZE][BOARD_SIZE];
	bool violates[BOARD_SIZE][BOARD_SIZE];
	int n;
	std::cin >> n;
	for (int k=0; k<n; k++) {
		
		for (int i=0; i<BOARD_SIZE; i++) {
			for (int j=0; j<BOARD_SIZE; j++) std::cin >> board[i][j];
		}
		init2(violates);
		
		check_vertical(board, violates);
		check_horizontal(board, violates);
		check_cell(board, violates);
		
		if (k>0) std::cout << std::endl;
		for (int i=0; i<BOARD_SIZE; i++) {
			for (int j=0; j<BOARD_SIZE; j++) {
				if (violates[i][j]) std::cout << "*";
				else std::cout << " ";
				std::cout << board[i][j];
			}
			std::cout << std::endl;
		}
	}
	return 0;
}




Measured memory_bytes: 3072
#include<stdio.h>
#include<string.h>

int main(){
	char buffer[3][201];
	char* S=buffer[0];
	char* D=buffer[1];
	char* F=buffer[2];
	int M,H;
	int A,B,C;
	while(1){
		scanf("%s",S);
		if(*S=='-')
			break;
		scanf("%d",&M);
		for(A=0;A<M;A++){
			scanf("%d",&H);
			strcpy(D,S+H);
			S[H]=0;
			strcpy(F,S);
			strcat(D,F);
			F=S;
			S=D;
			D=F;
			F=buffer[2];
		}
		printf("%s\n",S);
	}
	return 0;
}

Measured memory_bytes: 600
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN) = readLine.split(" ").map(_.toInt)
    val cardB = for(i <- 1 to datN) yield (readLine.split(" ").head)
    val Array(datM) = readLine.split(" ").map(_.toInt)
    val cardR = for(i <- 1 to datM) yield (readLine.split(" ").head)

    def countCard(result: Map[String, Int], card: List[String]): Map[String, Int] = card match {
      case Nil => result
      case head :: tail => {
        val result2 = result + (head -> (result.getOrElse(head, 0) + 1))
        countCard(result2, tail)
      }
    }
    val cardB2 = countCard(Map(), cardB.toList).toList
    val cardR2 = countCard(Map(), cardR.toList)

    val countup = cardB2.map(e => e._2 - cardR2.getOrElse(e._1, 0))

    val ans = math.max(countup.max, 0)

    println(ans)
  }
}


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

typedef long long ll;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define debug(x) cout << '>' << #x << ':' << x << "\n";
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair



int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n){
        cin >> a[i];
    }
    int flag=1;
    for(int i=n-1;i>0;i--){
        if(a[i-1]>a[i]){
            if(a[i-1]-1<=a[i]){
                a[i-1]--;
            }
            else{
                flag=0;
                break;
            }
        }
    }
    if(flag==1){
        cout <<"Yes";
    }
    else{
        cout << "No";
    }


return 0;
}

Measured memory_bytes: 640
import collections

n=int(input())
r=list(map(int,input().split()))

eNum=collections.Counter(r[1::2]).most_common()
oNum=collections.Counter(r[::2]).most_common()
eNum.append((0,0))
oNum.append((0,0))



if eNum[0][0]==oNum[0][0]:
  print(len(r)-max(eNum[0][1]+oNum[1][1],eNum[1][1]+oNum[0][1]))
else:
  print(len(r)-eNum[0][1]-oNum[0][1])


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

int n;
string s;
int cnt;
int ans[2] = {0};

void solve();

int main() {
  cin >> n;
  cin >> s;
  solve();
  return 0;
}
void solve() {
  for(int i = 0; i < n; ++i) {
    if(s[i] == '(')
      ++cnt;
    else {
      if(cnt == 0)
        ++ans[0];
      else
        --cnt;
    }
  }
  ans[1] = cnt;
  for(int i = 0; i < ans[0]; ++i) cout << "(";
  cout << s;
  for(int i = 0; i < ans[1]; ++i) cout << ")";
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <chrono>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;
using namespace std;
bool solve(vector<int> & a) {
    auto start = chrono::system_clock::now();
    int n = a.size();
    const ll nc2 = n*(n+1ll)/2;
    const ll sum_a = whole(accumulate, a, 0ll);
    if (sum_a % nc2 != 0) return false;
    repeat (q, sum_a / nc2) {
        int i = whole(min_element, a) - a.begin();
        if (a[i] <= 0) break;
        repeat      (k,i)   a[k] -= (n+k)-i+1;
        repeat_from (k,i,n) a[k] -=    k -i+1;
        if (q % 10 == 0) {
            auto end = chrono::system_clock::now();
            double t = chrono::duration<double>(end - start).count();
            if (t > 1.9) {
                return true;
                // random_device device;
                // uniform_int_distribution<int> dist(0, 1);
                // return dist(device);
            }
        }
    }
    return whole(count, a, 0) == n;
}
int main() {
    int n; cin >> n;
    vector<int> a(n); repeat (i,n) cin >> a[i];
    cout << (solve(a) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

ll gcd (ll a, ll b)
{
    return b ? gcd(b, a%b) : a;
}

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

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

    ll x, y;
    cin >> x >> y;

    ll k=2, cnt(0);
    for (ll i=x; i<=y; i=i*k)
    {
        //cout << i << endl;
        ++cnt;     
    }

    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int k;cin>>k;
  vector<long long> s;
  for(int i=1;i<10;i++) s.push_back(i);
  int b=0;int e=9;
  while(1){
    if(s.size()>k) break;
    for(int i=b;i!=e;++i){
      long long a=s[i];
      long long k=a%10;
      if(k!=0) s.push_back(a*10+k-1);
               s.push_back(a*10+k);
      if(k!=9) s.push_back(a*10+k+1);
    }
    b=e;
    e=s.size();
  }
  cout<<s[k-1]<<endl;
  return 0;
}


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

#define rep(i,n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar,val) memset(ar, val, sizeof(ar))
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;
struct data_t {
    ll key;
    ll value;
};

bool cmp(const data_t& left, const data_t& right) {
    return (left.key == right.key) ? (left.value < right.value) : (left.key < right.key);
}
int main(void)
{
  ll n, m, tmp = 0;
  ll ans = 0;
  struct data_t data[100000];
  cin >> n >> m;
  rep(i, n) cin >> data[i].key >> data[i].value;
  sort(data, data + n, cmp);
  rep(i, n){
    if(tmp + data[i].value >= m){
      ans += data[i].key * (m - tmp);
      break;
    }
    ans += data[i].key * data[i].value;
    tmp += data[i].value;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1792
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<assert.h>
#include<stack>
ll z = 1000000007 ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b){if(b <= 0) return 1 ; ll c = power(a , b/2) ; if(b%2 == 0) return ((c*c)%z) ; else return ((((c*c)%z)*a)%z) ;}
ll inverse(ll a ,ll n){return power(a , n-2) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
using namespace std ;


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

 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	ll h , a ;
	cin >> h >> a ;
	h += (a-1) ;
	cout << (h/a) << endl ;
	return 0;
}

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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll R, D, X; cin >> R >> D >> X;
	for (int i = 0; i < 10; i++) {
		X = R * X - D;
		cout << X << '\n';
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cassert>
using namespace std;
int INF = (1<<24);

vector<int> U;
map < int,bool > used;

map < char , vector<int> > t;

string str;
int pos;

bool input();

vector<int> calc(vector<int>,char ch,vector<int>);

vector<int> compute();
vector<int> get();

int main(){
  vector<int> ans;
  while(input()){
    pos=0;
    ans=compute();
    /*
    for(int i=0;i<(int)t['A'].size();i++){
      cout<<t['A'][i]<<' ';
    }
    cout<<endl;
    for(int i=0;i<(int)t['B'].size();i++){
      cout<<t['B'][i]<<' ';
    }
    cout<<endl;

    ans=calc(t['A'],'s',t['B']);
    for(int i=0;i<(int)ans.size();i++){
      cout<<ans[i]<<' ';
    }
    cout<<endl;
    */
    
    for(int i=0;i<(int)ans.size();i++){
      if(i)cout<<' ';
      cout<<ans[i];
    }
    if(ans.size()==0)cout<<"NULL";
    cout<<endl;
  }
  return 0;
}


bool input(){
  int n,a;
  char ch;
  U.clear();
  used.clear();
  t.clear();
  while(1){
    if(cin>>ch){
    }else{
      return false; 
    }
    cin>>n;
    if(ch=='R'&&n==0)break;
    for(int i=0;i<n;i++){
      cin>>a;

      if(used[a]==false){U.push_back(a);used[a]=true;}

      t[ch].push_back(a);
    }
    sort(t[ch].begin(),t[ch].end());
  }
  sort(U.begin(),U.end());
  t['U']=U;
  cin>>str;
  str.push_back('=');
  return true;
}

vector<int> calc(vector<int> A,char ch,vector<int> B){

  int a=0,b=0,Asize=A.size(),Bsize=B.size(),nowA,nowB; 
  vector<int> res;

  if(ch=='u'){
    while(a<Asize||b<Bsize){
      nowA=(a<Asize?A[a]:INF);
      nowB=(b<Bsize?B[b]:INF);
      if(nowA==nowB){
	res.push_back(nowA);
	a++;b++;
      }else if(nowA<nowB){
	res.push_back(nowA);
	a++;
      }else{
	res.push_back(nowB);
	b++;
      }
    }

  }else if(ch=='i'){
    while(a<Asize||b<Bsize){
      nowA=(a<Asize?A[a]:INF);
      nowB=(b<Bsize?B[b]:INF);
      if(nowA==nowB){
	res.push_back(nowA);
	a++;b++;
      }else if(nowA<nowB){
	a++;
      }else{
	b++;
      }
    }

  }else if(ch=='d'){
    while(a<Asize||b<Bsize){
      nowA=(a<Asize?A[a]:INF);
      nowB=(b<Bsize?B[b]:INF);
      if(nowA==nowB){
	a++;b++;
      }else if(nowA<nowB){
	res.push_back(nowA);
	a++;
      }else{
	b++;
      }
    }
    
  }else if(ch=='s'){
    while(a<Asize||b<Bsize){
      nowA=(a<Asize?A[a]:INF);
      nowB=(b<Bsize?B[b]:INF);
      if(nowA==nowB){
	a++;b++;
      }else if(nowA<nowB){
	res.push_back(nowA);
	a++;
      }else{
	res.push_back(nowB);
	b++;
      }
    }
  }

  return res;
}


vector<int> compute(){

  vector<int> res,X;
  char ch;
  res=get();

  while(1){
    ch=str[pos++];
    if(ch=='='||ch==')')break;
    X=get();
    res=calc(res,ch,X);
  }

  return res;
}


vector<int> get(){
  
  assert(str[pos]!=')');
  assert(str[pos]!='=');


  if(str[pos]=='('){
    pos++;
    return compute();
  }else if(str[pos]=='c'){
    pos++;
    return calc(U,'d',get());
  }else{
    pos++;
    return t[str[pos-1]];
  }
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define rep(i, x) for (int i = 0; i < x; ++i)
#define rep2(i, a, b) for (int i = a; i < b; ++i)
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main() {
    int n, m;
    cin >> n >> m;
    vector<P> p(m);
    rep (i, m) cin >> p[i].first >> p[i].second;
    rep (x, 1000) {
        int nx = x / 10;
        vector<int> d(1, x % 10);
        while (nx) {
            d.push_back(nx % 10);
            nx /= 10;
        }
        if (d.size() != n) continue;
        reverse(d.begin(), d.end());
        bool ok = true;
        rep (i, m) {
            if (d[p[i].first-1] != p[i].second) ok = false;
        }
        if (ok) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

using namespace std;

#define int long long 
#define double long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SIZE 10000005

int32_t main()
{
    int x,n,a[105];
    
    cin >> x >> n;
    
    if(n == 0)
    {
		cout << x << endl;
		return 0;
	}
    map<int,int>mp,mp2;
    for(int i = 1;i <= n;i++)
    {
		cin >> a[i];
		mp[a[i]]++;
	}	
	int mn = 1e10;
	int ans = 1e10;
	for(int i = -200; i <= 200; i++)
	{
		if(mp.count(i) == 0)
		{
			int rest = abs(x-i);
			if(rest <= mn)
			{
				if(rest == mn) ans = min(ans,i);
				else ans = i; 
				mn = rest;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>

using namespace std;

const int MAX_MP = 10000;

int main() {
	int n,a,b,c;
	cin >> n;
	vector<int> goal(3);
	for (int i = 0; i < 3; i++) {
		cin >> goal[i];
	}
	vector<int> l(n);

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


	int ans = MAX_MP;
	for (int i = 0; i < (1 << (2 * n));i++) {
		int mp = 0;
		vector<int> abc(3);
		
		for (int j = 0; j < n; j++) {
			
			int flag = ((i >> (2 * j)) & 3);
			if (flag == 0) {
				continue;
			}
			

			if (abc[flag-1] != 0) {
				mp += 10;
			}
				abc[flag - 1] += l[j];
			
			
		}
		
		
		for (int i = 0; i < 3; i++) {
			if (abc[i] == 0) {
				mp = MAX_MP;
				break;
			}
			mp += abs(goal[i] - abc[i]);
		}

		if (ans > mp) {
			ans = mp;
		}
	}

	cout << ans << endl;
}


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


set<int>st;
int main()
{
    int n;cin>>n;
    auto it=st.begin();
    for(int i=0;i<n;i++){
        int a;cin>>a;
        it=st.insert(it,a);
    }
//    for(it=st.begin();it!=st.end();it++)
//        cout<<*it<<" ";
    int ans=st.size();
    if(ans%2==0)ans--;
    cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

bool is_no_need(int num, vector<int>& A, int K)
{
  int ix = num - 1;
  int n = A.size();
  vector<vector<int>> dp(n + 5, vector<int>(K + 5, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int sum = 0; sum <= K; ++sum) {
      dp[i + 1][sum] = dp[i][sum];
      if (i != ix and sum >= A[i]) {
        dp[i + 1][sum] |= dp[i][sum - A[i]];
      }
    }
  }
  for (int sum = max(0, K - A[ix]); sum < K; ++sum) {
    if (dp[n][sum]) { return false; }
  }
  return true;
}

// bool is_no_need(int num, vector<int>& A, int K)
// {
//   int ix = num - 1;
//   int n = A.size();

//   vector<int> v(A.begin(), A.begin() + ix);
//   copy(A.begin() + ix + 1, A.end(), back_inserter(v));

//   vector<vector<int>> dp(n, vector<int>(K + 5, false));
//   dp[0][0] = 1;
//   int M = v.size();
//   for (int i = 0; i < M; ++i) {
//     for (int sum = 0; sum <= K; ++sum) {
//       dp[i + 1][sum] = dp[i][sum];
//       if (sum - v[i] >= 0) {
//         dp[i + 1][sum] |= dp[i][sum - v[i]];
//       }
//     }
//   }
//   bool ret = true;
//   for (int sum = max(0, K - A[ix]); sum < K; ++sum) {
//     if (dp[M][sum]) {
//       ret = false;
//       break;
//     }
//   }
//   return ret;
// }

int main()
{
  int N, K; scanf("%d %d", &N, &K);
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }

  sort(A.begin(), A.end());
  int high = N + 1, low = 0;
  while (high - low > 1) {
    int mid = (high + low) / 2;
    if (is_no_need(mid, A, K)) { low = mid; }
    else { high = mid; }
  }

  int ans = low;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 98344
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;
const int inf = 1e18;



int32_t main(){
    FAST;



  int n;  cin >> n;
  if(n&1){
    cout << 0 << endl;
    return 0;
  }
  int a[n]; 
  for(int x=0;x<n;x++){
    cin >> a[x];
  }

  sort(a,a+n);

  int se = a[n/2] , fi = a[n/2-1];

  cout << (se - fi) << '\n';


  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3

N, K, Q = map(int, input().split())
c = [0 for _ in range(N+1)]
for i in range(Q):
    x = int(input())
    c[x] += 1
for i in range(1,N+1):
    if Q - c[i] < K:
        print('Yes')
    else:
        print('No')


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

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

    int ans = 1;
    int ah, xh, ai, xi;
    cin >> ah;
    for (int i = 1; i < n; i++) {
        cin >> ai;
        if (ah < ai) {
            xi = 1;
        } else if (ah > ai) {
            xi = -1;
        } else {
            xi = 0;
        }
        if (xh * xi < 0) {
            ans++;
            xh = 0;
        } else if (xi != 0) {
            xh = xi;
        }
        ah = ai;
    }

    cout << ans << endl;
}

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 ll;
const int INF = 1e9;

ll h, w, h2, h3, w2, w3, m1, m2, m3, mx, mn, ans = INF, H, W;

ll f(ll h, ll w) {
  for (int i = 1; i < h; ++i) {
    m1 = i * w;

    h2 = (h - i) / 2;
    m2 = h2 * w;
    m3 = h * w - m1 - m2;
    mx = max({m1, m2, m3});
    mn = min({m1, m2, m3});
    ans = min(ans, mx - mn);

    w2 = w / 2;
    m2 = (h - i) * w2;
    m3 = h * w - m1 - m2;
    mx = max({m1, m2, m3});
    mn = min({m1, m2, m3});
    ans = min(ans, mx - mn);
  }
  return ans;
}

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

  cout << min(f(H, W), f(W, H)) << endl;

  return 0;
}


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

int main(){
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='+') sum++;
        else sum--;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  cout << "ABC" << N << endl;
  return 0;
}

Measured memory_bytes: 256
a, b = [int(elem) for elem in input().split()]

flg = 0
for i in range(1, 1009):
  if int(i * 0.08) == a and int(i * 0.1) == b:
    print(i)
    flg = 1
    break
if flg == 0:
  print(-1)

Measured memory_bytes: 3064
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
a=array(N)
N.times do|i|
    a_=gets.to_i
    a[i]=[]
    a_.times do
        xy=get_i
        xy[0]-=1
        a[i].push(xy)
    end
end
res=0
(2**N).times do|bit|
    ans=0
    p_=array(N,-1)
    flag=true
    N.times do|i|
        unless (bit&(2**i)).zero?
          ans+=1
          if p_[i]!=-1 and p_[i]!=1
              flag=false
              break
          end
          p_[i]=1
          if a[i]!=[] 
            a[i].each do|x,y|
              if p_[x]==-1
                  p_[x]=y
              elsif p_[x]!=y
                  flag=false
                  break
              end 
            end
          end
        else
          if p_[i]!=-1 and p_[i]!=0
              flag=false
              break
          end
          p_[i]=0
          #if a[i]!=[]
              #a[i].each do|x,y|
                  #if p_[x]==-1
                      #p_[x]=(y+1)%2
                  #elsif p_[x]==y
                      #flag=false
                      #break
                  #end
              #end
          #end
        end
    end
    if flag
        res=ans if res<ans
    end
end
puts res

Measured memory_bytes: 3964
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3108
#include<stdio.h>

int main()
{
	char input;
	scanf("%c",&input);
	if ( input == 'A' ) {
		printf("T\n");
	}	else if ( input == 'T' ) {
		printf("A\n");
	} else if ( input == 'C' ) {
		printf("G\n");
	} else {
		printf("C\n");
	}
  return 0;
}

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

int main(){
  int N , M ;
  cin >> N >> M ;
  int sum = 0;
  vector<int> A(N,0);
  for(int i=0;i<N;i++){
    cin >> A[i];
    sum += A[i];
  }
  
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  
  if(A[M-1]*4*M>=sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define BASE 1000000007ULL
#define MAXN 300100
using namespace std;

typedef unsigned long long ull;

//Rolling Hash
set<ull> hash;
ull acc_h[MAXN]; //hash value for interval (-1,i)
ull power[MAXN];   //M power of i

void init_roll(string s,int n){
  acc_h[0] = 0;
  power[0] = 1;
  for(int i=1;i<=n;i++){
    power[i] = power[i-1] * BASE;
    acc_h[i] = acc_h[i-1] * BASE + s[i-1];
  }
}

ull rolling_hash(int l,int r){
  return acc_h[r] - acc_h[l] * power[r-l];
}

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

  string s;
  cin >> s;

  init_roll(s,n);

  set<ull> res;
  int l=0, r=0;
  while(m--){
    string q;
    cin >> q;
    if(q=="L++")l++;
    if(q=="L--")l--;
    if(q=="R++")r++;
    if(q=="R--")r--;
    
    res.insert(rolling_hash(l,r+1));
  }
  cout << res.size() << endl;
}

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

int main() {
    int cards[52];
    for (int i = 0; i < 52; i++) {
        cards[i] = 0;
    }
    int n, rank;
    char suit;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> suit >> rank;
        if (suit == 'S') {
            cards[rank - 1] = 1;
        } else if (suit == 'H') {
            cards[13 + rank - 1] = 1;
        } else if (suit == 'C') {
            cards[26 + rank - 1] = 1;
        } else {
            cards[39 + rank - 1] = 1;
        }
    }
    for (int i = 0; i < 52; i++) {
        if (cards[i] == 0) {
            if (i / 13 == 0) {
                suit = 'S';
            } else if (i / 13 == 1) {
                suit = 'H';
            } else if (i / 13 == 2) {
                suit = 'C';
            } else {
                suit = 'D';
            }
            rank = i % 13 + 1;
            printf("%c %d\n", suit, rank);
        }
    }
    return 0;
}


Measured memory_bytes: 3220
def ABC_66_A():
    a,b,c = map(int, input().split())
    
    if (a+b <= b+c) and (a+b <= a+c):
        print(a+b)
    elif (b+c <= a+b) and (b+c <= a+c):
        print(b+c)
    else:
        print(a+c)

if __name__ == '__main__':

    ABC_66_A()

Measured memory_bytes: 3060
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = int(input())
a = 0
for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,N+1):
            a = a + int(gcd(i,j,k))
print(a)

Measured memory_bytes: 69568
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

int n, s;

int part(int index, int count, int sum){
	if(index == 10){
		if(count == n && sum == s){
			return 1;
		}
		return 0;
	}
	return part(index + 1, count, sum) + part(index + 1, count + 1, sum + a[index]);
}

int main(){
	
	while(true){
		
		cin >> n >> s;
		
		if(n == 0){
			break;
		}
		
		cout << part(0, 0, 0) << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define f(a,b,c) for(int i=a;i<=b;i+=c)
#define d(a,b,c) for(int i=a;i>=b;i-=c)  
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	cout<<max(a+b*10+c,max(a+b+10*c,a*10+b+c))<<endl;
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
using ll = int64_t;

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

    ll ans = a*c;
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612