akhauriyash/Code-Regression huggingface dataset:
package main

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

//input
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

//solve
type Node struct {
	id int
	p  int
	l  int
	r  int
}

const MAX = 10000
const NIL = -1

var T [MAX]Node
var n int
var pos int
var post []int

func preParse(u int) {
	if u == NIL {
		return
	}
	fmt.Printf(" %d", u)
	preParse(T[u].l)
	preParse(T[u].r)
}

func inParse(u int) {
	if u == NIL {
		return
	}
	inParse(T[u].l)
	fmt.Printf(" %d", u)
	inParse(T[u].r)
}

func postParse(u int) {
	if u == NIL {
		return
	}
	postParse(T[u].l)
	postParse(T[u].r)
	fmt.Printf(" %d", u)

}

func solve(pre []int, in []int, l int, r int) {
	if l >= r {
		return
	}

	//posは、現在訪問中の節
	root := pre[pos]
	pos++

	m := index(in, root)

	//左側の部分木
	solve(pre, in, l, m)
	//右側の部分木
	solve(pre, in, m+1, r)
	post = append(post, root)
}

func index(l []int, t int) int {
	for i, v := range l {
		if v == t {
			return i
		}
	}
	return -1
}

func rec(pre, in []int) {
	pos = 0
	//preの両端を
	solve(pre, in, 0, len(pre))
	postOrder := make([]string, len(pre))
	for i := 0; i < len(pre); i++ {
		postOrder[i] = strconv.Itoa(post[i])
	}
	fmt.Println(strings.Join(postOrder, " "))
}

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()

	pre := make([]int, n)
	in := make([]int, n)
	for i := 0; i < n; i++ {
		pre[i] = nextInt()
	}
	for i := 0; i < n; i++ {
		in[i] = nextInt()
	}

	rec(pre, in)
}



Measured memory_bytes: 1132
#include<stdio.h>
int main(){

 int n,i,sum=0,x,Y;
 scanf("%d",&Y);
 scanf("%d",&n);

 for(i=1;i<=n;i++){
 scanf("%d",&x);
 sum = sum+x;

 }
 if(sum>=Y){
    printf("Yes");
 }
 else printf("No");







}


Measured memory_bytes: 128
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#define LL long long int
using namespace std;

int main(){
    LL a, b, c, d, n;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);//1, 2, 4 ,8
    scanf("%lld", &n);
    LL _a = a << 3, _b = b << 2, _c = c << 1, _d = d;
    LL mi = min(min(_a, _b), min(_c, _d));
    if (mi == _a) printf("%lld", (n << 2) * a); 
    else if (mi == _b) printf("%lld", (n << 1) * b);
    else if (mi == _c) printf("%lld", n * c);
    else {
        LL mi2 = min(_a, min(_b, _c));
        if (mi2 == _a) printf("%lld", (n >> 1) * d + ((n & 1) << 2) * a);
        else if (mi2 == _b) printf("%lld", (n >> 1) * d + ((n & 1) << 1) * b);
        else if (mi2 == _c) printf("%lld", (n >> 1) * d + (n & 1) * c);
    }
    return 0;
}

Measured memory_bytes: 128
from collections import deque
n,m = map(int,input().split())
#隣接リスト
print("Yes")
g = [[] for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  #0-indexにします
  g[a-1].append(b-1)
  g[b-1].append(a-1)
q = deque([])
q.append(0)
check = [0] * n
while len(q) > 0:
  e = q.popleft()
  for i in g[e]:
    if check[i] > 0:
      continue
    check[i] = e + 1
    q.append(i)
for i in range(1,n):
  print(check[i])


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

using namespace std;
const int MOD = 1000000007,MAX = 510000;
long int pow107 = (int)pow(10, 9) + 7,llimit = LONG_MAX,fac[MAX], finv[MAX], inv[MAX];
int ilimit = INT_MAX;

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long int COM(long int n,long int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool comp(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

long int Func2(long int n,long int m){
    long int s2 = 1,
        r = 1;
    for(long int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % (pow107);
    }
    return s2;
}

bool secsort(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)return a.first > b.first;
    else return a.second > b.second;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//階乗factorial
//コンビネーションFunc2
//コンビネーションCOMinit(),COM(n,m)

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size()/2; ++i){
        if(s[i] != s[s.size() - 1 - i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.next();
        scanner.close();

        if (input.equals("ABC")) {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
    }
}


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

const int N = 8;
const int FREE  = -1;
const int NOT_FREE = 1;

int row[N],col[N],DIAGONAL_L[2*N-1],DIAGONAL_R[2*N-1];
bool BOARD[N][N]= {false};

void printBoard(){
  for (int i = 0; i < N ; ++i) {
    for (int j = 0; j < N ; ++j) {
      if(BOARD[i][j])
        if(row[i] != j) return;
    }
  }

  for (int i = 0; i < N ; ++i) {
    for (int j = 0; j < N ; ++j) {
      cout << (row[i] == j ? 'Q' : '.');
    }
    cout << endl;
  }
}

void solve(int i){
  if(i == N){
    printBoard();
    return ;
  }

  for (int j = 0; j < N ; ++j) {
    if(col[j] == NOT_FREE or
                  DIAGONAL_L[i+j] == NOT_FREE or
       DIAGONAL_R[i-j+N-1] == NOT_FREE)
      continue;

    row[i] = j;
    col[j] = DIAGONAL_L[i+j] = DIAGONAL_R[i-j+N-1] = NOT_FREE;

    solve(i+1);

    row[i] = col[j] = DIAGONAL_L[i+j] = DIAGONAL_R[i-j+N-1] = FREE;
  }
}

int main(){
  for (int i = 0; i < N ; ++i) {
    col[i] = row[i] = FREE;
    DIAGONAL_L[i] = DIAGONAL_R[i] = FREE;
    DIAGONAL_L[2*i] = DIAGONAL_R[2*i] =FREE;
  }

  int k; cin >> k;
  while(k --){
    int r,c; cin >> r >> c;
    BOARD[r][c] = true;
  }

  solve(0);
}


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

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    vector<int> L(N);
    pair<int, int> itv[N];
    for(int i = 0; i < N; i++) {
        cin >> X[i];
        cin >> L[i];
        itv[i].first = X[i] + L[i];
        itv[i].second = X[i] - L[i];        
    }
    sort(itv, itv+N);
    int ans = 0;
    int point = -100000000;
    for(int i = 0; i < N; i++) {
        if(point <= itv[i].second) {
            ans++;
            point = itv[i].first;            
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long

signed main(){
    int M1,D1,M2,D2;
    cin >> M1 >> D1 >> M2 >> D2;
    
    if(M2-M1!=1){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste
// #include "UnionFind.h"
// #include "power.h"

int func(int n) {
    if(n % 4 == 0) return n;
    if(n % 4 == 1) return 1;
    if(n % 4 == 2) return n + 1;
    if(n % 4 == 3) return 0;
}


signed main() {
    int A, B;
    cin >> A >> B;
    cout << (func(A - 1) ^ func(B)) << endl;
}

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

#define ll long long

int isin(int a1,int a2)
{
    if(a2<=a1 && a2>=0)
        return 1;
    else
        return 0;
}

int main(void)
{
    int w,h,x,y,r;
    scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
    if(isin(w,x+r) && isin(h,y+r) && isin(w,x-r) && isin(h,y-r))
        printf("Yes\n");
    else    
        printf("No\n");
    return 0;
}




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

bool comp(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(void)
{
    int N;
    vector<pair<int, int> > pairs;
    cin >> N;
    for (int i = 0; i < N; i++){
        int x, l;
        cin >> x >> l;
        pairs.push_back(make_pair(x-l, x+l));
    }
    sort(pairs.begin(), pairs.end(), comp);
    
    int ans = 0, t = pairs[0].first;
    for (int i = 0; i < N; i++){
        if (t <= pairs[i].first) {
            ans++;
            t = pairs[i].second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
N = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if N == 1:
  print(0)
  exit(0)
f = factorization(N)
#print(f)
ans = 0
amari_cnt = 0
for a,b in f:
  wk = b
  tempc = 1
  while wk  - tempc >= 0:
    wk -= tempc
    ans += 1
    tempc += 1

print(ans)
    

Measured memory_bytes: 9488
#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>;

int main() {
    int n, m;
    cin >> n >> m;
    int most_left = -1;
    int most_right = n+1;
    rep(i,m) {
        int lef, rig;
        cin >> lef >> rig;
        most_left = max(lef, most_left);
        most_right = min(rig, most_right);
    }
    int ans = max(most_right - most_left + 1, 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 998244353;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
int a, b, c, d;
ll dp[2][3005][3005];

ll modpow(ll a, ll n){
	ll ret = 1;
	while(n){
		if(n & 1) ret = ret * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ret;
}
ll solve(int ty, int n, int m){
	assert(n > a);
	if(dp[ty][n][m] != -1) return dp[ty][n][m];
	if(m == b){
		return dp[ty][n][m] = ty?0:modpow(m, n-a);
	}
	dp[ty][n][m] = 0;
	if(ty == 0){
		//single
		ll coef = m;
		if(n == a+1) coef = coef * modpow(a, m-b) % mod;
		else coef = coef * (solve(0, n-1, m) + solve(1, n-1, m)) % mod;
		return dp[ty][n][m] = coef;
	}
	else{
		//double
		return dp[ty][n][m] = (1LL*n*solve(1, n, m-1) + solve(0, n, m-1))%mod;
	}
}

int main(){
	memset(dp, -1, sizeof(dp));
	cin >> a >> b >> c >> d;
	if(a == c){
		cout << modpow(a, d-b) << endl;
	}
	else{
		ll ans = solve(0, c, d) + solve(1, c, d);
		cout << (ans%mod+mod)%mod << endl;
	}
}

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

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
using namespace std;
vector<int> v;
int main(){
	int n, q, time, cnt_time=0;
	string name;
	cin >> n >> q;
	queue<pair<string, int> > que;
	for (int i = 0; i < n; ++i) {
		cin >> name >> time;
		que.push(make_pair(name, time));
	}
	while (!que.empty()) {
		pair<string, int> top = que.front();
		que.pop();
		if (top.second <= q) {
			cnt_time += top.second;
			cout << top.first << " " << cnt_time << endl;
		}
		else {
			cnt_time += q;
			que.push(make_pair(top.first, top.second - q));
		}
	}
	return 0;
}


Measured memory_bytes: 6200
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int x, y;
        cin >> x >> y;
        if(x == 0)
            return 0;

        vector<int> memo(y, -1);
        for(int i=0; ; ++i){
            if(memo[x] != -1){
                if(x == 0)
                    cout << (i-1) << ' ' << 0 << endl;
                else
                    cout << memo[x] << ' ' << (i - memo[x]) << endl;
                break;
            }
            memo[x] = i;
            x *= 10;
            x %= y;
        }
    }
}

Measured memory_bytes: 5100
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <deque>
#include <cstring>
#include <functional>
#include <climits>
#include <list>
#include <ctime>
#include <complex>

#define F1(x,y,z) for(int x=(y);x<(z);x++)
#define F2(x,y,z) for(int x=(y);x<=(z);x++)
#define F3(x,y,z) for(int x=(y);x>(z);x--)
#define F4(x,y,z) for(int x=(y);x>=(z);x--)
#define mp make_pair
#define pb push_back
#define LL long long
#define co complex<double>
#define fi first
#define se second

#define MAX 100005
#define AMAX 53
#define MOD 1000000007

#define f(c,d) ((1<<(c))*(d))

using namespace std;

int i,y;
char x[1005];

int main(){
	scanf("%s",x);
	while(1){
		if(x[i]==0){
			printf("No\n");
			break;
		}
		if(y==0){
			if(x[i]=='C')y++;
		}else if(y==1&&x[i]=='F'){
			printf("Yes\n");
			break;
		}
		i++;
	}
	#ifdef LOCAL_PROJECT
	system("pause");
	#endif
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))   
#define min2(a,b) ((a)<(b) ? (a) : (b)) 
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define ll long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'

using namespace std;
typedef vector<ll>   vll;
typedef vector<int>   vi;
typedef set<ll>      sll;
typedef set<int>      si;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
clock_t clk=clock();       

ll i,j;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
unordered_map < ll, ll > m;
bool func(pll p1, pll p2)
{
	return p1.fi<p2.fi;
}
// #define cerr if(0)cerr
void solve()
{
	ll n; cin>>n;
	vector < pll > b;

	rep(i,1,n)
	{
		ll u,v; cin>>u>>v;
        m[i]=u;
        b.pb({v,i});
	}
	sort(all(b),func);

ll s=0;
	rep(i,0,n-1)
	{
		ll id=b[i].se;

		if(s+m[id]<=b[i].fi)
			s+=m[id];
		else
		{
			cout<<"No\n"; return;
		}
	}
	cout<<"Yes\n";
}

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

int main() {
	int n, t;
	cin >>n >> t;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<int> mx(n, 0);
	for (int i = n - 2; i >= 0; i--) {
		mx[i] = max(mx[i + 1], a[i + 1]);
	}
	int count = 0;
	int dis = 0;
	for (int i = 0; i < n; i++) {
		if (dis < mx[i] - a[i]) {
			dis = mx[i] - a[i];
			count = 1;
		}
		else if (dis == mx[i] - a[i]) count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
int i,n;
int number;
long long int sum=0;
int min=0;
int max=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&number);
if(i==0)
{
min = number;
max = number;
}
if(number<min) min = number;
if(number>max) max = number;
sum += number;
}
printf("%d %d %lld\n",min,max,sum);
return 0;
}

Measured memory_bytes: 600
function Main(input) {
	input = input.split("\n");
	var H = input[0].split(" ").map(a => parseInt(a));
	var W = H[1];
	var D = H[2];
	H = H[0];
	var A;
	var x = new Array(H*W+1).fill(0).map(a => new Array(2));
	for(var i = 0; i < H; i++){
		A = input[i+1].split(" ").map(a => parseInt(a));
		for(var j = 0; j < W; j++){
			x[A[j]][0] = i;
			x[A[j]][1] = j;
		}
	}
	var y = new Array(H*W+1).fill(0);
	for(i = D+1; i <= H*W; i++){
		y[i] = y [i-D] + Math.abs(x[i-D][0] - x[i][0]) + Math.abs(x[i-D][1] - x[i][1]);
	}
	
	var Q = parseInt(input[H+1]);
	var ans = new Array(Q).fill(0);
	for(i = 0; i < Q; i++){
		var L = input[H+2+i].split(" ").map(a => parseInt(a));
		var R = L[1];
		L = L[0];
		ans[i] = y[R] - y[L];
	}
	
	console.log(ans.join("\n"));
}

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

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

int main() {
    int n, m, X, Y;
    int x[110], y[110];

    cin >> n >> m >> X >> Y;
    int max_x = X, min_y = Y;

    for (int i = 0; i < n; i++) {
        cin >> x[i];
        max_x = max(max_x, x[i]);
    }

    for (int i = 0; i < m; i++) {
        cin >> y[i];
        min_y = min(min_y, y[i]);
    }

    if (min_y > max_x) cout << "No War" << endl;
    else cout << "War" << endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool has_key(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vector<pair<string, pll> > data(N);
        rep(i, 0, N) {
                string s;
                ll p;
                cin >> s >> p;
                data[i] = pair<string, pll>{s, pll{-p, i}};
        }
        sort(all(data));
        rep(i, 0, N) {
                ll ans = data[i].second.second;
                cout << ans+1 << endl;
        }
}

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

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
//#define rep(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; i++)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)

using namespace std;
using ll = long long;

/*template<typename T>inline void in(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=false;if(c=='-')neg=true;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
 template<typename T>inline void out(T n){if(n<0){outchar('-');n*=-1;}char snum[65];ll i=0;do {snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
ll pr[M+1],freq[M+1];
ll fact[M+1],inv[M+1];*/

ll md=MD;
ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
//ll chose(ll n,ll k){ll r=fact[n]%md;r=(r+md)%md;r=r*inv[k]%md;r=(r+md)%md;r=r*inv[n-k]%md;r=(r+md)%md;return r;}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
double Max2(double a,double b){if(a>b)return a; return b;}
int main() {
    ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    
    ll n, k,i,p,res,j,max=0,l;
    double indi,ans=0.0;
    cin>>n>>k;
    double f=1.0;
    vector<double> v(n),pre(n,0);
    for(i=0;i<n;i++)
    {
        cin>>p;
        v[i]=((p+1)*f/2);
    }
    //rep(i,0,n-1)cout<<v[i]<<" ";
    pre[0]=v[0];
    rep(i,1,n-1) pre[i]=pre[i-1]+v[i];
    //rep(i,0,n-1)cout<<pre[i]<<" ";
    ans=pre[k-1];
    rep(i,1,n-k+1)ans=Max2(ans,(pre[k+i-1]-pre[i-1]));
   
    cout<<fixed<<setprecision(17)<<ans;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    int l,r,d;
    cin >> l >> r >> d;
    int count=0;
    for(int i=l;i<=r;++i){
        if(i%d==0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3572
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int givenNumber = scanner.nextInt();
        scanner.nextLine();
        List<Integer> array = new ArrayList<>();
        for(int i=0; i<givenNumber; i++) {
            array.add(scanner.nextInt());
        }
        Set<Integer> newArray = new HashSet<Integer>(array);
        System.out.println(newArray.size());
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 2000100;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

long long fac[MAX], finv[MAX], inv[MAX];

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  	COMinit();
    ll K;
    cin>>K;
    string S;
    cin>>S;
    ll Sz=S.size();
    ll Ans=0;
    for(ll i=Sz; i<=Sz+K; i++){
        ll T=COM(i-1, Sz-1);
        T*=myPow(25, i-Sz, MOD);
        T%=MOD;
        T*=myPow(26, Sz+K-i, MOD);
        T%=MOD;
        Ans+=T;
        Ans%=MOD;
    }
    cout<<Ans<<endl;
}

Measured memory_bytes: 52136
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

using ll = long long;

ll mod = 1000000007;

int main(int argc, char const *argv[]) {
	string str;
	std::cin >> str;
	int q = 0;

	// ? の数を数える
	for (size_t i = 0; i < str.size(); i++) {
		if (str[i] == '?') {
			q++;
		}
	}


	//3^qを計算しておく
	std::vector<ll> calc3q(str.size()+2);
	calc3q[0] = 1;
	for (size_t i = 1; i < calc3q.size(); i++) {
		calc3q[i] = (calc3q[i-1] * 3) % mod;
	}


	// left : [number of a, number of ?]pairのvector
	// right: [number of c, number of ?]pairのvector
	std::vector<std::vector<ll>> left(str.size(),std::vector<ll> (2,0)),right(str.size(),std::vector<ll> (2,0));
	for (size_t i = 1; i < str.size(); i++) {
		if (str[i-1] == 'A') {
			left[i][0] = left[i-1][0] + 1;
			left[i][1] = left[i-1][1];
		}
		else if (str[i-1] == '?') {
			left[i][0] = left[i-1][0];
			left[i][1] = left[i-1][1] + 1;
		}
		else {
			left[i][0] = left[i-1][0];
			left[i][1] = left[i-1][1];
		}
	}
	for (int i = str.size()-2; i > -1; i--) {
		if (str[i+1] == 'C') {
			right[i][0] = right[i+1][0] + 1;
			right[i][1] = right[i+1][1];
		}
		else if (str[i+1] == '?') {
			right[i][0] = right[i+1][0];
			right[i][1] = right[i+1][1] + 1;
		}
		else {
			right[i][0] = right[i+1][0];
			right[i][1] = right[i+1][1];
		}
	}
/*
	for (size_t i = 0; i < right.size(); i++) {
		std::cout << right[i][0] << ' ';
	}
	std::cout << '\n';
	for (size_t i = 0; i < right.size(); i++) {
		std::cout << right[i][1] << ' ';
	}
	std::cout << '\n';
	for (size_t i = 0; i < left.size(); i++) {
		std::cout << left[i][0] << ' ';
	}
	std::cout << '\n';
	for (size_t i = 0; i < left.size(); i++) {
		std::cout << left[i][1] << ' ';
	}
	std::cout << '\n';
*/

	ll ans = 0;
	for (size_t i = 1; i < str.size()-1; i++) {
		if (str[i] != 'B' && str[i] != '?') {
			continue;
		}
		if (str[i] == 'B') {
			// A B Cの場合
			ans = (ans + (((left[i][0] * right[i][0])%mod) * calc3q[q]) % mod) % mod;
			// ? B Cの場合
			ans = (ans + (((left[i][1] * right[i][0])%mod) * calc3q[q-1]) % mod) % mod;
			// A B ?の場合
			ans = (ans + (((left[i][0] * right[i][1])%mod) * calc3q[q-1]) % mod) % mod;
			// ? B ?の場合
			ans = (ans + (((left[i][1] * right[i][1])%mod) * calc3q[q-2]) % mod) % mod;
		}
		if (str[i] == '?') {
			// A ? Cの場合
			ans = (ans + (((left[i][0] * right[i][0])%mod) * calc3q[q-1]) % mod) % mod;
			// ? ? Cの場合
			ans = (ans + (((left[i][1] * right[i][0])%mod) * calc3q[q-2]) % mod) % mod;
			// A ? ?の場合
			ans = (ans + (((left[i][0] * right[i][1])%mod) * calc3q[q-2]) % mod) % mod;
			// ? ? ?の場合
			ans = (ans + (((left[i][1] * right[i][1])%mod) * calc3q[q-3]) % mod) % mod;
		}
	}

	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 12032
import numpy as np
n, m, q = input().split()
n, m, q = int(n), int(m), int(q)
s = np.zeros((501, 501))

for _ in range(m):
    l, r = input().split()
    l, r = int(l), int(r)
    s[l, r] += 1
    
"""
     1 2 3
    --------
1 | 1 2 3
2 | 1 0 1
"""
    
for i in range(1, n+1):
    for j in range(1, n+1):
        s[i, j] += s[i, j-1]
        
"""
     1 2 3
    --------
1 | 1 3 6
2 | 1 1 2
"""
        
for j in range(1, n+1):
    for i in range(1, n+1):
        s[i, j] += s[i-1, j]
        
"""
     1 2 3
    --------
1 | 1 3 6
2 | 2 4 8
"""

for _ in range(q):
    l, r = input().split()
    l, r = int(l), int(r)
    print(int(s[r, r] - s[r, l-1] - s[l-1, r] + s[l-1, l-1]))

Measured memory_bytes: 21400
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int n;
    long long int a, bb;
    cin >> n >> a >> bb;
    long long int ab = a - bb;
    vector<long long int> vh(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> vh[i];
    }
    long long int b = 1, e = 1e14;
    while (b < e) {
        long long int m = b / 2 + e / 2 + (b % 2 == 1 && e % 2 == 1 ? 1 : 0);
        long long int c = 0;
        for (auto h : vh) {
            if (h / bb + (h % bb > 0 ? 1 : 0) <= m) continue;
            long long int hh = h - m * bb;
            if (hh > 0) {
                c += hh / ab + (hh % ab > 0 ? 1 : 0);
            }
        }
        if (c <= m) {
            e = m;
        } else {
            b = m + 1;
        }
    }
    cout << b << endl;
}


Measured memory_bytes: 4052
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [k, x]: number[] = tmp[0].split(" ").map(int => parseInt(int));
    return `${500 * k >= x ? "Yes" : "No"}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


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

int main(void) {
    long long a, b, n, i;
    cin >> a >> b >> n;
    int max = floor(a*n/b)-a*floor(n/b);
    int k = n/b;
    for (i = b*k-1; i >= 0; i-=b) {
        int f = floor(a*i/b)-a*floor(i/b);
        if (max < f) {
            max = f;
        }
    }
    cout << max << endl;
    return 0;
}

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

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>8 || b>8)
    {
        printf(":(\n");
    }
    else printf("Yay!\n");
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

int main() {
  //
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll cnt = 1;
  char cur = s[0];
  REP(i, 1, n) {
    if (s[i] != cur) {
      cnt++;
      cur = s[i];
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
typedef long double ld;
int main(){
  ll n; cin >> n;
  vector<ll> a(n);
  ll cnt = 0;
  rep(i,0,n){
    cin >> a[i];
    if(a[i]<0) cnt++;
  }
  ll mi = 1e14;
  rep(i,0,n-1){
    if(a[i]<0){
      a[i] *= -1;
      a[i+1] *= -1;
    }
    mi = min(mi, abs(a[i]));
  }
  mi = min(mi, abs(a[n-1]));
  ll sum = 0;
  rep(i,0,n){
    sum += abs(a[i]);
  }
  if(cnt%2==1) sum -= 2*mi;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
signed main(){
  int n,k;
  cin>>n>>k;
  vector<int> as(n);
  for(int i=0;i<n;i++) cin>>as[i],as[i]--;

  vector< vector<int> > G(n);
  for(int i=1;i<n;i++)
    G[as[i]].emplace_back(i);

  int ans=as[0]!=0;
  MFP([&](auto dfs,int v,int p)->int{
        int res=1;
        for(int u:G[v])
          chmax(res,dfs(u,v)+1);

        if(res==k&&p>0){
          ans++;
          res=0;
        }

        return res;
      })(0,-1);

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
#define INF 100000007

using namespace std;

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

    vector<int> dp(100010);

    for(int i=0;i<100010;i++)dp[i] = INF;
    dp[0]=0;

    for(int i=0;i<=N;i++){
    for(int pow6=1;pow6<=i;pow6*=6)
        dp[i] = min(dp[i],dp[i-pow6]+1);


    for(int pow9=1;pow9<=i;pow9*=9)
        dp[i] = min(dp[i],dp[i-pow9]+1);

    }

    cout<<dp[N];
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
 
int main(void)
{
    int N, t[100001], x[100001], y[100001];
    int i, dt, dist,dx,dy,dz;
    scanf("%d", &N);
    t[0] = x[0] = y[0] = 0;
    for (i=1; i<N+1; i++)
    {
        scanf("%d %d %d", &t[i], &x[i], &y[i]);
    }
 
    for(i = 1;i < N+1;i++){
        dt = t[i] - t[i-1];
        dx = x[i] - x[i-1];
        dy = y[i] - y[i-1];

        dist = abs(dx) + abs(dy);
        
        if(dist > dt){
            printf("No");
            return 0;
        }
        
        if(dist % 2 != dt % 2){
            printf("No");
            return 0;
        }
        
    }
 
        printf("Yes\n");

    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
main(){
  int m,f,r;
  while(1){
    scanf("%d%d%d",&m,&f,&r);
    if(m==-1&&f==-1&&r==-1) break;
    else if(m==-1||f==-1) printf("F\n");
    else if(m+f>=80) printf("A\n");
    else if(m+f>=65&&m+f<80) printf("B\n");
    else if(m+f>=50&&m+f<65) printf("C\n");
    else if(m+f>=30&&m+f<50){
      if(r>=50) printf("C\n");
      else printf("D\n");
    }
    else printf("F\n");
  }
  return 0;
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	return cout<<(n+999) / 1000 * 1000 - n<<"\n" , 0 ;
}		

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 505
#define MOD 1000000007

/*素因数分解*/
map<ll,ll> prime_factorization(ll m){

    map<ll,ll> tmp;
    for(ll i = 2;i * i <= m;i++){
        while (m % i == 0) {
            tmp[i]++;
            m /= i;
        }
    }
    if(m != 1){
        tmp[m] = 1;
    }
    return tmp;
}


/*mod Mでの割り算は割る数aのM-2をかける*/
/*ここではaのb乗をpで割った余りを返す*/
ll calc(ll a,ll b,ll p){

   if(b == 0){
       return 1;
   }else if(b % 2 == 0){
       ll tmp = (calc(a,b/2,p)) % p;
       return ((tmp%p)*(tmp%p))%p;
   }else{
       return ((a%p)*(calc(a,b-1,p)%p)) % p;
   }
}


/*nCrの計算*/
ll nCr(ll n,ll r){

    if(n < r){
        return 0;
    }else if(n == r || r == 0){
        return 1;
    }else{
        ll total = n,under1 = n-r,under2 = r;
        /*n!を求める*/
        for(ll i = n-1; i > 0;i--){
            total *= i;
            total %= MOD;
        }
        /*(n-r)!を求める*/
        for(ll i = n-r-1; i > 0;i--){
            under1 *= i;
            under1 %= MOD;
        }
        /*r!を求める*/
        for(ll i = r-1; i > 0;i--){
            under2 *= i;
            under2 %= MOD;
        }
        /*(n-r)! * r!を求める*/
        ll under = (under1*under2) % MOD;
        return ((total % MOD) * calc(under,MOD-2,MOD)) % MOD;
    }
}


int main(){

    ll n,m;
    cin >> n >> m;

    map<ll,ll> mp = prime_factorization(m);//素因数分解

    ll ans = 1;
    for(auto itr:mp){
        ans *= nCr(n+itr.second-1,itr.second);
        ans %= MOD;
    }
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
import zlib,base64
exec(zlib.decompress(base64.b85decode("c-l2k%Wi`(5WMphj;e}XSdx$`mw@vl76$_+EaG9nDM`P+j+!2JMw*?~Xtr6VK~z)Uo67Mtu7U?UEiMY6r40#IavmGHp)}vRhj7pqcyz?0y*t4DYJ2vK6h>bd3{=Y>wh;Z9;q4-oq(!v7Of6zC%i7F$0}9q8CFkde1qNHoy%F;z5KnqgCFi}JEMOqG5w&_2>QUrJzZK222rYONiym(VPG`JmDy2Rg&dG`Nr^k$?j-Od4%lMJKk7bp$SH31`-sRg)4vGua71!`1+)2>o3L4`Vm6)G)K3!XD#u|XBqslk@S9;U9w;HGD``E>Q1Zvgzmg?pKe*wqdW>^")))

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

using namespace std;

int main(){
	const int Max_M=2010;
	int n;
	cin >> n;
	int A[25];
	bool ans[Max_M];
	rep(i,n) cin >> A[i];
	rep(i,Max_M) ans[i]=false;
	int q;
	cin >> q;
	for(int bit=0; bit<(1<<n); bit++){
		int sum=0;
		rep(i,n){
			if(bit&(1<<i)) sum+=A[i];
		}
		ans[sum]=true;
	}
	rep(i,q){
		int m;
		cin >> m;
		if(ans[m]) cout << "yes" << endl;
		else cout << "no" << endl;
	}

	return 0;
}


Measured memory_bytes: 3096
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc176_b
{
  class Program
  {
    static void Main(string[] args)
    {
      if (CIn.Read().Sum(e => e - '0') % 9 == 0)
      {
        Console.WriteLine("Yes");
      }
      else
      {
        Console.WriteLine("No");
      }
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int sum=a+b+c;
  if(sum>=22){
    cout<<"bust"<<endl;
  }else{
    cout<<"win"<<endl;
  }
}

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

int main()

{
	int x,y;
	cin >> x >> y;
	
	if(y%2 == 0 && ((2*x)<=y && (4*x)>=y)){
		cout<<"Yes"<<endl;
	}
	
	else{
		cout<<"No"<<endl;
	}
	
	return 0;
}


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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MAX = 1e5 + 5;

int main()
{
	//IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		ll n;
		cin >> n;
		string s;
		while(n > 0)
		{
			n -= 1;
			s += (97 + (n % 26));
			n /= 26;
		}
		for(int i = s.length() - 1; i >= 0; --i)
		{
			cout << s[i];
		}
	}
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ri register int
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// input a string
	inline void read (char *s){
		for(c = gc(); c != '0' && c != '1'; c = gc()) ;
		for(; c == '0' || c == '1'; c = gc()) *++s = c;
		*++s = '\0';
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: read;
using io :: putc;
using io :: print;
const int N=2e3+5,inf=2e9;
int tot,head[N],nxt[N<<1],adj[N<<1],sz[N],cnt[N],f[N];
char s[N];
inline void addedge(ri x,ri y){
	nxt[++tot]=head[x];
	adj[head[x]=tot]=y;
}
inline void dfs(ri x,ri fa,ri dis){
	sz[x]=0;
	cnt[x]=0;
	ri y,i,res,son=0;
	for(i=head[x];i;i=nxt[i])
		if((y=adj[i])!=fa)
			dfs(y,x,dis+1),
			sz[y]+=cnt[y],
			sz[x]+=sz[y],
			cnt[x]+=cnt[y],
			son=sz[y]>sz[son]?y:son;
	if(son){
		res=sz[x]-sz[son];
		if(sz[son]<=res)
			f[x]=sz[x]>>1;
		else
			f[x]=res+min(f[son],sz[son]-res>>1);
	}
//	printf("f %d %d %d %d\n",x,sz[x],cnt[x],f[x]);
	cnt[x]+=s[x]&15;
}
int main(){
	ri n,i,ans,x,y;
	gi(n);
	read(s);
	for(i=1;i^n;++i) gi(x),gi(y),addedge(x,y),addedge(y,x);
	ans=inf;
	for(x=1;x<=n;++x){
	///	printf("rt = %d\n",x);
		dfs(x,0,0);
		if((~sz[x]&1)&&(f[x]<<1)==sz[x])
			ans=min(ans,f[x]);
	}
	ans=ans==inf?-1:ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] answer = new int[3];
        
        for(int i=0;i<3;i++){
            answer[i] = sc.nextInt();
            for(int j=i;j>0;j--){
                if(answer[j]<answer[j-1]){
                    int num = answer[j];
                    answer[j] = answer[j-1];
                    answer[j-1] = num;
                }else{
                    break;
                }
            }
        }
        System.out.println(answer[0]+" "+answer[1]+" "+answer[2]);
    }
}


Measured memory_bytes: 26304
#include<iostream>
#include<algorithm>
#include <string>
#include<cstdio>
#include<stack>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}

using namespace std;
typedef long long ll;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}

//------------------変数-----------------------//
ll n, cou[40][50], kekka[40];
string a[60];
//-------------------関数----------------------//
int main() {
	memset(kekka, -1, sizeof(kekka));
	cin >> n;
	REP(i, n) { cin >> a[i]; }
	REP(i, n) {
		REP(j, a[i].size()) {
			cou[a[i][j] - 'a'][i] ++;
		}
	}
	for (int i = 0; i < 40; i++)
	{
		kekka[i] = 789423;
	}
	REP(i, n) {
		REP(j, 40) {
			kekka[j] = min(kekka[j], cou[j][i]);
		}
	}
	REP(i, 40) {
			REP(j, kekka[i]) {
				cout << (char)((int)'a' + (int)i);
			}
	}
	cout << endl; return 0;
}

Measured memory_bytes: 256
import heapq
import bisect

n,k=map(int, input().split())
A=[int(i) for i in input().split()]
ng=0
ok = max(A)
while(ng+1!=ok):
    mid = (ok+ng)//2
    ans = 0
    for i in A:
        ans += 0--i//mid-1
    if(ans<=k):
        ok = mid
    else:
        ng = mid
print(ok)


Measured memory_bytes: 31124
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 99999999999999;
const ll MOD = 998244353;
ll a, b, c, d, e, f, p, t, x, y,z, q, m, n, r, h, k, ans = 0, w;

vl gragh[100001];
void input() {
	cin >> a >> b;
}

void solve() {
	cout << max(0LL, a - b * 2) << endl;
}

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

Measured memory_bytes: 2560
def solve
  a, b, c, d = gets.split.map!(&:to_i)
  flg = false
  cnt = 0
  loop do
    if a <= 0
      break
    elsif c <= 0
      flg = true
      break
    end
    if (cnt % 2).zero?
      c = c - b
    else
      a = a - d
    end
    cnt += 1
  end

  if flg == true
    print 'Yes'
  else
    print 'No'
  end
end
solve

Measured memory_bytes: 14276