akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

template<typename Monoid>
struct SegmentTree{
    using F=function<Monoid(Monoid,Monoid)>;
    int sz;
    vector<Monoid> seg;
    const F f;
    const Monoid gen;
    SegmentTree(int n,const F f,const Monoid &gen):f(f),gen(gen){
        sz=1;
        while(sz<n)sz<<=1;
        seg.assign(2*sz,gen);
    }
    void set(int k,const Monoid &x){
        seg[k+sz]=x;
    }
    void build(){
        for(int k=sz-1;k>0;k--) seg[k]=f(seg[2*k],seg[2*k+1]);
    }
    void update(int k,const Monoid &x){
        k+=sz;
        seg[k]=x;
        while(k>>=1) seg[k]=f(seg[2*k],seg[2*k+1]);
    }
   // [a,b)
    Monoid query(int a,int b){
        Monoid L=gen,R=gen;
        for(a+=sz,b+=sz;a<b;a>>=1,b>>=1){
            if(a&1) L=f(L,seg[a++]);
            if(b&1) R=f(seg[--b],R);
        }
        return f(L,R);
    }
    Monoid operator[](const int &k)const {
       return seg[k+sz];
    }
};
ll f(ll a,ll b){
    return a+b;
}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    SegmentTree<ll> seg(200000,f,0);
    vector<ll> cnt(200000,0);
    rep(i,n){
        ll a;cin>>a;
        cnt[a]++;
    }
    rep(i,200000){
        seg.set(i,cnt[i]*i);
    }
    seg.build();

    int q;cin>>q;
    rep(i,q){
        ll b,c;cin>>b>>c;
        seg.update(b,0);
        cnt[c]+=cnt[b];
        cnt[b]=0;
        seg.update(c,c*cnt[c]);

        cout<<seg.query(0,200000)<<endl;
    }

    return 0;
}


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

  int n,y;
  int bangou;
  double kinri;
  int syurui;
  double max;
  int maxb;
  double sum,sum1;
  int i,j;


  while(1){
    max=0;

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

    scanf("%d",&y);

    for(i=0;i<n;i++){

      scanf("%d %lf %d",&bangou,&kinri,&syurui);


      if(syurui==1){

	sum=1+(double)y*kinri/100;

      }else if(syurui==2){

	sum1=1+(double)kinri/100;

	sum=1;
	for(j=1;j<=y;j++){

	  sum*=sum1;
	

	}


      }

      if(sum>max){
	
	maxb=bangou;
	
	max=sum;
      }
      
    }


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

  }

  return 0;
}

Measured memory_bytes: 628
/*ALDS1_2_A:Bubble Sort*/

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#define N 100

int bubbleSort(int *A, int n);
void swap(int *A, int x, int y);

int main(void){
	int n, i = 0, A[N] = {0}, sw;

	scanf("%d", &n);
	while(i < n) scanf("%d", &A[i++]);

	sw = bubbleSort(A, n);

	for( i = 0; i < n; i++){
		if(i > 0) printf(" ");
		printf("%d", A[i]);
	}

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

	return 0;
}

int bubbleSort(int *A, int n){
	int sw = 0, i, j;

	for(i = 0; i < n-1; i++){
		for(j = n-1; j > i; j--){
			if(A[j] < A[j - 1]){
				swap(A, j, j-1);
				sw++;
			}
		}
	}

	return sw;
}

void swap(int *A, int x, int y){
	int temp;

	temp = A[x];
	A[x] = A[y];
	A[y] = temp;
}


Measured memory_bytes: 1960
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>

#define mod 998244353
#define sz 1<<20

long modpow(long x, long y, long m){
	long res = 1l, tmp = x;
	while(y){
		if(y&1)res = res * tmp % m;
		tmp = tmp * tmp % m;
		y >>= 1;
	}
	return res;
}

int bit_rev[sz];
__attribute__((constructor))
void bit_rev_init(){
	int _bit_rev(int x){
		int res = 0;
		for(int i=0; i<20; i++){
			res <<= 1;
			res |= x&1;
			x >>= 1;
		}
		return res;
	}
	for(int i=0; i<sz; i++){
		bit_rev[i] = _bit_rev(i);
	}
	return;
}
void bit_rev_perm(long a[], int h){
	long *A = (long*)malloc(sizeof(long) * (1<<h));
	memcpy(A, a, sizeof(long) * (1<<h));
	for(int i=0; i<1<<h; i++){
		a[bit_rev[i]] = A[i];
	}
	free(A);
	return;
}
void dft(long a[], bool sign){
	bit_rev_perm(a, 20);
	for(int s=1; s<=20; s++){
		int tmp = 1<<s;
		long zeta = modpow(3, (mod-1)>>s, mod);
		if(!sign)zeta = modpow(zeta, mod-2, mod);
		for(int k=0; k<sz; k+=tmp){
			long pow_zeta = 1;
			for(int j=0; j<tmp/2; j++){
				long t = pow_zeta * a[k+j+tmp/2] % mod,
					 u = a[k+j];
				a[k+j] = (u + t) % mod;
				a[k+j+tmp/2] = (mod + u -t) % mod;
				pow_zeta = pow_zeta * zeta % mod;
			}
		}
	}
	return;
}

int N, M;
long A[sz], B[sz];
int main(){
	scanf("%d%d", &N, &M);
	for(int i=0; i<N; i++)scanf("%ld", &A[i]);
	for(int i=0; i<M; i++)scanf("%ld", &B[i]);
	dft(A, true); dft(B, true);
	for(int i=0; i<sz; i++)A[i] = A[i] * B[i] % mod;
	dft(A, false);
	long inv = modpow(sz, mod-2, mod);
	for(int i=0; i<N+M-1; i++){
		if(i)putchar(32);
		printf("%ld", A[i] * inv % mod);
	}putchar(10);
	return 0;
}

Measured memory_bytes: 39412
from itertools import accumulate
from operator import sub
N, C = map(int, input().split())
X, V = map(list, zip(*[tuple(map(int, input().split())) for _ in range(N)]))
VA = list(accumulate([0]+V))
VR = list(accumulate([0]+V[::-1]))
XR = [0]+list(map(lambda x:C-x, X[::-1]))
X = [0]+X
VA = list(accumulate(map(sub, VA, X), max))
VR = list(accumulate(map(sub, VR, XR), max))
print(max(VA[i]+VR[N-i]-min(X[i], XR[N-i]) for i in range(N+1)))

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

const int MOD = (int)1e9+7;

int main(){
  string S;
  cin >> S;

  vector<bool> nwse(4,false);
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='N')  nwse.at(0)=true;
    else if(S.at(i)=='W')  nwse.at(1)=true;
    else if(S.at(i)=='S')  nwse.at(2)=true;
    else if(S.at(i)=='E')  nwse.at(3)=true;
  }
  if(nwse.at(0)==nwse.at(2) && nwse.at(1)==nwse.at(3))  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
  mapping = {
    'pon': [0,1,6,8],
    'bon': [3],
    'hon': [2,4,5,7,9]
  }
  
  n = int(input()) % 10
  
  for k, vv in mapping.items():
    if n in vv:
      print(k)
  
  
if __name__ == '__main__':
  main()


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);

	ll b[n];
	b[0]=a[0];
	for(int i=1; i<n; i++) b[i]=b[i-1]+a[i];
	int cnt=0;
	for(int i=0; i<n-1; i++){
		if(2*b[i]<a[i+1]) cnt=i+1;
	}
	cout << n-cnt << endl;
	return 0;
}

Measured memory_bytes: 1792
import heapq

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

pq = []
for a in A:
    heapq.heappush(pq, -a)
for _ in range(M):
    a = (-heapq.heappop(pq)) // 2
    heapq.heappush(pq, -a)

print(-sum(pq))


Measured memory_bytes: 64916
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>

using namespace std;

int main() {

    string S;
    cin >> S;

    int num = 0;
    for (int i = 0; i < S.size(); ++i) {
        string sss = S.substr(i, 1);
        if (sss == "+") {
            ++num;
        } else {
            --num;
        }
    }

    cout << num << endl;
    return 0;
}


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

using namespace std;

char s[5];

int main() {
	scanf("%s", s);
	
	int l = strlen(s);
	
	for (int i = 0; i < l; i++) {
		if (s[i] == '7') return 0 * printf("Yes\n");
	}
	
	printf("No\n");
}


Measured memory_bytes: 3740
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
const int MAX = 1e5 + 10;
vector<int> z1, z2, z3, z4;
vector<int> z_function(string &s) {
    int n = s.size();
    vector<int> z(n);
    for (int i = 1, x = 0, y = 0; i < n; i++) {
        z[i] = max(0, min(z[i - x], y - i + 1));
        while (i + z[i] < n && s[z[i]] == s[i + z[i]]) {
            x = i, y = i + z[i], z[i]++;
        }
    }
    return z;
}
unordered_map<int, int> mp;
bool checksz(int x) {
    return z1[x] == 5 || z2[x] == 5 || z3[x] == 6 || z4[x] == 7;
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    string s;
    cin >> s;
    string t1 = "erase#" + s, t2 = "dream#" + s, t3 = "eraser#" + s, t4 = "dreamer#" + s;
    int n = sz(s);

    z1 = z_function(t1);
    z2 = z_function(t2);
    z3 = z_function(t3);
    z4 = z_function(t4);
    z1.erase(z1.begin(), z1.begin() + 6);
    z2.erase(z2.begin(), z2.begin() + 6);
    z3.erase(z3.begin(), z3.begin() + 7);
    z4.erase(z4.begin(), z4.begin() + 8);
    int cur = 0;
    bool ok = 0;
    int cnt = 0;
    while (1) {
        int op1 = cur + z1[cur], op2 = cur + z2[cur], op3 = cur + z3[cur], op4 = cur + z4[cur];
        if (op1 == n || op2 == n || op3 == n || op4 == n) {
            ok = 1;
            break;
        }
        if (op1 - 5 >= cur && checksz(op1)) {
            cur = op1;
        } else if (op2 - 5 >= cur && checksz(op2)) {
            cur = op2;
        } else if (op3 - 6 >= cur && checksz(op3)) {
            cur = op3;
        } else if (op4 - 7 >= cur && checksz(op4)) {
            cur = op4;
        } else {
            break;
        }
        cnt++;
        if (cnt > 1e6) break;
    }
    if (ok)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    // cout << "erase" << endl;
    // forn(i, sz(z1)) cout << z1[i] << " ";
    // cout << endl;
    // cout << "dream" << endl;
    // forn(i, sz(z2)) cout << z2[i] << " ";
    // cout << endl;
    // cout << "eraser" << endl;
    // forn(i, sz(z3)) cout << z3[i] << " ";
    // cout << endl;
    // cout << "dreamer" << endl;
    // forn(i, sz(z4)) cout << z4[i] << " ";
    // cout << endl;
    return 0;
}

Measured memory_bytes: 2384
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int x,t;
int main(){
	scanf("%d%d",&x,&t);
	printf("%d\n",max(0,x-t));
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
#define ll long long
using namespace std;
const int N=2e5+5,mo=1e9+7;
int n,a[N],ct[N],iv[N],pr[N],ipr[N],prx[N];
int ans,s;
struct nod{
	int mx,su,mi,su2,ct;
}t[N*4],an;
int ksm(int x,int y){
	int t=1;
	for(;y;y>>=1,x=(ll)x*x%mo)if(y&1)t=(ll)t*x%mo;
	return t;
}
void ch(int v,int l,int r,int x){
	if(prx[x]>t[v].mx)t[v].mx=prx[x],t[v].su=0;
	if(prx[x]==t[v].mx)t[v].su=(t[v].su+ipr[x])%mo;
	if(prx[x]<t[v].mi)t[v].mi=prx[x],t[v].su2=0;
	if(prx[x]==t[v].mi)t[v].su2=(t[v].su2+pr[x])%mo;
	++t[v].ct;
	if(l==r)return;
	int m=l+r>>1;
	if(x<=m)ch(v*2,l,m,x);else ch(v*2+1,m+1,r,x);
}
void qu(int v,int l,int r,int x){
	if(r<=x){
		if(t[v].mx>an.mx)an.mx=t[v].mx,an.su=0;
		if(t[v].mx==an.mx)an.su=(an.su+t[v].su)%mo;
		return;
	}
	int m=l+r>>1;
	if(x<=m){
		if(t[v*2+1].mi<an.mi)an.mi=t[v*2+1].mi,an.su2=0;
		if(t[v*2+1].mi==an.mi)an.su2=(an.su2+t[v*2+1].su2)%mo;
		an.ct+=t[v*2+1].ct;
		qu(v*2,l,m,x);
	}else{
		if(t[v*2].mx>an.mx)an.mx=t[v*2].mx,an.su=0;
		if(t[v*2].mx==an.mx)an.su=(an.su+t[v*2].su)%mo;
		qu(v*2+1,m+1,r,x);
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	fo(i,1,n)cin>>a[i],++ct[a[i]];
	fd(i,1,n-1)ct[i]+=ct[i+1]-1;
	fo(i,1,n)if(ct[i]<=0)return puts("0"),0;
	iv[1]=1;
	fo(i,2,n)iv[i]=mo-(ll)iv[mo%i]*(mo/i)%mo;
	s=1;
	pr[0]=1;
	fo(i,1,n){
		s=(ll)s*ct[i]%mo;
		prx[i]=prx[i-1];
		pr[i]=pr[i-1];
		if(ct[i]==1)++prx[i];else pr[i]=(ll)pr[i]*(ct[i]-1)%mo*iv[ct[i]]%mo;
		ipr[i]=ksm(pr[i],mo-2);
	}
	fo(i,1,n*4)t[i].mi=N,t[i].mx=-1;
	fo(i,1,n){
		an.ct=an.su=an.su2=0;
		an.mx=-1;an.mi=N;
		int y=a[i];
		qu(1,1,n,y);
		if(an.mx==prx[y])ans=((ll)an.su*pr[y]%mo*iv[2]%mo*s+ans)%mo;
		if(an.mi==prx[y])ans=(-(ll)an.su2*ipr[y]%mo*iv[2]%mo*s+ans)%mo;
		ans=((ll)an.ct*s+ans)%mo;
		ch(1,1,n,y);
	}
	cout<<(ans+mo)%mo;
}

Measured memory_bytes: 20608
import sys

input = sys.stdin.readline

def main():
    count = 1
    while True:
        a = int(input())
        if a == 0:
            sys.exit()
        else:
            print("Case " + str(count)+ ": " + str(a))
            count = count + 1 
    
if __name__ =="__main__":
    main()


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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 long long ll;

const long long INF = 1LL << 60;

int main()
{
    int c[3][3];

    rep(i, 3) {
        rep(j, 3) {
            cin >> c[i][j];
        }
    }

    bool flag = true;
    rep(i, 3) {
        int a1, a2, a3;
        int ch = 0;
        if (i == 2) {
            ch = 3;
        }
        a1 = c[i][0] - c[i + 1 - ch][0];
        a2 = c[i][1] - c[i + 1 - ch][1];
        a3 = c[i][2] - c[i + 1 - ch][2];
        if (a1 == a2 && a2 == a3 && a3 == a1) {
            flag = true;
        }
        else {
            flag = false;
            break;
        }
    }

    if (flag) {
        rep(i, 3) {
            int a1, a2, a3;
            int ch = 0;
            if (i == 2) {
                ch = 3;
            }
            a1 = c[0][i] - c[0][i + 1 - ch];
            a2 = c[1][i] - c[1][i + 1 - ch];
            a3 = c[2][i] - c[2][i + 1 - ch];
            if (a1 == a2 && a2 == a3 && a3 == a1) {
                flag = true;
            }
            else {
                flag = false;
                break;
            }
        }
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 20000000;
const int MOD = 998244353;
int pow_mod(int b, int p) {
	int ret = 1;
	while( p ) {
		if( p & 1 ) ret = 1LL*ret*b%MOD;
		b = 1LL*b*b%MOD;
		p >>= 1;
	}
	return ret;
}
int fct[MAXN + 5], ifct[MAXN + 5];
void init() {
	fct[0] = 1;
	for(int i=1;i<=MAXN;i++)
		fct[i] = 1LL*fct[i-1]*i%MOD;
	ifct[MAXN] = pow_mod(fct[MAXN], MOD-2);
	for(int i=MAXN-1;i>=0;i--)
		ifct[i] = 1LL*ifct[i+1]*(i+1)%MOD;
}
int pw1[MAXN + 5], pw2[MAXN + 5];
int main() {
	init();	int N, M;
	scanf("%d%d", &N, &M);
	int ans = 0;
	pw1[0] = pw2[0] = 1;
	for(int i=1;i<=max(N, M);i++)
		pw1[i] = 1LL*pw1[i-1]*(N+1)%MOD, pw2[i] = 1LL*pw2[i-1]*(M+1)%MOD;
	for(int i=0,f=1;i<=min(N,M);i++,f=1LL*f*(MOD-1)%MOD) {
		int del = 1LL*ifct[N-i]*ifct[M-i]%MOD*ifct[i]%MOD;
		del = 1LL*del*pw1[M-i]%MOD*pw2[N-i]%MOD;
		ans = (ans + 1LL*f*del)%MOD;
	}
	printf("%lld\n", 1LL*ans*fct[N]%MOD*fct[M]%MOD);
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007LL

#define MA 60

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

    int N; cin >>N;
    vector<int> popcnt(MA, 0);

    for (int i = 0; i < N; i++) {
        ll a; cin >> a;
        for (int b = 0; b < MA; b++) {
            if (a & (1LL<<b)) popcnt[b]++;
        }
    }
// cout_h(popcnt);
    ll ans = 0;
    for (int b = 0; b < MA; b++) {
        ans += (ll)popcnt[b] * (N - popcnt[b]) % MOD * ((1LL<<b) % MOD) % MOD;
        ans %= MOD;
        // ans += popcnt[b] * (N - popcnt[b]) * modpow(2ULL, b, (ull)MOD);
        // ans = (ans + popcnt[b] * (N-popcnt[b]) * modpow((ull)2, (ull)b, (ull)MOD) % (ull)MOD) % (ull)MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array

main = do
  n <- (read::String -> Int) <$> getLine
  print $ solve n 1


solve::Int -> Int -> Int
solve n digit
  | n < digit = 0
  | n >= digit * 10 = digit * 9 + solve n (digit * 100)
  | otherwise = n - digit + 1


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int a, b;
signed main() {
    cin >> a >> b;
    if (a + b == 15) {
        cout << "+" << endl;
    } else if (a * b == 15) {
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }
}

Measured memory_bytes: 256
import itertools
import math
n = int(input())
loc = []
for i in range(n):
    x,y = map(int,input().split())
    loc.append([x,y])
p = list(itertools.permutations(loc, n))
ans = 0
for i in range(len(p)):
    cnt = 0
    for j in range(n-1):
        a = p[i][j]
        b = p[i][j+1]
        cnt += ((a[0]-b[0])**2 + (a[1]-b[1])**2)**0.5
    ans += cnt
print(ans/math.factorial(n))



Measured memory_bytes: 7972
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
const int maxx=2*1e5+5;
int read(){
	char x=getchar(); int u=0;
	while(!isdigit(x)) x=getchar();
	while(isdigit(x)) { u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return u;
}
int a[maxx],b[maxx],l=1,n,m;
bool work(){
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	For(i,1,m){
		while(a[l]!=b[i]){ ++l; if(l>n) return false;}
		l++;
	}
	return true;
}
		
int main(){
//#ifndef ONLINE_JUDGE
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
//#endif
	n=read();
	For(i,1,n) a[i]=read();
	m=read();
	For(i,1,m) b[i]=read();
	if(!work()) puts("NO");
	else puts("YES");	
	return 0;
}

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

int main()
{
    long long int N, K;
    cin >> N;
    cin >> K;
    vector<long long int> P(N + 1);
    vector<long long int> C(N + 1);
    long long int i, j;
    for (i = 1; i < N + 1; i++)
    {
        cin >> P[i];
    }
    for (i = 1; i < N + 1; i++)
    {
        cin >> C[i];
    }
    vector<vector<long long int>> score(N + 1, vector<long long int>(N + 1));
    vector<vector<long long int>> move(N + 1, vector<long long int>(N + 1));
    vector<long long int> end(N + 1);
    for (i = 1; i < N + 1; i++)
    {
        score[i][0] = 0;
        move[i][0] = i;
        end[i] = -1;
        for (j = 1; j < N + 1; j++)
        {
            move[i][j] = P[move[i][j - 1]];
            if (move[i][j] == i && end[i] == -1)
            {
                end[i] = j;
            }
            score[i][j] = score[i][j - 1] + C[move[i][j]];
        }
    }
    long long int result = -1000000001;
    long long int ans;
    for (i = 1; i < N + 1; i++)
    {
        if (score[i][end[i]] > 0 && K > end[i])
        {
            ans = max(score[i][end[i]] * (K / end[i]) + *(max_element(score[i].begin(), score[i].begin() + K % end[i] + 1)), score[i][end[i]] * (K / end[i] - 1) + *(max_element(score[i].begin(), score[i].begin() + end[i] + 1)));
            if (ans > result)
            {
                result = ans;
            }
        }
        else if (K > end[i])
        {
            ans = *max_element(score[i].begin() + 1, score[i].begin() + end[i] + 1);
            if (ans > result)
            {
                result = ans;
            }
        }
        else
        {
            ans = *max_element(score[i].begin() + 1, score[i].begin() + K + 1);
            if (ans > result)
            {
                result = ans;
            }
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 394808
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 1010
#define P 1000000007
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
int n,m,a[N],b[N],posa[N*N],posb[N*N],ans;
int row,line;
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	n=read(),m=read();
	for (int i=1;i<=n;i++)
	{
		a[i]=read();
		if (posa[a[i]]) {cout<<0;return 0;}
		posa[a[i]]=i;
	}
	for (int i=1;i<=m;i++)
	{
		b[i]=read();
		if (posb[b[i]]) {cout<<0;return 0;}
		posb[b[i]]=i;
	}
	row=0,line=0;ans=1;
	for (int i=n*m;i>=1;i--)
	{
		if (posa[i]&&posb[i]) {row++,line++;continue;}
		if (!posa[i]&&!posb[i])
		{
			if (row*line-(n*m-i)<=0) {cout<<0;return 0;}
			ans=1ll*ans*(row*line-(n*m-i))%P;
		}
		if (posa[i]) ans=1ll*ans*line%P,row++;
		if (posb[i]) ans=1ll*ans*row%P,line++;
	}
	cout<<ans;
}

Measured memory_bytes: 2304
#include <iostream>

using namespace std;



struct pt {

	double x;

	double y;

};



int main() {

	int num;

	cin >> num;

	while(num--) {

		pt p1, p2, p3, p4;

		cin >> p1.x >> p1.y;

		cin >> p2.x >> p2.y;

		cin >> p3.x >> p3.y;

		cin >> p4.x >> p4.y;

		pt v1 = {p1.x-p2.x, p1.y-p2.y};

		pt v2 = {p3.x-p4.x, p3.y-p4.y};

		if (v1.y==0 && v2.y==0) cout << "YES\n";

		else if (v1.x/v1.y == v2.x/v2.y) cout << "YES\n";

		else cout << "NO\n";

	}

	return 0;

}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ull = unsigned long long;
using P = pair<int, int>;

static constexpr ull MOD = 1000000007;
static constexpr double pi = 3.14159265359;

ull N;
set<ull> ans;

bool is575(ull i) {
    set<char> s;
    for (char c : to_string(i)) {
        s.insert(c);
    }
    return s.count('3') && s.count('5') && s.count('7');
}

void dfs(ull i) {
    if (i > N) return;
    if (i != 0 && is575(i)) ans.insert(i);
    for (ull j : {3, 5, 7}) {
        dfs(10 * i + j);
    }
}

int main() {
    cin >> N;
    dfs(0);
    cout << ans.size() << endl;
}


Measured memory_bytes: 1536
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int MOD = 1000000007;

int main(){
  int N;
  cin >> N;
  int maxn,curr;
  cin >> maxn;
  for(int i=1;i<N;i++){
    cin >> curr;
    if(maxn - curr > 1){
      cout << "No";
      return 0;
    }
    maxn = max(curr, maxn);
  }
  cout << "Yes";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

int main() {
	int n;
	long long cnt = 0;
	std::cin >> n;
	long long h[100000];
	long long dp[100000];
	for (int i = 0; i < n; i++) {
		std::cin >> h[i];
		dp[i] = 0;
	}
	for (int i = 1; i < n; i++) {
		dp[i] = h[i - 1] >= h[i] ? (dp[i - 1] + 1) : 0;
	}
	std::cout << *std::max_element(dp, dp + n) << "\n";
	return 0;
}

Measured memory_bytes: 5184
#include <cstdio>
#include <algorithm>
using namespace std;

const int N = 100500;
int A[N];
typedef long long llong;


int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    int cur = 0;
    llong ans = 0;
    for (int i = 0; i < n; i++) {
        int a = A[i];
        if (a <= cur) {
            continue;
        } else if (a == cur + 1) {
            cur++;
            continue;
        } else {
            int q = a / (cur + 1);
            if (a == q * (cur + 1)) {
                ans += q - 1;
            } else {
                ans += q;
            }
            cur = max(1, cur);
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    
    if (m1 != m2) {
        cout << 1;
        return 0;
    } else if (m1 == m2){
        cout << 0;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,a[100111];
void check(int x)
{
	int cnt0=0,cnt1=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==x)cnt0++;
		else if(a[i]==x-1)cnt1++;
	}
	if(cnt0==1)return;
	assert(cnt0+cnt1==n);
	int lb=cnt0>0,ub=cnt0/2;
	lb+=cnt1;ub+=cnt1;
	if(lb<=x&&x<=ub)
	{
		puts("Yes");
		exit(0);
	}
}
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)geti(a[i]);
	int mn=a[1],mx=a[1];
	for(int i=1;i<=n;i++)mn=min(mn,a[i]),mx=max(mx,a[i]);
	if(mn<mx-1)
	{
		puts("No");
		return 0;
	}
	check(mx);
	if(mn==mx)check(mx+1);
	puts("No");
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int a[100000];

int parttion(int p, int r)
{
    int x, i, j;
    x = a[r];
    i = p - 1;
    for (int j = p; j < r; j++)
    {
        if (a[j] <= x)
        {
            i++;
            swap(a[i], a[j]);
        }
    }
    swap(a[i + 1], a[r]);
    return i + 1;
}

int main()
{
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];

    int q = parttion(0, n - 1);

    rep(i, n)
    {
        if (i)
            cout << " ";
        i == q ? cout << "[" << a[i] << "]" : cout << a[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3460
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#define _for(i,n) for(int i = 0; i < n; i++)

using namespace std;



int main() {
  int a,b,c,d,e,k;
  cin >> a >>b>>c>>d>>e>>k;
  if(e-a>k) cout << ":(" << endl;
  else cout << "Yay!" << endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    if (n%2 == 0) {
        string s;
        cin >> s;
        for (int i=0; i<n/2; i++) {
            if (s[i] != s[n/2+i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f;
int main () {
	cin >> a >> b >>c >>d;
	e= a*b;
	f= c*d;

if (e>f){
	cout << e << endl;
}
else{
	cout << f << endl;
}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int w,h,i,j;
    while(1){
        scanf("%d %d",&h,&w);
        if(w==0 && h==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2120
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
        int n;
        cin >> n;
        while(n > 0){ 
                double x[2] = {1,0};
                while(--n){
                        double _x[2] = {-x[1],x[0]};
                        for(int i = 0; i < 2; i++){
                                _x[i] /= pow(x[0]*x[0]+x[1]*x[1],0.5);
                        }   
                        for(int i = 0; i < 2; i++){
                                x[i] += _x[i];
                        }   
                }   
                printf("%.2f\n%.2f\n",x[0],x[1]);
                cin >> n;
        }   
}

Measured memory_bytes: 0
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int f[105][10], p[105][10];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) {
    REP(j, 10) cin >> f[i][j];
  }
  REP(i, n) {
    REP(j, 11) cin >> p[i][j];
  }

  int ret = -INF;
  FOR(i, 1, 1<<10) {
    int sum = 0;
    REP(j, n) {
      int cnt = 0;
      REP(k, 10) {
        if((i&1<<k) && f[j][k]) {
          cnt++;
        }
      }
      // cout << "j:" << j << " " << cnt << " " << p[j][cnt] << endl;
      sum += p[j][cnt];
    }
    // cout << bitset<10>(i) << " " << sum << endl;
    chmax(ret, sum);
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
s = list(input())
if s[0] == ">":
    s.insert(0, "<")
if s[len(s) - 1] == "<":
    s.append(">")
t = "<"
a, b = 0, 0
ans = 0
for i in s:
    if i == "<":
        if not b == 0:
            x = max(a, b)
            y = min(a, b) - 1
            ans += (x * (x + 1)) // 2 + (y * (y + 1)) // 2
            a, b = 0, 0
        a += 1
    else:
        b += 1
x = max(a, b)
y = min(a, b) - 1
ans += (x * (x + 1)) // 2 + (y * (y + 1)) // 2
print(ans)

Measured memory_bytes: 7712
//https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_b
//B - 仲良しうさぎ / Friendly Rabbits
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N; cin>>N;
    vector<ll> an(N+1,0);
    FOR(i,1,N+1){
        cin>>an.at(i);
    }
    ll ans=0;
    FOR(i,1,N+1){
        ll a=an.at(i);
        if(an.at(a)==i) ++ans;
    }
    ans/=2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> as(100000 + 2, 0);
  for (auto i = 0; i < N; i++) {
    ll x;
    cin >> x;
    as[x]++;
  }

  ll res = 0;
  for (auto i = 1; i < as.size()-1; i++) {
    res = max(res, as[i-1] + as[i] + as[i+1]);
  }

  cout << res << endl;

  return 0;
}


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll X, K, D, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> X >> K >> D;
    tmp = X%D;
    if(tmp<0) tmp+=D;
    if(tmp>abs(tmp-D)) tmp -= D;
    ll ct = abs(X-tmp);
    ct /= D;
    if(ct>K) {
        if(X>=0) ans = abs(X-D*K);
        else ans = abs(X+D*K);
    }
    else {
        K -= ct;
        if(K%2==0) ans = abs(tmp);
        else ans = min(abs(tmp+D), abs(tmp-D));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << ((a<=c&&c<=b)?"Yes":"No") << endl;
}








Measured memory_bytes: 256
using System;

class CF2016FA
{
	static public void Main(string[] args)
	{
		int H, W;
		string[] vals = Console.ReadLine().Split(' ');
		H = int.Parse(vals[0]);
		W = int.Parse(vals[1]);
		bool  found = false;
		int i=0, j=0;
		for(; i < H; i++)
		{
			vals = Console.ReadLine().Split(' ');
			for(j=0; j < W; j++)
			{
				if(vals[j] == "snuke")
				{
					found = true;
					break;
				}
			}
			if(found)
				break;
		}
		Console.WriteLine("{0}{1}", (char)('A' + j), i + 1);
	}
}



Measured memory_bytes: 13268
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

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

  ll h, w, k;
  cin >> h >> w >> k;

  vector<string> mp(h);
  rep(i, h) cin >> mp[i];

  ll ans = 0;
  rep(i, 1 << h) {
    rep(j, 1 << w) {
      ll cnt = 0;
      rep(y, h) rep(x, w){
        bool red = ((i >> y) & 1) | ((j >> x) & 1);
        bool wht = mp[y][x] == '.';
        bool blk = !red && !wht;
        if(blk) cnt++;
      }
      if(cnt == k) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=1e5+5;
const int MOD=1e9+7;
//ll a[N];
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    ll a,b,x;
    cin>>a>>b>>x;
    if(a>x||a+b<x)  cout <<"NO"<<endl;
    else    cout <<"YES"<<endl;

    return 0;
}


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

int main(){
    int N, L, pre=0;
    cin >> N >> L;
    vector<int> a(N);
    for(int i=0; i<N; i++){
        a.at(i) = L+i;
        pre += a.at(i);
    }

    int late = 50000000;
    for(int i=0; i<N; i++){
        if(abs(late-pre) >= abs(a.at(i))){
            late = pre-a.at(i);
        }
    }
    cout << late << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

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

int dp[100005];

int solve(int v, vector<int> *to) {
  if (dp[v] != -1) return dp[v];

  int res = 0;
  for (auto nv : to[v]) { res = max(res, solve(nv, to) + 1); }

  return dp[v] = res;
}

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> to[n];
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    to[x].push_back(y);
  }

  rep(i, n) dp[i] = -1;
  int ans = 0;
  rep(i, n) ans = max(ans, solve(i, to));

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


Measured memory_bytes: 8192
#include <cstdio>
    #include <algorithm>
    using namespace std;
     
    int N, M, X, A[200];
     
    int main()
    {
    	scanf("%d%d%d", &N, &M, &X);
    	for (int i = 0; i < M; ++i) scanf("%d", A + i);
     
    	int left = 0, right = 0;
    	for (int i = 0; i < M; ++i) {
    		if (A[i] < X) ++left;
    		else ++right;
    	}
    	printf("%d\n", min(left, right));
     
    	return 0;
    }

Measured memory_bytes: 128
import numpy as np
N, K = map(int, input().split())
X = np.array(list(map(int, input().split())))
arr = X[K - 1:] - X[:-K + 1]
arr1 = arr + np.abs(X[:-K + 1])
arr2 = arr + np.abs(X[K - 1:])
if len(arr) == 0:
    print(0)
else:
    ans = min(arr1.min(), arr2.min())
    print(ans)


Measured memory_bytes: 23108
// A - ∴ (Therefore)
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S; cin>>S;
	string ans = "hon";
	if(S.back() == '0') ans = "pon";
	if(S.back() == '1') ans = "pon";
	if(S.back() == '6') ans = "pon";
	if(S.back() == '8') ans = "pon";
	if(S.back() == '3') ans = "bon";
	cout<< ans <<endl;
}


Measured memory_bytes: 3624
#input
H, W = map(int, input().split())
a = ["" * W for _ in range(H)]
for i in range(H):
    a[i] = list(map(str, input().split()))

#output
mod = 10**9 + 7

dp = [[0]*W for _ in range(H)]
dp[0][0] = 1

for j in range(W):
    if a[0][0][j] == ".":
        dp[0][j] = 1
    else:
        break
for i in range(H):
    if a[i][0][0] == ".":
        dp[i][0] = 1
    else:
        break

for i in range(H-1):
    for j in range(W-1):
        if a[i+1][0][j+1] == "#":
            dp[i+1][j+1] = 0
        else:
            dp[i+1][j+1] = dp[i+1][j] % mod + dp[i][j+1] % mod

print(dp[H-1][W-1] % mod)

Measured memory_bytes: 52080
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int t[n];
	for(int i=0; i<n; i++) cin>>t[i];
	int cnt=0;
	sort(t, t+n);
	for(int i=0; i<n; i++)
	{
		for(int j=i+1; j<n; j++)
		{
			if(t[i]==t[j]) continue;
			for(int k=j+1; k<n; k++)
			{
				if(t[j]==t[k]||t[k]==t[i]) continue;
				if(t[i]!=t[j]&&t[i]!=t[k]&&t[j]!=t[k]&&t[i]+t[j]>t[k]) 
				{
					
					cnt++;
				}
			}
		}
	}
	cout<<cnt<<endl;
	
	return 0;
	
}

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

using namespace std;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) {
        cout << "A" << endl;
    } else {
        cout << "B" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();

		for(int i=0;i<n;i++) {
			list.add(sc.nextInt());
		}
		sc.close();

		List<Integer> list2 = new ArrayList<Integer>(new HashSet<>(list));


		if(list2.size() != n) {
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}


	}

}

Measured memory_bytes: 96896
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(void){
    int N, ans;
    cin >> N;
    if(N < 10){
        ans = N;
    } else if(N < 100){
        ans = 9;
    } else if(N < 1000){
        ans = N - 90;
    } else if(N < 10000){
        ans = 909;
    } else if(N < 100000){
        ans = N - 90 - 9000;
    } else {
        ans = 90909;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  int i;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int ans=0;
  int count[100001]={0};
  for(i=0;i<n;i++){
    if(a[i]<100001){
      count[a[i]]++;
    }
    else{
      ans++;
    }
  }
  for(i=1;i<100001;i++){
    if(count[i]<i){
      ans+=count[i];
    }
    else{
      ans+=count[i]-i;
    }
  }

  printf("%d",ans);

  return 0;

}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<int> sw(s.size()+1), se(s.size()+1);
  rep(i,s.size()) {
    sw[i+1] = sw[i];
    se[i+1] = se[i];
    if (s[i] == 'E') se[i+1]++;
    if (s[i] == 'W') sw[i+1]++;
  }
  //rep(i,sw.size()) printf("%d%c", sw[i], i==sw.size()-1?'\n':' ');
  //rep(i,se.size()) printf("%d%c", se[i], i==se.size()-1?'\n':' ');

  int total_e = count(rng(s), 'E');

  // sw: 0 1 1 1 2 3
  // se: 0 0 1 2 2 2
  //      W E E W W
  // 5    0 1 2 3 4

  int ans = INF;
  rep(i,n) {
    int lw = sw[i];
    int re = total_e - se[i+1];
    ans = min(ans, lw+re);
    //printf("%d %d %d\n", i, n-i-1, csum[n]-csum[i+1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3076
n = gets.to_i
alphabets = ('a'..'z').to_a
array = [n - 1]
while array[0] > 25
  div, mod = array[0].divmod(26)
  array[0] = mod
  array.unshift(div - 1)
end
puts array.map { |n| alphabets[n] }.join

Measured memory_bytes: 14372
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
int d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];
char field[200][200];

int main(){
  while(1){
    cin >> n >> m >> l;
    if(n == 0 && n == m && n == l)break;
    vp vec;
    ll ans = 0;
    rep(i,1,l){
      rep(j,1,l){
        if((i * (100+n))/100 + (j*(100+n))/100 == l){
          vec.pb(P(i,j));
        }
      }
    }
    rep(i,0,vec.sz){
      int x = vec[i].first;
      int y = vec[i].second;
      if((x * (100 + m))/100 + (y * (100 + m))/100 > ans)ans = (x * (100 + m))/100 + (y * (100 + m))/100;
    }
    print(ans);
  }
  return 0;
}


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

int main(void){
  string str;
  int k;
  char not1 = '0';
  size_t max;
  cin >> str >> k;
  max = min((int)str.length(),k);
  for(size_t i = 0;i<max;i++){
    if(str.at(i) != '1') {
      not1 = str.at(i);
      break;
    }
  }
  if(not1 == '0') cout << 1 << endl;
  else cout << not1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll f(ll a){
	int b = a%4;
	
	if(b==0){
		return a;
	}
	if(b==1){
		return 1;
	}
	if(b==2){
		return a+1;
	}
	if(b==3){
		return 0;
	}
	
}



int main() {
	ll a,b;
	cin>>a>>b;
	
	ll ans = f(a-1)^f(b);
	
	cout<<ans<<'\n';
	
	
	
	
	return 0;
}


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

int main()
{
	string S;
	cin >> S;
	int a = 0;
	int b = 0;
	for (int i = 0; i < S.size(); ++i)
	{
		if (S[i] == '0') a++;
		else b++;
	}

	cout << min(a,b) * 2 << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
long long int knapsack(long long int value,long long int w,long long int wt[],long long int val[],long long int n)
{
   long long int dp[n+1][value+1];
   for(int i=0;i<=n;i++)
   {
     dp[i][0]=0;
   }
   for(int i=0;i<=value;i++)
   {
     dp[0][i]=100000000000;
   }
   dp[0][0]=0;
   long long int ans=-1;
   for(long long int i=1;i<=n;i++)
   {
     for(long long int j=1;j<=value;j++)
     {
       if(j>=val[i-1])
       {
         dp[i][j]=min(dp[i-1][j],wt[i-1]+dp[i-1][j-val[i-1]]);
       }
      else
      {
         dp[i][j]=dp[i-1][j];
      }
      if(dp[i][j]<=w)
      {
         ans=max(ans,j);
      }
     }
   }
   return ans;
}
int main()
{
   long long int n,w;
   cin>>n>>w;
   long long int wt[n];
   long long int val[n];
   for(int i=0;i<n;i++)
   {
     cin>>wt[i];
     cin>>val[i];
   }
   long long int value=0;
   for(int i=0;i<n;i++)
   {
     value+=val[i];
   }
   long long int x=knapsack(value,w,wt,val,n);
   cout<<x<<"\n";
   return 0;
 
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
int main () {
  int A,B;
  int ans,ans1,ans2,ans3;
  int AA,BB;
  
  cin >> A >> B;
  ans1=A+A-1;
  ans2=A+B;
  ans3=B+B-1;
  if(ans1>ans2){
    ans=ans1;
  }
  else{
    ans=ans2;
  }
  if(ans3>ans){
    ans=ans3;
  }
  cout<< ans;
}

Measured memory_bytes: 256
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
MOD = 10**9+7
for i in range(2, 10**6+1):
    g1.append((g1[-1] * i) % MOD)
    inverse.append((-inverse[MOD % i] * (MOD // i)) % MOD)
    g2.append((g2[-1] * inverse[-1]) % MOD)

def memo_comb(n, r, mod=MOD):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n-r] % mod

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

ans = 0
for i, a in enumerate(A, 1):
  ans = (ans + a*(memo_comb(i-1, K-1) - memo_comb(N-i, K-1)))
  ans %= MOD

print(ans)

Measured memory_bytes: 133008
(defn grid [h]
  (let [white? (fn [s] (re-find #"^\.+$" s))
        grid (for [_ (range h)] (read-line))
        not-whites (remove white? grid)
        result (->> (apply map (cons (fn [& args]
                                       (let [s (apply str args)]
                                         (if (white? s)
                                           nil
                                           s)))
                                     not-whites))
                    (remove nil?)
                    (apply map (fn [& args] (apply str args))))]
    (doseq [s result] (println s))))

(grid (Integer/parseInt (first (clojure.string/split (read-line) #"\s"))))

Measured memory_bytes: 84752