akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

typedef long long ll ;
typedef double db;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;

int main()
{
	string s,t;
	cin>>s;
	cin>>t;
	int l= t.size();
	s += t[l-1];
	if(s==t)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;
int main()
{
  int N,Y;
  cin >> N >> Y;
  int man=-1;
  int gosen=-1;
  int sen=-1;
  for(int x=0; x<=N; x++){
    for(int y=0; y<=N; y++){
      if(N-x-y>=0 && (Y-10000*x-5000*y)/1000==N-x-y){
        man = x;
        gosen = y;
        sen = (Y-10000*x-5000*y)/1000;
      }
    }
  }
  cout << man << " " << gosen << " " << sen << endl;
}

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

int main(){
    string s;
    cin >> s;
    bool isE=false;
    for(int i = 1;i < s.size();i ++){
        if(s[i]==s[i-1]) {cout << i << " " << i+1 << endl;isE=1;break;}
        if(i-1&&s[i]==s[i-2]) {cout << i-1 << " " << i+1 << endl;isE=1;break;}
    }
    if(!isE) cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <climits>

const int Maxn = 2e5;

int a[Maxn], b[Maxn];

bool cmp(int x, int y) {
    return x > y;
}

int main () {
    int i, j;
    int n;

    std::cin >> n;
    for (i = 1; i <= n; ++ i) {
        std::cin >> a[i];
        b[i] = a[i];
    }    

    std::sort(b + 1, b + 1 + n, cmp);

    for (i = 1; i <= n; ++ i) {
        if (a[i] == b[1]) std::cout << b[2] << "\n";
        else std::cout << b[1] << "\n";
    }

}

Measured memory_bytes: 3200
from itertools import chain, combinations

def powerset(iterable):
    """
    powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)
    """
    xs = list(iterable)
    return chain.from_iterable(combinations(xs,n) for n in range(len(xs)+1))
# print(len(list(powerset([1,2,3,4,5]))))

N, M, X = list(map(int, input().split()))
arr = []
for _ in range(N):
    arr.append(list(map(int, input().split())))

subsets = list(powerset([i for i in range(N)]))
ans = float('inf')
for item in subsets:
    if not item:
        continue
    tmp = [0] * (M + 1)
    cost = 0
    for idx in item:
        cost += arr[idx][0]
        for i, v in enumerate(arr[idx]):
            tmp[i] += v
    flag = True
    for i in range(1, M+1):
        if X > tmp[i]:
            flag = False
    if flag:
        ans = min(ans, cost)

if ans == float('inf'):
    print(-1)
else:
    print(ans)
            
    
    

        



    

    




Measured memory_bytes: 9384
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;
const ll sz = 5e5 + 1;

ll bpow(ll x, ll p) {
	if (p == 0)
		return 1;
	if (p % 2)
		return (bpow(x, p - 1) * x) % mod;
	else {
		ll b = bpow(x, p / 2);
		return (b * b) % mod;
	}
}

ll inv(ll x) {
	return bpow(x, mod - 2);
}

ll fact[sz], inv_fact[sz];

void calc_fact() {
	fact[0] = 1;
	inv_fact[0] = inv(fact[0]);
	for (ll i = 1; i < sz; i++) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= mod;
		inv_fact[i] = inv(fact[i]);
	}
}

ll cnk(ll n, ll k) {
	return fact[n] * inv_fact[k] % mod * inv_fact[n - k] % mod;
}

void solve() {
	calc_fact();
	int n, m;
	cin >> n >> m;
	ll res1 = 1;
	for (int i = 0; i < n; i++) {
		res1 *= (m - i);
		res1 %= mod;
	}
	ll res2 = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2)
			res2 += cnk(n, i) * cnk(m - i, n - i) % mod * fact[n - i];
		else
			res2 -= cnk(n, i) * cnk(m - i, n - i) % mod * fact[n - i];
		res2 += mod;
		res2 %= mod;
	}
	res2 = (res1 - res2 + mod) % mod;
	cout << (res1 * res2) % mod;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 11336
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

int main(){
    for(;;){
        int n;
        cin >> n;
        if(!n)break;
        int g[n][n];
        memset(g, 0, sizeof(g));
        for (int i=0; i<n; i++) {
            int m;
            cin >> m;
            for (int j=0; j<m; j++) {
                int k;
                cin >> k;
                g[i][k-1]=1;
            }
        }
        int k;
        cin >> k;
        vector<int> de;
        rep(i,k){
            int l;
            cin >> l;
            de.push_back(l-1);
        }
        vector<int> ans;
        for (int i=0; i<n; i++) {
            int ch =0;
            for (int j=0; j<k; j++) {
                if(g[i][de[j]]==1)ch++;
            }
            if (ch==k) {
                ans.push_back(i+1);
            }
        }
        if (ans.size()==1) {
            cout <<ans[0] <<endl;
        }else{
            cout << -1 <<endl;
        }
    }
}

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

int main(){
   int N,W;
   cin >> N >> W;
   int v[N],w[N];
   for(int i=0;i<N;i++)
      cin >> v[i] >> w[i];
   int DP[N+1][W+1];
   for(int j=0;j<=W;j++)
      DP[0][j]=0;
   for(int i=1;i<=N;i++)
      for(int j=0;j<=W;j++)
         if(j<w[i-1])
            DP[i][j]=DP[i-1][j];
         else{
            if(DP[i-1][j]>DP[i-1][j-w[i-1]]+v[i-1])
               DP[i][j]=DP[i-1][j];
            else
               DP[i][j]=DP[i-1][j-w[i-1]]+v[i-1];
         }
   cout << DP[N][W] << endl;
   return 0;
}

Measured memory_bytes: 6996
import sys
input = sys.stdin.readline

n=int(input())
s=input().rsplit()[0]

def calc(k):
	D=M=DM=DMC=0
	for i in range(n):
		if k<=i:
			if s[i-k]=="D":
				D-=1
				DM-=M
			elif s[i-k]=="M":
				M-=1
		if s[i]=="D":
			D+=1
		elif s[i]=="M":
			M+=1
			DM+=D
		elif s[i]=="C":
			DMC+=DM
	return DMC

q=int(input())
*k,=map(int,input().split())
ans=[calc(x) for x in k]
print(*ans,sep="\n")

Measured memory_bytes: 59432
#include<bits/stdc++.h>
using namespace std;
int p[100001], e[100001];

int main(){
  int n,m,a,b,c;
  scanf("%d%d",&n,&m);

  for(int i=0;i<m;i++)scanf("%d",&p[i]);
  for(int i=1;i<m;i++){
    if(p[i]<p[i-1])e[p[i]]++, e[p[i-1]]--;
    else e[p[i]]--, e[p[i-1]]++;
  }

  long long ans = 0, num = 0;
  for(int i=1;i<n;i++){
    scanf("%d%d%d",&a,&b,&c);
    num += e[i];
    ans += min(num*a, num*b+c);
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 1952
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  int a[10000];
  int sum=0;
  for(int i=0;i<n;++i){
	cin>>a[i];sum+=a[i];
  }
  sort(a,a+n);
  cout<<(sum-a[n-1]>a[n-1]?"Yes":"No")<<endl;
  return 0;
  
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
int k,s,z;
cin>>k>>s;
int c=0;
for(int i=0;i<=k;i++){
for(int j=0;j<=k;j++){
	z=s-i-j; 
if(z>=0&&z<=k)
c+=1;
}
}
cout<<c;
return 0;
}

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

int main(void){
	int e;
	while(cin >> e,e){
		int cmin=e;
		for(int z=0;z*z*z<=e;z++){
			for(int y=0;y*y<=e-z*z*z;y++){
				int x=e-y*y-z*z*z;
				int m=x+y+z;
				cmin=min(cmin,m);
			}
		}
		cout << cmin << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N+1), B(N+1);
    for(int64_t i=0; i<=N; i++) {
        cin >> A[i];
    }

    partial_sum(A.rbegin(), A.rend(), B.rbegin());

    int64_t ans = 0;
    int64_t now = 1;
    for(int64_t i=0; i<=N; i++) {
        if(A[i] > now) {
            cout << -1 << endl;
            return 0;
        } else {
            ans += now;
            now = (now - A[i]) * 2;
            now = min(now, B[i+1]);
        }
    }

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


Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;

int main() {
				fast
                // #ifndef ONLINE_JUDGE
                // freopen("input.txt","r",stdin);
                // freopen("output.txt","w",stdout);
                // #endif
                ll k; cin>>k;
                queue<ll>q;
                for(ll i=1;i<=9;i++)
                {
                    q.pb(i);
                }
                for(ll i=1;i<=k;i++)
                {
                    if(i==k)
                    cout<<q.front();
                    ll x=q.front();
                    q.pop();
                    ll md=x%10;
                    if(md==0)
                    {
                        ll y=10*x;
                        ll z=10*x+1;
                        q.pb(y) ; q.pb(z);
                    }
                    else if(md==9)
                    {
                        ll y=10*x+8;
                        ll z=10*x+9;
                        q.pb(y);
                        q.pb(z);
                    }
                    else
                    {
                        ll a=10*x+(md-1);
                        ll b=10*x+md;
                        ll c=10*x+md+1;
                        q.pb(a); q.pb(b); q.pb(c);
                    }
                }

                return 0;
            }

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

ll gcd(ll a, ll b){
	if(b==0){
		return a;
	}else{
		return gcd(b, a%b);
	}
}

int main(void){
	string inp;
	cin>>inp;
	list<int> s;
	s.push_front('X');
	int memo = 'X';
	rep(i, inp.size()){
		if(memo != inp[i]){
			s.push_back(inp[i]);
			memo = inp[i];
		}
	}
	s.push_back('Y');
	int count[200];
	rep(i,200){
		count[i] = 0;
	}
	for(auto itr = s.begin(); itr != s.end(); itr++){
		count[*itr]++;
	}
	int a='X',b='X',c='X';
	if(count['A'-0] >= count['B'-0]){
		if(count['A'-0] >= count['C'-0]){
			a = 'A';
			if(count['B'-0] >= count['C'-0]){
				b = 'B';
				c = 'C';
			}else{
				b = 'C';
				c = 'B';
			}
		}else{
			a = 'C';
			b = 'A';
			c = 'B';
		}
	}else{
		if(count['B'-0] >= count['C'-0]){
			a = 'B';
			if(count['A'-0] >= count['C'-0]){
				b = 'A';
				c = 'C';
			}else{
				b = 'C';
				c = 'A';
			}
		}else{
			a = 'C';
			b = 'B';
			c = 'A';
		}
	}


	auto iter = s.begin();
	iter++;
	//cout<<count[a]<<count[b]<<count[c]<<endl;
	while(count[a] != count[b] && iter != s.end()){
		if(*iter != a){
			iter++;
			continue;
		}
		iter--;
		char before = *iter;
		iter++;iter++;
		char after = *iter;
		iter--;
		if(before != after){
			iter = s.erase(iter);
			count[a]--;
		}else{
			iter++;
		}

	}


	iter = s.begin();
	int eb = count[a] - count[c];
	int ec = count[a] - count[b];
	while(eb > 0 || ec > 0){
		char now = *iter;
		iter++;
		char next = *iter;
		iter--;
		if(eb > 0 && ((now == a && next == b) || (now == b && next == a))){
			iter--;
			char before = *iter;
			iter++;iter++;iter++;
			char after = *iter;
			iter--;iter--;
			if(before == after){
				iter++;
				continue;
			}
			count[a]--;
			count[b]--;
			iter = s.erase(iter);
			iter = s.erase(iter);
			eb--;
		}else if(ec > 0 && ((now == a && next == c) || (now == c && next == a))){
			iter--;
			char before = *iter;
			iter++;iter++;iter++;
			char after = *iter;
			iter--;iter--;
			if(before == after){
				iter++;
				continue;
			}
			count[a]--;
			count[c]--;
			iter = s.erase(iter);
			iter = s.erase(iter);
			ec--;
		}else{
			iter++;
		}
	}

	for(auto itr = s.begin(); itr != s.end(); itr++){
		if(*itr != 'X' && *itr != 'Y'){
			cout<<(char)(*itr);
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 33412
#include <cstdio>

#define max(a, b) ((a) > (b) ? (a) : (b))

int main()
{
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  printf("%d\n", a + b + c - max(a, max(b, c)));
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define int long long int
#define ld long double
#define ar array
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<int> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const int ths = 1LL << 40;
const int NN = 5e3 + 6;

const int maxN = 1007;

///atcoder 171
///

void solve()
{

    char x;
    cin>>x;
    if(x >= 'A' and x <= 'Z')
        cout<<'A';
    else
        cout<<'a';
    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		if (A+B>=C) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23124
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010
ll n, m;
vector<int> res, g[N];
bool used[N];

void dfs(int u){
	used[u] = true;
	res.push_back(u);
	for(int v: g[u]) if(!used[v]){
		dfs(v);
		return;
	}
}

int main(){
	cin>>n>>m;
	rep(i, m){
		int a, b;
		cin>>a>>b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0);
	reverse(all(res));
	res.pop_back();
	used[0] = false;
	dfs(0);
	cout<<res.size()<<endl;
	rep(i, res.size()) cout<<res[i]+1<<" "; cout<<endl;
	return 0;
}


Measured memory_bytes: 9720
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll A, B; cin >> A >> B;
    cout << A * B / __gcd(A,B) << endl;
}

Measured memory_bytes: 256
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, m = input_a
h = input_a
good = Array.new(n, 1)

m.times do |i|
  a, b = input_a
  if h[a - 1] > h[b - 1]
    good[b - 1] = 0
  else
    good[a - 1] = 0
  end
  if h[a - 1] == h[b - 1]
    good[a - 1] = 0
    good[b - 1] = 0
  end
end
puts good.count(1)


Measured memory_bytes: 24316
N, Y = gets.split.map(&:to_i)
test = -> do
  (0..N).each do |m|
    (0..N-m).each do |g|
      if m * 10000 + g * 5000 + 1000 * (N - m - g) == Y
        return [m, g, (N-m-g)]
      end
    end
  end
  [-1, -1, -1]
end
m, g, s = test.()
puts "#{m} #{g} #{s}"

Measured memory_bytes: 3836
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	count := 0

	for i := 1; i <= N; i++ {
		var a int
		fmt.Scan(&a)
		if a%2 == 1 && i%2 == 1 {
			count++
		}
	}
	fmt.Println(count)

}


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

using namespace std;

typedef long long ll;

int main(){
	int n,m;
	cin >> n >> m;
	vector<pair<int,int> > war;
	for(int i = 0; i < m; i++){
		int a,b;
		cin >> a >> b;
		war.push_back(make_pair(a,b));
	}
	sort(war.begin(),war.end());
	int ans = 0;int pre=n+1;
	for(int i = m-1; i+1; i--){
		if(war[i].second >= pre)continue;
		else{
			ans++;
			pre=war[i].first+1;
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
ws = [[0] * K for _ in range(K)]
bs = [[0] * K for _ in range(K)]
for _ in range(N):
  x, y, c = input().split()
  x = int(x)
  y = int(y)
  t = x // K + y // K
  if t % 2:
    if c == "W": c = "B"
    elif c == "B": c = "W"
  ws[y % K][x % K] += int(c == "W")
  bs[y % K][x % K] += int(c == "B")
#print(ws)
#print(bs)
csw = [[0] * (K + 1) for _ in range(K + 1)]
csb = [[0] * (K + 1) for _ in range(K + 1)]
for i in range(K):
  for j in range(K):
    csw[i + 1][j + 1] = csw[i + 1][j] + csw[i][j + 1] - csw[i][j] + ws[i][j]
    csb[i + 1][j + 1] = csb[i + 1][j] + csb[i][j + 1] - csb[i][j] + bs[i][j]
res = 0
for i in range(K + 1):
  for j in range(K + 1):
    u = csw[-1][-1] - csw[i][-1] - csw[-1][j] + csw[i][j] + csw[i][j]
    v = csb[i][-1] - csb[i][j] + csb[-1][j] - csb[i][j]
    res = max(res, u + v)
    u = csb[-1][-1] - csb[i][-1] - csb[-1][j] + csb[i][j] + csb[i][j]
    v = csw[i][-1] - csw[i][j] + csw[-1][j] - csw[i][j]
    res = max(res, u + v)
    #print(i, j, res)
print(res)

Measured memory_bytes: 77148
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn solve(mut abs: Vec<(u32, u32)>) -> bool {
    abs.sort_by_key(|ab| ab.1);

    let mut acc = 0;
    for (a, b) in abs {
        acc += a;
        if acc > b {
            return false;
        }
    }

    return true;
}

fn main() {
    let n = parse_line!(usize);
    let abs = (0..n)
        .map(|_| parse_line!(u32, u32))
        .collect::<Vec<(u32, u32)>>();
    println!("{}", if solve(abs) { "Yes" } else { "No" });
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![(2, 4), (1, 9), (1, 8), (4, 9), (3, 12)]), true);
    assert_eq!(solve(vec![(334, 1000), (334, 1000), (334, 1000)]), false);
    assert_eq!(
        solve(vec![
            (384, 8895),
            (1725, 9791),
            (170, 1024),
            (4, 11105),
            (2, 6),
            (578, 1815),
            (702, 3352),
            (143, 5141),
            (1420, 6980),
            (24, 1602),
            (849, 999),
            (76, 7586),
            (85, 5570),
            (444, 4991),
            (719, 11090),
            (470, 10708),
            (1137, 4547),
            (455, 9003),
            (110, 9901),
            (15, 8578),
            (368, 3692),
            (104, 1286),
            (3, 4),
            (366, 12143),
            (7, 6649),
            (610, 2374),
            (152, 7324),
            (4, 7042),
            (292, 11386),
            (334, 5720)
        ]),
        true
    );
}


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

vector<int> a;

bool solve(int i, int m) {
    if (m == 0) return true;
    if (i >= a.size()) return false;

    return solve(i+1, m) || solve(i+1, m-a.at(i));
}
int main() {
    int n; cin >> n;
    //vector<int> a(n);
    rep(i, n) {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    int q; cin >> q;
    vector<int> m(q);
    rep(i, q) cin >> m.at(i);

    for (auto i : m) {
        bool ans = solve(0, i);
        ans ? puts("yes") : puts("no");
    }
}



Measured memory_bytes: 3140
import java.util.Scanner
import scala.util.control.TailCalls._

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val h = Vector.fill(n)(sc.nextInt)

    def count(vector: Vector[Int], acc: Int): TailRec[Int] = {
      if (vector.isEmpty) done(acc)
      else if (vector.forall(_ > 0)) tailcall(count(vector.map(_ - 1), acc + 1))
      else if (vector.forall(_ == 0)) done(acc)
      else {
        val idx = vector.indexOf(0)
        if (idx == 0) tailcall(count(vector.tail, acc))
        else for {
          x <- tailcall(count(vector.take(idx), 0))
          y <- tailcall(count(vector.drop(idx + 1), acc))
        } yield x + y
      }
    }

    println(count(h, 0).result)
  }
}


Measured memory_bytes: 27820
x,k,d = map(int,input().split())

def f(m):
    ret = x
    ret -= d * m
    ret += d * (k - m)
    return abs(ret)

l = 0
r = k

for _ in range(1000):
    c1 = (l * 2 + r) // 3
    c2 = (l + 2 * r) // 3
    if f(c1) > f(c2):
        l = c1
    else:
        r = c2
res = 10 ** 1000
for i in range(l - 1000, r + 1000):
    if i < 0 or i > k:
        continue
    res = min(res, f(i))
print(res)

Measured memory_bytes: 67428
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
S = list(input())
lr = [list(map(int, input().split())) for _ in range(Q)]
cnt = [0]*N
is_a = False
for i in range(N-1):
  if S[i] + S[i+1] == 'AC':
    cnt[i+1] = 1
for i in range(1, N):
  cnt[i] += cnt[i-1]

for l, r in lr:
  l -= 1
  r -= 1
  print(cnt[r]-cnt[l])

Measured memory_bytes: 68232
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
const int INF=2*1e5+10;
int main(){
  int N;cin>>N;
  vi a;
  for (int i=0;i<N;++i){
    int a_;cin>>a_;a.push_back(a_-1);
  }

  int dp[N];
  int used[N];
  memset(dp, 0, sizeof(dp));
  memset(used, 0, sizeof(used));

  for (int i=0;i<N;++i){
    used[a[i]]=1;
    if (a[i]!=0||used[a[i]-1]==1){
      dp[a[i]]=dp[a[i]-1]+1;
    }else{
      dp[a[i]]=1;
    }
  }

  int ans=0;
  for (int i=0;i<N;++i){
    ans=max(ans, dp[i]);
  }
  cout << N-ans << endl;
  return 0;
}

Measured memory_bytes: 2676
import sys
input = sys.stdin.readline
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))
table = [0] * 3
for p in P:
  if p <= A:
    table[0] += 1
  elif A < p <= B:
    table[1] += 1
  else: 
    table[2] += 1
print(min(table))

Measured memory_bytes: 38384
#include<stdio.h>

int main()
{
    int x,y,a;

    for (;;){
        scanf("%d %d",&x,&y);

        if (x==0&&y==0) break;
        if(x>y){
            a=x;
            x=y;
            y=a;
        }
        printf("%d %d\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 600
def main():
	n,m = map(int,input().split())

	num = []
	ans = []
	for i in range(m):
		na,a = input().split()
		num.append(na)
		ans.append(str(a))
	
	ac = 0
	wa = 0
	ans_l = []
	for i in range(1,n+1):
		ans_l.append([i,1,0])
	ac_temp = []
	wa_temp = 0

	for i in range(m):
		if ans[i] == "WA":
			ans_l[int(num[i])-1][2] += 1
		elif ans[i] == "AC" and ans_l[int(num[i])-1][1] == 1:
			ac += 1
			ans_l[int(num[i])-1][1] = 0
			wa += ans_l[int(num[i])-1][2]
			ans_l[int(num[i])-1][2] = 0
	print(ac,wa)

if __name__ == '__main__':
	main()

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

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

int main(){
    int n, count = 0;
    int x;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> x;
        count += is_prime(x);
    }
    cout << count << endl;
}



Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> h(n);
    vector<int> cost(n);

    for(int i = 0;i < n;i++)    cin >> h[i];

    cost[0] = 0;
    cost[1] = abs(h[1] - h[0]);
    for(int i = 2;i < n;i++){
        if(abs(h[i] - h[i-1])+cost[i-1] < abs(h[i] - h[i-2])+cost[i-2]){
            cost[i] = cost[i-1] + abs(h[i] - h[i-1]);
        }else{
            cost[i] = cost[i-2] + abs(h[i] - h[i-2]);
        }
    }

    cout << cost[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
   ll n;
   cin>>n;
   ll a[n+1]={0};
   for(int i=1;i<n;i++){
       int aa;
       cin>>aa;
       a[aa]++;
   }
   for(int i=1;i<=n;i++)
       cout<<a[i]<<endl;
}
 

Measured memory_bytes: 5144
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int x;

    scanf("%d", &x);

    if(x < 1200){
        printf("ABC\n");
    }else{
        printf("ARC\n");
    }

    return 0;
}

Measured memory_bytes: 1616
import java.util.Scanner;

public class Main {

    public static int aa = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int zen = Integer.valueOf(s.substring(0, 2));
        int kou = Integer.valueOf(s.substring(2, 4));
        String res = "AMBIGUOUS";
        if (1 <= zen && zen <= 12 && 1 <= kou && kou <= 12) {
            System.out.println("AMBIGUOUS");
            return;
        }

        if (12 < zen && 12 < kou) {
            System.out.println("NA");
            return;
        }

        if (zen < 0 || kou < 0) {
            System.out.println("NA");
            return;
        }

        if (zen == 0 && kou == 0) {
            System.out.println("NA");
            return;
        }

        if (zen == 0 && 0 < kou && kou <= 12) {
            System.out.println("YYMM");
            return;
        } else if (zen == 0 && 12 < kou) {
            System.out.println("NA");
            return;
        }

        if (kou == 0 && 0 < zen && zen <= 12) {
            System.out.println("MMYY");
            return;
        }else if (kou == 0 && 12 < zen) {
            System.out.println("NA");
            return;
        }

        if (12 < zen) {
            System.out.println("YYMM");
        } else {
            System.out.println("MMYY");
        }
    }
}

Measured memory_bytes: 21716
import math

matrix = input().split(" ")
points = []
for i in range(int(matrix[0])):
  points.append(input().split(" "))
  
counter = 0
for j in range(len(points)):
  for k in range(j+1, len(points)):
    result = 0
    for col_idx in range(int(matrix[1])):
      result += (int(points[j][col_idx]) - int(points[k][col_idx])) ** 2
    result = math.sqrt(result)
    if result.is_integer():
      counter += 1
      
print(counter)

Measured memory_bytes: 3064
import numpy as np
n=int(input())
a=np.array(input().split(),dtype=np.int32)
b=np.array(input().split(),dtype=np.int32)
def f(t,a,b):
  power=1<<t
  mask=(power<<1)-1
  aa=a&mask
  bb=b&mask
  aa.sort()
  bb.sort()
  x1,x2,x3=(np.searchsorted(bb,v-aa).sum() for v in [power,power*2,power*3])
  zero_cnt=x1+x3-x2
  return (n-zero_cnt)%2
ans=0
for t in range(30):
  x=f(t,a,b)
  if x==1:
    ans+=1<<t
print(ans)

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

LL N,A,B,C,D;

int main(){
	scanf("%lld%lld%lld%lld%lld" , &N , &A , &B , &C , &D);
	LL E = A-B;
	LL r = D-C;
	repp(i,0,N){
		LL y = D * (N-1-2*i);
		if(y - r * (N-1-i) <= E && E <= y + r * i){
			printf("YES\n");
			//printf("%d %lld %lld %lld %lld %lld\n" , i , E , r , y , y - r * (N-1-i) , y + r * i);
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  int n;
  cin >> n;
  cout << (1000-n%1000)%1000 << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(min(a+b,b+c),a+c) << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int solve(int A, int B)
{
    return std::max(0, A - (2 * B));
}

int main() {
    fast_io();

    int A = fetch<int>();
    int B = fetch<int>();
    
    std::cout << solve(A, B) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int ans = 0;
  int curmin = 10000000;
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P.at(i);
  }
  for (int i = 0; i < N; i++) {
    curmin = min(curmin,P.at(i));
    if (curmin >= P.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int n, a;
    cin >> n >> a;
    n %= 500;
    if (n <= a)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }
    return -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;

int main(){

    string s;
    cin >> s;

    int size = s.size();

    vector<ll> a(100001);
    vector<ll> ab(100001);
    vector<ll> abc(100001);

    ll q = 1;

    for(int i = 1; i <= size; i++){
        if(s[i - 1] == 'A'){
            a[i] = (a[i - 1] + q) % MODN;
            ab[i] = ab[i - 1];
            abc[i] = abc[i - 1];

        }else if(s[i - 1] == 'B'){

            a[i] = a[i - 1];
            ab[i] = (ab[i - 1] + a[i - 1]) % MODN;
            abc[i] = abc[i - 1];

        }else if(s[i - 1] == 'C'){

            a[i] = a[i - 1];
            ab[i] = ab[i - 1];
            abc[i] = (abc[i - 1] + ab[i - 1]) % MODN;

        }else{
            
            a[i] = (3 * a[i - 1] + q) % MODN;
            ab[i] = (3 * ab[i - 1] + a[i - 1]) % MODN;
            abc[i] = (3 * abc[i - 1] + ab[i - 1]) % MODN;

            q = (q * 3) % MODN;
        }

        //cerr << a[i] << " " << ab[i] << " " << abc[i] << endl;
    }

    cout << abc[size] << endl;
    return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
using namespace std;

const int MAX_LEN = 111111;

struct State {
	State*suf, *go[27];

	int top;

	int val, cnt;
	State() :
		suf(0), val(0){
		top = 0;
		cnt = 0;
		val = 0;
		memset(go, 0, sizeof go);
	}
}*root, *last;

//THE CODE BELOW CAN'T BE MODIFIED - INNER SAM OPERATIONS
State statePool[MAX_LEN * 2], *cur;
void init() {
	cur = statePool;
	root = last = cur++;
}
void garbage(){
	while(cur != statePool){
		*cur = State();
		cur--;
	}
	*cur = State();
}

void extend(int w, int pos) {
	State*p = last, *np = cur++;
	np->val = p->val + 1;
	np->cnt = 1;
	while (p && !p->go[w])
		p->go[w] = np, p = p->suf;
	if (!p)
		np->suf = root;
	else {
		State*q = p->go[w];
		if (p->val + 1 == q->val) {
			np->suf = q;
		} else {
			State*nq = cur++;
			memcpy(nq->go, q->go, sizeof q->go);
			nq->val = p->val + 1;
			nq->suf = q->suf;
			q->suf = nq;
			np->suf = nq;
			while (p && p->go[w] == q)
				p->go[w] = nq, p = p->suf;
		}
	}
	last = np;
}
//END OF SAM OPERATIONS


char s[MAX_LEN];int n;
State *b[MAX_LEN*2],**curB;

int RR[111111];

int q;

void process(){
	for(State *p=statePool; p!=cur; p++)
		if(p->suf)p->suf->top++;
	curB = b;
	for(State *p=statePool; p!=cur; p++)
		if(p->top==0){
			*curB = p;
			curB++;
		}
	State**u=b;
	State*w;
	while(u!=curB){
		w = (*u)->suf; u++;
		if(w==0)continue;
		if(--(w->top)==0){
			*curB=w;
			curB++;
		}
	}

	for(u=b; u!=curB; u++){
		w=*u;
		if(w == root)continue;

		RR[w->suf?w->suf->val+1:1] ++;
		RR[w->val + 1] --;

		if(w->suf){
			w->suf->cnt += w->cnt;
		}
	}

	int bes = 0, now = 0;
	for(int i=1; i<=n; i++){
		now += RR[i];
		if(now > bes)bes = now;
	}
	printf("%d\n",bes);
}
int main() {
		init();
		scanf("%s",s);
		n=strlen(s);
		for(int i=0; i<n; i++)
			extend(s[i]-'a', i);
		process();
		garbage();

	return 0;
}

Measured memory_bytes: 54272
#include <stdio.h>
#include<algorithm>
using namespace std;
int memo[101][10001];
int w[100],v[100];
int  dp(int i,int j){
    if(i == 0)return 0;
    if(memo[i][j]>=0) return memo[i][j];
    if(j-w[i-1]<0)return memo[i][j]=dp(i-1,j);
    return memo[i][j]=max(dp(i-1,j),dp(i-1,j-w[i-1])+v[i-1]);
}
int main (void){
    int N,W; 
    scanf("%d%d",&N,&W);
    for(int i=0;i<100;i++){
        scanf("%d%d",&v[i],&w[i]);
    }
    for (int i = 0;i < 101;i++){
        for(int j=0;j<10001;j++){
            memo[i][j]=-1;
        }
    }
    printf("%d\n",dp(N,W));
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int X, Y, A, B, C;
priority_queue <Pli> que;

int main(){
  cin >> X >> Y >> A >> B >> C;
  for (int i = 0; i < A; i++){
    ll P; cin >> P;
    que.push({P, 0});
  }
  for (int i = 0; i < B; i++){
    ll Q; cin >> Q;
    que.push({Q, 1});
  }
  for (int i = 0; i < C; i++){
    ll R; cin >> R;
    que.push({R, 2});
  }

  ll ans = 0;
  int cnt0 = 0, cnt1 = 0, cnt2 = 0;
  while (cnt0 + cnt1 + cnt2 < X + Y){
    Pli Q = que.top(); que.pop();
    if (Q.se == 0 && cnt0 < X){
      ans += Q.fi; cnt0++;
    }
    if (Q.se == 1 && cnt1 < Y){
      ans += Q.fi; cnt1++;
    }
    if (Q.se == 2){
      ans += Q.fi; cnt2++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11624
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int m = stdIn.nextInt();
        int q = stdIn.nextInt();
        LinkedList list = new LinkedList(n);
        for(int i = 0; i < m; i++) {
            int a = stdIn.nextInt();
            if(a%2 == 0) {
                for(int j = 0; j < a; j++) {
                     
                    list.now = list.now.next;
                }
            }
            else {
                for(int j = 0; j < a; j++) {
                     
                    list.now = list.now.prev;
                }
            }
             
            list.remove();
             
        }
        for(int i = 0; i < q; i++) {
            int qx = stdIn.nextInt();
            if(list.isntalive[qx]) {
                System.out.println("0");
            }
            else {
                System.out.println("1");
            }
        }
    }
     
     
}
class LinkedList {
    boolean[] isntalive;
    Data now;
     
    LinkedList(int n) {
        isntalive = new boolean[n];
        now = new Data();
        Data tmp = now;
        now.id = 0;
        now.next = new Data();
        now.next.id = 1;
        now.next.next = now;
        now.next.prev = now;
        now.prev = now.next;
        now = now.next;
        for(int i = 2; i < n; i++) {
            add();
        }
        now = tmp;
    }
     
    void add() {
        Data tmp = now.next;
        now.next = new Data();
         
        now.next.id = now.id+1;
        now.next.next = tmp;
        now.next.next.prev = now.next;
        now.next.prev = now;
         
        now = now.next;
    }
    void remove() {
        isntalive[now.id] = true;
        now.prev.next = now.next;
        now.next.prev = now.prev;
        now = now.next;
    }
}
 
class Data {
    Data prev;
    Data next;
    int id;
     
}

Measured memory_bytes: 98992
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define li long
#define pb push_back
#define mem(arr,x) memset(arr,x,sizeof(arr))

int n,mat[22][22];
int dp[1<<22];

int totalWays(int manCount,int mask)
{
    if(manCount==n)  return 1;
    if(dp[mask]!=-1)  return dp[mask];
    ll i,ans=0;
    for(i=1;i<=n;i++)
    {
        int flag = mask & (1<<i);
        if(mat[manCount][i-1]==1 && flag==0)
        {
            int newMask = mask|(1<<i);
            ans+=totalWays(manCount+1,newMask)%MOD;
        }
    }
    dp[mask]=ans%MOD;
    return ans%MOD;
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    int i,j;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            cin>>mat[i][j];
        }
    }
    mem(dp,-1);
    cout<<totalWays(0,1);
    return 0;
}

Measured memory_bytes: 19976
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void) {
	int N;
	int a = 1;
	scanf("%d", &N);
	for (int i = 0; i < 3; i++) {
		a *= N;
	}
	printf("%d", a);

	return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int a[100]={0};
int main()
{
	int n,i,j,p=0;
	int min=10000000;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	for(i=a[0];i<=a[n-1];i++){
		for(j=0;j<n;j++){
			p+=(a[j]-i)*(a[j]-i);
		}
		if(p<min)
			min=p;
		p=0;
	} 
	printf("%d",min);
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll n,k, ans = 0LL;
    cin >> n >> k;
    reppp(b, k+1, n+1){
        ans += n/b*(b-k) + max(((n-n/b*b)+1-k),0LL);
        // cerr << n/b*(b-k) << " " << ((n-n/b*b)+1-k) << endl;
    }

    cout << min(n*n, ans) << endl;
}


Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)

def bubble_sort(a, n)
  count = 0

  loop do
    flag = false

    (n - 1).downto(1) do |i|
      if a[i] < a[i - 1]
        a[i], a[i - 1] = a[i - 1], a[i]
        count += 1
        flag = true
      end
    end

    break unless flag
  end

  puts a.join(' ')
  puts count
end

bubble_sort(A, N)

Measured memory_bytes: 8740
N = int(raw_input())

line = ['a' for i in range(N)]

lis = [ 0 for i in range(5)]

for i in range(N):
    lit = raw_input()
    if lit[0] == 'M':
        lis[0] += 1
    elif lit[0] == 'A':
        lis[1] += 1
    elif lit[0] == 'R':
        lis[2] += 1
    elif lit[0] == 'C':
        lis[3] += 1
    elif lit[0] == 'H':
        lis[4] += 1

tot = (lis[0] * lis[1] * (lis[2] + lis[3] + lis[4]) + lis[0] * lis[2] * (lis[3] + lis[4]) + lis[0] * lis[3] * lis[4] + 
       lis[1] * lis[2] * (lis[3] + lis[4]) + lis[1] * lis[3] * lis[4] + lis[2] * lis[3] * lis[4])

print tot

Measured memory_bytes: 6668
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

int main(){
    int a[5]={};
    rep(i,5)cin>>a[i];
    int k;
    cin>>k;
    for(int i=0;i<5;++i){
        for(int j=i+1;j<5;++j){
            if(a[j]-a[i]>k){
                cout<<":("<<endl;
                return 0;
            }
        }
    }
    cout<<"Yay!"<<endl;
}



Measured memory_bytes: 3588
n = int(input())
iro = [-1 for i in range(2*(10**5)+1)]
dp = [1 for i in range(n+1)]
mod = 10**9 + 7
for i in range(1,n+1):
    dp[i] = dp[i-1]
    now = int(input())
    if iro[now] != -1 and iro[now] != i-1:
        dp[i] += dp[iro[now]]
    iro[now] = i
    dp[i] %= mod
print(dp[n])

Measured memory_bytes: 22324
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() (int, int, int, int) {
	q, h, s, d := scanInt(sc), scanInt(sc), scanInt(sc), scanInt(sc)
	return q, h, s, d
}

type pair struct{ f, s int }

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Less(i, j int) bool {
	return (8/p[i].f)*p[i].s < (8/p[j].f)*p[j].s
}

func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func resolve(q, h, s, d int) int {
	n := scanInt(sc) * 4
	cands := []pair{{1, q}, {2, h}, {4, s}, {8, d}}
	sort.Sort(pairs(cands))
	costs := 0
	for _, p := range cands {
		div := n / p.f
		costs += div * p.s
		n %= p.f
	}
	return costs
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c;cin>>a>>b>>c;
  cout<<min(c,b/a)<<endl;
  return 0;
}



Measured memory_bytes: 256
#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()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	int div;
	int ans;
	div = 2;
	int maxdiv;
	maxdiv = 0;
	ans = 0;
	while (n > 0)
	{
		while (n % div == 0)
			div *= 2;
		if (div > maxdiv)
		{
			maxdiv = div;
			ans = n;
		}
		n--;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256