akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int frontNum = scanner.nextInt();
			int sideNum = scanner.nextInt();
			if (frontNum == 0) {
				scanner.close();
				break;
			}

			int[] front = new int[frontNum];
			Map<Integer, Queue<Integer>> frontMap = new HashMap<Integer, Queue<Integer>>();
			Map<Integer, Queue<Integer>> sideMap = new HashMap<Integer, Queue<Integer>>();
			for (int i = 1; i <= 20; i++) {
				Queue<Integer> frontList = new ArrayDeque<Integer>();
				Queue<Integer> sideList = new ArrayDeque<Integer>();
				frontMap.put(i, frontList);
				sideMap.put(i, sideList);
			}

			for (int y = 0; y < front.length; y++) {
				front[y] = scanner.nextInt();
				frontMap.get(front[y]).add(y);
			}

			int[] side = new int[sideNum];
			for (int x = 0; x < side.length; x++) {
				side[x] = scanner.nextInt();
				sideMap.get(side[x]).add(x);
			}

			int[][] ans = new int[sideNum][frontNum];
			int sum = 0;
			for (int height = 20; height >= 1; height--) {
				while (!sideMap.get(height).isEmpty()
						&& !frontMap.get(height).isEmpty()) {
					int sidex = sideMap.get(height).poll();
					int fronty = frontMap.get(height).poll();
					ans[sidex][fronty] = height;
					sum += height;
				}
			}

			for (int height = 20; height >= 1; height--) {
				while (!sideMap.get(height).isEmpty()) {
					int sidex = sideMap.get(height).poll();
					for (int y = 0; y < ans[sidex].length; y++) {
						if (ans[sidex][y] == 0 && front[y] >= height) {
							ans[sidex][y] = height;
							sum += height;
							break;
						}
					}
				}

				while (!frontMap.get(height).isEmpty()) {
					int frontH = frontMap.get(height).poll();
					for (int j = 0; j < ans.length; j++) {
						if (ans[j][frontH] == 0 && side[j] >= height) {
							ans[j][frontH] = height;
							sum += height;
							break;
						}
					}
				}
			}
			System.out.println(sum);

		}

	}
}

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

bool fst[26], crct[1050000];
string s;
char ss[22], anss[10][22];

int main()
{
    while(true){
        cin >> s;
        if(s.size() == 1 && s[0] == '#') break;
        int n = s.size();
        fill(crct, crct + (1 << n), false);
        int ans = 0;
        for(int bit = 0; bit < (1 << n); bit++){
            for(int i = 0; i < n; i++) ss[i] = s[i];
            bool overz = false;
            for(int i = 0; i < n; i++){
                if((bit >> i) & 1){
                    if(s[n - 1 - i] == 'z'){
                        overz = true;
                        break;
                    }
                    ss[n - 1 - i]++;
                }
            }
            if(overz) continue;
            fst[0] = false;
            crct[bit] = true;
            for(int i = 1; i < 26; i++) fst[i] = true;
            for(int i = 0; i < n; i++){
                if(fst[ss[i] - 'a']){
                    fst[ss[i] - 'a'] = false;
                    ss[i] -= 1;
                }
                if(s[i] != ss[i]) crct[bit] = false;
            }
            if(crct[bit]) ans++;
        }
        cout << ans << endl;
        if(ans < 10){
            for(int bit = 0; bit < (1 << n); bit++){
                if(crct[bit]){
                    for(int i = 0; i < n; i++) ss[i] = s[i];
                    for(int i = 0; i < n; i++){
                        if((bit >> i) & 1) ss[n - 1 - i]++;
                    }
                    for(int i = 0; i < n; i++) cout << ss[i];
                    cout << endl;
                }
            }
        }
        else{
            int count = 0;
            for(int bit = 0; bit < (1 << n); bit++){
                if(crct[bit]){
                    for(int i = 0; i < n; i++) ss[i] = s[i];
                    for(int i = 0; i < n; i++){
                        if((bit >> i) & 1) ss[n - 1 - i]++;
                    }
                    for(int i = 0; i < n; i++) cout << ss[i];
                    cout << endl;
                    count++;
                }
                if(count == 5) break;
            }
            int a[5];
            for(int bit = (1 << n) - 1; bit >= 0; bit--){
                if(crct[bit]){
                    a[9 - count] = bit;
                    count++;
                }
                if(count == 10) break;
            }
            for(int j = 0; j < 5; j++){
                for(int i = 0; i < n; i++) ss[i] = s[i];
                for(int i = 0; i < n; i++){
                    if((a[j] >> i) & 1) ss[n - 1 - i]++;
                }
                for(int i = 0; i < n; i++) cout << ss[i];
                cout << endl;
                count++;
            }
            if(count == 10) break;
        }
    }
}


Measured memory_bytes: 4176
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------


int main()
{
    Phuong_; /// <3
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while (a>0 && c>0)
    {
        c-=b;
        if (c<=0) break;
        a-=d;
    }
    if (a>0) cout << "Yes"; else cout << "No";
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; t=1; while(t--)
typedef long long int ll;
int main() {
    FIO;
    test{
        ll n,k,i,ans=0;
        cin>>n>>k;
        ll pre[n+1],suff[n+1];
        pre[0]=0;
        for(i=1;i<=n;i++){
            pre[i]=i+pre[i-1];
        }
        suff[0]=n;
        for(i=n-1;i>=0;i--){
            suff[n-i]=suff[n-i-1]+i;
        }
        for(i=k-1;i<=n;i++){
            ans+=(suff[i]-pre[i]);
            ans++;
            ans%=mod;
        }
        cout<<ans<<endl;
    }
	return 0;
}


Measured memory_bytes: 6760
#include <iostream>
#include <algorithm>
typedef long long ll;

using namespace std;

int main(){
   int num[3] = {0};
   for (size_t i = 0; i < 3; i++){
       cin >> num[i];
   }
   int k;
   cin >> k;

   sort(num, num+3);
   for (size_t i = 0; i < k; i++){
       num[2] *=2;
   }

   cout << num[0]+num[1]+num[2] << endl;

   return 0;
}


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

using namespace std;

int main() {
    int H, N, X;
    cin >> H>> N;
    for (int i = 0; i < N; ++i) {
        cin >> X;
        H -= X;
    }
    if (H <= 0)
        cout << "Yes";
    else
        cout << "No";


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K;
		K=sc.nextInt();
		int length =1;
		int a[] = new int[20];
		a[0]=0;
		for (int i =0;i<K;i++) {
			if (length==1) {
				a[0]++;
				if (a[0]>=10) {
					a[0]=1;
					a[1]=0;
					length++;
				}

			} else {
				int j=length-1;
				while(j>0&&a[j-1]<a[j]) {
					j--;
				}
				if (j==length-1) {
					if (a[j]==9) {
						int k = j;
						while (k>=0&&a[k]==9) {
							k--;
						}
						if (k==-1) {
							length++;
							for (int m=1;m<length;m++) {
								a[m]=0;
							}
							a[0]=1;
						} else {
							while (k>0&&a[k-1]<a[k]) {
								k--;
							}
							a[k] ++;
							int s = a[k];
							k=k+1;
							for (;k<length;k++) {
								if (s>0) {
									s--;
								}
								a[k]=s;
							}
						}
					} else {
						a[j]++;
					}
				} else {
					a[j]++;
					int s=a[j]-1;
					for (int k=j+1;k<length;k++) {
						a[k]=s;
						if (s>0) {
							s--;
						}
					}
				}
//				for (int k=0;k<length-1;k++) {
//					if (Math.abs(a[k+1]-a[k])>1) {
//						System.out.println(i);
//						for (int m=0;m<length;m++) {
//							System.out.print(a[m]);
//						}
//						return;
//					}
//				}

			}
		}
		for (int i=0;i<length;i++) {
			System.out.print(a[i]);
		}
	}
}

Measured memory_bytes: 21844
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	string s = chomp(readln());
	int n = to!int(s.length);
	int K;
	scanf("%d", &K);
	string[] S;
	foreach (len; 1..K+1) {
		foreach (i; 0..n-len+1) {
			S ~= s[i..i+len];
		}
	}
	writeln(S.sort.uniq.array[K-1]);
}

Measured memory_bytes: 2836
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    string s;
    cin>>s;
    ll A=753;
    ll ans=E;
    for(int i=0;i+2<s.size();i++){
        ll count=0;
        for(int t=0;t<3;t++){
            count*=10;
            count+=s[i+t]-'0';
        }
        ans=min(ans,abs(A-count));
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}


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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll k;
    cin >> k;
    ll ans = 0;
    FOR(a,1,k){
        FOR(b,1,k){
            ll tmp = gcd<ll,ll>(a,b);
            FOR(c,1,k){
                ans += gcd<ll,ll>(tmp,c);
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int,int>
#define mii map<int,int>
#define mci map<char,int>
#define fir first
#define sec second
#define eline "\n"

int main() {

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

	int s, w;
	cin >> s >> w;
	if(w >= s) cout << "unsafe" << eline;
	else cout << "safe" << eline;

	return 0;
}


Measured memory_bytes: 3496
from sys import stderr
import json

def debug(*args):
    print(*args, file=stderr)

n_observatory_num, m_roads_num = map(int, input().split())
hi_heights = list(map(int, input().split()))

ab_roads_fromto = [map(int, input().split()) for _ in range(m_roads_num)]


class ObservatoryController():
    observatories_by_id = {}

    def add(self, a_observatory):
        self.observatories_by_id[a_observatory.id] = a_observatory

    def connect_by_id(self, a_id, b_id):
        observatory_a = self.observatories_by_id[a_id]
        observatory_b = self.observatories_by_id[b_id]

        observatory_a.connect_to(observatory_b)
        observatory_b.connect_to(observatory_a)

    
    def count_good_observatories(self):
        result = 0
        for id, a_observaotry in self.observatories_by_id.items():
            if a_observaotry.is_good():
                result += 1
        return result


class Observatory():
    id = None
    height = None
    connected_to = []


    def __init__(self, id, height):
        self.id = id
        self.height = height
        self.connected_to = []


    def __repr__(self):
        construct = json.dumps({
            'id': self.id,
            'height': self.height,
        })
        return "<Observatory '%s'>" % (construct)

    def connect_to(self, a_observaotry):
        self.connected_to.append(a_observaotry)
    
    def is_good(self):
        for a_connected_observatory in list(self.connected_to):
            # debug('comparing...', self, a_connected_observatory)
            if self.height <= a_connected_observatory.height:
                return False
        return True

observatoryController = ObservatoryController()

for i, height in enumerate(hi_heights):
    id = i + 1
    observatory = Observatory(id, height)
    observatoryController.add(observatory)

for a, b in ab_roads_fromto:
    observatoryController.connect_by_id(a, b)

result = observatoryController.count_good_observatories()

print(result)


Measured memory_bytes: 89364
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  ll n,k;
  cin >> n >> k;
  int ans=0;
  while(true){
      if (n==0) break;
      ans++;
      n/=k;
  }
  cout << ans << endl;
}


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

int cnt = 0;

void factor(ll x) {
    for (ll i = 2; i*i <= x; i++) {
        if (x % i == 0) {
            while (x % i == 0) {
                x /= i;
            }
            cnt++;
            factor(x);
            return;
        }
    }
    if (x > 1) cnt++;
}

int main() {
    ll A, B; cin >> A >> B;
    ll gc = __gcd(A,B);
    factor(gc);
    cout << cnt+1 << '\n';
}



Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto a = RDR.ARR;
	long[13] cnt;
	foreach (e; a)
	{
		++cnt[e/400];
	}
	long[2] ans;
	foreach (i; 0..8)
	{
		if (cnt[i] != 0)
			++ans[0];
	}
	ans[1] = ans[0];
	foreach (i; 8..13)
	{
		ans[1] += cnt[i];
	}
	writeln(max(ans[0], 1), " ", ans[1]);
	stdout.flush();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k;
struct edge 
{ 
	int y;
	int next; 
}e[5100];
int a[2100];
int b[2100];
int lin[2100];
int len;
int sum;
int ans=0x3f3f3f3f;
void DJ(int xx,int yy) 
{
	e[++len].y=yy;
	e[len].next=lin[xx];
	lin[xx]=len;
}
void dfs(int x,int fa,int deep) 
{
	if(deep>k)	
	++sum;
	for(int i=lin[x];i;i=e[i].next) 
	{
		int y=e[i].y;
		if(y==fa)	
		continue;
		dfs(y,x,deep+1);
	}
}
int main() 
{
	cin>>n>>k;
	for(int i=2;i<=n;i++) 
	{
		int x;
		int y;
		cin>>x>>y;
		DJ(x,y);
		DJ(y,x);
		a[i]=x;
		b[i]=y;
	}
	if(k&1) 
	{
		k>>=1;
		for(int i=2;i<=n;i++) 
		{
			sum=0;
			dfs(a[i],b[i],0);
			dfs(b[i],a[i],0);
			ans=min(ans,sum);
		}
	} 
	else 
	{
		k>>=1;
		for(int i=2;i<=n;i++) 
		{
			sum=0;
			dfs(i,0,0);
			ans=min(ans,sum);
		}
	}
	cout<<ans;
	return 0;
}
/*
6 5
1 2
3 2
4 2
1 6
5 6
*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n,k;
    cin >> n >> k;

    if(2 * k > (n-1) * (n-2)){
        cout << -1 << endl;
        return 0;
    }
    int g[n+1][n+1];
    REP(i,n+1){
        REP(j,n+1) g[i][j] = 0;
    }
    FOR(i,2,n+1){
        g[1][i] = 1;
        g[i][1] = 1;
    }

    int res = n-1;
    int cnt = (n-1) * (n-2) / 2 - k;

    FOR(i,2,n){
        FOR(j,i+1,n+1){
            if(cnt ==0) break;
            g[i][j] = 1;
            g[j][i] = 1;
            res ++;
            cnt --;
            if(cnt ==0) break;
        }
        if(cnt ==0) break;

    }

    cout << res << endl;
    FOR(i,1,n){
        FOR(j,i+1,n+1){
            if( g[i][j] == 1){
                cout << i << " " <<j << endl;
            }
        }
    }
}

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

int path[15][15];
int dp[1<<15];
int cnt[15];

int main(){
	
	int sum=0;
	
	//??????????????????
	for(int i=0;i<15*15;i++)path[i/15][i%15]=11451419;
	for(int i=0;i<(1<<15);i++)dp[i]=11451419;
	
	//??°???????????\???(?????????????????£??????????????¨??§??????????????????)
	int v,e;
	cin>>v>>e;
	for(int i=0;i<e;i++){
		int s,t,d;
		cin>>s>>t>>d;
		path[s][t]=min(path[s][t],d);
		path[t][s]=min(path[t][s],d);
		sum+=d;
		cnt[s]++;
		cnt[t]++;
	}
	
	//???????????£???????????????
	for(int k=0;k<v;k++){
		for(int i=0;i<v;i++){
			for(int j=0;j<v;j++){
				path[i][j]=min(path[i][j],path[i][k]+path[k][j]);
			}
		}
	}
	
	//dp????????????
	int tmp=0;
	for(int i=0;i<v;i++){
		if(cnt[i]%2==0){
			tmp+=(1<<i);
		}
	}
	dp[tmp]=sum;
	
	for(int i=0;i<(1<<v);i++){
		if(dp[i]==11451419)continue;
		for(int j=0;j<v;j++){
			if(i & (1<<j))continue;
			for(int k=j+1;k<v;k++){
				if(i & (1<<k))continue;
				dp[i+(1<<j)+(1<<k)]=min(dp[i+(1<<j)+(1<<k)],dp[i]+path[j][k]);
			}
		}
	}
	
	//??????
	cout<<dp[(1<<v)-1]<<endl;
	
	return 0;
}


Measured memory_bytes: 3212
N = int(input())

restrans = []
for i in range(N):
	inputs = list(input().split())
	restrans.append((str(inputs[0]), int(inputs[1]), i + 1))

restrans = sorted(restrans, key = lambda x: (x[0], x[1] * -1))

for r in restrans:
	print(r[2])




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

int main(){
  int N;
  string S;
  cin >> N;
  for(int i = 0;i < N;i++){
    cin >> S;
    int x;
    if(S == "Y"){
      cout << "Four\n";
      break;
    }
    else
      x++;
    if(x == N){
      cout << "Three\n";
      break;
    }
  }
  return 0;
}
    

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;


int main() {
	llong N, T;
	vector<lpair> eat;
	vector<llong> dp;

	cin >> N >> T;
	eat.resize(N);
	for (auto &in: eat) {
		cin >> in.first >> in.second;
	}
	sort(ALL(eat));

	dp.resize(T + 3000 + 1, -inf);
	dp[0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = T + 3000; j >= 0; --j) {
			if (T > j - eat[i].first && j - eat[i].first >= 0) {
				dp[j] = max(dp[j], dp[j - eat[i].first] + eat[i].second);
			}
		}
	}

	sort(ALL(dp));
	cout << dp.back() << endl;

	return 0;
}

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

int main()
{
    int n;
    std::string s;
    std::deque<char> deq;
    std::cin >> n >> s;
    std::pair<int,int> cur = {0,0};// first : ') / second : '('


    for(int i = 0; i < n; i++){
        deq.push_back(s[i]);
        if(s[i] == ')' && cur.second == 0)deq.push_front('(');
        else if(s[i] == ')')cur.second--;
        if(s[i] == '(')cur.second++;
    }
    cur.second = std::max(cur.second, 0);
    for(int i = 0; i < cur.second; i++)deq.push_back(')');






    for(int i = 0; i < (int)deq.size(); i++)std::cout << deq[i];
    std::cout << std::endl;
}

Measured memory_bytes: 256
#! python3
# stack.py

symbols = input().split(' ')
stack = []

def calc(op):
    global stack
    if op == '+':
        return stack.pop()+stack.pop()
    elif op == '-':
        return -1 * stack.pop()+stack.pop()
    elif op == '*':
        return stack.pop()*stack.pop()

for s in symbols:
    if s in ['+', '-', '*']:
        stack.append(calc(s))
    else:
        stack.append(int(s))

print(stack.pop())


Measured memory_bytes: 5596
#include <iostream>
#include<algorithm>
#include <set>
#include <utility>
#include <cmath>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <ctime>
#include <limits>
#include <istream>
#include <ostream>
#include <complex.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define INF 1e16
#define mod 10000000007
#define mmax(x,y)(x>y?x:y);
#define mmin(x,y)(x<y?x:y);
int main()
{
	int a,b;
	cin>>a>>b;
	int k;
	int flag=1;
	if(a==b)
		k=0;
	else if(((a+b)/2<=a&&(a+b)/2>=b)||((a+b)/2>=a&&(a+b)/2<=b))
	{
		if(a%2==0&&b%2==0)
		k=(a+b)/2;
	else if(a%2!=0&&b%2!=0)
		k=(a+b)/2;
	else
		flag=0;
	}
	if(flag==0)
		cout<<"IMPOSSIBLE"<<endl;
	else
		cout<<k<<endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	static final long MOD = 1000000007;

	static int H, W, K;
	static long[][] dp = new long[110][10];
	static int ans = 0;
	static long n = 0;





	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] x = new int[n];
		int[]y = new int[n];
		int[] h = new int[n];
		for(int i = 0;i < n;i++){
			x[i] =sc.nextInt();
			y[i] = sc.nextInt();
			h[i] = sc.nextInt();
		}
		for(int cx = 0;cx <= 100;cx++){
			for(int cy = 0;cy <= 100;cy++){
				long H = 0;
				for(int i = 0;i < n;i++){
					if(h[i] != 0){
						H= (long)( h[i] +(long) Math.abs(x[i]-cx) +  Math.abs(y[i]-cy));
						break;
					}
				}


				boolean flag = true;
				for(int i = 0;i < n;i++){
						if(h[i] !=Math.max( H - Math.abs(x[i]-cx) -  Math.abs(y[i]-cy),0)){
							flag = false;
							break;
						
					}
				}
				
				if(flag){
					System.out.println(cx + " " + cy + " " + H);
					return;
				}
			}
		}
	}
}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 22356
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a<=c&&c<=b)cout<<"Yes"<<endl;
  else cout << "No" << endl;
}

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

int main () {
    string S,T;
    cin >> S >> T;
    int N = 0;

    for (int i = 0; i < 3; i++) {
        if (S.at(i) == T.at(i)) {
            N++;
        }
    }

    cout << N << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>//AC 2 may 2020
using namespace std;
int main()
{
    long long  val=100,i,x,yr=0;
    cin>>x;
while(val<x)
    {
       // while(1){
               // if()
            yr++;
            val+=(val/100);
      //  }
    }


        cout<<yr<<endl;

    return 0;
}



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

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


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

using namespace std;
#define pb push_back

typedef long long ll;

//forget that max is with property abc = (ab)c = a(bc)
//can use Binary Index Tree to solve for 0-h[i]'s max val in logn

int n;
const int maxn = 2e5+5;
const int maxa = 1e9;
ll MOD = 1e9+7;
ll a[maxn];
int h[maxn];
ll dp[maxn];
ll bit[maxn*2];//actually maxh = maxn

inline int lowbit(int x){return  x&(-x);}

void update(int k, ll val)
{
 for(;k<=n;k+=lowbit(k)) bit[k] = max(bit[k], val);
}

ll query(int k)
{
  ll ret = 0ll;
  for(;k>0;k-=lowbit(k)) ret = max(ret, bit[k]);
  return ret;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> n;
  for(int i = 0; i < n; i++) cin >> h[i];
  for(int i = 0; i < n; i++) cin >> a[i];
  memset(bit, 0ll, sizeof(bit)); //reset = 0 maximum
  for(int i = 0; i < n; i++)
  {
    dp[i] = query(h[i]) + a[i];
    update(h[i], dp[i]);
  }
  ll maxv = 0;
  for(int i = 0; i < n; i++) maxv = max(maxv, dp[i]);
  cout << maxv << endl;

  return 0;
}


Measured memory_bytes: 7296
#include <stdio.h>
#include <vector>
#include <math.h>
using namespace std;
int main(void) {
  int num;
  while(scanf("%d", &num)==1) {
    vector<int> A;
    int ans;
    int count = 0;
    for (int i = 0; i < num - 1; i++) {
      A.push_back(i+2);
    }
    for (int i = 0; i < num - 1; i++) {
      if(A[i] != 0) {
      int k = 2;
      while(k*A[i] < num + 1) {
        if(A[k*A[i]-2] != 0) {
          A[k*A[i]-2] = 0;
          count++;
        };
        k++;
      }
    }
      if(i > sqrt(num)) break;
    }
    ans = num - 1 - count;
    printf("%d\n",ans);
  }
  return 0;
}



Measured memory_bytes: 10404
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    bool f = false;
    if(a == b && b != c){
        f = true;
    } else if(b == c && c != a){
        f = true;
    } else if(a == c && c != b){
        f = true;
    }

    if(f){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int res = 0;
	//int calculation_cnt = 0;

	for (int a = 0; a <= A; ++a) {
		for (int b = 0; b <= B; ++b) {
			for (int c = 0; c <= C; ++c) {
				//calculation_cnt++;
				int total = 500 * a + 100 * b + 50 * c; // 合計金額
				if (total == X)
				{
					//cout << "A : " << a << ", B : " << b << ", C : " << c << endl;
					++res; // 合計金額が X に一致したら答えをインクリメント
				}
			}
		}
	}
	cout << res << endl;
	//cout << "calculation_cnt : " << calculation_cnt << endl;

}

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

int main(){
    int N,M,i,j;

    //N枚の赤いカードsiを
    cin >> N;
    vector<string> s(N);
    for(i=0;i<N;i++){
        cin >> s.at(i);
    }

    cin >> M;
    vector<string> t(M);
    for(i=0;i<M;i++){
        cin >> t.at(i);
    }

    vector<int> money(N,0);

    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if(s.at(i)==s.at(j)){
                money.at(i)++;
            }
        }
    }
    for(i=0;i<N;i++){
        for(j=0;j<M;j++){
            if(s.at(i)==t.at(j)){
                money.at(i)--;
            }
        }
    }

    int result=0;
    for(i=0;i<N;i++){
        if(result<money.at(i)){
            result=money.at(i);
        }
    }
   
    if(result<0){
        result=0;
    }
    cout << result << endl;
    
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN2(a,b);
  OUT(max({a+b,a-b,a*b}));
}

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


struct SegTree{
  int n;
  vector<int> data;
  SegTree(int n): n(n), data(n * 2){}
  void set(int at, int val){
    at += n;
    data[at] = 1 << val;
    while(at >>= 1){ data[at] = data[at << 1] | data[at << 1 | 1]; }
  }
  int get(int l, int r){
    int ans = 0;
    for(l += n, r += n; l < r; l >>= 1, r >>= 1){
      if(l & 1) ans |= data[l++];
      if(r & 1) ans |= data[--r];
    }
    return __builtin_popcount(ans);
  }
};
int main(){
  int n, q;
  string s;
  cin >> n >> s >> q;
  for(auto& i : s) i -= 'a';
  SegTree seg(n);
  for(int i = 0; i < n; i++) seg.set(i, s[i]);
  while(q--){
    int type;
    cin >> type;
    if(type == 1){
      int at;
      char c;
      cin >> at >> c;
      seg.set(at - 1, c - 'a');
    }
    else{
      int l, r;
      cin >> l >> r;
      cout << seg.get(l - 1, r) << endl;
    }
  }
}

Measured memory_bytes: 4868
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int cal(vector<int> a,vector<int> b){
	int n=a.size(),ret=0,i1=0,i2=0;
	sort(All(a));sort(All(b));
	while(i1<n && i2<n){
		if(a[i1]==b[i2]){
			ret++;i1++;i2++;
		}
		else if(a[i1]>b[i2]) i2++;
		else i1++;
	}
	return ret;
}
int a[100100],x[100100],y[100100];
vector<int> gr[100100];
bool used[100100];
vector<int> v;
void dfs(int p){
	if(used[p]) return;used[p]=true;v.pb(p);
	rep(i,gr[p].size()) dfs(gr[p][i]);
}
int main()
{
	int n,m,out=0;cin>>n>>m;
	rep(i,n){
		cin>>a[i];a[i]--;
	}
	rep(i,m){
		cin>>x[i]>>y[i];x[i]--;y[i]--;
		gr[x[i]].pb(y[i]);gr[y[i]].pb(x[i]);
	}
	rep(i,n){
		if(!used[i]){
			v.clear();dfs(i);
			vector<int> w;
			rep(j,v.size()) w.pb(a[v[j]]);
			out+=cal(v,w);
		}
	}
	cout<<out<<endl;
}


Measured memory_bytes: 10744
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

i = 0
while True:
    x = x - a[i]
    if x >= 0 and i+1 != len(a):
        i += 1
    elif x == 0 and i+1 == len(a):
        i += 1
        break
    else:
        break

print(i)

Measured memory_bytes: 61900
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, R);
    IN(ll, G);
    IN(ll, B);
    IN(ll, N);
    ll ans = 0;
    REP(r, N + 1)
    {
        REP(g, N + 1)
        {
            if (N >= r * R + g * G and (N - r * R - g * G) % B == 0)
            {
                ++ans;
            }
        }
    }
    OUT(ans);
}

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

using namespace std;

struct I{I(){ios::sync_with_stdio(false);cin.tie(0);}}init;
typedef long long LL;
const LL MOD=1e9+9;
typedef vector<LL> V;
typedef vector<V> M;

LL d[70][100][100];
void pow_init(int n){
    for(int b=1;b<70;b++){
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++){
                d[b][i][j]=0;
                for(int k=0;k<n;k++)
                    d[b][i][j]+=d[b-1][i][k]*d[b-1][k][j]%MOD;
                d[b][i][j]%=MOD;
            }
    }
}
M o(int n){
    return M(n,V(n,0));
}
M e(int n){
    M ret=o(n);
    for(int i=0;i<n;i++)
        ret[i][i]=1;
    return ret;
}
M mul(M a, M b){
    int n=a.size();
    M c=o(n);
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++)
                c[i][j]+=a[i][k]*b[k][j]%MOD;
            c[i][j]%=MOD;
        }
    return c;
}
M mul(M a,int m){
    int n=a.size();
    M c=o(n);
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++)
                c[i][j]+=a[i][k]*d[m][k][j]%MOD;
            c[i][j]%=MOD;
        }
    return c;
}
M mat_pow(int m,LL n){
    M ret=e(m);
    int i=0;
    while(n){
        if(n&1)ret=mul(ret,i);
        n>>=1;
        i++;
    }
    return ret;
}

V mul(V a,M b){
    int n=a.size();
    V res(n,0);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
            res[i]+=a[j]*b[j][i]%MOD;
        res[i]%=MOD;
    }
    return res;
}

LL solve(LL C,LL R,LL N){
    map<LL,vector<LL>> O;
    O[R]=vector<LL>();
    for(LL i=0,r,c;i<N;i++){
        cin>>c>>r;
        O[r].push_back(c-1);
    }
    LL now=1;
    for(int i=0;i<C;i++)
        for(int j=0;j<C;j++)
            d[0][i][j]=0;
    for(int i=0;i<C;i++)
        for(int j=max(0,i-1);j<min((int)C,i+2);j++)
            d[0][i][j]++;
    pow_init(C);
    V res(C,0);
    res[0]=1;
    for(auto &it:O){
        LL nxt=it.first;
        res=mul(res,mat_pow(C,nxt-now));
        for(auto &c:it.second)res[c]=0;
        now=nxt;
    }
    return res[C-1];
}
int main(){
    for(LL i=1,w,h,n;cin>>w>>h>>n,w+h+n;i++){
        cout<<"Case "<<i<<": "<<solve(w,h,n)<<endl;
    }
    return 0;
}


    


    

Measured memory_bytes: 7592
#D
n = int(input())
a = list(map(int, input().split()))
min = 10e19
sum = 0
count = 0
for i in range(n):
    sum += abs(a[i])
    if abs(a[i]) < min:
        min=abs(a[i])
    if a[i] < 0:
       count += 1
    # print(sum,count,min)
if count % 2 == 0 or count == 0:
    ans = sum
else:
    ans = sum - abs(min * 2)
print(ans)


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	string str;
	cin >> str;
	int res=0;
	for(int i=0;i<(n-2);i++){
		if(str[i]=='A' && str[i+1]=='B' && str[i+2]=='C') res++;
	}
	cout << res << "\n";
}

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

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

using namespace std;
typedef long long lint;
typedef long double ldb;
typedef unsigned long long uli;

#define X first
#define Y second
#define F(i, l, r) for(auto i = l; i != r; i++)
#define Df(i, l, r) for(auto i = l; i != r; i--)
#define I(i, a) for(auto i : a)
#define pb push_back
#define rs resize
#define mk make_pair
#define asg assign
#define all(x) x.begin(),x.end()
#define ret return
#define cont continue
#define brk break
#define ins insert
#define era erase
#define fi0(x) memset(x, 0, sizeof(x))
#define finf(x) memset(x, 127, sizeof(x))
#define acpy(y, x) memcpy(y, x, sizeof(y))
#define y1 adjf
#define tm dhgdg

const int MAXN = 2e6 + 5;
const int mod = 1000000007;

int p[MAXN];
int rnk[MAXN];
pair<int, int> a[MAXN];
int la[MAXN];
int n;
int x, y;
pair<int, int> t[MAXN];

int find_set(int v){
	ret (p[v] == v) ? v : p[v] = find_set(p[v]);
}

void unite(int v, int u){
	v = find_set(v); u = find_set(u);
	if(v == u)ret;
	if(rnk[v] > rnk[u])swap(v, u);
	p[v] = u;
	if(rnk[v] == rnk[u])rnk[u]++;
}

int ccol[MAXN];
int tm[MAXN];
int gt = 0;

int get(int pos){
	if(tm[pos] < gt)ret 0; else ret ccol[pos];
}

void upd(int pos, int val){
	tm[pos] = gt;
	ccol[pos] = val;
}

lint inv[MAXN];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	scanf("%d%d%d", &n, &x, &y);
	F(i, 0, n)scanf("%d%d", &a[i].Y, &a[i].X);
	sort(a, a + n);
	F(i, 0, n){p[i] = i; rnk[i] = 0;}
	F(i, 1, n + 1)la[i] = -1;
	int c1 = -1, c2 = -1;
	int p1, p2;
	F(i, 0, n){
		if(c1 == -1){p1 = i; c1 = a[i].Y; cont;}
		if(c2 == -1 && c1 != a[i].Y){p2 = i; c2 = a[i].Y; cont;}
	}
	F(i, 0, n){
		if(la[a[i].Y] != -1 && a[la[a[i].Y]].X + a[i].X <= x){unite(la[a[i].Y], i);}
		if(c1 != a[i].Y){if(a[p1].X + a[i].X <= y){unite(p1, i);}}
		else if(c2 != -1){if(a[p2].X + a[i].X <= y){unite(p2, i);}}
		if(la[a[i].Y] == -1){
			la[a[i].Y] = i;
		}
	}
	inv[1] = 1;
	F(i, 2, MAXN){
		inv[i] = (mod-((mod/i) * 1ll * inv[mod%i] % mod))%mod;
		if(inv[i] < 0){inv[i] = (inv[i] + mod)%mod;}
	}
	F(i, 0, n)t[i] = mk(find_set(i), a[i].Y);
	sort(t, t + n);
	lint ans = 1ll;
	int cnt = 0;
	gt++; fi0(tm);
	F(i, 0, n){
		ans *= (cnt + 1);
		cnt++;
		ans %= mod;
		int prv = get(t[i].Y);
		prv++;
		upd(t[i].Y, prv);
		ans = (ans * inv[prv]) % mod;
		if(i != n - 1 && t[i+1].X != t[i].X){
			gt++; cnt = 0;
		}
	}
	printf("%lld", ans);
	ret 0;
}



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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string S; cin >> S;
    if(S[1] == 'B') cout << "ARC";
    else cout << "ABC";
  	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>

int main(int argc, char *argv[]){
    int N;
    std::cin >> N;
    std::vector<int> D(N);
    for(auto &d : D){
        std::cin >> d;
    }
    std::sort(D.begin(),D.end());
    int abcMax = D[N/2-1];
    int arcMin = D[N/2];
    std::cout << (arcMin-abcMax) << std::endl;
    return 0;
}


Measured memory_bytes: 640
#include"bits/stdc++.h"

using namespace std;

int main()
{
	int N;
	cin >> N;
	int i = N % 4;
	switch(i)
	{
		case 0:
			cout << "Yes" << endl;
			break;
		case 1:
		{
			int y = (N - 21);
			if ((y >= 0) && (y % 4 == 0))
			{
				cout << "Yes" << endl;
			}
			else
			{
				cout << "No" << endl;
			}
		}
			break;
		case 2:
		{
			int y = (N - 14);
			if ((y >= 0) && (y % 4 == 0))
			{
				cout << "Yes" << endl;
			}
			else
			{
				cout << "No" << endl;
			}
		}
			break;
		case 3:
		{
			int y = (N - 7);
			if ((y >= 0) && (y % 4 == 0))
			{
				cout << "Yes" << endl;
			}
			else
			{
				cout << "No" << endl;
			}
		}
			break;
	}
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
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() {
  int n;cin>>n;
  if(n==1){
    cout<<"Hello World"<<endl;
  }else{
    int a,b;cin>>a>>b;
    cout<<(a+b)<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	string s;
	cin>>s;
	
	bool jud=true;
	REP(i,3){
		if(s[0]==s[i]){}
		else jud=false;
	}
	
	cout<<((jud)?"No":"Yes")<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  
  int N;
  cin >> N;
  
  int h[N];
  for (int i = 0; i<N; i++){
    cin >> h[i];
  }
  
  int cnt, i_max;
  cnt = 0;
  i_max = 0;
  for (int i = 0; i<N-1; i++){
    if (h[i] >= h[i+1]) {
    cnt = cnt + 1;
    i_max = max(cnt, i_max);
    }else{
    cnt = 0;
    }
  } 
  
  cout << i_max << endl;
  
  return 0; 
}


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

int gcd(int a, int b, int c){
    int result;
    int init = a<b?(a<c?a:c):(b<c?b:c);
    for(int i = init; i >= 1; i--){
            if(a%i == 0 && b%i == 0 && c%i == 0){
                result = i;
                break;
            }
    }
    return result;
}

int main()
{
    ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    int k;
    int sum = 0;
    cin >> k;

    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                sum += gcd(i, j, l);
            }
        }
    }

    cout << sum << '\n';

    return 0;
}


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

int main() {
  int a,b;
  cin>>a>>b;
  vector<vector<char>> data(a, vector<char>(b));
  
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < b; j++) {
      cin >> data.at(i).at(j);
    }
  }
  
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < b; j++) {
    cout<<data.at(i).at(j);
  }
    cout<<endl;
    for (int j = 0; j < b; j++) {
    cout<<data.at(i).at(j);
  }
    cout<<endl;
  }
 
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

// long long int ok(long long int n){
// 	string s = to_string(n);
// 	int sz = s.size();
// 	vector<vector<vector<vector<ll>>>> dp(sz + 1, vector<vector<vector<ll>>>(2, vector<vector<ll>>(2, vector<ll>(10, 0))));
// 	dp[0][0][0][0] = 1;
// 	rep(i, sz)
// 		{
// 			int D = s[i] - '0';
// 			rep(j, 2)
// 			{
// 				rep(k,2){
// 					rep(l,2){
// 						for (int d = 0; d <= (j ? 9 : D);d++){
// 							dp[]
							
// 						}
// 					}
// 				}
				
// 			}
// 		}
// }

int d[20],n;
int dp[20][10][2][2];

int calc(long long int m){
	for(n=0;m;m/=10)d[n++]=m%10;
	reverse(d,d+n);
	memset(dp,0,sizeof(dp));
	dp[0][0][0][0]=1;
	rep(i,n)rep(j,10)rep(k,2)rep(l,2){
		rep(nj,10)if(k||nj<=d[i])if(abs(nj-j)<=1||l==0){
			int nk=k||nj<d[i], nl=l||nj;
			dp[i+1][nj][nk][nl]+=dp[i][j][k][l];
		}
	}
	int res=0;
	rep(i,10)rep(j,2)res+=dp[n][i][j][1];
	return res;
}

class JumpyNum {
	public:
	int howMany(long long int high,int low=1) 
	{
		return calc(high)-calc(low-1);
	}
};

int main()
{
	int k;
	cin >> k;
	JumpyNum j;
	long long int l = 0, r = 1e12;
	while(l + 1 < r){
		long long int mid = (l + r) / 2;
		if (j.howMany(mid) < k)
			l = mid;
		else
			r = mid;
	}
	cout << r << endl;

	return 0;
}

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

using namespace std;
typedef  long long ll;

#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const int maxn=1e6+10;
const int mod=1e9+7;

int main()
{
    char c;
    cin>>c;
    cout<<(char)(c+1)<<endl;
    return 0;
}


Measured memory_bytes: 256