akhauriyash/Code-Regression huggingface dataset:
module mod_modulo_util
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer(8), allocatable :: f(:), invf(:)
contains
  subroutine init(n)
    integer, intent(in) :: n
    integer :: i
    if (allocated(f)) deallocate(f)
    if (allocated(invf)) deallocate(invf)
    allocate(f(0:n),invf(0:n))
    f = 0_8
    invf = 0_8
    f(0) = 1_8
    do i = 1, n
      f(i) = mod(f(i-1)*int(i,8),md)
    end do
    invf(n) = inv(f(n))
    do i = n, 1, -1
      invf(i-1) = mod(invf(i)*int(i,8),md)
    end do
  end
  integer(8) function perm(n,k)
    integer, intent(in) :: n, k
    perm = 0_8
    if (k > n .or. n < 0 .or. k < 0) return
    perm = mod(f(n)*invf(n-k),md)
  end
  integer(8) function comb(n,k)
    integer, intent(in) :: n, k
    comb = mod(perm(n,k)*invf(k),md)
  end
  integer(8) function homo(n,k)
    integer, intent(in) :: n, k
    homo = 1_8
    if (n == 0 .and. k == 0) return
    homo = comb(n+k-1,k)
  end
  function inv(n) result(y)
    integer(8), intent(in) :: n
    integer(8) :: a, b, x, y, t, q
    a = mod(n,md)
    b = md
    x = 0_8
    y = 1_8
    do while (b /= 0_8)
      q = a/b
      t = b
      b = mod(a,b)
      a = t
      t = y
      y = x
      x = t-q*x
    end do
    y = mod(mod(y,md)+md,md)
  end
  function pow(a,b) result(r)
    integer(8), intent(in) :: a
    integer, intent(in) :: b
    integer :: i
    integer(8) :: r, p
    r = 1_8
    p = a
    do i = 0, 32
      if (btest(b,i)) r = mod(r*p,md)
      p = mod(p*p,md)
    end do
  end
  integer(8) function fact(n)
    integer, intent(in) :: n
    fact = 0_8
    if (n < 0) return
    fact = f(n)
  end
  integer(8) function comb3(a,b,c,d)
    integer, intent(in) :: a, b, c, d
    comb3 = 0_8
    if (a < 0 .or. b < 0 .or. c < 0 .or. d < 0 .or. a < b+c+d) return
    comb3 = mod(mod(invf(b)*invf(c),md)*mod(invf(d)*invf(a-b-c-d),md),md)
    comb3 = mod(comb3*f(a),md)
  end
end module mod_modulo_util
program one_two_three_pairs
  use mod_modulo_util
  implicit none
  integer(8) :: ans = 0_8
  integer :: n, a, b, c, p, q, r
  read(*,*) n, a, b, c
  if (mod(b,2) == 1) then
    write(*,'(i0)') 0
    stop
  end if
  call init(n)
  do p = 0, min(a,c)
    do q = mod(c-p,3), c-p, 3
      r = (c-p-q)/3
      ans = mod(ans+mod(comb3(r+a+b/2,r,b/2,a-p)*homo(b/2,q),md),md)
    end do
  end do
  write(*,'(i0)') ans
end program one_two_three_pairs

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
D={}
for i in A:
    if i in D:
        D[i]+=1
    else:
        D[i]=1
Total=0
for i in D:
    Total+=D[i]*(D[i]-1)//2

for i in A:
    print(Total-(D[i]-1))

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


main(){
	int t;
	double max=0;
	cin >> t;
	int n, m, v;
	double r, M=0, rr;
	while(0<=t--){
		M=0;rr=0;
		cin >> n >> m;
		while(m--){
			cin >> v >> r;
			M += v*r;
			rr += r;
		}
		M /= rr;
		if(0<=t && max < M) max = M;
	}
	
	cout << ((max - M > 0.0000001) ? "YES" : "NO") << endl;
}

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


void solve(long long N, std::vector<long long> L){
    sort(L.begin(), L.end());
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            for (int k = j+1; k < N; k++) {
                if (L[i] == L[j] || L[j] == L[k]) {
                    continue;
                }
                if (L[i] + L[j] > L[k]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

long long x[100001], V[100001], VM[100001], VM2[100001];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N;
	long long C, ans;
	cin>>N>>C;
	for(int i=1;i<=N;i++) {
		cin>>x[i]>>V[i];
		V[i]+=V[i-1];
		VM[i]=max(VM[i-1],V[i]-x[i]);
		VM2[i]=max(VM2[i-1],V[i]-2*x[i]);
	}
	ans=VM[N];
	for(int i=N;i>0;i--) {
		ans=max(ans,V[N]-V[i-1]+max(VM[i-1]-2*(C-x[i]),VM2[i-1]-(C-x[i])));
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

struct Info{
	int id,sum;
};

int main(){

   int n,k,table[100],left,right,count,m;

   while(true){
	   scanf("%d",&n);
	   if(n == 0)break;

	   for(int i=0; i < n; i++)scanf("%d",&table[i]);

	   scanf("%d",&k);

	   count = 0;
	   left = 0,right = n-1;
	   m = (left+right)/2;
	   while(left <= right){
		   count++;
		   if(table[m] == k)break;
		   else{
			   if(table[m] < k){
				   left = m+1;
				   m = (left+right)/2;
			   }else{
				   right = m-1;
				   m = (left+right)/2;
			   }
		   }
	   }

	   printf("%d\n",count);

   }

    return 0;
}

Measured memory_bytes: 2612
num753=[]
def checkall(n):
    flag = [0,0,0]
    while n > 0:
        if n % 10 == 3:
            flag[0] = 1
        elif n % 10 == 5:
            flag[1] = 1
        elif n % 10 == 7:
            flag[2] = 1
        else:
            pass
        n = n // 10
    return flag == [1,1,1]

def makelist(n,list1):
    if n > 10**9:
        return
    n3 = 10*n+3
    list1.append(n3)
    makelist(n3,list1)
    n5 = 10*n+5
    list1.append(n5)
    makelist(n5,list1)
    n7 = 10*n+7
    list1.append(n7)
    makelist(n7,list1)

makelist(0,num753)

N = int(input())
ans = 0
for x in num753:
    if x <= N and checkall(x):
        ans+=1
print(ans)

Measured memory_bytes: 7064
X = input()

stack_s = []
out = []

for x in X:
    if x == "S":
        stack_s.append("S")
    else:
        if len(stack_s) > 0:
            stack_s.pop()
        else:
            out.append("T")

while len(stack_s) > 0:
    out.append(stack_s.pop())

print(len(out))



Measured memory_bytes: 10856
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int n,k;
    cin>>n>>k;
    int ans=0;
    rep(i,k,n+1){
        ll f=1ll*i*(i-1)/2;
        ll s=1ll*n*(n+1)/2-1ll*(n-i)*(n-i+1)/2;
        ans=(ans+s-f+1)%mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3688
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn readv<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn readvv<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| readv()).collect()
}

fn main() {
    let (n, m) = {
        let tv = readv();
        (tv[0], tv[1])
    };
    // println!("n: {}, m: {}", n, m);

    let mut ss = vec![];
    for _ in 0..m {
        let s = readv::<usize>();
        let s = s.into_iter().skip(1).map(|i| i - 1).collect::<Vec<usize>>();
        ss.push(s);
    }

    // println!("ss: ");
    // for s in ss {
    //     println!("{:?}", s);
    // }
    // println!("----");

    let pp = readv::<usize>();

    // println!("{:?}", pp);

    let pf = |ls, i| {
        let mut count = 0;
        for sv in ls {
            // println!("        sv: {}, i: {}", sv, i);
            if i & (0x1 << sv) > 0 {
                // println!("          OKOK");
                count += 1;
            }
        }
        count % 2
    };
    // zentansaku
    let mut count = 0;
    for i in 0..(1 << n) {
        let ok = ss.iter().enumerate().all(|(l, s)| {
            // println!("i: {} , l: {}, s: {:?}", i, l, s);
            let pv = pf(s, i);
            let p = pp[l];
            // println!("  (pv: {}, p: {})", pv, p);
            pv == p
        });
        if ok {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

void exchange(int *a, int *b)
{
    int swap;

    swap = *a;
    *a = *b;
    *b = swap;

    return;
}

int main(void)
{
    int X, Y, Z;

    cin >> X >> Y >> Z;

    exchange(&X, &Y);
    exchange(&X, &Z);

    cout << X << ' ' << Y << ' ' << Z;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b;
    cin >> a >> b;
    reps(i, 1, 4) {
        if ((a * b * i) % 2 == 1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	double r,t;
	cin>>n>>r>>t;
	using P=complex<double>;
	vector<P> p(n);
	rep(i,n){
		int a,b; cin>>a>>b;
		p[i]=P(a,b);
	}
	int mx=10000;
	vector<vvd> dp(mx+1,vvd(n,vd(n,LINF)));
	vector<vvd> a(n,vvd(n,vd(n)));
	rep(i,n)rep(j,n)rep(k,n)if(j!=k){
		a[i][j][k]=(i==j?0:abs(arg((p[j]-p[i])/(p[k]-p[j])))*180/PI);
	}
	dp[0][0][0]=0;

	ll ans=0;
	rep(i,mx)rep(j,n)rep(k,n)if(dp[i][j][k]!=LINF)rep(l,n)if(j!=l and k!=l){
		if(a[j][k][l]<=t+EPS){
			double dst=dp[i][j][k]+abs(p[k]-p[l]);
			if(dst<=r+EPS and chmin(dp[i+1][k][l],dst)){
				ans=i+1;
			}
		}
	}
	puta(ans);
	
	return 0;
}


Measured memory_bytes: 42548
#include <iostream>

using namespace std;

int main()
{
    string a;
    cin>>a;
    int a0,a1,a2;
    a0=a[0];
    a1=a[1];
    a2=a[2];
    if(((a2*100)+(a1*10)+a0) == ((a0*100)+(a1*10)+a2)){
       cout<<"Yes";
    }
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,mmx,avx")
#include "bits/stdc++.h"
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
const int MOD=1000000007;
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const int INF=1<<30;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;
#ifdef ONLINE_JUDGE
#define assert(...) /* nothing */
#endif
#define DEBUG_CAT
#ifdef DEBUG_CAT
#define dbg(...)   printf( __VA_ARGS__ )
#else 
#define dbg(...)   /****nothing****/
#endif
// mt19937 rng; rng.seed(std::chrono::high_resolution_clock::now().time_since_epoch().count());
// template<typename T> int bins(vector<T> &v, T key) {int imin=0,imax=v.size();while(imin<imax) {int imid=(imin+imax)>>1;if (v[imid]<key) imin=imid+1;else imax=imid;}return imin;}


void solve(long long N, long long A, long long B){
  ll d=abs(B-A);
  ll ans=LLONG_MAX;
  if (d%2==0) ans=d/2;
  else {
    for (int k=0;k<2;k++) {
      ll boundary=(k==0)?1:N;
      ll da=abs(A-boundary);
      ll db=abs(B-boundary);
      ll cand = min(da,db) + 1 + d/2;
      chkmin(ans,cand);
    }
  }
  printf("%lld\n",ans);
}

int main(){
    long long B;
    long long N;
    long long A;
    scanf("%lld",&N);
    scanf("%lld",&A);
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}

const int MAX = 100000;
class shuturyoku_unko {
public:
	char C[MAX * 5];
	constexpr shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 5) {
				C[i * 5 + 4 - j] = '0' + X % 10;
				X /= 10;
			}
		}
	}
};
constexpr shuturyoku_unko f;

const int dm = 1 << 17;
char *dn = cn, * di = dn, * owad = dn + dm - 20;
void putint(ll A) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	int dig = 1;
	if (A >= 100000) {
		if (A >= 1000000000) dig = 5;
		else if (A >= 100000000) dig = 4;
		else if (A >= 10000000) dig = 3;
		else if (A >= 1000000) dig = 2;
		memcpy(di + dig, f.C + A % 100000 * 5, 5);
		A /= 100000;
		memcpy(di, f.C + A * 5 + 5 - dig, dig);
		di += 5 + dig;
	}
	else {
		if (A >= 10000) dig = 5;
		else if (A >= 1000) dig = 4;
		else if (A >= 100) dig = 3;
		else if (A >= 10) dig = 2;
		memcpy(di, f.C + A * 5 + 5 - dig, dig);
		di += dig;
	}
	*di++ = ' ';
}

int A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();

	int kei = 0;
	rep(i, N) {
		A[i] = getint();
		kei ^= A[i];
	}
	rep(i, N) putint(kei ^ A[i]);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4964
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static long[] ReadLongArray()
    {
	return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] x = new int[n];
	int[] y = new int[n];
	long[] h = new long[n];

	int xt=0, yt=0; long ht=0;
	
	for (int i = 0; i < n; i++)
	{
	    var tmp = ReadLongArray();	    
	    x[i] = (int) tmp[0]; y[i] = (int) tmp[1]; h[i] = tmp[2];

	    if (h[i] > 0)
	    {
		xt = x[i]; yt = y[i]; ht = h[i];
	    }
	}

	for (int cx = 0; cx <= 100; cx++)
	{
	    for (int cy = 0; cy <= 100; cy++)
	    {
		long v = ht + Math.Abs(cx - xt) + Math.Abs(cy - yt);
		bool consistent = true;
		for (int k = 0; k < n; k ++)
		{
		    long vv = v - Math.Abs(cx - x[k]) - Math.Abs(cy - y[k]);
		    vv = Math.Max(vv, 0);
		    if (vv != h[k])
		    {
			consistent = false;
			break;
		    }
		}
		if (consistent)
		{
		    WriteLine($"{cx} {cy} {v}");
		    return;
		}
	    }
	}
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
    
    int sn = 0;
    int a;
    
    cin >> a;
    
    int b = a;
    
    for(;;)
    {
        if(a != 0){
            sn += a % 10;
            a /= 10;
        }
        else break;
    }
    std::cout << ((b % sn == 0) ? "Yes" : "No") << endl ;
    
    return 0;
    
}


Measured memory_bytes: 256
#include<stdio.h>

int n,A[50];

int solve(int x,int y){
  int r;
  if (y == 0)return 1;
  if (x >= n)return 0;
  r = solve(x+1,y)||solve(x+1,y-A[x]);
  return r;
}

int main(){
  int q,m,i;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2108
import java.util.Scanner;

/**
 *
 * @author must
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int[] A = new int[M];
        
        for (int i=0;i<M;i++){
            A[i] = sc.nextInt();
        }
        
        //0 1 2 3 4 5 6
        
        int cost0X = 0;
        int costXN = 0;
        for(int i=0;i<M;i++){
            if(A[i] < X){
                cost0X++;
            }else if(A[i] > X){
                costXN++;
            }
        }
        int ans;
        if (cost0X > costXN){
            ans = costXN;
        }else{
            ans = cost0X;
        }
        System.out.println(ans);
        
    }
    
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=500+5;
const int N=2e5+5;
const ll oo=1e18+5;
const ll mod=998244353;

ll fac[N],inv[N];
int n,m,k;

void add_self(ll& a,ll b){
	a+=b;
	a%=mod;
}

ll mul(ll a,ll b){
	return a*b%mod;
}

ll poww(ll a,ll b){
	ll r=1;
	while(b){
		if(b&1) r=mul(r,a);
		a=mul(a,a);
		b>>=1;
	}
	return r;
}

void init(){
	fac[0]=1;
	inv[0]=poww(fac[0],mod-2);
	for(int i=1;i<N;++i){
		fac[i]=mul(fac[i-1],1ll*i);
		inv[i]=poww(fac[i],mod-2);
	}
}

ll bino(ll n,ll k){
	if(k<0||k>n) return 0;
	return mul(fac[n],mul(inv[n-k],inv[k]));
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	init();
	cin>>n>>m>>k;
	vector<ll> choose_dif(n+1);
	choose_dif[1]=m;
	for(int i=2;i<=n;++i){
		choose_dif[i]=mul(choose_dif[i-1],1ll*(m-1));
	}
	ll ans=0;
	for(int i=0;i<=k;++i){
		int rem=n-i;
		add_self(ans,mul(choose_dif[rem],bino(n-1,rem-1)));
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 7932
gets;a,b=$<.map{|s|s.split.map &:to_i};
t=eval((b*?+)+?-+(a*?-));
A=[a,b].transpose.reduce(0){|s,a|s+=a[0]>a[1] ?a[0]-a[1]:0};
B=[a,b].transpose.reduce(0){|s,a|s+=a[0]>a[1] ?0:(a[1]-a[0]+1)/2};
puts [A,B].max>t ?:No: :Yes

Measured memory_bytes: 25852
import numpy as np
import sys
INF = float('inf')
sys.setrecursionlimit(10**5)
max = 10**5+5

def dk(start,node,edge):
  ans = [INF] * node
  ans[0] = 0
  q = [start]
  
  while(len(q) != 0):
    i = q.pop()
    for j, cost in edge[i]:
      if(ans[j] != INF):
        continue
      ans[j] = (ans[i] + cost)%2
      q.append(j)
  return ans

#入力
N = int(input())
#エッジ
E = [[] for _ in [0]*(max)]

for i in range(N-1):
  a,b,w = (int(x) for x in input().split())
  E[a-1].append((b-1, w))
  E[b-1].append((a-1, w))


ans = dk(0, N, E)

#出力
print(*ans, sep = "\n")
    

Measured memory_bytes: 49296
if __name__ == '__main__':
    # We have a string S of length N consisting of uppercase English letters.
    n = input()
    s = input()
    num = 0
    for i in range(len(s)):
        if 'ABC' in s:
            num += 1
            s = s.replace('ABC', '', 1)
    print(num)

Measured memory_bytes: 2940
#include <stdio.h>

#define MAX 2000000
#define UNCHECKED 0
#define PRIME 1
#define COMPO 2


bool isPrime(int n);

int main(void){
    int n;
    int primes;
    
    while (scanf("%d", &n)!=EOF){
        primes = 0;
        for (int i=2; i<=n; i++){
            if (isPrime(i)) primes++;
        }
        printf("%d\n", primes);
    }
}

bool isPrime(int n){
    static int table[MAX]={0};
    static int minPrime=2;
    
    if (n<2) return 0;
    
    do{
        if (table[n] != UNCHECKED){
            return table[n] == PRIME ? 1 : 0;
        }
        table[minPrime] = PRIME;
        for (int i=2; i*minPrime<=MAX; i++){
            table[i*minPrime] = COMPO;
        }
        while (minPrime<=MAX && table[minPrime]!=UNCHECKED) minPrime++;
    }while(minPrime<=MAX);
}

Measured memory_bytes: 8836
program main
  implicit none
  integer :: n, i, m
  character(100000) :: s
  read (*, *) s
  n = len(trim(s))
  m = 0
  do i = 1, n
    if (s(i:i) == "0") m = m + 1
  end do

  write(*, "(i0)") min(m, n - m) * 2
end program main


Measured memory_bytes: 828
s = input()
t = input()

ans = len(s)

for i in range(len(s)):
  if i + len(t) - 1 >= len(s):break;
  dif=0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      dif += 1
  ans = min(ans, dif)
print(ans)

Measured memory_bytes: 9040
// https://www.youtube.com/watch?v=1CaS4pSpS3c     lana is <3
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 
const ll inf=1e18+1e17;
const ll mod = 1e9+7;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}
ll sub( ll a, ll b){ if ( a-b<0) return a-b+mod; return a-b;}
ll add( ll a, ll b){ if ( a+b>=mod) return a+b-mod; return a+b;}
const ll N =21000000;

void solve(){
	ll n;
	cin>>n;
	cout<<add(sub(sub(powm(10,n),powm(9,n)),powm(9,n)),powm(8,n))<<'\n';

}


int main(){

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

	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif

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

Measured memory_bytes: 3616
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define fst first
#define snd second
using ll = long long;
using I = pair<int, int>;
const ll INF = 1ll << 60;

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<ll> x(N), y(N), z(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i] >> z[i];
    ll res = -INF;
    for (int m = 0; m < (1 << 3); m++) {
      int xs = ((m >> 0) & 1) ? 1 : -1;
      int ys = ((m >> 1) & 1) ? 1 : -1;
      int zs = ((m >> 2) & 1) ? 1 : -1;
      vector<ll> dp(M + 1, -INF);
      dp[0] = 0;
      for (int i = 0; i < N; i++) {
        for (int j = M - 1; j >= 0; j--) {
          if (dp[j] <= -INF) continue;
          dp[j + 1] = max(dp[j + 1], dp[j] + x[i] * xs + y[i] * ys + z[i] * zs);
        }
      }
      res = max(res, dp[M]);
    }
    cout << res << endl;
  }
  return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int K = Integer.parseInt(scanner.next());

        int[] heights = new int[N];
        for (int i = 0; i < N; i++) {
            int height = Integer.parseInt(scanner.next());
            heights[i] = height;
        }
        scanner.close();

        Arrays.sort(heights);

        int minDiff = Integer.MAX_VALUE;
        for (int i = 0; i <= N - K; i++) {
            int min = heights[i];
            int max = heights[i + K - 1];
            int diff = max - min;
            if (diff < minDiff) {
                minDiff = diff;
            }
        }

        System.out.println(minDiff);
    }
}


Measured memory_bytes: 46544
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <stack>
using namespace std;

int map[12][12];

void SagasiteHappy(int i, int j)
{
	map[i][j] = 0;
	if (i > 0)
	{
		if (map[i - 1][j] == 1)
		{
			SagasiteHappy(i - 1, j);
		}
	}

	if (i < 11)
	{
		if (map[i + 1][j] == 1)
		{
			SagasiteHappy(i + 1, j);
		}
	}

	if (j > 0)
	{
		if (map[i][j - 1] == 1)
		{
			SagasiteHappy(i, j - 1);
		}
	}

	if (j < 11)
	{
		if (map[i][j + 1] == 1)
		{
			SagasiteHappy(i, j + 1);
		}
	}
}

int main()
{
	string line;
	while (cin >> line)
	{
		int cnt = 0;
		for (int i = 0; i < 12; i++)
		{
			map[0][i] = line[i] - '0';
		}
		for (int i = 1; i < 12; i++)
		{
			cin >> line;

			for (int j = 0; j < 12; j++)
			{
				map[i][j] = line[j] - '0';
			}
		}
	
		for (int i = 0; i < 12; i++)
		{
			for (int j = 0; j < 12; j++)
			{
				if (map[i][j] == 1)
				{
					cnt++;
					SagasiteHappy(i, j); //まずijを0にして、上下左右探して1ならそいつをSagasiteHappyする
				}
			}
		}
		cout << cnt << endl;
	}


	return 0;
}

Measured memory_bytes: 1188
program prob3
    implicit none
    integer::N, i, ans, tmp
    integer, allocatable::a(:), c(:)
    read(*,*) N
    allocate(a(N), c(N))
    read(*,*) a
    ans = 0
    tmp = 0
    do i = 1, N
        if(a(a(i)) == i) then
            ans = ans + 1
        end if
    end do
    write(*,*) ans/2
    deallocate(a,c)
    stop
end program

Measured memory_bytes: 3524
import bisect

man_count = int(input())

infos = [int(i) for i in input().split()]
infos.sort()

next_num = 0
end = 0
for i in range(len(infos)+1):
    if i != next_num:
        print(0)
        continue

    # 速度を上げるために添え字を吹き飛ばそう。
    start = bisect.bisect_right(infos, i+1, end)  # iが始まる添え字を得る。
    print(start - end)
    end = start

    # 添え字が最後の場合 or 最後でない で切り分け必要。
    if start == len(infos):
      next_num = infos[start-1] -1
    else:
      next_num = infos[start] -1

#for i in ans:
#    print(i)



Measured memory_bytes: 92224
#include <bits/stdc++.h>
#define int long long
#define N 400
using namespace std;
int dp[N+1][N+1];
vector<int> vec,pre;
int solve(int i, int j)
{
	int ans=LONG_MAX;
	//cout<<i<<" "<<j<<" "<<dp[i][j]<<'\n';
	if(dp[i][j]!=-1)
		return dp[i][j];
	if(i==j)
		return dp[i][j]=0;
	if(j-i==1)
		return dp[i][j]=vec[i]+vec[j];
	for(int k=i; k<j; k++)
	{
		int pre_sum;
		if(i>0)
			pre_sum=pre[j]-pre[i-1];
		else
			pre_sum=pre[j];
		ans=min(ans,solve(i,k)+solve(k+1,j)+pre_sum);
	}
//	cout<<i<<" "<<j<<" "<<ans<<'\n';
	return dp[i][j]=ans;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
vec.resize(n);
pre.resize(n);
for(int i=0; i<n; i++)
{
	cin>>vec[i];
	if(i==0)
		pre[i]=vec[i];
	else
		pre[i]=pre[i-1]+vec[i];
}
for(int i=0; i<=n; i++)
	for(int j=0; j<=n; j++)
		dp[i][j]=-1;
cout<<solve(0,n-1);
return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstring>
using namespace std;

typedef long long ll;

ll dp[2][60][5010];

int main() {
    int n, a;
    scanf("%d%d", &n, &a);
    int cur = 0;
    dp[cur][0][0] = 1;
    for(int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        memset(dp[cur ^ 1], 0, sizeof dp[cur ^ 1]);
        for(int j = 0; j < n; j++)
            for(int k = 0; k < 5000 - x; k++) if(dp[cur][j][k]) {
                dp[cur ^ 1][j + 1][k + x] += dp[cur][j][k];
                dp[cur ^ 1][j][k] += dp[cur][j][k];
            }
        cur ^= 1;
    }
    //cur ^= 1;
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += dp[cur][i][i * a];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
//wls niubi!
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const LL mod = 1e9 + 7;
inline int read()
{
	int x = 0,f = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar())if(ch == '-')f = -f;
	for(;isdigit(ch);ch = getchar())x = 10 * x + ch - '0';
	return x * f;
}
int n,K;
char ch[310];
int f[310][310][310];
int main()
{
	scanf("%s",ch + 1);n = strlen(ch + 1);K = read();
	for(int i=1;i<=n;i++)for(int j=0;j<=K;j++)f[i][i][j] = 1;
	for(int l=2;l<=n;l++)
	{
		for(int i=1;i+l-1<=n;i++)
		{
			int j = i + l - 1;
			for(int k=0;k<=K;k++)
			{
			    f[i][j][k] = max(f[i + 1][j][k],f[i][j - 1][k]);
			    if(ch[i] == ch[j])f[i][j][k] = max(f[i][j][k],f[i + 1][j - 1][k] + 2);
			    if(k)f[i][j][k] = max(f[i][j][k],f[i + 1][j - 1][k - 1] + 2);
			}
		}
	}
	int ans = 0;
	cout<<f[1][n][K];
}

Measured memory_bytes: 114560
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

vector<int> G[100000+10];

Int solve(int K,int n,int p) {
    int color_num;
    if(p == -1)
        color_num = K-1;
    else
        color_num = K-2;
    if(K < G[n].size())
        return 0;
    
    Int case_num = 1;
    for(auto v: G[n]) {
        if(v == p)
            continue;
        case_num = (case_num*color_num)%MOD;
        color_num--;
    }
    for(auto e: G[n]) {
        if(e == p)
            continue;
        case_num *= solve(K,e,n);
        case_num %= MOD;
    }
    
    return case_num;
}

int main(void) {
    int N,K;
    cin>>N>>K;

    for(int i = 0;i < N-1;i++) {
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    cout<<K*solve(K, 1, -1)%MOD<<endl;

    return 0;
}


Measured memory_bytes: 11520
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    n = I()
    ni = 0
    t = 0

    while ni < n:
        ni += 1
        a = LS()
        if a[1] == '(':
            t -= int(a[2])
        else:
            t += int(a[2])

        if t == 0:
            rr.append('Yes')
        else:
            rr.append('No')


    return '\n'.join(map(str, rr))


print(main())




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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,A,B;
    cin>>N>>A>>B;
    string s;cin>>s;
    int cntA=0,cntB=0;
    rep(i,s.size()){
        bool flag=false;
        if(s[i]=='a'){
            if(cntA+cntB<A+B)flag=true,cntA++;
        }
        else if(s[i]=='b'){
            if(cntA+cntB<A+B&&cntB<B)flag=true,cntB++;
        }
        cout<<(flag?"Yes":"No")<<endl;
    }
    return 0;
}


Measured memory_bytes: 896
N = int(input())
A = list(map(int,input().split()))
b = [0]*9
for a in A:
    if a <400:
        b[0] += 1
    elif a < 800:
        b[1] += 1
    elif a < 1200:
        b[2] += 1
    elif a < 1600:
        b[3] += 1
    elif a < 2000:
        b[4] += 1
    elif a < 2400:
        b[5] += 1
    elif a < 2800:
        b[6] += 1
    elif a < 3200:
        b[7] += 1
    else:
        b[8] += 1
ans = 8
for B in b[:8]:
    if B == 0:
        ans -= 1
ans2 = ans+b[8]
if ans == 0:
    ans = 1
print(ans,ans2)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long n;
	long i, mod, div, tmp;
	long ans;

	cin >> n;
	ans = n - 1;

	for (i = 1; i*i <= n; i++) {
		mod = n % i;
		if (mod == 0) {
			div = n / i;
			tmp = (div - 1) + (i - 1);
			ans = min(ans, tmp);
		}

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



Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>


using namespace std;


int main() {
	
	int a, b ,h;
	int cnt = 0;
	cin >> a >> b >> h;


	cout << (a + b) * h / 2 << endl;
	
}



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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int main(){
  double n, k;
  cin >> n >> k;
  double tmp = ceil(n / 2);
  if(tmp >= k){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

}


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

int main() {
  // 入力
  int H, A;
  cin >> H >> A;
  vector<int> p;

  int hp = H;
  int turn = 0;
  while(1) {
    hp = hp - A;
    turn++;
    if(hp <= 0) {
      break;
    } 
  }


  // 出力
  cout << turn << endl;
  return 0;
}

Measured memory_bytes: 256
#define HAVE_STRUCT_TIMESPEC
#include <bits/stdc++.h>
using namespace std;
int n;
int a[17], x[17][17], y[17][17];
inline bool check(int s) {
    for (int i = 0;i < n; ++i)
        if((s>>i)&1) {
            for(int j=0;j<a[i];++j){
                if (((s>>x[i][j])&1) != y[i][j])
                    return false;
            }
        }
    return true;
}
inline int count(int x){
    int res=0;
    while (x) {
        res += x&1;
        x >>= 1;
    }
    return res;
}
int main(){
    cin >> n;
    for (int i =0;i< n; ++i) {
        cin>>a[i];
        for(int j=0;j<a[i];++j){
            cin>>x[i][j]>> y[i][j];
            --x[i][j];
        }
    }
    int res = 0;
    for(int i=0;i<1<<n;++i){
        if (check(i))
            res = max(res, count(i));
    }
    cout << res << endl;
    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 sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main() {
 int N;
 string S;
 cin >> N >> S;
 int cnt = 0;
	for (int i = 0; i < 1000; i++) {
		int c[3] = {i / 100, (i / 10) % 10, i % 10};
		int f = 0;
		for (int j = 0; j < N; j++) {
			if (S[j] == ('0' + c[f])) f++;
			if (f == 3) break;
		}
		if (f == 3) cnt++;
	}
	cout << cnt << endl;
	return 0;

}

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

int n, k;
int a[100000];

signed main()
{
	while (true) {
		cin >> n >> k;
		if (n == 0 && k == 0) break;
		rep(i,n) cin >> a[i];

		int mx;
		int sum = 0;
		rep(i,k) {
			sum += a[i];
		}
		mx = sum;
		//cout << "first = " << mx << endl;

		for (int i=0; i<=n-k -1; i++) {
			sum -= a[i];
			sum += a[i+k];
			//printf("i = %d, sum = %d\n", i, sum);
			mx = max(mx, sum);
		}

		cout << mx << endl;
	}
}

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

int main(){
	int n;
	cin>>n;
	int kind[20]={0};
	int unkind[20]={0};
	for(int i=0; i<n; i++){
		int q;
		cin>>q;
		while(q--){
			int a,b;
			cin>>a>>b;
			a--;
			if(b) kind[i]|=(1<<a);
			else unkind[i]|=(1<<a);
		}
	}
	int ret = 0;
	for(int state = 0; state<(1<<n); state++){
		int total_kind = 0;
		int total_unkind = 0;
		for(int j=0; j<n; j++){
			if(state&(1<<j)){
				total_kind|=(1<<j);
				total_kind|=kind[j];
				total_unkind|=unkind[j];
			}
		}
		bool possible = true;
		for(int j=0; j<n; j++){
			if((1<<j)&total_kind && (1<<j)&total_unkind) possible = false;
		}
		if(state^total_kind) possible = false;
		if(possible) ret = max(ret,__builtin_popcount(state));
	}
	cout<<ret;
}

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

int main()
{
  int n;
  vector<int> p, q;

  cin >> n;
  rep(i,n){
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }
  rep(i,n){
    int tmp;
    cin >> tmp;
    q.push_back(tmp);
  }

  vector<int> first;
  rep(i,n) first.push_back(i+1);
  int pcnt=-1, qcnt=-1;
  int cnt = 1;
  do{
    if(first == p) {
      pcnt = cnt;
    }
    if(first == q) {
      qcnt = cnt;
    }
    if(pcnt>=0 && qcnt>=0) break;
    cnt++;
  }while(next_permutation(first.begin(), first.end()));

  cout << abs(pcnt-qcnt) << endl;

  return 0;
}


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

int main(){
  bool C[4]={0,0,0,0};
  string S;
  cin >> S;
  for(int i=0;i<S.length();i++){
    if(S[i]=='N'){C[0]=true;}
    if(S[i]=='S'){C[1]=true;}
    if(S[i]=='E'){C[2]=true;}
    if(S[i]=='W'){C[3]=true;}
  }
  if(C[0]==C[1] && C[2]==C[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    char s[5];
    char t[5];
    int count = 0;

    fgets(s, 5, stdin);
    fgets(t, 5, stdin);

    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i]) {
            count++;
        }
    }

    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


string Main(int N, int M)
{
    return (N == M) ? "Yes" : "No";
}

int main(void){
    int N, M;
    cin >> N >> M;
    cout << Main(N, M) << endl;
    return 0;
}

Measured memory_bytes: 256
n,k,s = map(int, input().split( ))
#editorial
#s..s,s+1,...s+1
#またはs,,,s,1,,,1
for i in range(k):
        print(s,end = " ")
if s<10**9:
    for i in range(k,n):
        print(s+1,end = " ")
else:
    for i in range(k,n):
        print(1,end = " ")

Measured memory_bytes: 4212
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;


int main(){
	ll n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	
	for(ll i=0; i<n; i++){
		string shelp,thelp;
		if(s[i]==t[0]){
			for(ll j=i; j<n; j++){
				shelp+=s[j];
			}
			for(ll j=0; j<n-i; j++){
				thelp+=t[j];
			}
			if(shelp==thelp){
				cout<<(2*n)-(shelp.size())<<endl;
				return 0;
			}
		}
	}
	cout<<n*2;
}



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

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

  int n; cin >> n;
  int ans = 0;
  int tmp;
  for(int i = 1; i*i <= n; ++i) {
    ans = max(ans, i*i);
    tmp = i;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <numeric>
#include <climits>
#include <deque>
#include <random>
#include <functional>
#include <unordered_map>
#define rep(i,n) for(int i=0;i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
int main(){
    int n;
    ll ans = 0;
    cin >> n;
    for(ll i = 1; i <= 100000; i++){
        if(i*i <=n)ans = i*i;
    }
    cout << ans << endl;
}


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

struct UnionFind{
    vector<int> par;
    vector<int> rank;
    UnionFind(int n=1){
        init(n);
    }
    void init(int n=1){
        par.resize(n); rank.resize(n);
        for(int i = 0; i < n; i++) par[i] = i, rank[i] = 0;
    }
    int root(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = root(par[x]);
        }
    }
    bool same(int x,int y){
        return root(x) == root(y);
    }
    bool unite(int x,int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x]==rank[y]) rank[x]++;
        }
        return true;
    }
};

int main(){
    int n,k,l; cin >> n >> k >> l;
    UnionFind uf1(n);
    UnionFind uf2(n);
    rep(i,k){
        int p,q; cin >> p >> q;
        p--,q--;
        uf1.unite(p,q);
    }
    rep(j,l){
        int r,s; cin >> r >> s;
        r--, s--;
        uf2.unite(r,s);
    }
    map<pair<int,int>, int> cnt;
    rep(i,n) cnt[make_pair(uf1.root(i),uf2.root(i))]++;
    rep(i,n) cout << cnt[make_pair(uf1.root(i),uf2.root(i))] << " ";
    cout << endl;
    return 0;
}

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define str string
#define s_vec(data,name,vertical,horizontal) vector<vector<(data)>> (name)((vertical),vector<(data)>((horizontal)));




int main(){
    str s,t;
    cin>>s>>t;

    char a,b,c;

    ll test=0;
    int co=0;
    while(co<100){
        a = s.at(0);
        s.erase(0,1);
        s = s + a;
        if(s==t){
            test=1;
            break;
        }
        co++;
    }
    if(test==1){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


}




Measured memory_bytes: 256
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x; cin >> x;
    ll tmp = x / 100;
    ll rem = x % 100;
    if ((rem + 4) / 5 > tmp) cout << 0 << '\n';
    else cout << 1 << '\n';
    return 0;
}


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

int A, B, C, K;

int main(){
    cin >> A >> B >> C;
    cin >> K;

    bool flag = 0;
    for(int i = 0; i <= K; i++){
        if(C*pow(2, K-i) > B*pow(2, i) && B*pow(2, i) > A && C*pow(2, K-i) > A){
            flag = 1;
            break;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4096
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

M, D = map(int, input().split())
ans = 0
for m in range(1, M+1):
	for d in range(D+1):
		if d < 10:
			continue
		if d//10 >= 2 and d%10 >= 2 and (d//10)*(d%10) == m:
			ans += 1
print(ans)

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Measured memory_bytes: 9188
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>

using namespace std;

int main(void)
{
	string s1, s2, s3;

	cin >> s1 >> s2 >> s3;

	cout << char(s1[0] - 'a' + 'A') << char(s2[0] - 'a' + 'A') << char(s3[0] - 'a' + 'A') << endl;

	return 0;
}

Measured memory_bytes: 256