akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

w = raw_input()
cnt = [0]*26
for c in w:
    cnt[ord(c) - ord("a")] += 1
print "Yes" if all([cnt[i]%2 == 0 for i in xrange(26)]) else "No"


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

int main()
{
	int N;cin >> N;
	string S;cin >> S;
	int ans=0;
	for (int i=0;i<1000;i++)
	{
		string pass=to_string(i);
		if (pass.size()!=3)
		{
			string newpass;
			for (int i=0;i<3-pass.size();i++)
			{
				newpass+="0";
			}
			pass=newpass+pass;
		}
		int cnt=0;
		int step=0;
		while (cnt!=3 && step<N)
		{
			if(S[step]==pass[cnt]) cnt++;
			step++;
		}
		if (cnt==3) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 

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

	int num = N / 1000;
	int ans = 0;
	if(N-num*1000 == 0){
		cout << ans << endl;
		return 0;
	}
	cout << (num+1)*1000 - N << endl;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N; 
  int alice = 0, bob = 0;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int i=0; i<vec.size(); i++){
    if(vec.size()%2 == 0){
      if(i%2==0){
        bob += vec.at(i);
      }else{
        alice += vec.at(i);
      }
    }else{
      if(i%2==1){
        bob += vec.at(i);
      }else{
        alice += vec.at(i);
      }
    }
  }
 
  cout << alice-bob << endl;
}

Measured memory_bytes: 256
n = int(input())
ms = []
say = []
for i in range(n):
    m = int(input())
    ms.append(m)
    say.append([])
    for j in range(m):
        p,q = list(map(int, input().split()))
        say[i].append([p,q])

# ms =  [2, 2, 2]
# say = [[[2, 1], [3, 0]], [[3, 1], [1, 0]], [[1, 1], [2, 0]]]

def bitlist(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

ans = 0
for i in range(2**n):
    flag = 1
    nowbit = bitlist(i,n)
    for j in range(n):
        for k in range(ms[j]):
            if nowbit[j]==1:
                if say[j][k][1] != nowbit[say[j][k][0]-1]:
                    flag = 0
    if flag == 1:
        ans = max(ans, sum(nowbit))

print(ans)


Measured memory_bytes: 43612
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

order = [a,b,c,d,e]
set = []
for i in order:
  set.append([(i-1)%10,i])

set.sort(reverse=True)

time = 0

for i in set[:-1]:
  time += 10 * ((i[1]-1) // 10 + 1)
time += set[-1][1]

print(time)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll L, R, d;
	std::cin >> L >> R >> d;

	ll ans = 0;
	repeq(i, L, R) {
		if (i % d == 0) {
			ans++;
		}
	}
	std::cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long int
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define pb           push_back
#define ff           first
#define ss           second
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define Pi           2*acos(0.0)
#define pii          pair<int,int>
#define pll          pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
using namespace std;

ll expo(ll a,ll b,ll m = mod){
	a%=mod;
	ll res = 1;
	while(b){
		if(b&1)
			res = (res*a)%m;
		a = (a*a)%m;
		b>>=1;
	}
	return res;
}
ll gcd(ll a,ll b){
	while(b>0){
		ll r = a%b;
		a = b; b = r;
	}
	return a;
}
int main()
{
	 
   boost
   #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int t=1;
// 	cin>>t;
	while(t--)
	{
	    int N,W;
	    cin>>N>>W;
	    int wt[N+1],val[N+1];
	    for(int i=1;i<=N;i++){
	        cin>>wt[i]>>val[i];
	    }
	    ll dp[N+1][W+1];
	    for(int i=0;i<=N;i++){
	        for(int w=0;w<=W;w++){
	            if(i==0 || w==0) dp[i][w] = 0;
	            else{
	                dp[i][w] = dp[i-1][w];
	                if(w>=wt[i])
	                dp[i][w] = max(dp[i][w],dp[i-1][w-wt[i]]+val[i]);
	            }
	        }
	    }
	    cout<<dp[N][W]<<"\n";
	}
    return 0;
}


Measured memory_bytes: 82416
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int n;
vector<ll> a;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    a.resize(n);
    rep(i,0,n) cin>>a[i];
    ll ans=0;
    rep(i,0,n){
        if(i%2) ans-=a[i];
        else ans+=a[i];
    }
    cout << ans<<" ";
    ll res=ans;
    rep(i,1,n){
        res=2*a[i-1]-res;
        cout << res<<" ";
    }
    cout <<"\n";
}

Measured memory_bytes: 2176
n,m=map(int,input().split())
a=list(map(int,input().split()))
sumA=sum(a)
cnt=0
for i in a:
    if i>=sumA/(4*m):
        cnt=cnt+1
    else:
        cnt=cnt
if cnt>=m:
    print('Yes')
else:
    print('No')

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;

int n;
vi a, b;

int range(int lo, int hi) {
	return lower_bound(b.begin(), b.end(), hi) - lower_bound(b.begin(), b.end(), lo);
}


int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	cin >> n;

	a.assign(n, 0);
	b.assign(n, 0);

	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	for (int i = 0; i < n; ++i) {
		cin >> b[i];
	}

	int ans = 0;

	for (int k = 28; k >= 0; --k) {
		for (int i = 0; i < n; ++i) {
			a[i] %= (1 << (k + 1));
			b[i] %= (1 << (k + 1));
		}
		sort(b.begin(), b.end());
		ll cnt = 0;
		int T = 1 << k;
		for (int i = 0; i < n; ++i)
			cnt += range(T - a[i], 2 * T - a[i]) + range(3 * T - a[i], 4 * T - a[i]);
		if (cnt & 1)
			ans ^= (1 << k);
	}

	cout << ans << '\n';

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 50;
int n, m, c;
int b[N];

int main() {
	
	cin >> n >> m >> c;
	for(int i = 1; i <= m; i++) {
		scanf("%d", &b[i]);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		int tmp = 0, x;
		for(int j = 1; j <= m; j++) {
			scanf("%d", &x);
			tmp += x * b[j];
		}
		tmp += c;
		if(tmp > 0) {
			ans++;
			//break;
		}
	}
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 3252
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
int n,m,cnt=0,aa[330000],ans=0,ab[220000];
pair<int,int> pp[220000];
string s,sa[220000];
char ca[220000];
queue<int> que;
signed main(){
    cin>>n>>m;
    rep(i,n){
        cin>>aa[i];
    }
    for(int i=m;i<n;i++){
        if(aa[i]>aa[i-m]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 12176
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine());
        var sqrt = (int)Ceiling(Sqrt(n));
        long min = long.MaxValue;
        for (int i = 1; i <= sqrt; i++)
        {
            if (n % i == 0) min = Min(min, i + n / i - 2);
        }
        Console.WriteLine(  min);
    }
}


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



using namespace std;
typedef long long lint;

#define rep(i, n) for(int i=0; i<n; i++)
#define max(a, b) (a > b)? a:b

lint N;
lint H;
lint a[100010];
lint b[100010];


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

    lint maxa = -1;
    rep(i, N) {
        scanf("%ld %ld", &a[i], &b[i]);
        maxa = max(maxa, a[i]);
    }
    
    sort(b, b + N);
    
    lint x = 0;
    for(int i = N-1; b[i] > maxa && H > 0; i--) {
        H -= b[i];
        x++;
    }
    if(H > 0) {
        x += H / maxa;
        if(H % maxa) x += 1;
    }
    cout << x  << " " << endl;
    
}

Measured memory_bytes: 1792
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    string n;
    cin >> n;
    int ans = 0;
    for(char c : n) ans += c-'0';
    ans %= 9;
    Yes(ans == 0);
}

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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define int long long
using ll = long long;
using State = string::const_iterator;
int expression(State &begin);
int term(State &begin);
int factor(State &begin);
int number(State &begin);
int flip[3] = {2, 1, 0};
int mul[3][3] = {{0, 0, 0}, {0, 1, 1}, {0, 1, 2}};
int add[3][3] = {{0, 1, 2}, {1, 1, 2}, {2, 2, 2}};

int expression(State &begin) {
    int ret = term(begin);
    for (;;) {
        if (*begin == '+') {
            begin++;
            ret = add[ret][term(begin)];
        } else if (*begin == '*') {
            begin++;
            ret = mul[ret][term(begin)];
        } else
            break;
    }
    return ret;
}
int term(State &begin) {
    if (*begin == '-') {
        begin++;
        return flip[term(begin)];
    } else
        return factor(begin);
}
int factor(State &begin) {
    if (*begin == '(') {
        begin++;
        int ret = expression(begin);
        begin++;
        return ret;
    } else
        return number(begin);
}
int number(State &begin) {
    int ret = *begin - '0';
    begin++;
    return ret;
}

bool solve() {
    string S;
    cin >> S;
    if (S == ".") return false;
    int ans = 0;
    REP(p, 3) REP(q, 3) REP(r, 3) {
        string tmp = S;
        REP(i, tmp.size()) {
            if (tmp[i] == 'P')
                tmp[i] = '0' + p;
            else if (tmp[i] == 'Q')
                tmp[i] = '0' + q;
            else if (tmp[i] == 'R')
                tmp[i] = '0' + r;
        }
        State begin = tmp.begin();
        if (expression(begin) == 2) ans++;
    }
    cout << ans << endl;
    return true;
}
signed main() {
    while (solve())
        ;
}


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

int main() {
  int A,B;
  cin>>A>>B;
  for(int i=0;i<3;i++){
  	if(A*B*i%2==1){
    	cout<<"Yes"<<endl;
        break;
    }
    if(i==2) cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
N=int(input())
S=list(input())

count=[0]*3
for i in range(N-1,-1,-1):
    if S[i]=="R":
        count[0]+=1
    elif S[i]=="G":
        count[1]+=1
    else:
        count[2]+=1
        
cnt=0
for i in range(1,N//2+1):
    for j in range(N-2*i):
        a,b,c=S[j],S[j+i],S[j+2*i]
        if a!=b and a!=c and c!=b:
            cnt+=1

ans=count[0]*count[1]*count[2]-cnt
print(ans)

Measured memory_bytes: 73740
#include <cstdio>
#include <cstring>

bool ht(char* dat){
int le=strlen(dat);
int i,j;
char no='A';
for(i=0;i<le;i++){
if(dat[i]=='0')dat[i]=0;
switch(no){

case 'A':
if(dat[i]==0)no='X';
else no='Y';
break;

case 'X':
if(dat[i]==0)no='*';
else no='Z';
break;

case 'Z':
if(dat[i]==0)no='W';
else no='B';
break;

case 'B':
if(dat[i]==0)no='Y';
else no='X';
break;

case 'W':
if(dat[i]==0)no='B';
else no='Y';
break;

case 'Y':
if(dat[i]==0)no='X';
else no='*';
break;
}
}
//printf("%c\n",no);

if(no=='B')return true;
else return false;
}

int main(void){
char dat[105];

while(1){
scanf("%s",dat);
if(dat[0]=='#')break;
if(ht(dat))printf("Yes\n");
else printf("No\n");

}
return 0;
}

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

int main()
{
        int n;
        cin >> n;
        int arr[n];
        for(int i= 0;i<n; i++)
        {
                cin >> arr[i];
        }
        sort(arr,arr + n);
        bool ans = true;
        for(int i = 0; i< n-1; i++)
        {
                if(arr[i] == arr[i + 1])
                {
                        ans = false;
                        break;
                }
        }
        if(ans == true)
        {
                cout << "YES" << endl;
        }
        if(ans == false)
        {
                cout << "NO" << endl;
        }
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>

#define fi first
#define se second
#define pb push_back
#define eb emplace_back #define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;
  string x, y;
  cout << 0 << endl;
  cin >> x;

  cout << 1 << endl;
  cin >> y;

  int left = 0, right = n+1;
  while (right - left > 1) {
    int mid = (right + left) / 2;

    cout << mid << endl;
    string v; cin >> v;

    if (mid % 2) {
      if (v == y) left = mid;
      else right = mid;
    } else {
      if (v == x) left = mid;
      else right = mid;
    }
  }

  cout << (right + left) / 2 << endl;
}


Measured memory_bytes: 3832
import java.io.PrintWriter;
    import java.util.Arrays;
    import java.util.Scanner;
     
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    /**
     *
     * @author i.mekni
     */
    public class Main {
     
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            // TODO code application logic here
     
            Scanner read = new Scanner(System.in);
     
            PrintWriter write = new PrintWriter(System.out);
     
            int x = read.nextInt();
            int y = read.nextInt();
            int a = read.nextInt();
            int b = read.nextInt();
            int c = read.nextInt();
     
            int aTe[] = new int[a];
            int bTe[] = new int[b];
            int cTe[] = new int[c];
            for (int i = 0; i < a; i++) {
                aTe[i] = read.nextInt();
            }
     
            for (int i = 0; i < b; i++) {
                bTe[i] = read.nextInt();
            }
     
            for (int i = 0; i < c; i++) {
                cTe[i] = read.nextInt();
            }
     
            Arrays.sort(aTe);
            Arrays.sort(bTe);
            Arrays.sort(cTe);
     
            int minA = a - x;
            int minB = b - y;
     
            for (int i = 1; i <= c; i++) {
                if ((minA < a && minB < b && aTe[minA] < bTe[minB])
                 || (minA < a && minB == b)) {
                    if (cTe[c - i] > aTe[minA]) {
                        aTe[minA] = cTe[c - i];
                        minA++;
                    }
                } else {
                    if (minB < b && cTe[c - i] > bTe[minB]) {
                        bTe[minB] = cTe[c - i];
                        minB++;
                    }
                }
            }
     
            long d = 0;
     
            for (int i = 1; i <= x; i++) {
                d += aTe[a - i];
            }
     
            for (int i = 1; i <= y; i++) {
                d += bTe[b - i];
            }
     
            write.println(d);
            write.close();
        }
     
    }

Measured memory_bytes: 94692
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007



void Solve()
{
	string s,t;
	cin>>s>>t;
	
	if(s.length()==t.length()-1)
	{
		f(i,0,s.length()-1)
		{
			if(s[i]!=t[i])
			{
				cout<<"No";
				return;
			}
		}
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	
	
}

signed main() 
{
	speed		
	
	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

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

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int N; cin >> N; int last = 0;
  for (int i = 0; i < N; i++) {
    int h; cin >> h;
    if (h-1 >= last) last = h-1;
    else if (h >= last) last = h;
    else {
      cout << "No\n"; exit(0);
    }
  }
  cout << "Yes\n";
  return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  set<int> br, bc;
  vector<vector<char>> A(H, vector<char>(W));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> A.at(i).at(j);
      if(A.at(i).at(j) == '#'){
        br.insert(i);
        bc.insert(j);
      }
    }
  }
  
  int cnt =0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(br.count(i) == 1  && bc.count(j) == 1 ){
        cout << A.at(i).at(j);
        cnt++;
        if(cnt == bc.size()){
          cout << endl;
          cnt = 0;
        }
      }
    }
  }  
}


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


int main(){
    int a, b; cin >> a >> b;
    if(a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static long p(int n) throws IOException {
		long ans = 1;
		for (int i = 0; i < n; i++) {
			ans *= i + 1;
			ans %= 1000000007;
		}
		return ans;
	}

	public static void solve() throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		sc.close();
		if (Math.abs(n - m) == 0) {
			long pn = p(n);
			long pm = p(m);
			long ans = 2 * pn * pm;
			ans %= 1000000007;
			System.out.println((int) ans);
		} else if (Math.abs(n - m) == 1) {
			long pn = p(n);
			long pm = p(m);
			long ans = pn * pm;
			ans %= 1000000007;
			System.out.println((int) ans);
		} else {
			System.out.println(0);
		}
	}

	public static void main(String[] args) {
		try {
			solve();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}


Measured memory_bytes: 23764
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///



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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {			cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


int dx[] = { 0, 0, +1, -1, -1  +1, -1, +1 };
int dy[] = { +1, -1, 0, 0, -1, +1, +1, -1 };


bool seive[1010000];
vi prime;

void seiveGen(int limit) {
	limit += 100;
	int sqrtn = sqrt(limit);
	for(int i = 3; i <= sqrtn; i += 2) {
			if(!seive[i>>1]) {
					for(int j = i * i; j < limit; j += i + i) {
							seive[j>>1] = 1;
					}
			}
	}
	prime.PB(2);
	for(int i = 3; i < limit; i += 2) {
			if(!seive[i>>1]) prime.PB(i);
	}
}

map<ll, int> cnt;

set<ll> factorize ( ll n )
{
	set<ll> ret;
	for ( auto p : prime ) {
		if ( 1LL * p * p > n || n == 0 ) break;

		if ( n % p == 0 ) {
			ret.insert ( p );

			while ( n % p == 0 ) {
				n /= p;
				cnt[p]++;
			}
		}
	}

	if ( n > 1 ) {
		cnt[n]++;
		ret.insert ( n );
	}

	return ret;
}


ll mypow ( ll a, ll b )
{
	ll ret = 1;
	for ( int i = 0; i < b; i++ ) {
		ret *= a;
	}

	return ret;
}

map<ll, bool> vis;

int main()
{
	optimize();

	seiveGen(1e6);

	ll n;
	cin >> n;
	set<ll> fact = factorize(n);

	for ( auto u : fact ) {
		for ( int i = 1; i <= cnt[u]; i++ ) {
			vis[mypow(u, i)] = 1;
		}
	}

	vl v;
	for ( ll i = 1; i <= n; i++ ) {
		if ( i * i > n ) break;
		if ( n % i == 0 ) {
			if ( vis[i] ) v.PB ( i );
			if ( vis[n/i] == 1 && n / i != i ) v.PB ( n/ i );
		}
	}

	sort ( all ( v ) );

	int ans = 0;
	for ( auto u : v ) {
		if(n == 0) break;
		if ( n % u == 0 ) {
			n /= u;
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

















Measured memory_bytes: 4324
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 100000 + 5;

LL n;
LL a[N];

int main() {
	read(n); LL sum = 0;
	for (int i = 1; i <= n; i++) read(a[i]), sum += a[i];
	LL tmp = 1LL * n * (1 + n) / 2LL;
	if (sum % tmp) {printf("NO\n"); return 0;}
	LL w = sum / tmp, cnt = 0;
	a[n + 1] = a[1];
	for (int i = 1; i <= n; i++) {
		LL tmp = a[i] - a[i + 1] + w;
		if (tmp < 0 || tmp % n) {printf("NO\n"); return 0;}
		cnt += tmp / n;
	}
	if (cnt != w) {printf("NO\n"); return 0;}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
int dp[100005];
int h[100005];
int n,k;
using namespace std;
int solve(int i)
{
    if(i >= n )
    return 0;
    if(dp[i] != -1)
      return dp[i];
    int mins = INT_MAX,temp;
    for(int j=i+1;j<=i+k;j++)
    {
        if(j>n)
            continue;
       temp  = abs(h[j]-h[i]) + solve(j);
    //    cout<<"\n"<<" i "<<i<<" j "<<j<<temp<<endl;
       mins = min(temp,mins);
    }
    dp[i] = mins;
   // cout<<"vlue of ith "<<i<<" "<<dp[i]<<endl;
    return dp[i];
}
int main()
{
    cin>>n>>k;
    h[0] = 0;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    dp[0] = 0;
    cout<<solve(1);
}


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

int main() {
  int N;
  string A;
  cin >> N;
  int p = 0;
  int w = 0;
  int g = 0;
  int y = 0;
  
  
  for(int i = 0; i < N; i++){
    cin >> A;
    if(p == 0 && A == "P"){
      p++;
    }
    if(w == 0 && A == "W"){
      w++;
    }
    if(g == 0 && A == "G"){
      g++;
    }
    if(y == 0 && A == "Y"){
      y++;
    }
  }
  if(p+w+g+y == 3){
    cout << "Three"<< endl;
  }
  if(p+w+g+y == 4){
    cout << "Four"<< endl;
  }
}
      
    
    
    


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - Prefix and Suffix
https://atcoder.jp/contests/agc006/tasks/agc006_a

"""
import sys


def solve(N, s, t):
    for i in range(N, 0, -1):
        if s[-i:] == t[:i]:
            return N*2 - i
    return N*2


def main(args):
    N = int(input())
    s = input()
    t = input()
    ans = solve(N, s, t)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,m; cin >> n >> m;
    vector<int> b(n),p(m);
    vector<int> v;
    int one=0;
    for(int i=0;i<n;i++){
        cin >> b[i];
        if(b[i]){one++;v.push_back(i);}
    }
    int e=0;
    for(int i=0;i<m;i++){
        cin >> p[i];
        if(i%2==0)e+=p[i];
    }
    int res=2e5;
    if(e==one){
        int t=-1;
        int id=0;
        int sum=0;
        for(int i=0;i<m;i++){
            for(int j=0;j<p[i];j++){
                t++;
                if(i%2==0){
                    sum+=abs(t-v[id]);
                    id++;
                }
            }
        }
        res=min(res,sum);
    }
    if(n-e==one){
        int t=-1;
        int id=0;
        int sum=0;
        for(int i=0;i<m;i++){
            for(int j=0;j<p[i];j++){
                t++;
                if(i%2==1){
                    sum+=abs(t-v[id]);
                    id++;
                }
            }
        }
        res=min(res,sum);
    }
    printf("%d\n",res);
}



Measured memory_bytes: 3304
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio> 
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
string s;
string t="-";
int res=0;
int n;
int main()
{
	cin >>s;
	n=s.size();
	for (int i=0;i<n;i++)
	{
		if (t.size()==1)
		{
			if (i==n-1)
			{
				res++;
				break;
			}
			if (s[i]==s[i+1])
			{
				t="";
				t+=s[i];
				t+=s[i+1];
				i++;
				res++;
			}
			else
			{
				t="";
				t+=s[i];
				res++;
			} 
		}
		else
		{
			t="";
			t+=s[i];
			res++;
		}
	}
	cout <<res;
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int n;
    cin >> n;
    
    int x;
    int res = 0;
    f(i,n)
    {
        cin >> x;
        
        if(i % 2 == 0 && x % 2 == 1) res++;
    }
    
    cout <<res;
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  vi s(3);
  re(i, 3) {
    int x;
    cin >> x;
    s[i] = x;
  }
  int k;
  cin >> k;

  sort(all(s));
  cout << s[0] + s[1] + s[2] * pow(2, k) << endl;

  return 0;
}


Measured memory_bytes: 256
# coding: utf-8


def idx(n):
    i = 0
    while True:
        if 2**i > n:
            return i - 1
        i += 1


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    a_max = max(A)
    K = idx(a_max) + 1

    pow_list = [[] for _ in range(K)]
    for a in A:
        pow_list[idx(a)].append(a)

    # print(pow_list)

    no_k0 = False
    for k in range(K-1, 0, -1):  # k=1までの処理
        # print("-------")
        # print(M)
        # print(k)
        # print(pow_list)
        if len(pow_list[k]) <= M:
            tmp = [p // 2 for p in pow_list[k]]
            pow_list[k-1].extend(tmp)
            M -= len(pow_list[k])

            if M == 0:
                limit = k
                no_k0 = True
                break
        else:  # len(...) > M
            pow_list[k] = sorted(pow_list[k], reverse=True)
            pow_list[k-1].extend([p // 2 for p in pow_list[k][0:M]])
            for i in range(M):
                pow_list[k][i] = 0
            limit = k + 1
            no_k0 = True
            break

    if not no_k0:
        if len(pow_list[0]) <= M:
            return 0
        else:
            pow_list[0] = sorted(pow_list[0], reverse=True)
            for m in M:
                pow_list[0][m] = 0
            return sum(pow_list[0])

    ans = 0
    for i in range(limit):
        ans += sum(pow_list[i])

    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 14252
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int q8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	ll n;
	cin>>n;
	vector<string> s(n);
	vector<char> v;
	REP(i, n)cin>>s[i];
	REP(i, 26) {
		ll mcnt = INF;
		REP(j, n) {
			ll cnt = 0;
			REP(k, s[j].size()) {
				if(s[j][k] == 97 + i) ++cnt;
			}
			mcnt = min(mcnt, cnt);
 		}
		REP(j, mcnt) {
			v.pb(97 + i);
		}
	}
	sort(ALL(v));
	REP(i, v.size())cout<<v[i];
	cout<<endl;
}


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

int n;
typedef long long LL;
const int maxn = 1e5 + 5;

pair<LL, int> a[maxn];
LL cnt[maxn];
int main(){
    cin >> n;
    for(int i = 1;i <= n;i++){
        scanf("%lld", &a[i].first);
        a[i].first *= -1;
        a[i].second = i;
    }
    a[0] = make_pair(0, 0);
    sort(a, a + n + 1);
    set<int> s;
    s.insert(a[0].second);
    LL now = -a[0].first;
    for(int i = 1;i <= n;i++){
        if(-a[i].first != now){
            int id = *s.begin();
            cnt[id] += 1LL * s.size() * (now + a[i].first);
        }
        s.insert(a[i].second);
        now = -a[i].first;
    }
    for(int i = 1;i <= n;i++){
        printf("%lld\n", cnt[i]);
    }
    return 0;
}


Measured memory_bytes: 8064
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	sum := 0
	var a int
	for i := 0; i < m; i++ {
		fmt.Scan(&a)
		sum += a
	}
	if n < sum {
		fmt.Println(-1)
		return
	}

	fmt.Println(n - sum)
}


Measured memory_bytes: 2364
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000500

ll n, W, w[105], v[105], dp[105][100005];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> n >> W;
    for (int i = 1; i <= n; i++) cin >> w[i] >> v[i];
    for (int c = 0; c <= W; c++){
        for (int cnt = 1; cnt <= n; cnt++){
            dp[cnt][c] = max(dp[cnt][c], dp[cnt - 1][c]);
            if (c + w[cnt] <= W) 
                dp[cnt][c + w[cnt]] = max(dp[cnt][c + w[cnt]], dp[cnt - 1][c] + v[cnt]);
        }
    }
    cout << dp[n][W];
    return 0;
}


Measured memory_bytes: 79360
#include<iostream> 

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	char s;
	cin >> s;
	if (s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o') {
		puts("vowel");
	}
	else {
		puts("consonant");
	}
	
	return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	string a,b;
	cin>>a>>b;
	for (int i = 0; i < sz(a); ++i)
		if(a[i]!=b[i]){cout<<"No\n";return 0;}
	cout<<"Yes\n";
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 3648
#include <stdio.h>
typedef long long ll;

ll n, m;
ll a, b;
ll node[100005];

int main()
{
    scanf("%lld %lld", &n, &m);
    for (int i = 0; i < m; i++) {
        scanf("%lld %lld", &a, &b);

        node[a]++;
        node[b]++;
    }

    int i = 0;
    while (i <= n && node[i] % 2 == 0) {
        i++;
    }

    if (i > n) {
        puts("YES");
    }
    else {
        puts("NO");
    }

    return 0;
}


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

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CINS(int, d, N);
    sort(d.begin(), d.end());

    int u = d[N / 2 + 0];
    int l = d[N / 2 - 1];

    int ans = 0;
    if ( u != l ) {
        ans = u - l;
    }

    cout << ans << "\n";
    return 0;
}

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

using namespace std;

#define lint long long
#define P pair<int, int>

int main(){
    string S;

    cin >> S;

    int cnt = 0;
    for(int i = 0; i < S.length(); ++i){
        if((S[i] - '0') == (i % 2)){
            cnt++;
        }
    }

    cout << min(cnt, (int)S.length() - cnt) << endl;
}

Measured memory_bytes: 512
fn main() {
    let n: u32 = read();

    let mut counter = 0;

    for a in 1..n {
        for b in 1..n {
            let a_x_b = a * b;
            if a_x_b >= n {
                break;
            }

            counter += 1;
        }
    }

    println!("{}", counter);
}

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()
}


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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

using namespace std;

typedef uint64_t ulint;
typedef int64_t lint;

// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;

template<class T> lint sum(vector<T> a);
template<class T> double ave(vector<T> a);
template<typename T> ostream& operator << (ostream& s, const vector<T>& v);
ulint gcd(lint a, lint b);
ulint lcm(lint a, lint b);

bool flagdebug = false;





int main(){
//////////////////////////////////////////////////////

    flagdebug = true; ///本番時削除！！！！！

    //入力
    lint n;
    string s;

    cin >> n;
    cin >> s;

    lint ans = 0;
    rep0(i, n-2)
    {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')ans ++;
    }

    cout << ans << endl;
    

    // lint n;
    // cin >> n;

    // vector<lint> a(n);
    //2次元配列
    //vector<vector<lint>> mat(row, vector<lint>(column, 初期値));

    // rep0(i, n)
    // {
    //     cin >> a[i];
    // }

    //2次元配列
    //vector<vector<lint>> mat(row, vector<lint>(column, 初期値));
    //ペア
    //pair<lint,lint> p = make_pair(1,2);
    //vector<pair<lint,lint>> c(100010, pair<lint,lint>(0,0));
    //タプル
    //tuple<lint,lint,lint> t  = make_tuple(1,2,3);


    //昇順ソート
    //sort(all(a));
    //降順ソート
    //sort(all(a),greater<lint>());
    //特殊なソート（ラムダ式）
    //sort(all(mat), [&i](const vector<lint> &a, const vector<lint> &b){return a[i] < b[i];});
    // //[&i]は参照する変数，いらなければからの大括弧でよし．
    //ソート済集合（順序付き集合）
    //set<lint> st;
    //itr.insert(0);
    //auto itrmin = st.begin(); //最小値の次へアクセス
    //auto itrmax = st.end(); //最大値の次へアクセス（かならずデクリメントが必要）
    //itrmax --; //最大値はst.end()の1つ前
    //st.erase(0);
    //st.find;
    
    //////////////////////////////////////////////////////
    //キュー
    //queue<lint> que;
    //que.push(value);
    //que.front(); //トップを参照（消されないので消したい場合は直後にpop()を使う）
    //que.pop(); //追い出す
    //que.empty(); //空なら1，あれば0
    //優先度付きキュー
    //priority_queue<lint> que;
    //キューにque.push()で入れると最大値順に並べられる．que.pop()で取り出すときは常に最大値が前にくる．
    //最小値から取り出したい時はpriority_queue< lint, std::vector<lint>, std::greater<lint> >
    //////////////////////////////////////////////////////
    //スタック
    //stack<lint> stk;
    //stk.push(value);
    //stk.top(); //先頭を参照（消されないので消したい場合は直後にpop()を使う）
    //stk.pop(); //トップを削除
    //stk.empty(); //空なら1,あれば0
    //stk.size(); //数
    //
    // sort(input.begin() , input.end());
    // uint64_t max = numeric_limits<uint64_t>::max();

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}

//vectorprint用
template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
    s << "[\t";
    for (auto i = v.begin(); i < v.end() - 1; i++){s << *i << "\t";}
    s << *(v.end() - 1) << "\t]\n";
	return s;
}

// 最大公約数
ulint gcd(lint a, lint b){
    if(b!=0){return gcd(b, a % b);}
    return a;    
}

//最小公倍数
ulint lcm(lint a, lint b){
    return a / gcd(a, b) * b;
}


Measured memory_bytes: 256