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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vi a(N),A(N+1),B(N+1),D(N+1);
    rep(i,N){
        cin>>a[i];
        A[a[i]]++; D[a[i]]++;
    }
    rep(i,N){
        int b; cin>>b;
        B[b]++; D[b]++;
    }

    if (*max_element(all(D))>N){
        cout<<"No\n";
        return 0;
    }
    cout<<"Yes\n";

    auto solve = [&](vector<pi> &vp){
        int V = vp.size();
        vi next(N+1,-1);
        rep(i,V){
            next[vp[i].se] = vp[(i+1)%V].se;
        }

        vector<queue<int> > ans(N+1);
        int cur=vp[0].se;
        rep(i,V){
            int t = vp[i].se;
            if (cur == t){
                cur = next[cur];
            }
            int cnt=B[t];
            while(cnt>0){
                if (cur == t) return;
                while(A[cur]>0 && cnt>0){
                    A[cur]--; cnt--;
                    ans[cur].push(t);
                }
                if (cnt==0) break;
                cur = next[cur];
            }
        }
        rep(i,N){
            if (i>0) cout<<" ";
            cout<<ans[a[i]].front();
            ans[a[i]].pop();
        }
        cout<<"\n";
        exit(0);
        return;
    };

    vector<pi> vec;
    rep(i,N+1)if(D[i]>0) vec.pb({D[i],i});
    sort(rall(vec));
    solve(vec);

    return 0;
}


Measured memory_bytes: 143368
N = int(input())
a = list(map(int, input().split(' ')))
a.sort(reverse=True)

process = []
p_seed = a.pop(0)
n_seed = a.pop(-1)
for e in a:
    if e >= 0:
        process.append((n_seed, e))
        n_seed -= e
    else:
        process.append((p_seed, e))
        p_seed -= e
process.append((p_seed, n_seed))
m = p_seed - n_seed
print(m)
for x, y in process:
    print(str(x) + ' ' + str(y))


Measured memory_bytes: 61244
#include<stdio.h>
int main() {
	int a,b,c,d,e;
	d = 0;
	scanf("%d %d %d", &a, &b, &c);
	for (e = a; e <= b; e++) {
		if (c % e == 0) {
			d++;
		}
	}
	printf("%d\n", d);
	return 0;
}

Measured memory_bytes: 2752
#include<bits/stdc++.h>
#define YOU setprecision
using namespace std;
int i[11111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e,f;
  string s;
  cin >>a>>b;
  if(a%b==0) cout <<0<<'\n';
  else cout <<1<<'\n';
  return (0);
}


Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc001 {
    export class TaskA implements AtCoder.Task, AtCoder.Paramable {
        public constructor(public readonly args: string[][]) {
        }

        // 4 3
        // 1 2 3 4
        // 1 3
        // 2 3
        // 2 4
        public main(this: TaskA): void {
            const [n, m]: number[] = this.args[0].map(Number);
            const heights: number[] = this.args[1].map(Number);

            const road: number[][] = [];
            for (let i = 2; i < m + 2; i++) {
                road.push(this.args[i].map(Number));
            }

            let map = new Map();
            for (let i = 1; i <= n; i++) {
                map.set(i, true);
            }

            for (let i = 0; i < road.length; i++) {
                const road1: number = road[i][0];
                const road2: number = road[i][1];
                const height1: number = heights[road1 - 1];
                const height2: number = heights[road2 - 1];

                if (height1 === height2) {
                    map.set(road1, false);
                    map.set(road2, false);
                }
                if (height1 <= height2) {
                    map.set(road1, false);
                }
                if (height1 >= height2) {
                    map.set(road2, false);
                }
            }

            let ans: number = 0;
           // console.log(map);
            map.forEach((x, y) => {
                // console.log(`${x} ${y}`)
                if (x) ans++
            });

            // for (let i = 0; i < n; i++) {
            //     const myHeight: number = heights[i];
            //     let good: boolean = true;
            //     for (let j = 0; j < road.length; j++) {
            //         if (!road[j].find(x => x === i)) continue;
            //
            //         const height1: number = heights[road[j][0] - 1];
            //         const height2: number = heights[road[j][1] - 1];
            //         const maxHeight: number = Math.max(height1, height2);
            //
            //
            //         if (myHeight < maxHeight) {
            //             good = false;
            //             continue;
            //         }
            //     }
            //     if (good) ans++;
            // }
            console.log(ans);
        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(r => r.split(' '));
    const task: AtCoder.Task = new TaskA(args);
    task.main();
}



Measured memory_bytes: 84668
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;
    cout << ((s[0] == s[1] && s[1] == s[2])?"No":"Yes") << endl;
}


Measured memory_bytes: 256
k,n = map(int, input().split())
a = list(map(int, input().split()))

x = [0]*n
for i in range(n):
  t = a[i] - a[i-1]
  if i == 0:
    t += k
    x[i] = t
  x[i] = t

print(sum(i for i in sorted(x)[:-1]))

Measured memory_bytes: 26060
#include<cstdio>

const int mod=1e9+7,N=1e6+5;

int n,fac[N],inv[N],f[N];

inline int combn(int n,int m){
	if(n<m) return 0;
	else return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int main(){
	scanf("%d",&n); int ans=0; fac[0]=inv[0]=inv[1]=1;
	for(int i=1;i<=n-1;++i) fac[i]=1ll*fac[i-1]*i%mod;
	for(int i=2;i<=n-1;++i) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<=n-1;++i) inv[i]=1ll*inv[i-1]*inv[i]%mod;
	for(int i=1;i<=n-1;++i) f[i]=1ll*combn(i-1,n-1-i)*fac[i]%mod*fac[n-1-i]%mod;
	for(int i=1;i<=n-1;++i) ans=(ans+1ll*(f[i]-f[i-1]+mod)%mod*i%mod)%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11904
from sys import stdin
from itertools import groupby

a = ['_','.,!? ','abc','def','ghi','jkl','mno','pqrs','tuv','wxyz']
for i in xrange(input()):
	b = [[i for i in j] for i,j in groupby(raw_input())]
	c = []
	d = ''
	for i in b:
		index = int(i[0])
		s = a[index][(len(i))%len(a[index])-1]
		if s == '_':
			d = d + ''.join(c)
			c = []
		else:
			c.append(s)
	if d != '':
		print d

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

int main(){
	int n, k;
	vector<char> s;
	cin >> n >> k;
	while(n > 0){
		s.push_back((n % k) + '0');
		n /= k;
	}
	
	cout << s.size() << endl;
	
	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define pb push_back
#define FR first
#define SC second
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vl >
#define vb vector<bool>
#define vbb vector< vb >
#define vpl vector<pll>
#define vpll vector< vpl >

void solve()
{
	ll d, s, t;
	cin>>d>>s>>t;
	
	if((1.0 * d / s) <= 1.0 * t)
	    cout<<"Yes";
	else
	    cout<<"No";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


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

void move(int start, vector<vector<int>> route, vector<bool> flag, int &count){
  flag.at(start) = true;
  bool con = false;
  for (int i = 1; i < flag.size(); i++){
    if (flag.at(i) == false)
      con = true;
  }
  if (con == false)
    count++;
  
  for (int i : route.at(start)){
    if (flag.at(i) == false)
      move(i, route, flag, count);
  }
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> route(N + 1, vector<int>(0));
  for (int i= 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    route.at(a).push_back(b);
    route.at(b).push_back(a);
  }
  vector<bool> flag(N + 1, false);
  int count = 0;
  move(1, route, flag, count);
  cout << count << endl;
}

Measured memory_bytes: 256
S = input()

r = 0
l = 0
ans_lst = [0] * len(S)
v_b = ''
border = 1

for i, v in enumerate(S):
    if v_b == 'R' and v == 'L':
            border = i
            
    if v_b == 'L' and v == 'R' or i == len(S) - 1:
        if i == len(S) - 1:
            l += 1
        total = r + l
        ans_lst[border-1] = total // 2
        ans_lst[border] = total // 2
        
        if total % 2 == 1:
            if r > l and r % 2 == 0 or r < l and l % 2 == 1:
                ans_lst[border] += 1
            else:
                ans_lst[border-1] += 1
        l = 0
        r = 0

    v_b = v
    if v == 'R':
        r += 1
    else:
        l += 1
            
print(*ans_lst)

Measured memory_bytes: 6400
import java.io.*;
import java.util.*;

class FastReader 
{ 
    BufferedReader br; 
    StringTokenizer st; 
    
    public FastReader() 
    { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } 
    
    String next() 
    { 
        while (st == null || !st.hasMoreElements()) 
        { 
            try
            { 
                st = new StringTokenizer(br.readLine()); 
            } 
            catch (IOException  e) 
            { 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    
    int nextInt() 
    { 
        return Integer.parseInt(next()); 
    } 
    
    long nextLong() 
    { 
        return Long.parseLong(next()); 
    } 
    
    double nextDouble() 
    { 
        return Double.parseDouble(next()); 
    } 
    
    String nextLine() 
    { 
          String str = ""; 
        try
        { 
            str = br.readLine(); 
        } 
        catch (IOException e) 
        { 
            e.printStackTrace(); 
        } 
        return str; 
    } 
} 

class Solution
{
    void solve()
    {
        FastReader sc = new FastReader();

        int N = sc.nextInt(); //number of problems
        int M = sc.nextInt(); //number of submissions

        int wa = 0, ac = 0;

        boolean c[] = new boolean[N];
        int q[] = new int[N];

        Arrays.fill(c,true);
        Arrays.fill(q,0);

        for(int i = 0; i < M ; i++)
        {
            int qno = sc.nextInt() - 1;
            String st = sc.next();

            if(st.equals("WA") && c[qno]) q[qno]++;

            if(st.equals("AC") && c[qno])
            {
                c[qno] = false;
                wa += q[qno];
                ac++; 
            }
        }

        System.out.println(ac + " " + wa);
    }
}
  
public class Main 
{ 
    public static void main(String[] args) 
    { 
        Solution ob = new Solution();

        ob.solve();
    } 
} 

Measured memory_bytes: 55688
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <vector>

#define REP(i,N) for(i = 0; i < N; i++)

std::map<int, int> map;

int solve(int n)
{
	auto it = map.find(n);
	if (it != map.end())
	{
		return it->second;
	}
	int min;
	if (n < 6)
	{
		min = n;
	}
	else
	{
		int six = 1, nine = 1;
		std::vector<int> vec;
		while(six * 6 <= n)
		{
			six *= 6;
			vec.push_back(n - six);
		}
		while(nine * 9 <= n)
		{
			nine *= 9;
			vec.push_back(n - nine);
		}
		min = INT_MAX;
		for (int &i:vec)
		{
			min = std::min(min, solve(i) + 1);
		}
	}
	map[n] = min;
	return min;
}


int main(void)
{
	int N;
	scanf("%d", &N);
	printf("%d\n", solve(N));
	return 0;
}


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

int main()
{
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  rep(i, n - 2)
  {
    if (s.at(i) == 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C')
    {
      ans++;
    }
  }
  cout << ans << endl;
}

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

ll dp[110][100010]={0};

int main(void){
    int N,W;
    cin >> N >> W;
    vector<int> weight(110),value(110);
    for(int i=0;i<N;i++) cin >> weight[i] >> value[i];


    for(int i=1;i<=N;i++){
        for(int j=0;j<=W;j++){
            if(j-weight[i-1]>=0) dp[i][j] = max(dp[i][j],dp[i-1][j-weight[i-1]]+value[i-1]);
            dp[i][j] = max(dp[i][j],dp[i-1][j]);
        }
    }

    cout << dp[N][W] << endl;

}

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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define INF 1e9
// constexpr ll INF = 1LL << 60;

int main(){
  int N;
  cin >> N;
  ll ans = 0;
  REP(i, N-1){
    ans += i+1;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N, K;
ll P[5000];
ll C[5000];

vector<int> G[5000];

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> K;
    UnionFind uf(N);
    for(int i = 0; i < N; i++){
       cin >> P[i]; P[i]--;
       uf.unionSet(i, P[i]);
    }
     for(int i = 0; i < N; i++){
       cin >> C[i];
    }
    ll ans = -2e18;
    for(int i = 0; i < N; i++){
        ll sz = uf.size(i);
        ll rem = K%sz;
        ll m = K/sz;
        ll sum = 0;
        int cur = i;
        for(int j = 0; j < sz; j++){
            sum += C[cur];
            cur = P[cur];
            if(j < rem || m > 0){
                ans = max(ans, sum);
            }
        }
        ll sum_rem = 0;
        cur = i;
        for(int j = 0; j < rem; j++){
            sum_rem += C[cur];
            cur = P[cur];
            ans = max(ans, sum*m+sum_rem);
        }
        sum_rem = 0;
        if(m >= 1){
            for(int j = 0; j < sz+rem; j++){
                sum_rem += C[cur];
                cur = P[cur];
                ans = max(ans, sum*(m-1)+sum_rem);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3800
#include <stdio.h>
#include <iostream>
using namespace std;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)


int main()
{
	int N, K;
	scanf("%d%d", &N, &K);

	int *p = new int[N + 1];
	int max, sum = 0;

	rep(i, N) scanf("%d", p + i + 1);
	REP(i, 1, K + 1) sum += p[i];
	max = sum;
	REP(i, K + 1, N + 1) {
		sum = sum + p[i] - p[i - K];
		if (sum > max) max = sum;
	}
	
  	cout.precision(20);
	cout << (max + K) / 2.0 << endl;

	delete[] p;
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	ll memo = mypow(a, b >> 1);
	return memo * memo;
}
ll modpow(ll a, ll b, ll m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	ll memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
signed main() {
	int n, k;
	cin >> n >> k;
	cout << min(n % k, k - n % k) << endl;
	return 0;
}

Measured memory_bytes: 256
import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
if a<40:
    a = 40
if b<40:
    b = 40
if c<40:
    c = 40
if d<40:
    d = 40
if e<40:
    e = 40
s = [a,b,c,d,e]
print(math.floor(sum(s)/5))


Measured memory_bytes: 5660
#!/usr/bin/env python3
w, h, n = map(int, input().split())
def proj(x, y):
    if y == 0:
        return x
    elif x == w:
        return w + y
    elif y == h:
        return w + h + (w - x)
    elif x == 0:
        return w + h + w + (h - y)
    else:
        return None
ps = []
for i in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    p1 = proj(x1, y1)
    p2 = proj(x2, y2)
    if p1 is not None and p2 is not None:
        ps += [ (p1, i), (p2, i) ]
ps.sort()
stk = []
for _, i in ps:
    if stk and stk[-1] == i:
        stk.pop()
    else:
        stk.append(i)
result = not stk
print([ 'NO', 'YES' ][ result ])


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

using namespace std;

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

typedef long long ll;

ll const inf = 1LL<<50;

ll L, R;

void find_x(pair<ll, ll> a, pair<ll, ll> b) {
  ll r = min(a.second, b.second), l = b.first;
  L = max(L, l);
  R = min(R, r);
}

int main() {
  
  int N;
  while(cin >> N && N) {
    vector<ll> v(N);
    rep(i, N) {
      string s; cin >> s;
      if(s == "x") v[i] = inf; else v[i] = atol(s.c_str());
    }
    
    vector<pair<ll, ll> > w;
    w.push_back(make_pair(-inf, inf));
    rep(i, N) {
      if(v[i] != inf) { continue; }
      if(i&1) { // even
        if(i-1>=0)
          w.push_back(make_pair(v[i-1], inf));
        if(i+1<N)
          w.push_back(make_pair(v[i+1], inf));
      }
      else {
        if(i-1>=0)
          w.push_back(make_pair(-inf, v[i-1]));
        if(i+1<N)
          w.push_back(make_pair(-inf, v[i+1]));
      }
    }
    
    sort(w.begin(), w.end());
    w.erase(unique(w.begin(), w.end()), w.end());
    /*
    rep(i, w.size()) {
      cout << w[i].first << ", " << w[i].second << endl;
    }
    */
    L = -inf, R = inf;
    rep(i, w.size()) REP(j, i+1, w.size()) {
      find_x(w[i], w[j]);
    }
    
    if(w.size() == 1) {
      L = w[0].first, R = w[0].second;
    }
    
    // cerr << "L: " << L << ", R: " << R << endl;
    
    ll cnt = R-L;
    
    rep(i, N-1) {
      if(v[i] == inf || v[i+1] == inf) continue;
      if(i&1 && (v[i] <= v[i+1])) cnt = -inf;
      if(!(i&1) && (v[i] >= v[i+1])) cnt = -inf;
    }
    
    if(cnt <= 1) { cout << "none\n"; }
    else if(cnt == 2) { cout << L+1 << endl; }
    else { cout << "ambiguous\n"; }
  }
  
  return 0;
}

Measured memory_bytes: 1260
from collections import deque

N, Q = [int(x) for x in input().split()]

tree = {}
result = [0] * N

for _ in range(N-1):
    a, b = [int(x) - 1 for x in input().split()]
    if a in tree:
        tree[a].append(b)
    else:
        tree[a] = [b]

    if b in tree:
        tree[b].append(a)
    else:
        tree[b] = [a]


add = [0] * N
for _ in range(Q):
    p, x = [int(x) for x in input().split()]

    add[p-1] += x

queue = deque()
queue.appendleft((0, add[0]))

finished = set()

while queue:
    target = queue.pop()
    node = target[0]
    count = target[1]

    result[node] = count
    finished.add(node)

    if node in tree:
        for next_node in tree[node]:
            if not next_node in finished:
                queue.appendleft((next_node, count + add[next_node]))

print(" ".join(map(str, result)))


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

int main(void){
	string input;
	int blueCards,redCards;
	map<string,int> cardList;
	int max = 0;

	getline(cin,input);
	blueCards = stoi(input);
	for(int i=0;i<blueCards;++i){
		getline(cin,input);
		++cardList[input];
	}

	getline(cin,input);
	redCards = stoi(input);
	for(int i=0;i<redCards;++i){
		getline(cin,input);
		--cardList[input];
	}

	for(auto itr = cardList.begin(); itr!=cardList.end() ; ++itr){
		if( (*itr).second > max){
			max=(*itr).second;
		}
	}

	cout << max <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

#define F first
#define S second
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define MP make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define debug(x) cout << " > " << #x << ':' << x << endl;
#define kiyohime ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using vec = vector<T>;
template<typename T> using Prior = priority_queue<T>;
template<typename T> using prior = priority_queue<T, vec<T>, greater<T>>;

const int INF = 1e9;
const ll LLINF = (ll)4*1e18;
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
const int xx[8] = {0,1,0,-1,1,1,-1,-1};
const int yy[8] = {1,0,-1,0,1,-1,-1,1};

void pmod(ll &a, ll b) {a = (a+b)%MOD;}
void mmod(ll &a, ll b) {a = (a-b+MOD)%MOD;}
void tmod(ll &a, ll b) {a = (a*b)%MOD;}
ll POW(ll a, ll b) {ll res=1; do{if(b%2)tmod(res,a);tmod(a,a);}while(b>>=1); return res;}
template<typename T> void amax(T &a, T b) {if(a < b) a = b;}
template<typename T> void amin(T &a, T b) {if(a > b) a = b;}

#define N 20
#define lowbit(x) (x&(-x))

void solve(){
    int n;
    ll a[N][N], dp[(1<<16) + 10] = {};
    
    cin >> n ;
    rep(i, n) rep(j, n) cin >> a[i][j];
    
    rep1(i, (1<<n)-1){
        rep(j, n) REP(u, j+1, n-1)
            if((i & (1<<j)) && (i & (1<<u)))
                dp[i] += a[j][u];
        
        int tmp = (i-1) & i;
        while(tmp){
            amax(dp[i], dp[i-tmp] + dp[tmp]);
            tmp = (tmp - 1) & i;
        }
    }
    
    cout << dp[(1<<n) - 1] << endl;
}

int main(){
//    kiyohime
    int T = 1;
    
//    cin >> T;
    while(T--){
        solve();
    }
}


Measured memory_bytes: 4148
#include <iostream>
#include <string>
#include <vector>
#define llint long long
#define ulint unsigned long long
#define mod 1000000007

using namespace std;

struct node{
  int num;
  int next[26];
  node(){
    num = 0;
    for(int i = 0; i < 26; i++) next[i] = -1;
  }
};

int n;
string s, t;
int R = 430;
vector<string> vec;
vector<node> trie;
ulint beki[200005];
ulint shash[200005], thash[200005];
llint dp[100005];

ulint getHash(string &s)
{
  ulint ret = 0;
  for(int i = 0; i < s.size(); i++) ret = ret * mod + s[i];
  return ret;
}

int main(void)
{
  cin >> n;

  beki[0] = 1;
  for(int i = 1; i < 200005; i++) beki[i] = beki[i-1] * mod;

  trie.push_back(node());
  for(int i = 1; i <= n; i++){
    cin >> s;
    if(s.size() >= R){
      vec.push_back(s);
      shash[vec.size()-1] = getHash(s);
    }
    else{
      int p = 0;
      for(int j = 0; j < s.size(); j++){
        if(trie[p].next[s[j]-'a'] == -1){
          trie.push_back(node());
          trie[p].next[s[j]-'a'] = trie.size()-1;
        }
        p = trie[p].next[s[j]-'a'];
      }
      trie[p].num++;
    }
  }

  cin >> t;
  int m = t.size();
  t = "#" + t;
  thash[0] = t[0];
  for(int i = 1; i <= m; i++){
    thash[i] = thash[i-1] * mod + t[i];
  }

  dp[0] = 1;
  for(int i = 0; i < m; i++){
    int p = 0;
    for(int j = 1; j < R; j++){
      if(i+j > m) break;
      p = trie[p].next[t[i+j]-'a'];
      if(p == -1) break;
      if(trie[p].num) dp[i+j] += dp[i], dp[i+j] %= mod;
    }
    for(int j = 0; j < vec.size(); j++){
      int len = vec[j].size(), l = i+1, r = i+len;
      if(r > m) continue;
      if(thash[r] - thash[l-1] * beki[r-l+1] == shash[j]) dp[r] += dp[i], dp[r] %= mod;
    }
  }
  cout << dp[m] << endl;

  return 0;
}



Measured memory_bytes: 32300
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for (int i=0; i<N; i++) cin >> p[i];
  sort(p.begin(), p.end());
  int res = 0;
  for (int i=0; i<K; i++) res += p[i];
  cout << res << endl;
  return 0;
}

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

""" 3次元DP """

N,A = map(int, input().split())
xN = list(map(int, input().split()))
X = max(max(xN), A)

# i(=xNリストからどこまでを選べる範囲とするか)からj(=0～N)枚選んで、選んだ値の合計をkにするような選び方の総数
dp = [[[0] * (N*X+1) for j in range(N+1)] for i in range(N+1)]
dp[0][0][0] = 1

ans = 0
for i in range(1,N+1):
    for j in range(N+1):
        for k in range(N*X+1):
            # 求めたい合計(k)が、この周回で増えた選択肢(xN[i-1])より小さい場合、
            # 選び方の総数は増える見込みがないので前回の値をそのまま使用
            if k < xN[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            # 合計kが大きければ、増やせるかもしれないので、選んだ数と合計を減らしたところを見に行く
            # 選べる数j=0は論外だし、添え字[j-1]に良くないので条件で除外する
            elif k >= xN[i-1] and j > 0:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-xN[i-1]]
            # 選んだ数と合計から判断して、平均が条件に合うものなら答えに足す
            if i == N and j > 0 and k == j*A:
                ans += dp[i][j][k]

# ans = 0
# for k in range(1,N+1):
#     ans += dp[N][k][k*A]
        
print(ans)

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

#ifdef on_linux
	#include <sys/resource.h>
#endif

#ifdef dobby_is_a_free_elf
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
	#define trace(...) 0;
#endif

using namespace std;
using namespace __gnu_pbds;

#define int                     long long
#define ll                      long long

#define fi                      first
#define sc                      second
#define mp                      make_pair
#define pb                      push_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define sqr(a)                  ((a) * (a))
#define lbd                     lower_bound
#define ubd                     upper_bound
#define sz(x)                   (int)((x).size())
#define all(x)                  (x).begin(), (x).end()
#define mem0(x)                 memset(x, 0, sizeof (x))
#define mem1(x)                 memset(x, -1, sizeof (x))
#define pii                     pair<int32_t, int32_t>
#define pll                     pair<long long, long long>

#define DECIMAL(n)              cout << fixed << setprecision(n);
#define rep(i,a,b)              for(int32_t i = (a); i < (b); ++i)
#define between(i,x,y)          ((i) >= (x) && (i) <= (y))
// #define clamp(i,x,y)            (((i) < (x)) ? (x) : ((y) < (i)) ? (y) : (i));

template<typename T, typename U> static inline void remax(T &x, U y) {if (x < y) {x = y;}}
template<typename T, typename U> static inline void remin(T &x, U y) {if (y < x) {x = y;}}

static mt19937_64 gen(chrono::duration_cast<chrono::nanoseconds>
                      (chrono::high_resolution_clock::now().time_since_epoch()).count());

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase, insert same as normal set

const long double PI = 3.14159265358979323846264338;
const double eps = 1e-10;
const int32_t fftmod = 998244353;
const int32_t MOD = 1000000007;
const long long INF = 1e18;
const int32_t N = 1e5 + 10;
const int32_t NN = 1e6 + 10;



inline void elf_magic(int testcase)
{
	int n, m;
	cin >> n >> m;
	int k;
	cin >> k;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= m; ++j) {
			if (i * j + (n - i) * (m - j) == k) {
				cout << "Yes";
				return;
			}
		}
	}
	cout << "No";
	return;
}

int32_t main()
{
	#ifdef on_linux
	rlimit cpu_time {.rlim_cur = 2, .rlim_max = RLIM_INFINITY};
	setrlimit(RLIMIT_CPU, &cpu_time);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int TESTS = 1;
	//cin >> TESTS;
	for (int i = 1; i <= TESTS; ++i) {
		// cout << "Case #" << i << ": ";
		elf_magic(i);
		if (i != TESTS)	{ cout << '\n'; }
	}
	return 0;
}

Measured memory_bytes: 3600
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 1000000000
#define MOD 998244353
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 305
int h, w, k;
int gr[MN][MN];
int cnt[MN];
int ans[MN][MN];

void col(int x1, int x2, int y1, int y2, int val){
    FOR(i, x1, x2){
        FOR(j, y1, y2){
            ans[i][j] = val;
        }
    }
}

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

    cin >> h >> w >> k;
    int cur = 0;
    FOR(i, 1, h){
        FOR(j, 1, w){
            char c;
            cin >> c;
            if(c == '#'){
                gr[i][j] = ++cur;
                ++cnt[i];
            }
        }
    }

    int curt = 1;
    int curl = 1;
    FOR(i, 1, h){
        curl = 1;
        if(cnt[i] == 0){
            continue;
        }
        FOR(j, 1, w){
            if(gr[i][j] != 0){
                col(curt, i, curl, j, gr[i][j]);
                curl = j+1;
            }
        }
        if(curl != w+1){
            --curl;
            col(curt, i, curl, w, gr[i][curl]);
        }
        curt = i+1;
    }
    if(curt != h+1){
        --curt;
        FOR(j, 1, w){
            if(gr[curt][j] != 0){
                col(curt, h, curl, j, gr[curt][j]);
                curl = j+1;
            }
        }
        if(curl != w+1){
            --curl;
            col(curt, h, curl, w, gr[curt][curl]);
        }
    }

    FOR(i, 1, h){
        FOR(j, 1, w){
            cout << ans[i][j] << " ";
        }
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 1536
from collections import Counter
from operator import mul
from functools import reduce
def combinations_count2(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

#
N=int(input())
A=list(map(int,input().split()))
#
hoge=Counter(A)
ans=0
for i in hoge.values():
    if i>=2:
        ans += combinations_count2(i, 2)
for i in range(N):
    print(ans-hoge[A[i]]+1)



Measured memory_bytes: 91468
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int h1 = scanner.nextInt();
        int m1 = scanner.nextInt();
        int h2 = scanner.nextInt();
        int m2 = scanner.nextInt();
        int k = scanner.nextInt();
        int time = (h2 - h1) * 60 + (m2 - m1);
        System.out.print(time - k);
    }
}


Measured memory_bytes: 35752
def solve():
    N, Y = map(int, input().split())

    for x in range(N+1):
        for y in range(N+1-x):
            if (Y - x*10000 - y*5000) % 1000 == 0:
                z = (Y - x*10000 - y*5000) // 1000
                if x + y + z == N:
                    print(x, y, z)
                    exit()

    print(-1, -1, -1)



if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long A = input.nextLong();
		long B = input.nextLong();
		long C = input.nextLong();
		if (A%2==0||B%2==0||C%2==0) System.out.println(0);
		else {
			long answer = A*B;
			answer = Math.min(A*C, answer);
			answer = Math.min(B*C, answer);
			System.out.println(answer);
		}
	}
}

Measured memory_bytes: 21844
use scanner::Scanner;

fn main() {
    let mut sc = Scanner::new();
    let mut abc: Vec<u64> = (0..3).map(|_| sc.read()).collect();
    abc.sort();
    println!("{}", if abc == vec![5, 5, 7] { "YES" } else { "NO" });
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}


Measured memory_bytes: 4352
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
N,A,B = map(int,input().split())
V = list(map(int,input().split()))

V.sort(reverse=True)

ans1 = sum(V[:A])/A

ans2 = 1
cnt = V.count(V[0])
if cnt > A:
    ans2 = 0
    for i in range(A,min(B,cnt)+1):
        tmp = 1
        for j in range(i):
            tmp *= cnt-j
            tmp //= j+1
        ans2 += tmp
else:
    cnt1 = V.count(V[A-1])
    cnt2 = V[:A].count(V[A-1])
    if cnt1 > 1:
        for i in range(cnt2):
            ans2 *= cnt1-i
            ans2 //= i+1

print(ans1)
print(ans2)

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

using namespace std;
using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 2e5 + 5;

int n;
ll dp[MAXN], h[MAXN];

ll f(int j,  int i) {
    return dp[j] + (h[i] - h[j]) * (h[i] - h[j]);
}

ld intersection(int i, int j) {
    //return (ld) (f(j, 0) - f(i,  0)) / (ld) (2 * (h[j] - h[i]));
    return (ld) ((h[j] * h[j] + dp[j]) - h[i] * h[i] - dp[i]) / (2 * (h[j] - h[i]));
}

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

    ll C;
    cin >> n >> C;
    for (int i = 1; i<= n; i++) {
        cin >> h[i];
    }

    deque<int> Q = {1};
    int m = 1;
    for (int i = 2; i <= n; i++) {
        while (Q.size() > 1 and f(Q[1], i) < f(Q[0], i)) {
            m--;
            Q.pop_front();
        }

        dp[i] = f(Q[0], i) + C;

        while (Q.size() > 1 and intersection(Q[Q.size() - 2], i) <= intersection(Q[Q.size() - 2], Q.back())) {
            m--;
            Q.pop_back();
        }
        Q.push_back(i);
    }

    cout << dp[n] << "\n";
}


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

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

const long long INF = 1LL << 60;
long long dp[100010][3];
int n;
int main()
{
	cin >> n;
	int a[n][3];
	for (int i = 1; i < n+1; i++){
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}

	for (int i = 1; i < n+1; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 3; k++){
				if (j == k) continue;
				chmax(dp[i][j], dp[i-1][k]+ a[i][j]);
			}
		}
	}
	long long res = -INF;
	for (int i = 0; i < 3; i++) chmax(res, dp[n][i]);
	cout << res << endl;

}



Measured memory_bytes: 3712
#include <iostream>

using namespace std;

int main(void){
  int arr[]={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;
  cin >> K;

  cout << arr[K-1] << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
#define PI 3.14159265358979323846
using namespace std;
typedef long long ll;

#define MAX 1000000000000



int main(void) {
	int r; cin >> r;
	cout << 2 * r*PI << endl;
}


Measured memory_bytes: 3708
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from bisect import bisect_left

N = int(input())
a = [int(i) for i in input().split()]
vec = [[] for _ in range(N)]
for _ in range(N - 1) :
  u, v = map(int, input().split())
  vec[u - 1].append(v - 1)
  vec[v - 1].append(u - 1)

lis = [a[0]]
ret = [0] * N
def dfs(cur, pre) :
  for nex in vec[cur] :
    if nex == pre : continue
    if a[nex] > lis[-1] :
      lis.append(a[nex])
      ret[nex] = len(lis)
      dfs(nex, cur)
      lis.pop()
    else :
      pos = bisect_left(lis, a[nex])
      v = lis[pos]
      lis[pos] = a[nex]
      ret[nex] = len(lis)
      dfs(nex, cur)
      lis[pos] = v

dfs(0, -1)

ret[0] = 1
for i in range(N) :
  print(ret[i])

Measured memory_bytes: 344656
#include <stdio.h>
#define N 50

int main()
{
  int i,n,data[N];

  scanf("%d",&n);
  
  data[0] = 1;
  data[1] = 1;

  for(i=2; i<=n; i++)
    data[i] = data[i-1] + data[i-2];
  
  
  printf("%d\n",data[n]);
}



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

string cell[9] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

int main(){
    int n;
    scanf("%d\n", &n);

    for(int i = 0; i < n; i++){
        string s;
        getline(cin,s);
        int len = s.length();
        for(int j = 0; j < len; j++){
            int cnt = 0;
            char x = s[j];
            if(x == '0')    continue;
            while(j < len && s[j] == x)    j++, cnt++;
            int tmplen = cell[x-'1'].length();
            cout << cell[x-'1'][(cnt-1+tmplen)%(tmplen)];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
function Main(input) {
  var L = parseInt(input.split(" ")[0]);
  var R = parseInt(input.split(" ")[1]);
  var min = 2019;
  if((R - L) >= 2019){
     console.log(0);
    	return;
     }
  L = L % 2019;
  R = R % 2019;
  for(var i = L; i < R; i++){
    if(i % 2019 == 0){
       console.log(0);
    	return;
    }
    for(var j = i + 1; j <= R; j++){
      if(j % 2019 == 0){
         console.log(0);
    	return;
         }
      var cal = (i * j) % 2019;
      if(min > cal){
         min = cal;
        if(min == 0){
           console.log(min);
          return;
           }
      }
    }
  }
  console.log(min);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

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

    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }
    vector<int> in = X;
    sort(X.begin(), X.end());

    int middle = N / 2;
    for (int i = 0; i < N; i++) {
        if (in[i] >= X[middle]) {
            cout << X[middle - 1] << endl;
        } else {
            cout << X[middle] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4824
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
ll N, M, K,H,W,  mi1,mi2,sum;
string s;
int main() {
	cin >> N;
	vector<LL> A(N+1),ans(N+1);
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	
	for (int i = N; i > 0; i--) {
		M = 0;
		if (N / i > 1) {
			for (int j = 2 * i; j <= N; j += i) {
				M += ans[j];
			}
			M = M % 2;
			if (A[i] == 1) {
				if (M == 1) {
					ans[i] = 0;
				}
				else {
					ans[i] = 1;
				}
			}
			else {
				if (M == 1) {
					ans[i] = 1;
				}
				else {
					ans[i] = 0;
				}
			}
		}
		else {
			ans[i] = A[i];
		}
	}
	K = 0;
	for (int i = 1; i <= N; i++) {
		if (ans[i] == 1)K++;
	}
	cout << K << endl;
	for (int i = 1; i <= N; i++) {
		if (ans[i] == 1)cout << i<< " ";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3968
# place A blue balls first,
# then place B red balls after
# go until you get to N
n, a, b = map(int, input().split())
x = max(n // (a + b) - 2, 1)
while a * x + b * x < n:
    temp = a * x + b * x
    x += 1
temp = a * x + b * x
if temp - b >= n:
    temp = temp - b
    endsWithA = True
else:
    endsWithA = False
if endsWithA:
    print(a * x - (temp - n))
else:
    print(a * x)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
    int a[3];

    cin >> a[0] >> a[1] >> a[2];

    sort(a, a+3);

    int r =0;
    r += a[2] - a[1];
    r += a[1] - a[0];

    cout << r << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int n, x, x_a, x_b, x_c;
		try (Scanner sc = new Scanner(System.in)) {
			while (true) {
				n = sc.nextInt();
				x = sc.nextInt();
				int counter = 0;
				if(n == 0 && x == 0) {
					break;
				}
				for(int i = 1; i < x - 2; i++) {
					for(int j = 1; j < x - 2; j++) {
						for(int k = 1; k < x - 2; k++) {
							x_a = i;
							x_b = j;
							x_c = k;
							if(x_a + x_b + x_c == x) {
								if(x_a <= n && x_b <= n && x_c <= n) {
									if(x_a != x_b && x_b != x_c && x_c != x_a) {
										counter++;
									}
								}
							}
						}
					}
				}
				System.out.println(counter / 6);
			}
		}
	}
}



Measured memory_bytes: 27220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

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

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

mint c[4005][4005];

void init(){
    c[0][0] = 1;
    for(int i = 0; i <= 4000; i++){
        for(int j = 0; j <= i; j++){
            c[i+1][j] += c[i][j];
            c[i+1][j+1] += c[i][j];
        }
    }
}

mint comb(int n, int k){
    return c[n][k];
}

int main(){
    int n, k; cin >> n >> k;
    init();
    for(int i = 1; i <= k; i++){
        mint red = comb(k-1,i-1);
        mint blue = comb(n-k+1,i);
        mint ans = blue * red;
        cout << ans.x << endl;
    }
}

Measured memory_bytes: 125568
#include <iostream>

int main(int argc, const char **argv)
{
	int books = 0;

  	std::cin >> books;
  	int judge = books % 10;
  	if ( judge == 2 || judge == 4 || judge == 5 || judge == 7 || judge == 9 )
      	std::cout << "hon" << std::endl;
 	if ( judge == 0 || judge == 1 || judge == 6 || judge == 8 )
      	std::cout << "pon" << std::endl;
  	if ( judge == 3 )
      	std::cout << "bon" << std::endl;

  	return 0;
}

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

ll k;

int main(){
    cin>>k;
    ll x=k/50,y=k%50;
    cout<<50<<endl;
    rep(i,50){
        if(i)cout<<" ";
        cout<<(i<y?i+x-y+51:i+x-y);
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int x, y, i = 1;
	do {
		cin >> x >> y;
		if (x != 0 || y != 0) {
			if (x <= y) {
			cout << x << " " << y << endl;
			i++;				
			}else{
				cout << y << " " << x << endl;
				i++;
			}
		}
	} while (x != 0 || y != 0);
	return 0;
}


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

int main(){
    int n;
    cin>>n;
    int len=0;
    while(n>1){
        n /= 2;
        len++;
    }
    cout << (1<<len) << endl;
    return 0;
}

Measured memory_bytes: 256