akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vint a(5);
    int ans = 0;
    vint rem(5);
    REP(i,5){
        cin >> a[i];
        ans += a[i];
        int r = a[i]%10;
        rem[i] = (r==0)?(0):(10-r);
        ans+=rem[i];
    }
    sort(ALL(rem));
    ans-=rem[4];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
t = list(map(int,input().split()))
v = list(map(int,input().split()))

st = [0]
s = 0
for i in range(N):
    s+=t[i]
    st.append(s)

T = st[N]
i = 0
max_v = [0]
while i<=T:
    mv = 10**28
    for j in range(N):
        if i<st[j]:
            mv = min(v[j]+st[j]-i,mv)
        elif i>st[j+1]:
            mv = min(v[j]+i-st[j+1],mv)
        else:
            mv = min(v[j],mv)
    mv = min(T-i,i,mv)
    max_v.append(mv)
    i+=0.5

ans = 0
for i in range(len(max_v)-1):
    ans+=(max_v[i]+max_v[i+1])/4

print(ans)

Measured memory_bytes: 45660
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	int N, M;
	while (cin >> N >> M, N || M)
	{
		vector<int> point(N);
		for (int i = 0; i < N; ++i)
		{
			cin >> point[i];
		}
		point.push_back(0);
		vector<int> sum;
		for (int i = 0; i <= N; ++i)
		{
			for (int j = 0; j <= N; ++j)
			{
				sum.push_back(point[i] + point[j]);
			}
		}
		int ans = 0;
		sort(sum.begin(), sum.end());
		for (int i = 0; i < sum.size(); ++i)
		{
			if (M - sum[i] < 0)
			{
				continue;
			}
			int left = 0;
			int right = sum.size();
			while (left < right)
			{
				int middle = (left + right) / 2;
				if (sum[i] + sum[middle] > M)
				{
					right = middle;
				}
				else if (sum[i] + sum[middle] < M)
				{
					left = middle + 1;
				}
				else
				{
					break;
				}
			}
			ans = max(ans, sum[i] + sum[right - 1]);
		}
		cout << ans << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 100050
vector<vector<int> > adj(maxn);
vector<int> colorr(maxn,0);
vector<int> depthh(maxn,0);
map<pair<int,int>,int> map1;
int mx = 0;
void dfs(int node,int parent,int color,int depth){
  depthh[node] = depth;
  for(auto k:adj[node]){
    if(k!=parent){
      color++;
      color %= mx;
      colorr[k] = color;
      map1.insert({{min(k,node),max(k,node)},color});
      dfs(k,node,color,depth+1);
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int no_of_input;
  int input1,input2;
  cin >> no_of_input;
  vector<pair<int,int> > vect1;
  for(int i=0;i<no_of_input-1;i++){
    cin >> input1 >> input2;
    adj[input1].push_back(input2);
    adj[input2].push_back(input1);
    vect1.push_back({input1,input2});
  }
  for(int i=1;i<=no_of_input;i++){
    mx = max(mx,(int)adj[i].size());
  }
  colorr[1] = 0;
  dfs(1,-1,-1,0);
  /*for(int i=1;i<=no_of_input;i++){
    cout << colorr[i] << " ";
  }
  cout << endl;*/
  cout << mx << endl;
  for(auto k:vect1){
    cout << map1[{min(k.first,k.second),max(k.first,k.second)}]+1 << "\n";
    //cout << colorr[min(depthh[k.first],depthh[k.second])]+1 << "\n";
  }
}

Measured memory_bytes: 17908
#include<stdio.h>
int main()
{
	char input[5];
	scanf("%s",input);
	if(input[1] == 'B')
	{
		input[1] = 'R';
	}
	else{
		input[1] = 'B';
	}
	printf("%s",input);
	return 0;
}

Measured memory_bytes: 2072
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
#include <cstdint>
#include <cmath>
#include <algorithm>
using namespace std;

#define N 100

int a[N];

int main()
{
	int ans;
	int n, m, x;

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

	int l = 0;
	for( int i = 0; i < m; i++ ) {
		if( a[i] > x ) {
			break;
		}
		l++;
	}

	int r = 0;
	for( int i = m - 1; i >= 0; i-- ) {
		if( a[i] < x ) {
			break;
		}
		r++;
	}

	ans = min(l, r);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

template<typename T>
vector<T> getVector(int N) {
    vector<T> v(N);
    REP(i, N) cin >> v[i];
    return v;
}

int main(void)
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int> > A(N, vector<int>(M));
    REP(i, N) {
        cin >> C[i];
        REP(j, M)
            cin >> A[i][j];
    }
    int ret = INT_MAX;
    REP(mask, (1<<N)) {
        vector<int> S(M, 0);
        int cost = 0;
        REP(i, N) if ((mask >> i)&1) {
            REP(j, M) {
                S[j] += A[i][j];
            }
            cost += C[i];
        }
        bool ok = true;
        REP(i, M) if (S[i] < X) {
            ok = false;
            break;
        }
        if (ok) {
            ret = min(cost, ret);
        }
    }
    if (ret == INT_MAX) {
        cout << -1 << endl;
    }
    else {
        cout << ret << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
use proconio::input;
use std::collections::BTreeMap;
use std::cmp::Reverse;

fn main() {
    input! {
        n: usize,
        mut h: usize,
        ab: [(usize, usize); n],
    }

    let mut map = BTreeMap::new();

    for (a, b) in ab {
        if let Some(val) = map.get_mut(&Reverse(a)) {
            *val = h;
        } else {
            map.insert(Reverse(a), h);
        }

        if let Some(val) = map.get_mut(&Reverse(b)) {
            *val += 1;
        } else {
            map.insert(Reverse(b), 1);
        }
    }

    let mut count = 0;

    for (Reverse(key), val) in map.into_iter() {
        let div = h / key;
        if div < val {
            count += div;
            if h % key != 0 {
                count += 1;
            }
            break;
        }
        
        h -= key * val;
        count += val;
    }

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


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

int k,x;

void solve(){
    cin>>k>>x;
    for(int i=x-k+1; i<x+k; i++){
        if(i!=x-k+1)cout<<" ";
        cout<<i;
    }
    cout<<endl;
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
#include <stdio.h>

  int main(){
    long long int a,sum1=0;
    scanf("%lld",&a);
    for(int i=1;i<=a;i++){
      if(i%3!=0&&i%5!=0){
        sum1+=i;  
      }
  }
  printf("%lld",sum1);
  return 0;
  }


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;

  vector<int64_t> data(n);
 
  for (int i = 0; i < n; i++) {
    cin >> data.at(i);
  }
  
  int64_t total = 0;
  int64_t crtmax = data.at(0);
  for(int i=1;i<n;i++){
    if(data.at(i) < crtmax){
      //cout << "add at index " << i << ", " << crtmax - data.at(i) << endl;
      total += crtmax - data.at(i);
      data.at(i) = crtmax;
    }
    crtmax = max(data.at(i),crtmax);
  }
  
  //for(int64_t a : data){
  //  cout << a << endl;
  //}
  
  cout << total << endl;
  
  return 0; 
}


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

int dp[41][1<<18];
int main()
{
    int n, x, y, z; cin>>n>>x>>y>>z;
    const int mod=1e9+7;

    int xyz=(1<<x+y+z-1)|(1<<y+z-1)|(1<<z-1);
    int mask=(1<<x+y+z)-1;

    dp[0][0]=1;
    for(int i=0; i<n; ++i) {
        for(int j=1; j<=10; ++j) {
            for(int k=0; k<=mask; ++k) {
                int t=(k<<j|1<<j-1)&mask;
                if ((t&xyz)!=xyz)
                    (dp[i+1][t]+=dp[i][k])%=mod;
            }
        }
    }

    long res=1;
    for(int i=0; i<n; ++i) (res*=10)%=mod;
    for(int i=0; i<=mask; ++i) {
        res-=dp[n][i];
        (res+=mod)%=mod;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 20864
#include<stdio.h>
int main(void)
{
	int n,m,i,j,a[10000],b,c[10000]={0};
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=j=1;i<=m;i++,j=1){
		scanf("%d",&b);
		while(a[j]>b){
			if(a[j]<=b)break;
			j++;
		}
		c[j]+=1;
	}
	b=0;
	m=0;
	for(i=1;i<=n;i++)
	if(b<c[i]){
		b=c[i];
		m=i;
	}
	printf("%d\n",m);
	return 0;
}



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

int bubbleSort(int *arr, int n);

int main(int argc, char *argv[])
{
    int n, tmp;
    vector<int> v;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        v.push_back(tmp);
    }

    long sum = 0;
    for_each(v.begin(), v.end(), [&sum](int x) { sum += static_cast<long>(x); });
    sort(v.begin(), v.end());
    
    cout << v.front() << " " << v.back() << " " << sum << endl;

    return 0;
}

Measured memory_bytes: 3280
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()
mod = 10**9 + 7

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

    B = []
    for i, a in enumerate(A):
        B.append((a, i + 1))
    B.sort()
    #print(B)

    """
    活発度が大きい方から左右どちらかの端に移動させるが左右どちらになるかは一般に不明。
    しかし端から埋まるのは明らか（厳密な論証はmaspyさんの解説がわかりやすい）なので、
    ここから先をDPすればよい。具体的には
        dp[n][L] = (n人並べているとして左にL人いるときのうれしさの最大値)
    とすれば、これよりdp[n+1][L], dp[n+1][L+1]が更新できる。
    またn人の部分はdpとdp2間の遷移にしてメモリ削減。
    """

    dp = [0] * (N + 1)
    for n in range(1, N + 1):
        (a, i) = B.pop()
        dp2 = [0] * (N + 1)
        dp2[0] = dp[0] + a * abs((N - n + 1) - i)
        for l in range(1, n): # 1-indexedなことに注意
            dp2[l] = max(dp[l - 1] + a * abs(i - l), dp[l] + a * abs((N - n + l + 1) - i))
        dp2[n] = dp[n - 1] + a * abs(n - i)
        dp = dp2
        #print("{}人配置→dp={}".format(n, dp))
    print(max(dp))


if __name__ == "__main__":
    main()


Measured memory_bytes: 69276
#include<bits/stdc++.h>
using namespace std;
int main()
{
   char b;
   cin>>b;
   if(b=='A')
   {
       cout<<"T"<<endl;
       return 0;
   }
   else if(b=='T')
   {
       cout<<"A"<<endl;
       return 0;
   }
   else if(b=='C')
   {
     cout<<"G"<<endl;
       return 0;
   }
   else if(b=='G')
   {
     cout<<"C"<<endl;
       return 0;
   }
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	int  n, u, v;
	cin >>n >>u >>v;
	u--; v--;
	vector<VI> rd(n);
	rep(i, n-1){
		int a,b;
		cin >>a >>b;
		rd[a-1].push_back(b-1);
		rd[b-1].push_back(a-1);
	}

	const int INF= 1<<28;
	auto bfs = [&](int sy) -> VI{
		VI dd(n, INF);
		queue< int > que;
		que.emplace(sy); dd[sy]=0;
		while(!que.empty()){
			int cy = que.front();
			que.pop();
			for(auto z: rd[cy]){
				if(dd[z] == INF ){
					que.emplace(z);
					dd[z] = dd[cy] + 1;
				}
			}
		}
		return dd;
	};	
	
	auto fru = bfs(u);
	auto frv = bfs(v);
	//for(auto x :fru) cerr<<x<<" "; cerr<<"    u\n";
	//for(auto x :frv) cerr<<x<<" "; cerr<<"    v\n";
	int ans = 0;
	rep(i, n) if(fru[i] < frv[i]) ans = max(ans, frv[i]);
	cout << ans -1 <<"\n";
	return 0;
}


Measured memory_bytes: 6656
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0, k = 0;
    cin >> n >> k;
    vector<int> cnt(200001);
    int buf = 0;
    for (int i=0; i<n; i++) {
        cin >> buf;
        cnt.at(buf)++;
    }
    int kind = 0;
    sort(cnt.begin(), cnt.end());
    for (int a : cnt) {
        if (a > 0) {
            kind++;
        }
    }
    int now = 0, ans = 0;
    while (kind > k) {
        while (cnt.at(now) == 0) {
            now++;
        }
        ans += cnt.at(now);
        now++;
        kind--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){
    string w;
    cin >> w;
    int cnt = 0;
    while(1){
        string t;
        cin >> t;
        if(t == "END_OF_TEXT")break;

        if(0 == strcasecmp(w.c_str(),t.c_str()))cnt++;
    }
    cout << cnt << endl;




}


Measured memory_bytes: 3172
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;
#define N 2010
#define mod 1000000007
#define foru(i,l,r) for (int i=l; i<=r; i++)
#define ford(i,r,l) for (int i=r; i>=l; i--)
#define read(x) ((x)=getint())
#define inc(a,b) (((a)+=(b))%=mod)
#define mul(a,b) (LL(a)*(b)%mod)
typedef long long LL;

int n,k,fac[N*N],inv[N*N],f[N][N];

int getint()
{
	int x,f=1; char ch;
	while (!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	x=ch-'0';
	while (isdigit(ch=getchar())) x=x*10+ch-'0';
	return f*x;
}
int C(int n, int m)
{
	if (n<0||n<m) return 0;
	return mul(mul(fac[n],inv[m]),inv[n-m]);
}
int main()
{
	read(n), read(k);
	if (k==1) return puts("1"), 0;
	fac[0]=inv[0]=fac[1]=inv[1]=1;
	foru(i,2,n*k) fac[i]=mul(fac[i-1],i);
	foru(i,2,n*k) inv[i]=mul(mod-mod/i,inv[mod%i]);
	foru(i,2,n*k) inv[i]=mul(inv[i],inv[i-1]);
	f[0][0]=1;
	foru(i,0,n)
		ford(j,i,0)
		{
			inc(f[i+1][j+1],mul(C(i*k-j+k-2,k-2),f[i][j]));
			if (j) inc(f[i][j-1],f[i][j]);
		}
	printf("%lld\n",mul(f[n][0],fac[n]));
	return 0;
}

Measured memory_bytes: 46464
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <complex>
#include <cstring>

using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, a, b) for(int i = (a); i > (b); i--)
#define forIt(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define ft(a) __typeof((a).begin())
#define ll long long
#define ld long double
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define bitcount(n) __builtin_popcountll(n)


typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int N = 1000000 + 7;
const int M = 20;
const int inf = 786433;
const long long linf = 1e18 + 7;
const double pi = acos(-1);
const double eps = 1e-7;
//const double PI = acos(-1);


ll n, x;

ll calc(ll a, ll b) {
    if (a > b) return calc(b, a);
    if (b % a == 0) {
        return ((b / a) * 2 - 1) * a;
    }
    
    ll r = b % a;
    ll ans = (b / a) * 2 * a;
    //cout << a - r << " " << r << " " << calc(a - r, r) << "\n";
    ans += calc(r, a);
    return ans;
}

void solve() {
    cin >> n >> x;
    if (x == n - x) {
        cout << 3 * x ;
        return;
    }
    
    
    ll ans = 0;
    
    if (x < n - x) {
        ans = n + calc(x, n - x);
    } else {
        ans = n + calc(n - x, x);
    }
    
    cout << ans;
    
}

int main() {
//    freopen("alpinism.in", "r", stdin);
//    freopen("alpinism.out", "w", stdout);
    //freopen("in.txt", "r", stdin);
    int T = 1;
    //    cin >> T;
    rep(i, 1, T + 1) {
        //printf("Case #%d: ", i);
        solve();
    }
    
}

Measured memory_bytes: 256
import sys

while True:
    n = sys.stdin.readline()

    cnt = 0
    if n:
        for a in range(10):
            for b in range(10):
                for c in range(10):
                    for d in range(10):
                        if (a + b + c + d == int(n)):
                            cnt += 1
        print cnt

    else:
        break
    

Measured memory_bytes: 4204
#include <stdio.h>
#include <stdlib.h>

int main() {
    int n;
    int* array;
    int index = 0;
    int min, max;
    long long int sum;

    scanf("%d", &n);
    array = (int*)malloc(sizeof(int) * n);

    for (index = 0; index < n; index++) {
        scanf("%d", &array[index]);
    }
    
    min = array[0];
    max = array[0];
    sum = array[0];

    for (index = 1; index < n; index++) {
        if (min > array[index]) min = array[index];
        if (max < array[index]) max = array[index];
        sum += array[index];
    }

    printf("%d %d %lld\n", min, max, sum);

    free(array);

    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  int a, b, m;
  cin >> a >> b >> m;

  vi va;
  vi vb;
  
  int min_a = 100005;
  for (int i = 0; i < a; ++i) {
    int k;
    cin >> k;

    va.pb(k);
    min_a = min(min_a, k);
  }

  int min_b = 100005;
  for (int i = 0; i < b; ++i) {
    int k;
    cin >> k;

    vb.pb(k);
    min_b = min(min_b, k);
  }

  int res = min_a+min_b;

  for (int i = 0; i < m; ++i) {
    int xi, yi, ci;
    cin >> xi >> yi >> ci;
    xi--; yi--;

    res = min(res, va.at(xi)+vb.at(yi)-ci);
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1528
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a >> b >>c;
    if(a < b){
        if(b < c){
            cout << a << " " << b << " " << c << endl;
        }else{
            if(a < c){
                cout << a << " " << c << " " << b << endl;
            }else{
                cout << c << " " << a << " " << b << endl;
            }
        }
    }else{
        if(b < c){
            if(a < c){
                cout << b << " " << a << " " << c << endl;
            }else{
                cout << b << " " << c << " " << a << endl;
            }
        }else{
            cout << c << " " << b << " " << a << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3068
s = list(input())
s2 = list(reversed(s))
ss = s[:((len(s)-1)//2)]
ss2 = list(reversed(ss))
sss = s[-((len(s)-1)//2):]
sss2 = list(reversed(sss))
if s == s2 and ss == ss2 and sss == sss2:
         print("Yes")
else:
         print("No")



Measured memory_bytes: 3060
#include <stdio.h>

int n, A[2000];


int ExhaustiveSearch(int i, int m){
    if(m == 0)
    return 1;
    if(i >= n)
    return 0;

    int res = ExhaustiveSearch(i + 1, m) || ExhaustiveSearch(i + 1, m - A[i]);
    return res;
}



int main(){

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

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

int main() {
  constexpr int kMax = 1000000;
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  int gcd = 0;
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
    gcd = std::gcd(gcd, A[i]);
  }
  if (gcd != 1) {
    std::cout << "not coprime" << std::endl;
    return 0;
  }
  std::vector<bool> is_prime(kMax + 1, true);
  is_prime[0] = is_prime[1] = false;
  std::vector<int> primes;
  for (int p = 2; p <= kMax; ++p) {
    if (is_prime[p]) {
      primes.push_back(p);
      for (int j = p * 2; j <= kMax; j += p) {
        is_prime[j] = false;
      }
    }
  }
  std::vector<bool> seen(kMax + 1);
  bool duplicated = false;
  for (int i = 0; i < N; ++i) {
    auto a = A[i];
    if (is_prime[a]) {
      if (seen[a]) {
        duplicated = true;
        break;
      }
      seen[a] = true;
    } else {
      for (const auto p : primes) {
        if (p > a) break;
        if (a % p == 0) {
          if (seen[p]) {
            duplicated = true;
            break;
          }
          seen[p] = true;
          do {
            a /= p;
          } while (a % p == 0);
        }
      }
    }
    if (duplicated) break;
  }
  if (duplicated) {
    std::cout << "setwise coprime" << std::endl;
  } else {
    std::cout << "pairwise coprime" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 7880
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define F first
#define S second   
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).end()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef vector<int> vi;
typedef pair<int, int> pii; 
typedef pair<int , pii> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

int id[N] , sz[N];
void init(int n){ rep(i , n + 1) id[i] = i , sz[i] = 1; }
int rt(int x){ return (x == id[x] ? x : id[x] = rt(id[x]));}
void merge(int x, int y){
    x = rt(x);
    y = rt(y);
    if(sz[x] > sz[y]) swap(x , y);
    if(x == y) return;
    sz[y] += sz[x];
    sz[x] = 0;
    id[x] = y; 
}

vi adj[N] , gadj[N];

void solve()
{
    int n , m , k;
    cin >> n >> m >> k ;
    init(n);
    rep(i , m){
        int x, y;
        cin >> x >> y;
        --x , --y ; 
        gadj[x].pb(y);
        gadj[y].pb(x);
        merge(x , y);
    }
    rep(i , k){
        int x , y;
        cin >> x >> y;
        --x , --y;
        adj[x].pb(y);
        adj[y].pb(x);
    }

    rep(i , n){
        int res = sz[rt(i)] - sz(gadj[i]) - 1;
        trav(x , adj[i])
            if(rt(x) == rt(i)) res--;
        cout << res << ' '; 
    }
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 26740
#include<iostream> 
using namespace std;
int main(){
    int val, num, sum = 0;
    cin >> val;
    num = val;
    while (num != 0)
    {
        sum = sum + num % 10;
        num = num / 10;
    }
    if(val%sum==0)cout<<"Yes";
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 3624
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
from functools import lru_cache, reduce
INF = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# ここから書き始める
N = int(input())
ans = INF
for A in range(1, int(sqrt(N)) + 1):
    if N % A != 0:
        continue
    B = N // A
    A_length = len(str(A))
    B_length = len(str(B))
    ans = min(ans, max(A_length, B_length))
print(ans)

Measured memory_bytes: 65772
#include<stdio.h>

int main(void)
{
  int n, a[100], i, j, x, count=1;

  scanf("%d", &n);

  for (i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }

  for (i = 0; i < n; ++ i) {
    for (j = 0; j < n-1; ++ j) {     
      if (a[j] < a[j+1]) {
        x = a[j];
        a[j] = a[j + 1];
        a[j + 1] = x;
      }
    }
  }

  x = a[0];
  for (i = 1; i < n; i++) {
    if( x > a[i] ) {
      x = a[i];
      count++;
    }
  }

  printf("%d", count);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int n,m,x,y,k;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> m >> x >> y;
	rep(n){
		cin >> k;
		x=max(x,k);
	}
	rep(m){
		cin >> k;
		y=min(y,k);
	}
	print1(x>=y?"War":"No War");
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int n,k,a[100007];
int gcd(int x,int y){return !y ? x:gcd(y,x%y);}
int main(){
	scanf("%d%d",&n,&k);
	int g;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(i==1)g=a[i];
		else g=gcd(g,a[i]);
	}
	for(int i=1;i<=n;++i)
		if(a[i]>=k && (a[i]-k)%g==0){
		    printf("POSSIBLE");
			return 0;
		}
	printf("IMPOSSIBLE");
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int mp[555555];
int ret[555555];

int main(){

	int r,s,p;cin >> r >> s >> p;
	REP(i,p){
		int a,b;cin >> a >> b;
		if(b <= s) {
			mp[abs(a - (r + 1)) + abs(b - (s + 1))]++;
		}
		else{
			mp[abs(a - (r + 1)) + abs(b - s)]++;
		}
	}

	int seica = 0;
	REP(i,555554){
		seica += mp[i];
		if(seica){
			ret[i]++;
			seica--;
		}
	}

	for(int i = 555554;i >= 0;i--){
		if(ret[i]){
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,B,C,D;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B>>C>>D;
	
	while(1) {
		C-=B;
		if(C<=0) return _P("Yes\n");
		A-=D;
		if(A<=0) return _P("No\n");
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

const int P = 1000 * 1000 * 1000 + 7;

void Add(vector<int>& fen, int pos, int val) {
	for (int x = pos; x < sz(fen); x = (x | (x + 1))) {
		fen[x] = (fen[x] + val) % P;
	}
}

int Sum(vector<int>& fen, int pos) {
	int res = 0;
	for (int x = pos; x >= 0; x = (x & (x + 1)) - 1) {
		res = (res + fen[x]) % P;
	}
	return res; 
}

int main () {
    ios_base::sync_with_stdio(0);
//	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);

	int n;
	cin >> n;

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

   	vector<int> xs = x;
   	vector<int> vs = v;

   	sort(xs.begin(), xs.end());
    sort(vs.begin(), vs.end());

    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
    	int x_ind = lower_bound(xs.begin(), xs.end(), x[i]) - xs.begin();
    	int v_ind = lower_bound(vs.begin(), vs.end(), v[i]) - vs.begin();
    	p[x_ind] = v_ind;
    }

    vector<int> left(n);
    vector<int> right(n);
    
    right[0] = p[0] + 1;
    for (int i = 1; i < n; ++i) {
    	right[i] = max(right[i - 1], p[i] + 1);
    }

    left[n - 1] = p[n - 1];
    for (int i = n - 2; i >= 0; --i) {
    	left[i] = min(left[i + 1], p[i]);
    }

    vector<int> res(n + 1, 0);
    vector<int> fen(n + 1, 0);
    res[0] = 1;
    Add(fen, 0, 1);

    for (int i = 0; i < n; ++i) {
    	int sum = Sum(fen, right[i]) - Sum(fen, left[i] - 1);
    	sum = (sum + P) % P;
    	res[right[i]] = (res[right[i]] + sum) % P;
    	Add(fen, right[i], sum);
    }

    cout << res[n] << endl;

	return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  if (n % 2 == 1)
  {
    n++;
  }
  if (n / 2 >= k)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import numpy as np
from collections import deque

H, W = map(int, input().split())
board = np.ones((H, W))
for i in range(H):
    for j, c in enumerate(input()):
        if c == '#':
            board[i, j] = 0

history = np.zeros((H, W))
history[0, 0] = 1

dirs = [(1, 0), (-1, 0), (0, 1), (0, -1)]
q = deque()
q.append((0, 0))
# 幅優先探索
while len(q):
    p = q.popleft()

    # ゴール
    if p == (H - 1, W - 1):
        break

    for d in dirs:
        # 移動
        nxt = (p[0] + d[0], p[1] + d[1])

        # 迷路内
        if not (0 <= nxt[0] < H and 0 <= nxt[1] < W):
            continue

        # 白マスでない
        if board[nxt[0], nxt[1]] == 0:
            continue

        # 訪問済
        if history[nxt[0], nxt[1]] != 0:
            continue

        q.append(nxt)
        history[nxt[0], nxt[1]] = history[p[0], p[1]] + 1

if history[-1, -1] == 0:
    print(-1)
else:
    print(int(board.sum() - history[-1, -1]))


Measured memory_bytes: 18920
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

N, A, B, C = (int(i) for i in input().split())
T = []
for i in range(N):
    T.append(int(input()))
res = float("inf")
for i in range(4**N):
    L = [0] * N
    cc = i
    ans = 0
    for j in range(N):
        L[j] = cc//4**(N-1-j)
        cc %= 4**(N-1-j)
    a = b = c = 0
    if 1 not in L or 2 not in L or 3 not in L:
        continue
    for j in range(N):
        if L[j] == 1:
            if a != 0:
                ans += 10
            a += T[j]
        elif L[j] == 2:
            if b != 0:
                ans += 10
            b += T[j]
        elif L[j] == 3:
            if c != 0:
                ans += 10
            c += T[j]
    ans += abs(A-a) + abs(B-b) + abs(C-c)
    res = min(res, ans)
print(res)


Measured memory_bytes: 47468
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(b%a == 0) {
            System.out.println(a + b);
        } else {
            System.out.println(b - a);
        }
    }
}


Measured memory_bytes: 20692
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine(T * ((N + X - 1) / X));
	}
	int N,X,T;
	public Sol(){
		var d = ria();
		N = d[0]; X = d[1]; T = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main() {
    int n, w;
    cin>>n>>w;
    int wt[n+1], v[n+1];
    wt[0]=0, v[0]=0;
    for(int i=1; i<=n; i++){
        cin>>wt[i]>>v[i];
    }
    
    long long int mat[n+1][w+1];
    
    for(int i=0; i<=n; i++){
        mat[i][0]=0;
    }
    
    for(int i=0; i<=w; i++){
        mat[0][i]=0;
    }
    
    for(int i=1; i<=n; i++){
        for(int j=1; j<=w; j++){
            if(wt[i]>j) mat[i][j]=mat[i-1][j];
            else mat[i][j]=max(mat[i-1][j], mat[i-1][j-wt[i]]+v[i]);
        }
    }
    
    cout<<mat[n][w];
    
    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007

int32_t main()
{

	ios::sync_with_stdio(0), cin.tie(0);

	int t = 1;
	cin >> t;

    int cnt = 0, res = 0;

	while(t--)
	{
        int x, y;
        cin >> x >> y;
        
        if(x == y) cnt++;
        else cnt = 0;

        if(cnt == 3) res = 1;
	}

    if(res == 1) cout<<"Yes\n";
    else cout<<"No\n";

	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> height;
    for(int i = 0; i < n; ++i) {
        int h;
        cin >> h;
        height.push_back(h);
    }
    vector<bool> good(n, true);
    for(int i = 0; i < m; ++i) {
        int c1, c2;
        cin >> c1 >> c2;
        if (good[c1 - 1]) {
            if (height[c1- 1] <= height[c2 - 1]) {
                good[c1 - 1].flip();
            }
        }
        if (good[c2 - 1]) {
            if (height[c2 - 1] <= height[c1 - 1]) {
                good[c2 - 1].flip();
            }
        }
    }
    cout << accumulate(good.begin(), good.end(), 0) << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3928
n,a,b=map(int,input().split())
s=input().strip()
njp=0
nop=0
for i in range(len(s)):
  if s[i]=='a':
    if njp<(a+b):
      njp+=1
      print('Yes')
    else:
      print('No')
  elif s[i]=='b':
    if njp<(a+b):
      if nop<b:
        nop+=1
        njp+=1
        print('Yes')
      else:
        print('No')
    else:
      print('No')
  else:
    print('No')


Measured memory_bytes: 9240
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


class BinaryIndexTree:
    def __init__(self, n):
        self._size = n
        self._tree = [0] * (n+1)

    def sum(self, i):
        s = 0
        i += 1
        while 0 < i:
            s += self._tree[i-1]
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self._size:
            self._tree[i-1] += x
            i += i & -i


def solve(N: int, a: "List[int]"):
    c = N * (N + 1) // 2
    th = (c + 1) // 2

    xs = list(sorted(set(a)))
    lo = 0
    hi = len(xs)

    def _f(x):
        ss = [0] + list(accumulate([1 if x <= v else -1 for v in a]))
        n = max([abs(s) for s in ss])
        bit = BinaryIndexTree(2 * n + 1)

        ret = 0
        for s in ss:
            ret += bit.sum(s + n) 
            bit.add(s + n, 1)
        return ret

    while (lo + 1) < hi:
        mid = (lo + hi) // 2
        if th <= _f(xs[mid]):
            lo = mid
        else:
            hi = mid
    return xs[lo]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, a)
    print(result)

if __name__ == '__main__':
    main()


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e10;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)
typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;


int main() {
    int x, y;
    cin >> x >> y;
    cout << x + (y / 2) << endl;
}



Measured memory_bytes: 256
#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;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set


int main() 
{
	ll n;
	cin>>n;
	ll sum = 0;
	REP(i,1,n+1){
		REP(j,1,n+1){
			REP(k,1,n+1){
				sum += __gcd(i,__gcd(j,k));
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}  


Measured memory_bytes: 3648
#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;
  cin >> n;

  if (n>81){
    cout << "No" << endl;
    return 0;
  }

  for (int i = 1; i <= 9; ++i){
    if(n % i == 0){
      if ( n/i < 10){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
 
using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
 
const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;
 
const int MAX = 50;
int N, Ma, Mb;
int a[MAX], b[MAX], c[MAX];
int dp[MAX][1000][1000];
 
int main(void) {
    scanf("%d%d%d", &N, &Ma, &Mb);
    REP(i, N) {
        scanf("%d%d%d", a + i, b + i, c + i);
    }
    REP(i, MAX)REP(j, 1000) REP(k, 1000) {
        dp[i][j][k] = INF;
    }
    dp[0][0][0] = 0;
    REP(i, N) {
        REP(j, 1000) REP(k, 1000) {
            chmin(dp[i + 1][j][k], dp[i][j][k]);
            if (a[i] + j < 1000 && b[i] + k < 1000) {
                chmin(dp[i + 1][a[i] + j][b[i] + k], dp[i][j][k] + c[i]);
            }
        }
    }
    int ma = Ma, mb = Mb;
    int ans = INF;
    while (ma < 1000 && mb < 1000) {
        chmin(ans, dp[N][ma][mb]);
        ma += Ma; mb += Mb;
    }
    if (ans == INF) ans = -1;
    cout << ans << endl;
}

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

int main(){
  int A, B, C, D, E;
  cin>>A>>B>>C>>D>>E;
  vector<int> menu ={A, B, C, D, E};
  int time=0;
  int min=10;
  for(int i=0; i<5; i++){
    int amari=menu.at(i)%10;
    if(amari!=0 && amari<min) min=amari;
    if(amari==0) time+=menu.at(i);
    if(amari!=0) time=time+menu.at(i)-amari+10; 
  }
  cout<<time-10+min<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,can,arr[111],ans;

int main(){
    scanf("%d %d",&n,&can);
    for(int i=1;i<=n;i++) scanf("%d",&arr[i]);
    sort(arr+1,arr+1+n);
    for(int i=1;i<n;i++){
        if(arr[i] <= can) ans++;
        else break;
        can-=arr[i];
    }
    printf("%d",ans+(arr[n] == can));
}


Measured memory_bytes: 256