akhauriyash/Code-Regression huggingface dataset:
// Aizu 0551: Icicles
// 2017.9.22 bal4u@uu

#include <stdio.h>

/* ????????????????????????????????\????????????????????? */
#define QSIZE 100010
#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

typedef struct { int key, a; } QUE;	// ???????????????????§??????????????´????????????????t?????????????±?
QUE que[QSIZE + 5];
int qsize;

void max_heapify(int i)
{
	int l, r, max;
	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].key > que[i].key) max = l; else max = i;
	if (r < qsize && que[r].key > que[max].key) max = r;
	if (max != i) {
		QUE t = que[i]; que[i] = que[max], que[max] = t;
		max_heapify(max);
	}
}

int deq(int *a)
{
	if (qsize == 0) return 0;
	*a = que[0].a;
	que[0] = que[--qsize];
	max_heapify(0);
	return 1;
}

void enq(int t, int a)
{
	int i, max;
	i = qsize++;
	que[i].key = t, que[i].a = a;
	while (i > 0 && que[max = PARENT(i)].key < que[i].key) {
		QUE t = que[i]; que[i] = que[max], que[max] = t;
		i = max;
	}
}
/* ????????????????????????????????\????????????????????? */


#define MAX 100010
typedef struct { int a, b; } T;
T len[MAX]; int n;

int check(int k)
{
	if (k < 0 || k >= n) return 0;
	if (k == 0   && len[0].a > len[1].a) return 1;
	if (k == n-1 && len[n-1].a > len[n-2].a) return 1;
	if (len[k].a > len[k-1].a && len[k].a > len[k+1].a) return 1;
	return 0;
}

int main(void)
{
	int l, i, t, ans;

	scanf("%d%d", &n, &l);
	qsize = 0; for (i = 0; i < n; i++) scanf("%d", &t), len[i].a = len[i].b = t;
	for (i = 0; i < n; i++) if (check(i)) enq(len[i].b, i);
	ans = 0;
	while (deq(&i)) {
		if (l - len[i].b > ans) ans = l - len[i].b;
		len[i].a = 0;
		if (check(i-1)) len[i-1].b -= ans, enq(len[i-1].b, i-1);
		if (check(i+1)) len[i+1].b -= ans, enq(len[i+1].b, i+1);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
 
  int numa=0;
  int numz=0;
  int i=0;
  int j=s.size()-1;
  
  while(numa==0){
    if(s[i]=='A'){
      numa++;
    }
    i++;
  }
  
  while(numz==0){
    if(s[j]=='Z'){
      numz++;
    }
    j--;
  }
  
  cout << j-i+3 << endl;
  
}


Measured memory_bytes: 3716
import java.util.*;
import java.io.*;
import java.lang.*;
class Main{
    public static void main(String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n  = Integer.parseInt(br.readLine());
        int arr[] = new int[n];
        StringTokenizer st = new StringTokenizer(br.readLine());
        for(int i=0;i<n;i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        Arrays.sort(arr);
        int count  = 0;
        HashSet<String> set = new HashSet<>();
        ArrayList<String> alist = new ArrayList<>();
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(j!=i){
                    for(int k=j+1;k<n;k++){
                        if(k!=j&&k!=i){
                            if(arr[i]+arr[j]>arr[k]&&arr[k]+arr[j]>arr[i]&&arr[i]+arr[k]>arr[j] && arr[i]!=arr[j] && arr[j]!=arr[k]&&arr[i]!=arr[k]){
                                count++;
                                //set.add(arr[i]+" "+arr[j]+" "+arr[k]);
                                //alist.add(arr[i]+" "+arr[j]+" "+arr[k]);
                            }
                        }
                    }
                }
            }
        }
        // for(String string:alist){
        //     System.out.println(string);
        // }
        System.out.println(count);
    }
}

Measured memory_bytes: 33624
N, X = map(int, input().split())

def len_L(num):
    l = 0
    for i in range(num+1):
        if i== 0:
            l = 1
        else:
            l = 3 + 2*l
    return l

def count_P(level):
    P = 0
    for i in range(level+1):
        if i == 0:
            P = 1
        else:
            P = 2*P + 1
    return P

count = 0
if N == 1:
    count = min(X-1, 3)
else:
    while True:
        half = int((len_L(N) + 1) / 2)
        if X == 1:
            count += 0
            break
        elif X == len_L(N):
            count += count_P(N)
            break
        elif X == half:
            count += int((count_P(N) + 1) / 2)
            break
        elif X > half:
            count += int((count_P(N) + 1) / 2)
            X = X - half
            N = N - 1
            if N == 1:
                count += min(X-1, 3)
                break
        else:
            X = X - 1
            N = N - 1
            if N == 1:
                count += min(X-1, 3)
                break
print(count)

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = 2e5 + 10;

int n,m;
vi adj[N];

bool vis[N];
int pre[N], a = -1,b;
void dfs_cycle(int u, int p) {
    vis[u] = true;
    pre[u] = p;
    for (int v : adj[u]) if (v != p) {
        if (vis[v]) {
            if (a == -1) {
                a = v; 
                b = u;
            }
        }
        else dfs_cycle(v,u);
    }
}

vi cycle;
bool cyc[N];
void build_cycle() {
    for (int x = b; x != -1; x = pre[x]) {
        //cerr << x << ' ' << pre[x] << endl;
        cyc[x] = true;
        cycle.pb(x);
        if (x == a) break;
    }
}

ll res = 0;
int bal[N];
void dfs(int u, int p) {
    bal[u] = 1;
    for (int v : adj[u]) if (!cyc[v] && v != p) {
        dfs(v,u);
        bal[u] -= bal[v];
    }
    if (p != -1) res += abs(bal[u]);
}

void result(ll res) {
    printf("%lld\n", res);
    exit(0);
}

int main() {
    scanf("%d %d", &n, &m);
    forn(_,m) {
        int u,v;
        scanf("%d %d", &u, &v);
        u--; v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    if (m == n) {
        dfs_cycle(0,-1); build_cycle();
        vi cbal;
        for (int r : cycle) {
            dfs(r,-1);
            cbal.pb(bal[r]);
        }

        if (si(cycle) % 2) {
            ll total = 0;
            forn(i,si(cbal)) {
                if (i%2 == 0) total -= cbal[i]; else total += cbal[i];
            }
            if (total%2) result(-1);
            total /= 2;
            for (auto b : cbal) {
                res += abs(total);
                total = -total-b;
            }
            result(res);
        }
        else {
            vector<ll> cum;
            cum.pb(0);
            forn(i,si(cbal)) {
                if (i%2 == 0) cum.pb(cum.back()-cbal[i]);
                else cum.pb(cum.back()+cbal[i]);
            }
            if (cum.back() != 0) result(-1);

            cum.pop_back(); sort(all(cum));
            ll med = cum[si(cum)/2];
            for (ll x : cum) res += abs(x-med);
            result(res);
        }
    }
    else {
        dfs(0,-1);
        if (bal[0] != 0) result(-1);
        result(res);
    }

    return 0;
}


Measured memory_bytes: 19344
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
string s;
int a=10000005,b;
int main(){
	cin>>s;
	for (int i=0; i<s.size(); i++)
	{
		if (s[i]=='C') a=min(a,i);
		if (s[i]=='F') b=max(b,i);
	}
	if (a<b) cout<<"Yes"; else cout<<"No";
    return 0;
}

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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
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":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
template<class T> inline bool is_overlap(const T& as, const T& ae, const T& bs, const T& be)
{ return bs <=ae && as <= be; }
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N,M,X,Y; cin >>N>>M>>X>>Y;
    
    int x_max = X;
    int y_min = Y;
    int tmp;
    rep(i, N) {
        cin >> tmp;
        chmax(x_max, tmp);
    }
    rep(i, M) {
        cin >> tmp;
        chmin(y_min, tmp);
    }
    cout << (y_min <= x_max ? "War" : "No War") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

ll x,y,z,k;

int main(){
    cin >> x >> y >> z >> k;
    ll a[1005],b[1005],c[1005];
    inrep(x,a);
    inrep(y,b);
    inrep(z,c);

    vector<ll> v;
    
  
    rep(i,0,x){
        rep(j,0,y){
            v.pb(a[i] + b[j]);
        }
    }
   
    rvsort(v,ll);
    
    vector<ll> v2;
    rep(i,0,min(k,x*y)){
        rep(j,0,z){
            v2.pb(v[i] + c[j]);
        }
    }

    rvsort(v2,ll);
    
    rep(i,0,k){
       P(v2[i]);
    }
	return  0;
}

Measured memory_bytes: 43108
#include<iostream>
#include<cstdio>
#include<cstring>
namespace test
{
	const int N=101000;
	struct bit
	{
		int s[N];
		inline void init(){memset(s,0,sizeof(s));}
		inline int lowbit(int x){return x&(-x);}
		inline void inc(int p,int w){for(;p<N;p+=lowbit(p))s[p]+=w;}
		inline int ask(int p){int ret=0;for(;p;p-=lowbit(p))ret+=s[p];return ret;}
		inline int query(int L,int R){return ask(R)-ask(L-1);}
	}t0,tk;
	int a[4][N],s[N];
	bool f[N],df[N];
	int n;
	bool initialize()
	{
		scanf("%d",&n);
		for(int i=1;i<=3;i++)
			for(int j=1;j<=n;j++)
				scanf("%d",&a[i][j]);
		for(int i=1;i<=n;i++)
		{
			if(a[2][i]%3!=2)return 0;

			int x=(a[1][i]+2)/3;
			s[i]=x;
			if(a[2][i]==a[1][i]+1 && a[3][i]==a[2][i]+1)f[i]=0;
			else if(a[2][i]==a[1][i]-1 && a[3][i]==a[2][i]-1)f[i]=1;
			else return 0;
		}
		for(int i=1;i<=n;i++)
			if((i%2)!=(s[i]%2))return 0;
		return 1;
	}
	bool check()
	{
		int cnta=0,cntb=0;
		for(int i=1;i<=n;i+=2)
			cnta+=f[i];
		for(int i=2;i<=n;i+=2)
			cntb+=f[i];
		if(cnta%2 || cntb%2)return 0;
		return 1;
	}

	bool fuck()
	{
		int k=0;
		for(int i=1;i<=n;i++)k=k*2+f[i];

		if(k&16)k^=30;
		if(k&8)k^=15;
		if(k&4)k^=5;
		return k==0;
	}
	void solve()
	{
		if(!initialize()){printf("No\n");return;}

		t0.init(),tk.init();
		for(int i=2;i<=n;i+=2)t0.inc(s[i],1);
		for(int i=2;i<=n;i+=2)
		{
			t0.inc(s[i],-1);
			int k=t0.query(1,s[i]);
			tk.inc(s[i],1),tk.inc(i+k*2,-1);

			df[s[i]]=f[i]^(((i-s[i])/2)&1);
		}
		for(int i=2;i<=n;i+=2)f[i]=df[i];
		for(int i=1;i<=n;i+=2)f[i]^=tk.ask(i)&1;

		t0.init(),tk.init();
		for(int i=1;i<=n;i+=2)t0.inc(s[i],1);
		for(int i=1;i<=n;i+=2)
		{
			t0.inc(s[i],-1);
			int k=t0.query(1,s[i]);
			tk.inc(s[i],1),tk.inc(i+k*2,-1);

			df[s[i]]=f[i]^(((i-s[i])/2)&1);
		}
		for(int i=1;i<=n;i+=2)f[i]=df[i];
		for(int i=2;i<=n;i+=2)f[i]^=tk.ask(i)&1;


//		for(int i=1;i<=n;i++)
//			printf("%d ",f[i]);
//		printf("\n");

		if(n>=6)printf("%s\n",check()?"Yes":"No");
		else printf("%s\n",fuck()?"Yes":"No");
	}
}
int main()
{
//	freopen("in","r",stdin);
	test::solve();
	return 0;
}


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

int main(){
    int k, s;
    int z = 0;
    cin >> k >> s;
    int count = 0;
    for(int x = 0; x <= k; ++x) {
        for(int y = 0; y <= k; ++y) {
            z = s - x - y;
            if(0 <= z && z <= k) count++;
        }
    }
    cout << count << '\n';
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h.at(i);
  ll dp[100010];
  rep(i,100010) dp[i] = LLONG_MAX;
  dp[0] = 0;
  for(int i = 1; i < n; i++) {
    for(int j = 1; i-j >= 0 && j <= k; j++) {
      dp[i] = min(dp[i], dp[i-j]+abs(h.at(i)-h.at(i-j)));
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1408
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table
print(sum(num_divisors_table(int(input()))[1:-1]))

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

constexpr array<llong, 9> nw = {0, 1, 0, -1, -1, 1, 1, -1, 0};
constexpr array<llong, 9> nh = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int main() {
  llong H, W;
  llong Ch, Cw;
  llong Dh, Dw;
  vector<string> area;

  cin >> H >> W;
  cin >> Ch >> Cw;
  cin >> Dh >> Dw;
  Ch--;
  Cw--;
  Dh--;
  Dw--;
  area.resize(H);
  for (auto &in: area) {
    cin >> in;
  }

  vector<vector<llong>> ans(H, vector<llong>(W, inf));
  deque<lpair> que;
  ans[Ch][Cw] = 0;
  que.push_front(lpair(Ch, Cw));
  while (que.size()) {
    lpair now = que.front();
    que.pop_front();

    for (int i = 0; i < 4; i++) {
      lpair next(now.first + nh[i], now.second + nw[i]);
      if (next.first < 0 || next.second < 0 || next.first >= H || next.second >= W) {
        continue;
      }
      if (area[next.first][next.second] == '#') {
        continue;
      }
      if (ans[now.first][now.second] < ans[next.first][next.second]) {
        ans[next.first][next.second] = ans[now.first][now.second];
        que.push_front(next);
      }
    }
    for (int i = -2; i <= 2; i++) {
      for (int j = -2; j <= 2; j++) {
        lpair next(now.first + i, now.second + j);
        if (next.first < 0 || next.second < 0 || next.first >= H || next.second >= W) {
          continue;
        }
        if (area[next.first][next.second] == '#') {
          continue;
        }
        if (ans[now.first][now.second] + 1 < ans[next.first][next.second]) {
          ans[next.first][next.second] = ans[now.first][now.second] + 1;
          que.push_back(next);
        }
      }
    }
  }

  cout << (ans[Dh][Dw] == inf ? -1 : ans[Dh][Dw]) << endl;

  return 0;
}

Measured memory_bytes: 13508
import collections

S = input()

c = collections.Counter(S)
K = c.keys()

if len(K) == 4:
    print('Yes')
elif len(K) == 2:
    if 'N' in K and 'S' in K:
        print('Yes')
    elif 'W' in K and 'E' in K:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

#define eb emplace_back
#define sz(s) (int)(s.size())

const int N = 2e6 + 123;

int dist[N];

vector <int> g[N];

int res = 0;

void dfs(int v, int pr = -1) {
	for (auto to : g[v]) {
		if (to != pr) {
			dist[to] = dist[v] + 1;
			dfs(to, v);
		}
	}
}

void dfs2(int v, int pr, int d) {
	if (d >= dist[v])
		return;
	res = max(res, dist[v] - 1);
	for (auto to : g[v])
		if (to != pr)
			dfs2(to, v, d + 1);
}

int main () {
	cerr << "Ready\n";
	int n, s, f;
	cin >> n >> s >> f;
	for (int i = 1; i < n; ++ i) {
		int x, y;
		cin >> x >> y;
		g[x].eb(y);
		g[y].eb(x);
	}
	dfs(f);
	dfs2(s, -1, 0);
	cout << res;
	cerr << '\n';
}

Measured memory_bytes: 56320
from itertools import product

def check():
  n = int(input())
  prog = [input().split() for _ in range(n)]
  
  v = set()
  for ss in prog:
    for s in ss:
      if "a" <= s <= "z":
        v.add(s)
  v = sorted(list(v))
  var_state = [0] * len(v)
  var_to_ind = dict(zip(v, range(len(v))))
  
  line_to_ind = {}
  for i, ss in enumerate(prog):
    line_to_ind[ss[0]] = i
  
  def fix(p):
    if p[1] == "ADD":
      if p[4] in var_to_ind:
        return [0, var_to_ind[p[2]], var_to_ind[p[3]], var_to_ind[p[4]]]
      else:
        return [1, var_to_ind[p[2]], var_to_ind[p[3]], int(p[4])]
    if p[1] == "SUB":
      if p[4] in var_to_ind:
        return [2, var_to_ind[p[2]], var_to_ind[p[3]], var_to_ind[p[4]]]
      else:
        return [3, var_to_ind[p[2]], var_to_ind[p[3]], int(p[4])]
    if p[1] == "SET":
      if p[3] in var_to_ind:
        return [4, var_to_ind[p[2]], var_to_ind[p[3]]]
      else:
        return [5, var_to_ind[p[2]], int(p[3])]
    if p[1] == "IF":
      if p[3] in line_to_ind:
        return [6, var_to_ind[p[2]], line_to_ind[p[3]]]
      else:
        return [6, var_to_ind[p[2]], 100]
    if p[1] == "HALT":
      return [7]
  
  prog = list(map(fix, prog))
  used = [[False] * n for _ in range(16 ** len(v))]
  xs = [1, 16, 256, 4096, 65536]

  ind = 0
  h = 0
  while True:
    if ind >= n:
      return True, v, var_state
    if used[h][ind]:
      return False, v, var_state
    used[h][ind] = True
  
    p = prog[ind]
    ins = p[0]
    
    if ins == 0:
      v1, v2, v3 = p[1:]
      temp = var_state[v2] + var_state[v3]
      if not temp < 16:
        return True, v, var_state
      h += (temp - var_state[v1]) * xs[v1]
      var_state[v1] = temp
    
    elif ins == 1:
      v1, v2 = p[1:3]
      con = p[3]
      temp = var_state[v2] + con
      if not temp < 16:
        return True, v, var_state
      h += (temp - var_state[v1]) * xs[v1]
      var_state[v1] = temp
    
    elif ins == 2:
      v1, v2, v3 = p[1:]
      temp = var_state[v2] - var_state[v3]
      if not 0 <= temp:
        return True, v, var_state
      h += (temp - var_state[v1]) * xs[v1]
      var_state[v1] = temp
    
    elif ins == 3:
      v1, v2 = p[1:3]
      con = p[3]
      temp = var_state[v2] - con
      if not 0 <= temp:
        return True, v, var_state
      h += (temp - var_state[v1]) * xs[v1]
      var_state[v1] = temp
    
    elif ins == 4:
      v1, v2 = p[1:]
      h += (var_state[v2] - var_state[v1]) * xs[v1]
      var_state[v1] = var_state[v2]
    
    elif ins == 5:
      v1 = p[1]
      con = p[2]
      h += (con - var_state[v1]) * xs[v1]
      var_state[v1] = con
    
    elif ins == 6:
      v1 = p[1]
      dest = p[2]
      if var_state[v1]:
        ind = dest - 1
  
    else:
      return True, v, var_state
  
    ind += 1

flag, v, var_state = check()
if flag:
  for t in zip(v, var_state):
    print(*t, sep="=")
else:
  print("inf")


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

int main()
{
	int x,y;
  cin >> x >> y;
  
  bool flag = true;
  for(int i=0;i<=x;i++)
  {
    	if(2*i+4*(x-i) == y)
        {
          cout << "Yes";
          flag = false;
        }
  }
  if(flag == true)
  {
    cout << "No";
  }
}

Measured memory_bytes: 3524
x,y,a,b,c=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort(reverse=True)
A.sort()
B.sort()
C.sort(reverse=True)
A=A[a-x:]
B=B[b-y:]

i=0
j=0
k=0
lea=len(A)
leb=len(B)
while(True):
    if len(C)<1:
        break
    if i<lea and j<leb:
        if A[i]>B[j]:
            if B[j]<C[0]:
                B[j]=C.pop(0)
                
                j+=1
            else:
                break
        else:
            if A[i]<C[0]:
                A[i]=C.pop(0)
                i+=1
            else:
                break
    elif i<lea and j>=leb:
        if A[i]<C[0]:
                A[i]=C.pop(0)
                i+=1
        else:
            break
    elif i>=lea and j<leb:
        if B[j]<C[0]:
                B[j]=C.pop(0)
                j+=1
        else:
            break
    else:
        break
sum=0


for s in range(len(A)):
    sum+=A[s]
for t in range(len(B)):
    sum+=B[t]
print(sum)
            



Measured memory_bytes: 23328
import math
N = int(input())
A = 0
B = 0
Z = 0
C = {}
m = 1000000007

def mypow(dummy, num):
    ans = 1
    for i in range(num):
        ans = (ans*2)%1000000007
    return ans

def rNum(a, b):
    g = math.gcd(a, b)
    if a <0 and b<0:
        a *= -1
        b *= -1
    if a >0 and b <0:
        return (-1*(a//g), -1*(b//g))
    else:
        return (a//g, b//g)


for i in range(N):
    a, b = map(int, input().split())
    
    if a == 0 and b==0:
        Z += 1
        continue
    elif a==0:
        A += 1
        continue
    elif b==0:
        B +=1
        continue
    
    r = rNum(a, b)
    if r in C.keys():
        C[r] +=1
    else: C[r] = 1


used = set()
ans = 1
ans *= (mypow(2, A) + mypow(2, B) -1)%m


for c in C.keys():
    if c in used: continue
    a, b = c
    r = rNum(b, -1*a)
    if r in C.keys():
        if c == r: continue
        used.add(r)
        score = (mypow(2, C[c]) + mypow(2, C[r])- 1)
        ans *= score

    else:
        ans *= mypow(2, C[c])

ans += Z

print((ans-1)%m)






Measured memory_bytes: 47732
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main(){
  int w,a,b;
  cin>>w>>a>>b;
  if((a<=b&&b<=a+w)||(a<=b+w&&b<=a)){
    cout<<0<<endl;
  }else if(b>a+w){
    cout<<b-a-w<<endl;
  }else if(b+w<a){
    cout<<a-b-w<<endl;
  } 
  return 0;
}


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

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<P> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i].second >> Vec[i].first;
		}
		sort(Vec.begin(), Vec.end());
		int sum = 0;
		bool ok = true;
		for(int i = 0; i < n; ++i)
		{
			sum += Vec[i].second;
			if(sum > Vec[i].first)
			{
				ok = false;
			}
		}
		if(ok)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
}

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

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, M;

    cin >> N >> M;

    if(N==1 && M==1){
        cout << 1 << endl;
    }

    else if(N>=2 && M>=2){
        cout << (N-2)*(M-2) << endl;
    }

    else{
        cout << N*M-2 << endl;
    }

    return 0;
}

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


using ll = long long int;

ll a[100000*3+10] = {};

int main(void){
    // Here your code !
    
    ll n,res = 0;
    cin >> n;
    
    
    for(int i = 0; i < n*3; i++) cin >> a[i];
    
    sort(a,a+3*n);
    
    for(int i = 0; i < n; i++){
        //cout << a[ n*3 -2 - (i*2) ] << endl;
        res += a[ n*3 -2 - (i*2) ];
        
    }
    
    
    cout << res << endl;
    
    
    
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;

int main() {
	int n; cin >> n;
	int ans = 1e9;
	for (int i = 0; i <= n; i++) {
		int c = 0;
		int t = i;
		while (t > 0) c += t % 6, t /= 6;
		t = n - i;
		while (t > 0) c += t % 9, t /= 9;
		ans = min(ans, c);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int N; cin >> N;
    int b[100]; rep(i, N) cin >> b[i];

    int ans = 0;
    rep(i, N - 1) for (int j = i + 1; j < N; j++)
    {
        ans += b[i] * b[j];
    }
    cout << ans << endl;
}

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

int main() {
ios::sync_with_stdio(0);
cin.tie(0);
  
ll arr[3];
  for(int i=0; i<3; i++) {
    cin>>arr[i];
  }
  
  swap(arr[0],arr[1]);
  swap (arr[0], arr[2]);
  
  for(int i=0; i<3; i++) {
    cout<<arr[i]<<" ";
  }


}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
#define CRP(t, x) const t &x
#define OPL(t, x) bool operator<(CRP(t, x)) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
const int N = 1e6 + 60;
int sum(ll x)
{
    int r = 0;
    for (; x; x /= 10) r += x % 10;
    return r;
}
int main()
{
    int k;
    scanf("%d", &k);
    ll ans = 0, x = 1;
    for (int i = 0; i < k; i++)
    {
        while ((ans + x) * sum(ans + x * 10) >= (ans + x * 10) * sum(ans + x)) x *= 10;
        ans += x;
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a[11],b[11],c,d,n,m,x,y,k,h,w,sum,mi,ma,ans,s,t,l,r,res,tmp;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<int,int> > VP;

int main(){
    cin>>n>>d;
    rep(i,n)cin>>a[i]>>b[i];
    //どの問題群をコンプリートするかでbitDP
    ll num=0;
    mi=inf;
    rep(i,1<<n){
        sum=0;
        num=0;
        ma=-1;
        rep(j, n){
            if(i>>j & 1){
                sum+=b[j];
                sum+=a[j]*100*(j+1);
                num+=a[j];
            }
        }
        if(sum>=d)mi=min(mi,num);
        else{
            rep(j, n){
                if(!(i>>j & 1)){ma=max(ma,(ll)j);}
            }
            if(ma==-1)continue;
            res = (d-sum)/((ma+1)*100);
            if(res<a[ma]){
                if((d-sum)%((ma+1)*100)==0)mi=min(mi,num+res);
                else mi=min(mi,num+res+1);
            }
        }
    }
    p(mi);
    return 0;
}


Measured memory_bytes: 256
from sys import stdin

N = int(stdin.readline().rstrip())
a_lst = [int(x) for x in stdin.readline().rstrip().split()]

alice_sum = 0
bob_sum = 0

a_lst.sort(reverse=True)

for i, v in enumerate(a_lst):
  if i % 2 == 0:
    alice_sum += v
  else:
    bob_sum += v

print(alice_sum - bob_sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
using tii = tuple<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
//#define INF (ll)1E9
#define INF INT_MAX
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

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

//constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main() {
	int n;
	cin >> n;
	cout << (n*(1+(n % 2))) << endl;

}

Measured memory_bytes: 256
from collections import deque
n,m = [int(i) for i in input().split()]
F = [{} for i in range(n)]
for _ in range(m):
    i,j = [int(i) for i in input().split()]
    F[i][j] = 1
    F[j][i] = 1
q = int(input())
DP = [0 for i in range(n)]
c = 1
d = deque()
for i in range(n):
    if DP[i]:
        continue
    else:
        d.append(i)
    while(len(d)>0):
        tmp = d.pop()
        DP[tmp] = c
        for i in F[tmp]:
            if not DP[i]:
                d.append(i)
    c+=1

for i in range(q):
    s,t = [int(i) for i in input().split()]
    if DP[s] == DP[t]:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 38732
// AtCoder Beginner Contest 108
// B - Grid Compression
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int h, w;
  cin >> h >> w;

  vector<string> a(h);
  rep (i, h) cin >> a.at(i);

  vector<bool> hflg(h, false);
  vector<bool> wflg(w, false);

  rep (i, h) {
    rep (j, w) {
      if (a.at(i).at(j) == '#') {
        hflg.at(i) = true;
        wflg.at(j) = true;
      }
    }
  }

  rep (i, h) {
    if (hflg.at(i) == true) {
      rep (j, w) {
        if (wflg.at(j) == true) {
          cout << a.at(i).at(j);
        }
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c; cin>>a>>b>>c;
    int ans=1e9;
    vector <int> nums={a,b,c};
    do {
        ans=min(ans,abs(nums[1]-nums[0])+abs(nums[2]-nums[1]));
    } while( next_permutation(nums.begin(), nums.end()) );
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int y,y2;
	int i;
	int flg,flg2;
	flg=0;

	scanf("%d %d",&y,&y2);
	while(y!=0 && y2!=0){
		if(flg==0){
			flg=1;
		}
		else{
			printf("\n");
		}
		flg2=0;
		for(i=y;i<=y2;i++){
			if(y%400==0){
				printf("%d\n",y);
				flg2=1;
			}
			 if(y%4==0){
				if(y%100!=0){
					printf("%d\n",y);
				flg2=1;
				}
			}
			y++;
		}
		if(flg2==0){
			printf("NA\n");
		}
		scanf("%d %d",&y,&y2);
	}
	return 0;
}

Measured memory_bytes: 1048
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}


int main()
{
	int k;
	cin >> k;
	str s;
	cin >> s;
	if(s.size()<=k){
		cout << s << endl;
	}
	else{
		rep(i,k){
			cout << s.at(i);
		}
		cout << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

bool ok(int x)
{
    vector<int> v;
    while (x > 0)
    {
        v.push_back(x % 10);
        x /= 10;
    }
    vector<int> w = v;
    reverse(all(w));
    return v == w;
}
int f(int n)
{
    int res = 0;
    Rep(i, 1, n + 1) if (ok(i)) res++;
    return res;
}

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

    int a, b;
    cin >> a >> b;
    cout << f(b) - f(a - 1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

int main() {
	ll x;
	cin >> x;
	ll result = 100, count = 0;

	while(true) {
		if (result >= x) break;
		result = result + (result) / 100;
		count++;
	}
	cout << count << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n, a, b;
    cin >> n >> a >> b;

    cout << (n/(a+b))*a + min(a, n%(a+b)) << endl;
}

Measured memory_bytes: 256
import re
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


S = ii(str).lower()
if S == "keyence":
    print("YES")
    exit()
if (
    re.sub("k[a-z]*eyence", "", S)
    and re.sub("ke[a-z]*yence", "", S)
    and re.sub("key[a-z]*ence", "", S)
    and re.sub("keye[a-z]*nce", "", S)
    and re.sub("keyen[a-z]*ce", "", S)
    and re.sub("keyenc[a-z]*e", "", S)
    and re.sub("keyence[a-z]*", "", S)
):
    print("NO")
else:
    print("YES")


Measured memory_bytes: 3316
<?php
class SolveClass {
    function __invoke($N, $A) {
        $total = array_sum($A);
        $tmp = 0;
        $ret = [];
        
        for ($i = 2; $i < $N; $i+= 2) {
            $tmp += $A[$i] * 2;
        }

        for ($i = 0; $i < $N; $i++) {
            $tmp += $A[$i - ($i !== 0)] * ( ($i % 2 === 0) ? 1 : -1) * 2;
            $ret[] = abs($total - $tmp);
        }
        
        return $ret;
    }
}

fscanf(STDIN, "%d", $N);
$A = explode(" ", trim(fgets(STDIN)));

$abc133_d = new SolveClass;
echo implode(" ", $abc133_d($N, $A));


Measured memory_bytes: 20976
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1LL<<59)

int dp[200000];

const ll MOD = 1e9+7;

int fact(int n){
    if(dp[n]!=-1)return dp[n];
    return dp[n] = (fact(n-1)*n)%MOD;
}

signed main(){
    rep(i,200000)dp[i] = -1;
    dp[0] = 0;
    dp[1] = 1;
    dp[2] = 2;
    int n,m;
    cin>>n>>m;
    if(abs(n-m)>=2){
        cout<<0<<endl;
        return 0;
    }
    
    int ans = 0;
    ans = fact(n)%MOD;
    ans *= fact(m)%MOD;
    ans%=MOD;
    
    if(n==m)ans*=2;
    cout<<ans%MOD<<endl;
}

Measured memory_bytes: 3328
//In the name of God

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

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

const int N = 4e3+10 , mod = 998244353;

int dp[N][N] , b[N] , r[N];

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   string s;
   cin >> s;
   int n = s.length();
   for(int i = 0 ; i < n ; i++){
      b[i] += s[i] - '0' , r[i] += 2 - s[i] + '0';
      if(s[i] == '2')
         b[i]-- , b[i + 1]++;
      else if(s[i] == '0')
         r[i]-- , r[i + 1]++;
      if(i) b[i] += b[i - 1] , r[i] += r[i - 1];
      //cout << r[i] << " " << b[i] << endl;
   }
   b[n] += b[n - 1];
   r[n] += r[n - 1];
   dp[0][0] = 1;
   for(int i = 1 ; i <= 2 * n ; i++){
      for(int j = 0 ; j <= i ; j++){
         if(b[min(i - 1 , n)] >= j && r[min(i - 1 , n)] >= i - j){
            dp[i][j] = dp[i - 1][j];
            if(j > 0)
               (dp[i][j] += dp[i - 1][j - 1]) %= mod;
         }
         //cout << i << " " << j << " " << dp[i][j] << endl;
      }
   }
   cout << dp[2 * n][b[n]];
   return 0;
}


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

int main()
{
    int n,i,j,k,cnt=0;
    cin>>n;
    int ara[n];
    for(i=0; i<n; i++)
    {
        cin>>ara[i];
    }

	sort(ara, ara+n);

	for( int i = n-1; i >= 1; i--){
		int l = 0, r = i-1;
		while( l < r){
			if( ara[l] +ara[r] > ara[i]){
				cnt += r - l ;
				r--;
			}
			else
				l++;
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

const ll MOD=1e9+7;
const ll MAXN=52+5+2;

int N;
ll dp[9][MAXN];
char s1[MAXN], s2[MAXN];

int main() {
        cin >> N;
        for (int i=0; i<N; i++)
                cin >> s1[i];
        for (int i=0; i<N; i++)
                cin >> s2[i];

        for (int i=0; i<9; i++) {
                if ((s1[0] != s2[0]) ^ (i%3 == i/3)) {
                        dp[i][0] = 1;
                } else {
                        dp[i][0] = 0;
                }
        }

        for (int i=1; i<N; i++) {
                if (s1[i] == s1[i-1]) {
                        for (int j=0; j<9; j++)
                                dp[j][i] = dp[j][i-1];
                } else {
                        for (int j=0; j<9; j++) {
                                dp[j][i] = 0;
                                if ((s1[i] != s2[i]) ^ (j%3 == j/3)) {
                                        for (int k=0; k<9; k++) {
                                                if (j%3 != k%3 && j/3 != k/3) {
                                                        dp[j][i] += dp[k][i-1];
                                                        dp[j][i] %= MOD;
                                                }
                                        }
                                }
                        }
                }
        }

        int ret=0;
        for (int i=0; i<9; i++) {
                ret += dp[i][N-1];
                ret %= MOD;
        }

        cout << ret << "\n";
}

Measured memory_bytes: 256
def addbit(i):
    i += 1
    while i <= N:
        BIT[i] += 1
        i += i & (-i)
def getsum(i):
    ret = 0
    i += 1
    while i != 0:
        ret += BIT[i]
        i -= i&(-i)
    return ret
def bit(L):
    global BIT
    BIT=[0] * (N+1)
    re = 0
    for l in L:
        re += getsum(l)
        addbit(l)
    return N*(N-1)//2 - re
def get_rank(L):
    D = {x:i for i,x in enumerate(sorted(L))}
    return [D[x] for x in L]
def calc(Z):
    Z.sort()
    l, r, lc, rc = -1<<28, 1<<28, N*(N-1)//4+1, N*(N-1)//4+1
    while (r - l) / max(abs(l), 1) > 0.000000001:
        m = (l * rc + r * lc) / (lc + rc)
        A = get_rank([s*m+t for s, t in Z])
        c = bit(A)
        if c > N*(N-1)//4:
            l = m
            lc = ((c - N*(N-1)//4) * 2) ** 0.3
        else:
            r = m
            rc = ((N*(N-1)//4 - c) * 2 + 1) ** 0.3
    return l

N = int(input())
X, Y = [], []
for _ in range(N):
    a, b, c = map(int, input().split())
    X.append((-a/b, c/b))
    Y.append((-b/a, c/a))
print(calc(X), calc(Y))

Measured memory_bytes: 130040
arr = gets.split.map(&:to_i)
ans = 0
if  arr[0] > arr[3]
	ans = arr[3]
elsif	arr[0] + arr[1] >= arr[3]
	ans = arr[0]
else
	ans = arr[0] - (arr[3] - arr[0] - arr[1])
end

p ans

Measured memory_bytes: 14352
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <cmath>
using namespace std;



int main(){

    int N;
    cin >> N;

    vector<char> arr(N,'a');
    vector<int> R(N,0);
    vector<int> G(N,0);
    vector<int> B(N,0);

    vector<int> numR(N,0);
    vector<int> numG(N,0);
    vector<int> numB(N,0);
    
    char c;
    int ridx=0,gidx=0,bidx=0;

    for(int i=0;i<N;i++){
        cin >> c;
        switch(c){
            case 'R':
                R[ridx] = i;
                ridx++;
                break;
            case 'G':
                G[gidx] = i;
                gidx++;
                break;
            case 'B':
                B[bidx] = i;
                bidx++;
                break;
        }
        numR[i] = ridx;
        numG[i] = gidx;
        numB[i] = bidx;
        arr[i] = c;
        //cout << i << " : " << numR[i] << ", " << numG[i] << ", " << numB[i] << endl; 
    }

    //for(int i=0;i<ridx;i++) cout << R[i] << ", "; cout << endl;
    //for(int i=0;i<gidx;i++) cout << G[i] << ", "; cout << endl;
    //for(int i=0;i<bidx;i++) cout << B[i] << ", "; cout << endl; 

    // 6通り
    // RGB
    // RBG
    // GRB
    // GBR
    // BRG
    // BGR

    long count = 0;
    int prev,next,tmp;

    // RGB, BGR
    for(int i=0;i<gidx;i++){
        if(G[i]==0 || G[i]==N-1) continue;
        tmp = G[i]; prev = tmp-1; next = tmp+1;
        count += numR[prev]*(numB[N-1]-numB[tmp]);
        count += numB[prev]*(numR[N-1]-numR[tmp]);
        for(int j=0;tmp-j>=0&&tmp+j<N;j++){
            if(arr[tmp-j]=='R'&&arr[tmp+j]=='B') count--;
            if(arr[tmp-j]=='B'&&arr[tmp+j]=='R') count--;
        }
    }
    // RBG, GBR
    for(int i=0;i<bidx;i++){
        if(B[i]==0 || B[i]==N-1) continue;
        tmp = B[i]; prev = tmp-1; next = tmp+1;
        count += numR[prev]*(numG[N-1]-numG[tmp]);
        count += numG[prev]*(numR[N-1]-numR[tmp]);
        for(int j=0;tmp-j>=0&&tmp+j<N;j++){
            if(arr[tmp-j]=='R'&&arr[tmp+j]=='G') count--;
            if(arr[tmp-j]=='G'&&arr[tmp+j]=='R') count--;
        }
    }
    // GRB, BRG
    for(int i=0;i<ridx;i++){
        if(R[i]==0 || R[i]==N-1) continue;
        tmp = R[i]; prev = tmp-1; next = tmp+1;
        count += numG[prev]*(numB[N-1]-numB[tmp]);
        count += numB[prev]*(numG[N-1]-numG[tmp]);
        for(int j=0;tmp-j>=0&&tmp+j<N;j++){
            if(arr[tmp-j]=='G'&&arr[tmp+j]=='B') count--;
            if(arr[tmp-j]=='B'&&arr[tmp+j]=='G') count--;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3660
import sys
n,yen = map(int,input().split())

for i in range(n + 1):
    for j in range(n + 1):
        k = n - (i + j)
        if 10000 * i + 5000 * j + 1000 * k == yen and k >= 0:
            print("{} {} {}".format(i,j,k))
            sys.exit()
print("-1 -1 -1")

Measured memory_bytes: 3060