akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

bool dodp(const vector<int>& vec, int goal)
{
    set<int> dp;
    dp.insert(0);
    for (int x : vec) {
        if (x == 0)
            continue;

        set<int> ndp;

        for (int y : dp) {
            ndp.insert(y + x);
            ndp.insert(y - x);
        }

        dp.swap(ndp);
    }

    return dp.find(goal) != dp.end();
}

int main()
{
    string S;
    int GX, GY;
    cin >> S >> GX >> GY;

    size_t p = S.find('T');
    int ix = p == string::npos ? (int)S.size() : (int)p;

    bool isx = false;
    vector<int> dxs, dys;
    while (p != string::npos) {
        size_t op = p;
        p = S.find('T', op + 1);

        if (isx) {
            dxs.push_back(p == string::npos ?
                          (int)(S.size() - op - 1) : (int)(p - op - 1));
        } else {
            dys.push_back(p == string::npos ?
                          (int)(S.size() - op - 1) : (int)(p - op - 1));
        }

        isx = !isx;
    }

    cout << (dodp(dxs, GX - ix) && dodp(dys, GY) ? "Yes" : "No") << '\n';

    return 0;
}


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

struct node
{
	int key;
	node* lc, * rc, * p;
};

node* root = NULL;

void insert(int x)
{
	node* pre = root;
	node* prep = NULL;

	node* in = (node*)malloc(sizeof(node));
	in->key = x;
	in->lc = NULL;
	in->rc = NULL;

	while (pre != NULL)
	{
		prep = pre;
		if (in->key < pre->key)
			pre = pre->lc;
		else
			pre = pre->rc;
	}

	in->p = prep;

	if (prep == NULL)
		root = in;
	else
	{
		if (in->key < prep->key)
			prep->lc = in;
		else
			prep->rc = in;
	}
}

void Inorder(node* r)
{
	if (r->lc != NULL)
		Inorder(r->lc);

	cout << " " << r->key;

	if (r->rc != NULL)
		Inorder(r->rc);
}

void Preorder(node* r)
{
	cout << " " << r->key;

	if (r->lc != NULL)
		Preorder(r->lc);
	if (r->rc != NULL)
		Preorder(r->rc);
}

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

	int n, x;
	string p;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> p;

		if (p == "insert")
		{
			cin >> x;
			insert(x);
		}
		else
		{
			Inorder(root);
			cout << endl;
			Preorder(root);
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 26628
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;

void main() {
	auto ip = readln.split.to!(int[]), X = ip[0], Y = ip[1], Z = ip[2];
	auto a = X - Z, b = Z + Y;
	writeln(a / b);
}

Measured memory_bytes: 256
def selection_sort(A):
    count = 0
    for i in range(len(A)):
        mini = i
        for j in range(i, len(A)):
            if A[j] < A[mini]:
                mini = j
        count += swap(A, mini, i)
    print_array(A)
    return count


def swap(A, i, j):
    if i != j:
        tmp = A[j]
        A[j] = A[i]
        A[i] = tmp
        return 1
    else:
        return 0


def print_array(array):
    print(" ".join([str(x) for x in array]))


amount = int(input())
numbers = [0 for i in range(amount)]
numbers = list(map(int, input().split()))
count = selection_sort(numbers)
print(count)

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

template<typename T>
struct Segtree {
    int n;
    T e;
    vector<T> dat;
    typedef function<T(T a, T b)> Func;
    Func f;

    Segtree(int n_input, Func f, T e_input):f(f), e(e_input){
        n = 1;
        while(n < n_input) n <<= 1;
        dat.resize(2*n-1, e);
    }

    void update(int k, T a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1)/2;
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    T get(int k){
        return dat[k+n-1];
    }

    T between(int a, int b){
        return query(a, b+1, 0, 0, n);
    }

    T query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return e;
        if(a<=l && r<=b) return dat[k];
        T vl = query(a, b, 2*k+1, l, (l+r)/2);
        T vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};


int main(){
    int64_t N, X;
    cin >> N >> X;
    Segtree<int64_t> st(2*N, [](int64_t a, int64_t b){return min(a, b);}, 1e9+1);
    for(int i=0; i<N; i++){
        int64_t a;
        cin >> a;
        st.update(i, a);
        st.update(i+N, a);
    }

    int64_t ans = 1e18;
    for(int i=0; i<N; i++){
        int64_t result = X * i;
        for(int j=0; j<N; j++){
            result += st.between(j+N-i, j+N);
        }
        ans = min(ans, result);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n;
	scanf("%d", &n);
	char s[10000];
	scanf("%s", s);

	for(int i=0; i<strlen(s); i++){
		if(s[i]+n<='Z'){
			s[i]+=n;
		}
		else s[i]+=n-26;
	}

	for(int i=0; i<strlen(s); i++){
		printf("%c", s[i]);
	}
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> n;
	vector<ll>	a(n);
	bool zero=false,odd=false;
	for(i=0;i<n;i++) {
		cin >> a[i];
		if (a[i]==0) zero = true;
		if (a[i]<0) {
			odd = !odd;
			a[i] = -a[i];
		}
		ans += a[i];
	}
	if (!zero && odd) {
		ll m = a[0];
		for(i=1;i<n;i++) {
			m = min(m , a[i]);
		}
		ans -= 2*m;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4060
#include<cstdio>
#include<algorithm>
using namespace std;
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a+b>=c)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
"""
B - Time Limit Exceeded
"""

import numpy as np

n, t = map(int, input().split())

temp = []
for i in range(n):
    value = []
    for part in input().split():
        value.append(int(part))
    temp.append(value)

keiros = np.array(temp)

# 0番目の 0:コスト 1:時間
#print(keiros[0, 1])

keiros_sort = np.argsort(keiros[:, 1])

#print(keiros)
#print(keiros[keiros_sort])

min_cost = 1001
for keiro in keiros[keiros_sort]:
    #print(keiro)
    if keiro[1] <= t:
        min_cost = min(min_cost, keiro[0])

if min_cost == 1001:
    print("TLE")
else:
    print(min_cost)



Measured memory_bytes: 20760
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

def floor(a,b):
    return a//b

N = I()

ans = 0
for i in range(1,N+1):
    k = floor(N,i)
    ans += i*k*(k+1)//2

print(ans)

Measured memory_bytes: 68036
#include <iostream>
#include <string>
using namespace std;
using ll = long long int;

string solve(ll N, ll L) {
  string ans = string(L, ')') + string(L, '(');
  ll M = L * (L + 1) / 2;

  int pos = L;
  for(; M > N; M--) {
    swap(ans[pos], ans[pos-1]);
    pos--;
  }
  return ans;
}

int main() {
  ll N; cin >> N;
  ll sum = 0;
  for(ll i=1; ; i++) {
    sum += i;
    if(sum >= N) {
      cout << solve(N, i) << endl;
      return 0;
    }
  }
  return 1;
}



Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
int x, ans = 1;
int main() {
	cin >> x;
	for (int i = 2; i < 40; i++) {
		int num = i * i;
		while(num <= x) {
			ans = max(ans, num);
			num *= i;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        String ans = "No";
        for(int i=0;i<S.length();i++){
            StringBuilder sb = new StringBuilder();
            sb.append(S.substring(i,S.length()));
            sb.append(S.substring(0,i));
            if(T.equals(sb.toString())) {
                ans = "Yes";
                break;
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	vector<ll> A(3); cin>>A[0]>>A[1]>>A[2];
	if(A[0]%2==0 || A[2]%2==0 | A[1]%2==0) cout<<0;
	else{
		sort(A.bg,A.ed);
		cout<<A[0]*A[1];
	}
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num = new ArrayList<Integer>();
		ArrayList<String> param = new ArrayList<String>();
		int system = 0; // 文字の空白区切り 0:ON 1:OFF
 
		while (sc.hasNext()) {
			if (sc.hasNextInt()) {
				num.add(sc.nextInt());
			} else {
				if (system == 0)
					param.add(sc.next());
				if (system == 1)
					param.add(sc.nextLine());
			}
		}
		Method(num, param);
	}
 
	static void Method(ArrayList<Integer> num, ArrayList<String> param) {
		int count = 0;
		int jump = 0;
		
		while(true){
			count++;
			jump += count;
			if(jump >= num.get(0)) break;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21972
def 解():
    iN = int(input())
    iNow = 0
    iMem = 0
    iC = 0
    d = {}
    for a in reversed(sorted([int(_) for _ in input().split()])):
        if iNow == a:
            iC += 1
        else:
            iC = 1
            iNow = a
        if iC == 2:
            if iMem :
                print(iMem * iNow)
                exit()
            else:
                iMem = a
        elif iC == 4:
            print(iMem**2)
            exit()
    print(0)
解()


Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n]; 
  int xo=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    xo^=a[i];
  }
  for(int i=0;i<n;i++){ cout<<(xo^a[i])<<endl;}
  return 0;
}

Measured memory_bytes: 4296
#include <iostream>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main()
{
	long a,b,k;
	cin >> a >> b >> k;
	for (long i = a; i <= min(b, a+k-1); i++)
		cout << i << endl;
	for (long i = max(b - k + 1, a + k); i <= b; i++)
		cout << i << endl;
	return (0);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

struct aa {
	int a;
	int b;
	int cost;
};

int main()
{
	int N,C;cin>>N>>C;
	vector<aa>dates;
	for (int i = 0; i < N; ++i) {
		int a,b,c;cin>>a>>b>>c;
		dates.push_back(aa{ a,b,c });
	}
	vector<vector<vector<int>>>dp(2,vector<vector<int>>(100*N+1,vector<int>(C+1,-1e9)));

	dp[0][0][0]=0;
	for (int i = 0; i < N; ++i) {
		int now(i%2);
		int nex(1&(i-1));

		for (int a_love = 0; a_love <= 100*i; ++a_love) {
			for (int money = 0; money <= C; ++money) {
				dp[nex][a_love][money]=max(dp[nex][a_love][money],dp[now][a_love][money]);

				{
					const int next_money=money+dates[i].cost;
					if (next_money <= C) {
						dp[nex][a_love+dates[i].a][next_money]=max(dp[nex][a_love+dates[i].a][next_money],dp[now][a_love][money]+dates[i].b);
						dp[nex][a_love+dates[i].b][next_money]=max(dp[nex][a_love+dates[i].b][next_money],dp[now][a_love][money]+dates[i].a);
					}
				}
			}
		}
	}


	int ans=0;
	for (int i = 0; i < 100 * N + 1; ++i) {
		for (int money = 0; money <= C; ++money) {
			ans=max(ans,min(i,dp[N%2][i][money]));
			
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 15808
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        if (a * a + b * b == c * c || b * b + c * c == a * a || a * a + c * c == b * b) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}



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

int main() {
	int n;
	scanf("%d", &n);
	vector<int> a(n - 1);
	vector<int> v(n);
	for(int i = 0; i < n - 1; i++) {
		scanf("%d", &a[i]);
		v[a[i] - 1] += 1;
	}
	for(int i = 0; i < n; i++) {
		printf("%d\n", v[i]);
	}
}

Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n 
#define pl(n) cout<<n<<" "
const int N=2e5+2;
const int inf= (int)(1e19+10LL);
void solve(){
	int k;
	int a,b;
	sl(k);sl(a);sl(b);
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK"<<endl;
			return;
		}
	}
	cout<<"NG"<<endl;
	
} 
signed main(){
  int test=1;
// sl(test);
 while(test--){
 	solve();
 }
 
}

Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>

using namespace std;

int a[300010], n, sum = 0, A = 0, B = 0;

bool check(int x) {
    int mx = a[1];
    for(int i = 3; i <= n; i += 2) {
        if(mx >= x) mx += a[i] - a[i - 1], mx = max(mx, a[i]);
        else mx += a[i] - a[i - 1];
    }
    return mx >= x;
}

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]), sum += a[i], A += (i % 2) * a[i];
    B = sum - A;
    if(n % 2 == 0) printf("%d %d\n", max(A, B), min(A, B)); else {
        int ans = 0;
        for(int L = 0, R = sum; L <= R; ) {
            int md = (L + R) / 2;
            if(check(md)) ans = md, L = md + 1; else R = md - 1;
        }
        printf("%d %d\n", B + ans, sum - B - ans);
    }
    return 0;
}


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

ll comb(ll n) {
	return n * (n-1) / 2;
}

int main() {
	int n;
	cin >> n;
	vector<int> balls(n);
	rep(i, n) cin >> balls[i];
	rep(i, n) balls[i]--; // 0 startにするため
	vector<int> counts(n);
	rep(i, n) counts[balls[i]]++;
	ll total = 0;
	rep(i, n) total += comb(counts[i]);
	rep(i, n) {
		ll result = total;
		result -= comb(counts[balls[i]]);
		result += comb(counts[balls[i]] - 1);
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 4096
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

template <typename T>
void chmin(T& x, T y) {
    x = min(x, y);
}

template <typename T>
void chmax(T& x, T y) {
    x = max(x, y);
}

ll csum(ll x, ll y) {
    if (x > 0 && y > 0 && x > LL_MAX - y) {
        return LL_MAX;
    }
    if (x < 0 && y < 0 && x < LL_MIN - y) {
        return LL_MIN;
    }
    return x + y;
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,0,N) {
        cin >> A[i];
    }
    rep(k,0,K) {
        vector<ll> diff(N+1);
        rep(i,0,N) {
            ll add = i - A[i];
            ll subtract = i + 1 + A[i];
            auto clamp = [N](ll x){
                return min(N, max((ll)0, x));
            };
            add = clamp(add);
            subtract = clamp(subtract);
            diff[add] += 1;
            diff[subtract] -= 1;
        }
        ll val = 0;
        bool all_N = true;
        rep(i,0,N) {
            val += diff[i];
            A[i] = val;
            if (A[i] != N) {
                all_N = false;
            }
        }
        if (all_N) {
            break;
        }
    }
    rep(i,0,N) {
        cout << A[i];
        if (i != N-1) {
            cout << " ";
        }
    }
    cout << endl;
}

/*
 
 6 100
 0 0 0 0 0 0 0
 
 */


Measured memory_bytes: 5956
import heapq

N = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr, reverse = True)
ans = 0
q = []
heapq.heappush(q, -arr[0])

for i in range(1, N):
  tmp = heapq.heappop(q)
  tmp *= -1
  ans += tmp
  heapq.heappush(q, -arr[i])
  heapq.heappush(q, -arr[i])
  
print(ans)

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

using namespace std;

int main(){
	
	int n;
	
	cin >> n;
	
	int map[10][10];
	
	bool check[10][10];
	
	int chec[10];
	
	for(int loop = 0; loop < n; loop++){
		
		if(loop != 0){
			cout << endl;
		}
		
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				cin >> map[i][j];
				check[i][j] = false;
			}
		}
		
		for(int i = 0; i < 9; i++){
			for(int j = 0; j <= 9; j++){
				chec[j] = 0;
			}
			
			for(int j = 0; j < 9; j++){
				chec[map[j][i]]++;
			}
			
			for(int j = 1; j <= 9; j++){
				if(chec[j] > 1){
					for(int k = 0; k < 9; k++){
						if(map[k][i] == j){
							check[k][i] = true;
						}
					}
				}
			}
		}
		
		for(int i = 0; i < 9; i++){
			for(int j = 0; j <= 9; j++){
				chec[j] = 0;
			}
			
			for(int j = 0; j < 9; j++){
				chec[map[i][j]]++;
			}
			
			for(int j = 1; j <= 9; j++){
				if(chec[j] > 1){
					for(int k = 0; k < 9; k++){
						if(map[i][k] == j){
							check[i][k] = true;
						}
					}
				}
			}
		}
		
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 3; k++){
					for(int l = 0; l <= 3; l++){
						chec[k * 3 + l] = 0;
					}
				}
				
				for(int k = 0; k < 3; k++){
					for(int l = 0; l < 3; l++){
						chec[map[i * 3 + k][j * 3 + l]]++;
					}
				}
				
				for(int k = 1; k <= 9; k++){
					if(chec[k] > 1){
						for(int m = 0; m < 3; m++){
							for(int l = 0; l < 3; l++){
								if(map[i * 3 + m][j * 3 + l] == k){
									check[i * 3 + m][j * 3 + l] = true;
								}
							}
						}
					}
				}
				
			}
		}
		
		
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				if(check[i][j]){
					cout << "*";
				}else{
					cout << " ";
				}
				cout << map[i][j];
			}
			cout << endl;
		}
	}
	
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i];
    if(i == SZ(s)-1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}

ll hextobin(string s) {
  ll ans = 0;
  ll now = 1;
  RREP(i, SZ(s)-1) {
    switch(s[i]) {
      case 'a':
      case 'b':
      case 'c':
      case 'd':
      case 'e':
      case 'f':
        ans += ((ll)(s[i] - 'a') + 10) * now;
        break;
      default:
        ans += (ll)(s[i] - '0') * now;
        break;
    }
    now *= 16;
  }
  return ans;
}

string bintohex(ll a) {
  if(a == 0) return "0";
  string ans = "";
  vector<char> tmp = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
  while(a > 0) {
    ans += tmp[a % 16];
    a /= 16;
  }
  reverse(ALL(ans));
  return ans;
}

int digit(ll a) {
  int ans = 0;
  while(a > 0) {
    ans++;
    a /= 2;
  }
  return ans;
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int s; cin >> s;
  while(s > 0) {
    int n = 9;
    vector<string> tmp(n);
    REP(i, n) {
      cin >> tmp[i];
    }
    vll a(n);
    REP(i, n) {
      a[i] = hextobin(tmp[i]);
    }
    // printv(a);

    ll res = 0;
    for(int i=0;i<32;i++) {
      ll sum = 0;
      for(int j=0;j<8;j++) {
        sum += a[j] ^ res;
      }
      ll bit = (1ll<<i);
      if((sum&bit)!=(a[8]&bit)) {
        res |= bit;
      }
    }
    //printv(a);
    cout << bintohex(res) << endl;

    s--;
  }
}
// 1001001001001001010111111000111
// 10110110110110110001111110110111



Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<stdio.h>
using namespace std;

int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  if(a+b<=2*c){
    cout << a*x + b * y  << endl;
  }
  else {
    int abc = c *2 * min(x,y) + max(b*(y-x),a*(x-y));
    int ccc = c *2 * max(x,y);
    cout << min(abc, ccc)  << endl;
  }
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  cout<<n*n*3<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1)%LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a,int b){
  return a<b ?a : b;
}

int main(){
  int elaps = 0,c;
  int i,q;
  P u;
  scanf("%d%d",&n,&q);
  for(i = 1;i <= n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }

  head = 1;tail = n + 1;
  while(head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps +=c;
    if( u.t > 0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }

  return 0;
}





Measured memory_bytes: 11884
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h, w = map(int, readline().split())
s = [input() for i in range(h)]
q = [(0, 0)]
g = (h - 1, w - 1)
test = [(0, 1), (0, -1), (1, 0), (-1, 0)]
inf = float('inf')
dist = [[inf] * w for _ in range(h)]
dist[0][0] = 0
cnt = 0
while 1:
    qq = []
    cnt += 1
    for y, x in q:
        for dy, dx in test:
            yy, xx = y + dy, x + dx
            if xx < 0 or yy < 0 or xx > w - 1 or yy > h - 1:
                continue
            if s[yy][xx] == '#' or dist[yy][xx] != inf:
                continue
            dist[yy][xx] = cnt
            qq.append((yy, xx))
    q = qq
    if g in q:
        break
    if q:
        continue
    else:
        print(-1)
        exit()
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            cnt += 1
print(h * w - cnt - 1)


Measured memory_bytes: 3064
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int current = 1;
        int count = sc.nextInt();
        int added = sc.nextInt();
        while (count != 0 && added >= current) {
            current *= 2;
            count--;
        }
        while (count != 0) {
            current += added;
            count--;
        }
        System.out.println(current);
    }
}


Measured memory_bytes: 21972
#include <stdio.h>
#include <memory.h>
#include <math.h>
 
#define NUM 10000000
unsigned int prime[NUM+2];
unsigned int prime_value[700000];
unsigned int prime_size = 0;
 
void create_prime(void)
{
    unsigned int i, j;
    unsigned int size;
    unsigned int sq_num = (int)sqrt((double)NUM);
 
    memset((char*)prime, 0xFF, sizeof(prime));
    prime[0] = 0;
    prime[1] = 0;
     
    for (i=2;i<=sq_num;i++) {
        if (prime[i] != 0) {
            for (j=2;i*j<=NUM;j++){
                prime[i*j] = 0;
            }
        }
    }

	for(i=2;i<NUM;i++) {
		if(prime[i] != 0) {
		   	prime_value[prime_size] = i;
		   	prime_size ++;
		}	
	}  
}
 
int main(void) {
    int i, j, n, value;
    int count = 0;
    int sq_num;
     
    create_prime();
     
    scanf("%d\n", &n);
    for(i=0;i<n;i++) {
        scanf("%d\n", &value);
        if(value >= NUM) {
        	sq_num = (int)sqrt((double)value);
        	for(j=0;j<prime_size;j++) {
        		if(value % prime_value[j] == 0) {
        			break;
        		} else if(prime_value[j] > sq_num) {
        			count ++;
        			break;
        		}
        	}
        }
        else if(prime[value] != 0) {
            count++;
        }
    }
     
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 42268
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;

long long cnt;
int a[1000005];
vector<int> G;

void insertsort(int a[], int n, int g){
    for(int i = g; i < n; i++){
        int j = i - g;
        int v = a[i];
        while(j >= 0 && a[j] > v){
            a[j + g] = a[j];
            j -= g;
            cnt ++;
        }
        a[j + g] = v;
    }
}

void shellsort(int a[], int n){
    for(int h = 1; h <= n;){
        G.push_back(h);
        h = h * 3 + 1;
    }

    for(int i = G.size() - 1; i >= 0; i --){
        insertsort(a, n, G[i]);
    }
}

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    shellsort(a, n);
    printf("%d\n", G.size());
    for(int i = G.size() - 1; i >= 0; i--){
        printf("%d", G[i]);
        if(i) printf(" ");
    }
    puts("");
    cout << cnt << endl;
    for(int i = 0; i < n; i++){
        printf("%d\n", a[i]);
    }
    return 0;
}



Measured memory_bytes: 7140
from collections import defaultdict


def main():
    n, w = map(int, input().split())
    items = [list(map(int, input().split())) for _ in range(n)]
    DP = defaultdict(int)
    DP[0] = 0
    for weight, value in items:
        exists = list(DP.items())
        for key, total in exists:
            new_key = key + weight
            if new_key > w:
                continue
            new_total = total + value
            if DP[new_key] < new_total:
                DP[new_key] = new_total

    print(max(DP.values()))


if __name__ == "__main__":
    main()


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


def solve(h, n):
    if (4*h*n-N*n-N*h) == 0:
        return
    w = N*h*n // (4*h*n-N*n-N*h)
    if w < 1:
        return
    if w*(4*h*n-N*n-N*h) == N*h*n:
        print(h, n, w)
        exit()


if N < 2000:
    for h in range(1, 3501):
        for n in range(1, 3501):
            solve(h, n)
else:
    for h in reversed(range(1, 3501)):
        for n in reversed(range(1, 3501)):
            solve(h, n)


Measured memory_bytes: 9212
import numpy as np

n, d = list(map(int, input().split()))
xa = [np.array(list(map(int, input().split()))) for _ in range(n)]
s = 0
for i in range(n-1) :
    for j in range(i+1, n) :
        if np.linalg.norm(xa[i]-xa[j])%1 == 0.0:
            s += 1
print(s)

Measured memory_bytes: 12492
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
void trace(int n, vector<ll> arr){for(int i = 0; i < n; i++){cout << arr[i] << " ";} cout << endl << endl;}
const ll mod = 1e9 + 7;
int main()
{
    Hello
    int n, k;
    ll ans = 1;
    cin >> n >> k;
    vector<ll> pos, neg;
    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        ans = (ans * a) % mod;
        if(a < 0) neg.push_back(-a);
        else pos.push_back(a);
    }
    if(k == n) return cout << (ans + mod) % mod, 0;
    sort(neg.begin(), neg.end());
    sort(pos.begin(), pos.end());
    if(!pos.size()){
        ans = 1;
        if(k % 2){
            for(int i = 0; i < k; i++)
                ans = (ans * neg[i]) % mod;
            ans *= -1;
        }
        else
            for(int i = neg.size() - 1; i >= neg.size() - k; i--)
                ans = (ans * neg[i]) % mod;
        return cout << (ans + mod) % mod, 0;
    }
    else{
        vector<ll> final;
        if(k % 2){
            final.push_back(pos.back());
            pos.pop_back();
        }
        while(final.size() < k){
            bool foundPos = false, foundNeg = false;
            ll positive1, negative1, negative2, positive2;
            if(pos.size() >= 2){
                foundPos = true;
                positive1 = pos.back();
                positive2 = pos[pos.size() - 2];
            }
            if(neg.size() >= 2){
                foundNeg = true;
                negative1 = neg.back();
                negative2 = neg[neg.size() - 2];
            }
            if(foundNeg && foundPos){
                if(positive1 * positive2 > negative1 * negative2){
                    pos.pop_back();
                    pos.pop_back();
                    final.push_back(positive1);
                    final.push_back(positive2);
                }
                else {
                    neg.pop_back();
                    neg.pop_back();
                    final.push_back(negative1);
                    final.push_back(negative2);
                }
            }
            else if(foundNeg){
                neg.pop_back();
                neg.pop_back();
                final.push_back(negative1);
                final.push_back(negative2);
            }
            else if(foundPos){
                pos.pop_back();
                pos.pop_back();
                final.push_back(positive1);
                final.push_back(positive2);
            }
            else{
                final.push_back(pos.back());
                final.push_back(neg.back());
            }
        }
        ans = 1;
        for(int i = 0; i < final.size(); i++)
            ans = (ans * final[i]) % mod;
        return cout << ans, 0;
    }
    return 0;
}


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

int isprime(int);
int main(void){
  int n,i,count=0;
  int A[10000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);

  for(i=0;i<n;i++){
    if(isprime(A[i])==1)count++;
  }
  printf("%d\n",count);
  return 0;
}

int isprime(int x){
  int i=3;
  if(x==2)return 1;
  if(x<2 || x%2==0)return 0;
  while(i<=sqrt((double)x)){
    if(x%i==0)return 0;
    i+=2;
  }
  return 1;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;

    if(x >= r && y >= r && x <= w - r && y <= h - r)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
  
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include <string> 
using namespace std;
int max(int x, int y) {
	if (x > y)return x;
	return y;
}

int X, t,ans;

int main(){
	cin >> X >> t;
	if (X - t > 0) {
		cout << X - t;
	}
	else {
		cout << 0;
	}


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int N;
	cin>>N;
    int ans;
	for(int i=1;i<=9;i++){
		if(N<=i*111){
			ans=i*111;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
	int a,b;
	while(cin>>a>>b) 
	{
		int tmp[b];
		int cnt=0;
		map<int,int> m;
		string ans;
		bool f=false;
		while(a!=0) 
		{
			a*=10;
			if(m.count(a))
			{
				f=true;
				break;
			}
			m[a]=cnt;
			cnt++;
			ans+=a/b+'0';
			a%=b;
		}
		cout<<ans<<endl;
		if(f)
		{
			for(int i = 0; i < ans.size(); ++i)
			{
				if(i<m[a]) cout<<' ';
				else cout<<'^';
			}
			cout<<endl;
		}
	}
  return 0;
}

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

import sys

def is_pal(s):
    l = len(s)-1
    for i in range(l/2):
        if s[i] != s[l-1-i]:
            return False
    return True

count = 0
for line in sys.stdin:
    if is_pal(line):
        count += 1
print count

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

int N;
int A[210];

int main() {
  cin >> N;
  for(int i = 0; i< N; i++) cin >> A[i];
  
  int res = 0;
  while(true) {
    bool exist_odd = false;
    for(int i = 0; i < N; i++) {
      if(A[i] % 2 != 0) exist_odd = true;
    }
    
    if(exist_odd) break;
    
    for(int i = 0; i < N; i++) {
      A[i] /= 2;
    }
    res++;
  }
  
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	int a, b, c, d; std::cin >> a >> b >> c >> d;
	if (a + b < c + d) {
		std::cout << "Right\n";
	}
	else if (a + b == c + d) {
		std::cout << "Balanced\n";
	}
	else {
		std::cout << "Left\n";
	}
}



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


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

    long long n,m;
    cin>>n>>m;
    long long a;
    map<long long,long long> mp;
    for (int i = 0; i < m; i++)
    {
        cin>>a;
        mp[a]=1;
    }
    long long mod = 1e9+7;
    long long dp[n+1];
    for(int i=0;i<=n;i++) dp[i]=-1e9;
    dp[0]=1;
    for(int i=1;i<=n;i++){
        if(mp[i]==0){
            if(i>=2)dp[i] = max(0LL,dp[i-1]) + max(0LL,dp[i-2]);
            else dp[i] = max(0LL,dp[i-1]);
            dp[i]%=mod;
        }
    }
    cout << max(0LL,dp[n]%mod) << endl;

    
    
}

Measured memory_bytes: 7296
n=int(input())
v=list(input().split())
v0={}
v1={}
for i in range(0,n,2):
    if v[i] in v0:
        v0[v[i]]+=1
    else:
        v0[v[i]]=1
for i in range(1,n,2):
    if v[i] in v1:
        v1[v[i]]+=1
    else:
        v1[v[i]]=1
v0=sorted(v0.items(), key=lambda x:x[1], reverse=True)
v1=sorted(v1.items(), key=lambda x:x[1], reverse=True)
if v0[0][0]==v1[0][0]:
    if len(v0)==1:
        print(int(n/2))
    else:
        print(n-v0[0][1]-(v0[1][1] if v0[1][1]>v1[1][1] else v1[1][1] ))
else:
    print(n-v0[0][1]-v1[0][1])

Measured memory_bytes: 27404
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <string>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL n;
    LL a;
    LL b;
    LL ans;
    LL tmp;
    cin >> n >> a >> b;
    tmp = n/(a+b);
    ans = tmp*a;
    if(n-tmp*(a+b)>=a){
        ans+=a;
    }else{
        ans+=n-tmp*(a+b);
    }
    cout << ans << endl;

    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, Q;
std::string S;
char t[200100], d[200100];

bool can(int x){
    for(int i=0;i<Q;++i){
        if(S[x] == t[i]){
            if(d[i] == 'L'){
                x -= 1;
            }else{
                x += 1;
            }

            unless(0 <= x && x < N){
                return true;
            }
        }
    }

    return false;
}

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

    std::cin >> N >> Q >> S;

    for(int i=0;i<Q;++i){
        std::cin >> t[i] >> d[i];
    }

    int cnt = N;

    if(can(0)){
        int lb = 0, ub = N;
        while(ub - lb > 1){
            int m = (lb + ub) / 2;
            if(can(m)){
                lb = m;
            }else{
                ub = m;
            }
        }

        cnt -= lb + 1;
    }

    if(cnt > 0 && can(N - 1)){
        int lb = -1, ub = N - 1;
        while(ub - lb > 1){
            int m = (lb + ub) / 2;
            if(can(m)){
                ub = m;
            }else{
                lb = m;
            }
        }

        cnt -= N - ub;
    }

    std::cout << cnt << std::endl;
}


Measured memory_bytes: 976
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		sc.close();

		int ans = 0;
		for (int i = 0; i < t.length; i++) {
			if (s[i] != t[i]) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 41968
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n, k;
    cin >> n >> k;

    vector<lint> h(n);
    rep(i, n){
        cin >> h[i];
    }

    SORT(h);

    lint ans = 0;
    rep(i, n - k){
        ans += h[i];
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 1792
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	for i := 0; i < num; i++ {
		sc.Scan()
		sc.Text()
		sc.Scan()
		num2, _ := strconv.Atoi(sc.Text())
		r := make([]int, num)
		for j := 0; j < num2; j++ {
			sc.Scan()
			val, _ := strconv.Atoi(sc.Text())
			r[val-1] = 1
		}
		for i, v := range r {
			if i != 0 {
				fmt.Printf(" %v", v)
			} else {
				fmt.Printf("%v", v)
			}
		}
		fmt.Println()
	}
}



Measured memory_bytes: 1196
from heapq import heapify, heappushpop

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

former = aa[:n]
latter = [-a for a in aa[2 * n:]]
fs = sum(former)
ls = sum(latter)
heapify(former)
heapify(latter)

results = [0] * (n + 1)
results[0] = fs
results[-1] = ls

for i in range(n, 2 * n):
    a = aa[i]
    k = heappushpop(former, a)
    fs += a - k
    results[i - n + 1] += fs

for i in range(2 * n - 1, n - 1, -1):
    a = -aa[i]
    k = heappushpop(latter, a)
    ls += a - k
    results[i - n] += ls

print(max(results))


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

using namespace std;

int main(){
    string n;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    long long len = n.length();
    len -= 1;
    if(n[len] == '2' || n[len] == '4' || n[len] == '5' || n[len] == '7' || n[len] == '9')  cout << "hon";
    else if(n[len] == '0' || n[len] == '1' || n[len] == '6' || n[len] == '8') cout << "pon";
    else if(n[len] == '3') cout << "bon";
    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,a[300][300],f[301],ans=300;
void solve(){
    int cnt[301]={},p,q=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(f[a[i][j]]==0){
                cnt[a[i][j]]++;
                break;
            }
        }
    }
    for(int i=1;i<=m;i++){
        if(cnt[i]>q){
            p=i;
            q=cnt[i];
        }
    }
    f[p]=1;
    ans=min(ans,q);
}

int main(){
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(int i=0;i<m;i++){
        solve();
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 512
import math

n = int(input())

town = []

ans = 0

for i in range(n):
    town.append(list(map(int,input().split())))

for i in range(n):
    for s in range(i,n):
        ans += math.sqrt((town[i][0]-town[s][0])**2+(town[i][1]-town[s][1])**2)
        
print(ans*2/n)

Measured memory_bytes: 3064
//#define _USE_MATH_DEFINES
//#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>

using namespace std;


int main(){

	string s;

	getline(cin, s);

	for (int i = 0; i < s.size(); i++){
		s[i] = toupper(s[i]);
	}

	cout << s << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
  if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

int main(){
  int N; cin>>N;
  if(N%1000==0){
    cout << 0 << "\n";

  }else{
    cout << (N/1000+1)*1000-N << "\n";
  }
}

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

using namespace std;

typedef long long ll;

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

	set<int> st;
	int n = 3;
	rep(i, n){
		int x;
		cin >> x;
		st.insert(x);
	}

	if(st.size() == 2){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
n=int(input())
mod=10**9+7

dp=[[0,0,0,0] for _ in range(n)]

dp[0]=[8,1,1,0]

for i in range(1,n):
    dp[i][0]=(dp[i-1][0]*8)%mod
    dp[i][1]=(dp[i-1][0]+dp[i-1][1]*9)%mod
    dp[i][2]=(dp[i-1][0]+dp[i-1][2]*9)%mod
    dp[i][3]=(dp[i-1][1]+dp[i-1][2]+dp[i-1][3]*10)%mod

#print(dp)

print(dp[-1][3]%mod)


Measured memory_bytes: 198272
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	getline(cin, s);
	for (int i = 0; i < s.length(); i++) {
		if (65<=(int)s.at(i)&&(int)s.at(i)<=90) {
			cout << (char)(s.at(i)+32);
		}
		else if (97 <= (int)s.at(i) && (int)s.at(i) <= 122) {
			cout << (char)(s.at(i) - 32);
		}
		else {
			cout << s.at(i);
		}
	}
	cout << endl;
}


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

int main() {
	int n;
  	cin >> n;
  	vector<int> a(n);
  	for(int i = 0; i< n ;i++)
      	cin >> a[i];
  	sort(a.begin(), a.end());
  	cout << a[n-1] - a[0] << endl;
}


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

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin>>n>>k;
    ll a[n], i, pre[n], ans[n], sum = 0;
    map<ll, ll> m;
    for(i=0; i<n; i++) {
    	cin>>a[i];
    }
    pre[0] = a[0];
    for(i=1; i<n; i++) {
    	pre[i] = pre[i-1] + a[i];
    }
    m[0] = 1;
    for(i=0; i<n; i++) {
    	ans[i] = (pre[i] - i - 1)%k;
    	if(i - k >= 0) {
    		m[ans[i-k]]--;
    	}
    	if(i - k == -1) {
    		m[0]--;
    	}
    	sum += m[ans[i]];
    	m[ans[i]]++;
    }
    cout<<endl;
    cout<<sum<<"\n";
}


Measured memory_bytes: 17408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> l(m),r(m);
    for(int i=0;i<m;i++){
        cin >> l[i] >> r[i];
    }
    int L=l[0],R=r[0];
    for(int i=0;i<m;i++){
        if(L<l[i]){
            L = l[i];
        }
        if(r[i]<R){
            R = r[i];
        }
    }
    if(R-L+1>0){
        cout << R-L+1 << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 1024
a=int(input())
li = list(map(int,input().split()))
li = list(filter(lambda x:x%2==0,li))
t=len(li)
li = list(filter(lambda x:(x%3==0 or x%5==0),li))
c=len(li)
if(c==t):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064