akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define LL long long
#define db long double

using namespace std;
const int N=(1<<20)+10;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
int n,f1[N],f2[N],z1[N],z2[N],an[N];
vector<int> e1[N],e2[N],ee[N];
bool vs[N];
int d1(int x)
{
    int nn=e1[x].size(),an=!z1[x]?x:0;
    for(int i=0;i<nn;++i)
    {
	int y=e1[x][i],w=d1(y);
	if(!an||!w) an|=w;
	else
	{
	    ee[an].push_back(w),ee[w].push_back(an);
	    an=0;
	}
    }
    return an;
}
int d2(int x)
{
    int nn=e2[x].size(),an=!z2[x]?x:0;
    for(int i=0;i<nn;++i)
    {
	int y=e2[x][i],w=d2(y);
	if(!an||!w) an|=w;
	else
	{
	    ee[an].push_back(w),ee[w].push_back(an);
	    an=0;
	}
    }
    return an;
}

int main()
{
////
    n=rd();
    for(int i=1;i<=n;++i)
    {
	f1[i]=rd();
	if(~f1[i]) e1[f1[i]].push_back(i),z1[f1[i]]^=1;
    }
    for(int i=1;i<=n;++i)
    {
	f2[i]=rd();
	if(~f2[i]) e2[f2[i]].push_back(i),z2[f2[i]]^=1;
    }
    for(int i=1;i<=n;++i)
	if(z1[i]^z2[i]){puts("IMPOSSIBLE");return 0;}
    puts("POSSIBLE");
    for(int i=1;i<=n;++i)
	if(f1[i]<0){d1(i);break;}
    for(int i=1;i<=n;++i)
	if(f2[i]<0){d2(i);break;}
    queue<int> q;
    for(int i=1;i<=n;++i)
	if(!z1[i]&&!vs[i])
	{
	    an[i]=-1,vs[i]=1,q.push(i);
	    while(!q.empty())
	    {
		int x=q.front();
		q.pop();
		int nn=ee[x].size();
		for(int j=0;j<nn;++j)
		{
		    int y=ee[x][j];
		    if(!vs[y]) vs[y]=1,an[y]=-an[x],q.push(y);
		}
	    }
	}
    for(int i=1;i<=n;++i) printf("%d ",an[i]);
    return 0;
}
 


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

int main() {
  string s;
  cin >> s;
  bool ok=false;
  ok|=( s[0]==s[1] && s[1]==s[2] );
  ok|=( s[1]==s[2] && s[2]==s[3] );
  if ( ok ) {
    puts("Yes");
  }
  else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Program().solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();


    void solve()
    {
        var s = "aiueo";
        var c = cin.next;

        Console.WriteLine(s.IndexOf(c) == -1 ? "consonant" : "vowel");
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return Console.ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}


Measured memory_bytes: 3032
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <sstream>
 
using namespace std;
 
int main(){
     int n;
     int S;
     while(cin >> n){
        S = 0;
        for(int i = 0; i < 600; i += n){
            S += n * i * i;
        }
        cout << S << endl;
     }
    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>

typedef struct directedGraph{
  int *vertex;
  int *next;
  int *start;
  int v,e;
  int pointer;
} graph;

graph* newGraph(const int v,const int e){
  graph *g=(graph *)malloc(sizeof(graph));
  g->vertex=(int *)calloc(e,sizeof(int));
  g->next=(int *)calloc(e,sizeof(int));
  g->start=(int *)calloc(v,sizeof(int));
  for(int i=0;i<v;i++) g->start[i]=-1;
  g->v=v;
  g->e=e;
  g->pointer=0;
  return g;
}

void freeGraph(graph *g){
  free(g->vertex);
  free(g->next);
  free(g->start);
  free(g);
  return;
}

void addEdge(graph *g,const int from,const int to){
  const int p=g->pointer;
  g->vertex[p]=to;
  g->next[p]=g->start[from];
  g->start[from]=p;
  g->pointer++;
  return;
}

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  graph *g=newGraph(n+1,2*n);
  for(i=1;i<n;i++){
    int v,u;
    scanf("%d%d",&v,&u);
    v--;u--;
    addEdge(g,v,u);
    addEdge(g,u,v);
  }
  int *q=(int *)calloc(n,sizeof(int));
  int *parent=(int *)calloc(n,sizeof(int));
  int front=0,last=0;
  q[last++]=0;
  while(last<n){
    int v=q[front++];
    for(int p=g->start[v];p!=-1;p=g->next[p]){
      int u=g->vertex[p];
      if(u==parent[v]) continue;
      parent[u]=v;
      q[last++]=u;
    }
  }
  int *dp=(int *)calloc(n+1,sizeof(int));
  for(i=n-1;i>=0;i--){
    int v=q[i];
    int max=0;
    int64 sum=0;
    int d=0;
    for(int p=g->start[v];p!=-1;p=g->next[p]){
      int u=g->vertex[p];
      if(u==parent[v]) continue;
      d++;
      sum+=dp[u];
      max=MAX(dp[u],max);
    }
    if(d==0){
      dp[v]=a[v];
      continue;
    }
    if(d==1){
      if(sum!=a[v]){
	puts("NO");
	return;
      }
      dp[v]=sum;
      continue;
    }
    if(2*a[v]<sum || a[v]>sum){
      puts("NO");
      return;
    }
    int t=2*a[v]-sum;
    int l=(sum-t)/2;
    if(l>MIN(sum/2,sum-max)){
      puts("NO");
      return;
    }
    dp[v]=t;
  }
  int d=0;
  for(i=1;i<n;i++) if(parent[i]==0) d++;
  if(d==1 || dp[0]==0){
    puts("YES");
  } else {
    puts("NO");
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 5002
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
//__gcd(a,b), __builtin_popcount(a);
/*chrono::system_clock::time_point  start;
void timerstart(){start = chrono::system_clock::now();}
void timerend(){
	auto end = chrono::system_clock::now();
	int elapsed = chrono::duration_cast<chrono::milliseconds>(end-start).count();
	printf("%d[ms]\n", elapsed);
}*/

int dis[MAX][MAX], ans[MAX];
int c[5002], r[5002], cost[5002], cosn[5002];
vector<int> G[MAX], dik[MAX];

void bfs(int s, int m){
	fill(cost, cost+MAX, inf);
	fill(cosn, cosn+MAX, -1);
	queue<P> q;
	cosn[s] = m;
	q.push(P(m, s));
	while(!q.empty()){
		P p = q.front();q.pop();
		
		if(cosn[p.se] > p.fi || cosn[p.se] == 0)continue;
		for(int i = 0;i < G[p.se].size();i++){
			int from = p.se, to = G[p.se][i];
			if(cosn[to] < cosn[from]-1){
				q.push(P(cosn[from]-1, to));
				cosn[to] = cosn[from]-1;
			}
		}
		
	}
}

void dijkstra(){
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0, 1));
	ans[1] = 0;
	while(!q.empty()){
		P p = q.top();q.pop();
		if(ans[p.se] < p.fi)continue;
		
		for(int i = 0;i < dik[p.se].size();i++){
			int from = p.se, to = dik[p.se][i];
			if(ans[to] > ans[from]+dis[from][to]){
				ans[to] = ans[from]+dis[from][to];
				q.push(P(ans[to], to));
			}
		}
		
	}
}

int main(){
	int n, k, t1, t2;
	fill((int*)cost, (int*)(cost+MAX), inf);
	fill((int*)dis, (int*)(dis+MAX), inf);
	fill(ans, ans+MAX, inf);
	scanf("%d%d", &n, &k);
	rrep(i,n)scanf("%d%d", &c[i], &r[i]);
	rep(i,k){
		scanf("%d%d", &t1, &t2);
		G[t1].push_back(t2);
		G[t2].push_back(t1);
	}
	
	for(int i = 1;i <= n;i++){
		bfs(i, r[i]);
		for(int j = 1;j <= n;j++){
			if(i == j)continue;
			if(cosn[j] != -1){
				dik[i].push_back(j);
				dis[i][j] = c[i];
			}
		}
	}
	dijkstra();
	
	printf("%d\n", ans[n]);
	return 0;
}

Measured memory_bytes: 168376
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main() {
  int x,y;
  cin>>x>>y;
  if(y%2!=0){
    cout<<"No\n";
    return 0;
  }
  for(int i=0;i<=x;i++){
    int k=y-2*i;
    if(i==0 && k<4)continue;
    if(k>=0 && k%4==0 && k/4 + i ==x){
      cout<<"Yes\n";
      return 0;
    }
  }
  cout<<"No\n";

  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define f first 
#define s second 
#define int long long
#define pb push_back
#define mp make_pair
#define pi pair<int , int>
set<pi> st;
void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
    st.insert({2 , count});
        // cout << 2 << "  " << count << endl; 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i++) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
        st.insert({i , count});
            // cout << i << "  " << count << endl; 
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
    st.insert({n , 1});
        // cout << n << "  " << 1 << endl; 
} 
int32_t main(){
     int n;
     cin>>n;
     factorize(n);
     int ans = 0;
     int rem = 0;
     for(auto it:st){
           int sum =  it.second;
        //   cout<<"sum : "<<sum;
           int val = sqrtl(sum);
        //   cout<<" val : "<<val<<endl;
           while((val*(val+1))/2 <= sum){
               val++;
           }
           val--;
          ans += val;
     }
     cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 9999999999999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;
const int SIZE = 1 << 17;

int main() {
	int n, k[15], sum = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) { cin >> k[i]; }
	sort(k, k + n);
	for (int i = 0; i < n - 1; ++i) {
		sum += k[i];
	}
	if (sum > k[n - 1]) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll H, W;
    cin >> H >> W;
    ll white = 0;
    vector<string> grid(H);
    rep(i, H) {
        string s;
        cin >> s;
        grid[i] = s;
        rep(j, W) {
            if (s[j] == '.') white++;
        }
    }
    vector<vector<bool>> visited(H, vector<bool>(W, false));
    vector<vector<ll>> dist(H, vector<ll>(W, INF));
    queue<pair<P, ll>> que;
    que.push(make_pair(make_pair(0, 0), 1));
    visited[0][0] = true;
    dist[0][0] = 1;
    while (!que.empty()) {
        auto q = que.front();
        que.pop();
        P p = q.first;
        ll d = q.second;
        rep(i, 4) {
            ll h = dx[i] + p.first;
            ll w = dy[i] + p.second;
            if (h >= 0 && h < H && w >= 0 && w < W && !visited[h][w] && grid[h][w] == '.') {
                visited[h][w] = true;
                dist[h][w] = d + 1;
                que.push(make_pair(make_pair(h, w), dist[h][w]));
            }
        }
    }
    if (dist[H - 1][W - 1] != INF) {
        cout << white - dist[H - 1][W - 1] << '\n';
    } else {
        cout << -1 << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 10;

int N, Nr[MAX_N], minV, maxV;
int Cnt[MAX_N];

int finish(int isCan) {
	if(isCan) puts("Yes");
	else puts("No");
	return 0;
}
int main() {
	minV = INF, maxV = -INF;
	cin >> N;
	REP(i, N) {
		scanf("%d", &Nr[i]);
		minV = min(minV, Nr[i]);
		maxV = max(maxV, Nr[i]);
		Cnt[Nr[i]]++;
	}
	if(maxV - minV >= 2) return finish(0);
	if(maxV - minV == 1) {
		int x = minV + 1 - Cnt[minV];
		if(x <= 0) return finish(0);
		if(Cnt[maxV] >= 2*x) return finish(1);
		return finish(0);
	} else {
		if(minV == N-1) return finish(1);
		if(2*minV <= N) return finish(1);
		return finish(0);
	}
	return 0;
}

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

typedef vector<int> vi;
#define ll long long
#define loop(i,n) for(int i=0; i<n; i++)
#define loop1(i,n) for(int i=1; i<=n; i++)
#define loopi(i,s,e) for(int i=s; i < e; i++)
#define loopiRev(i,s,e) for(int i=s; i >= e; i--)
#define PI 3.14159265359
#define x first
#define y second
#define point pair<double,double>
#define len(s)   (int)s.length()
#define sz(v)    (int)v.size()
#define all(a)   a.begin(),a.end()
#define clr(x, val)	memset((x), (val), sizeof(x))

void initialize(vector<int> &F, int n){
    F = vector<int> (n+1, 0);

    for(int i=2; i*i  <= n; i++){
        if(F[i] == 0)
            for(int k=i*i; k <=n ; k+= i)
                if(F[k] == 0) F[k] = i;
    }
}

//you don't know math, unless you can do math!
int l,n;
vector<int> cuts;
ll dp[1100][1100];

ll solve(int i, int j){
    ll &ret= dp[i][j];
    if(ret != -1)
        return ret;

    int cur= lower_bound(cuts.begin(), cuts.end(), i+1) - cuts.begin();
    if(cur == cuts.size() || cuts[cur] >= j)
        return ret= 0;



    ret= 10000000;
    while(cur < n && cuts[cur] < j){
        ret = min(ret, solve(i, cuts[cur]) + solve(cuts[cur], j) + j - i);
        cur++;
    }

    return ret;
}
int main() {
    //freopen("input.txt" , "r" , stdin) ;
    //freopen("output.txt" , "w" , stdout) ;

    cin.tie(0);
    cin.sync_with_stdio(0);

    ll n,k; cin>>n>>k;
    vector<ll> freq(110000,0);

    ll a,b;
    loop(i,n){
        cin>>a>>b;
        freq[a]+= b;
    }

    int i=0;
    int ans=0;

    while(k > 0){
        k-= freq[i];
        if(k <= 0){
            ans=i;
        }

        i++;
    }

    cout<<ans;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
// #define DEBUG_MODE
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(x) fprintf(stderr, "[%s = %d]\n", #x, x)
#else
	#define errp(...)
	#define dbg(x) 
#endif


int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int sx, sy, tx, ty;
	scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
	int dx = tx - sx, dy = ty - sy;
	for (int i = 0; i < dx; i++) printf("R");
	for (int i = 0; i < dy; i++) printf("U");
	for (int i = 0; i < dx; i++) printf("L");
	for (int i = 0; i < dy; i++) printf("D");

	printf("D");
	for (int i = 0; i < dx + 1; i++) printf("R");
	for (int i = 0; i < dy + 1; i++) printf("U");
	printf("L");

	printf("U");
	for (int i = 0; i < dx + 1; i++) printf("L");
	for (int i = 0; i < dy + 1; i++) printf("D");
	printf("R");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    string s;cin>>s;
    int n=s.size();
    ll ans=0;
    ll cnt[2019];
    fill(cnt,cnt+2019,0);
    ll now=0;
    ll ten=1;
    cnt[0]=1;
    rrep(i,n-1,0){
        now+=ten*(s[i]-'0');
        now%=2019;
        ans+=cnt[now];
        cnt[now]++;
        (ten*=10)%=2019;
    }
    cout<<ans<<endl;
}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll a, b, c, k, result = 0;
  cin >> a >> b >> c >> k;
  result = a - b;
  if (k % 2 == 1) result = (a - b) * (-1);
  cout << result << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.StringTokenizer;

public class Main { // Template for CF
    public static class ListComparator implements Comparator<List<Integer>> {

        @Override
        public int compare(List<Integer> l1, List<Integer> l2) {
            for (int i = 0; i < l1.size(); ++i) {
                if (l1.get(i).compareTo(l2.get(i)) != 0) {
                    return l1.get(i).compareTo(l2.get(i));
                }
            }
            return 0;
        }
    }

    public static void main(String[] args) throws IOException {
        // Check for int overflow!!!!
        // Should you use a long to store the sum or smthn?
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        int N = Integer.parseInt(f.readLine());
        List<Double> list = new ArrayList<>();
        StringTokenizer st = new StringTokenizer(f.readLine());
        for (int i = 0; i < N; i++) {
            double a = Integer.parseInt(st.nextToken());
            list.add(a);
        }
        Collections.sort(list);
        double ans = list.get(0);
        for (int i = 1; i < list.size(); i++) {
            ans += list.get(i);
            ans /= 2;
        }
        out.println(ans);
        out.close();
    }

}

Measured memory_bytes: 21076
cost = gets.split.map(&:to_i)
n = gets.to_i
norm_d = cost.map.with_index{ |e, i| e.to_i*(2**(3-i)) }.sort
norm_s = cost[0..2].map.with_index{ |e, i| e.to_i*(2**(2-i)) }.sort
puts norm_d.first*(n/2)+norm_s.first*(n%2)

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(M, vector<int>(0));
  vector<int> p(M);
  rep(i, M) {
    cin >> k[i];
    rep(j, k[i]) {
      int ss;
      cin >> ss;
      s[i].push_back(ss-1);
    }
  }
  rep(i, M) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < (1<<N); i++) {
    bool all_on = true;
    rep(j, M) {
      int on = 0;
      rep(n, k[j]) {
        if ((1<<s[j][n]) & i) {
          on++;
        }
      }
      if (on % 2 != p[j]) {
        all_on = false;
        break;
      }
    }
    if (all_on) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import copy
N = int(input())
b = list(map(int, input().split()))
ans = []
while len(b) > 0:
  n = len(b)
  f = False
  for i in range(n):
    if b[n-i-1] == n-i:
      ans.append(b.pop(n-i-1))
      f = True
      break
  if not f:
    print('-1')
    break
  if len(ans) == N:
    ans.reverse()
    for v in ans:
      print(v)
    break


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

int main(){
	int a,b;

	cin >> a >> b;
	
	if (a < b){
		cout << "a < b" << endl;
	}
	else if (a > b){
		cout << "a > b" << endl;
	}
	else{
		cout << "a == b" << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9 + 7, INF = 1e18;
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;}


signed main(){
	int N,A,B;
	cin >> N >> A >> B;
	if(A * B < N || N + 1 < A + B){
		cout << -1 << endl;
		return 0;
	}
	vector<int>ans[A];
	int yobun = N - A;
	REP(i,A){
		ans[i].push_back(1);
		int t = min(yobun,B-1);
		REP(j,t){
			ans[i].push_back(1);
		}
		yobun -= t;
	}
	vector<int>out(N);
	iota(ALL(out),1);
	int now = 0;
	REP(i,N){
		reverse(out.begin()+i,out.begin()+i+ans[now].size());
		i += (int)ans[now].size() - 1;
		now++;
	}
	REP(i,N){
		if(i)cout << " ";
		cout << out[i];
	}
	cout << endl;
}


Measured memory_bytes: 18688
#include <stdio.h>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>

using namespace std;

string str;
bool bl=false;

int main(){
    int count = 0;
    cin >> str;
    if(str[0]=='A') bl = true;
    if(bl){
        bl = false;
        for(int i = 2; i < str.size()-1 ; i++){
            if(str[i]=='C') {
                bl = true;
                count += 1;
            }
        }
    }
    if(bl && (count == 1)){
        for(int i = 1; i<str.size() ; i++ ){
            bl *= ((str[i]>='a'&&str[i]<='z')|| (str[i]=='C'));
        }
    }else bl=false;
    if(bl) cout << "AC" << endl;
    else cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

vector<ll> sum_b,sum_w;
void pre_process(vector<ll> &a, vector<ll> &s)
{ //累積和のvector
    ll n = (ll)a.size();
    s.assign(n + 1, 0);
    for (ll i = 0; i < n; i++)
    {
        s[i + 1] = s[i] + a[i];
    }
}
ll query(ll i, ll j, vector<ll> &s)
{ //区間[i,j]の和
    return (s[j] - s[i]);
}

int main(){
    string s;cin>>s;
    ll n=s.size();

    ll ans=0;
    rep(i,n-1){
        if(s[i]!=s[i+1]){
            ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3748
#include <algorithm>
    #include <bits/stdc++.h>
    #include <cctype>
    #include <cmath>
    #include <cstdio>
    #include <iomanip>
    #include <iostream>
    #include <list>

    #include <stack>
    #include <string>
    #include <vector>
    #include <bits/stdc++.h>
    #define INFINI (1000 * 1000 * 1000)

    using namespace std;
    //#define s(T) scanf("%d", &T)
    #define sl(T) scanf("%lld", &T)
    #define fill(a, val) memset(a, val, sizeof(a))
    #define mp make_pair
    #define pb push_back
    #define all(x) x.begin(), x.end()
    #define DREP(x) sort(all(x)); x.erase(unique(all(x)), x.end())
    #define INDEX(a, val) (lower_bound(all(a), val) - a.begin())

    typedef long long ll;


    bool compare_first(pair<int,int>a,pair<int,int >b)
    {
        return a.first<b.first;
    }

     bool compare_second(pair<int,pair<int , int> > a,pair<int,pair<int , int> > b)
    {
        return a.second.first<b.second.first;
    }


    ll min(ll a,ll b)
    {
        if(a>b)return b;
        return a;
    }
     ll max(ll a,ll b)
    {
        if(a>b)return a;
        return b;
    }

    ll toINT(string s)
    {
        ll a=0;
        for(ll index=0;index<s.size();index++)
            a=a*10+(s[index]-'0');
        return a;
    }


    int main(){


int a,b;
cin>>a>>b;
if(a<10&&b<10)
    cout<<a*b<<endl;
else
    cout<<-1<<endl;



    return 0 ;
}



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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n,10000000);
    std::vector<int> b(n-1);
    for(int i=0; i<n-1; i++){
        std::cin >> b[i];
        // a[i+1] = b[i];
    }
    // a[0] = a[1];
    for(int i=0; i<n-1; i++){
        if(b[i] < a[i]) a[i] = b[i];
        if(b[i] < a[i+1]) a[i+1] = b[i];
    }
    int asum = std::accumulate(a.begin(), a.end(), 0);

    std::cout << asum << std::endl;
    return 0;
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  string ans;
  if(N%2 == 1){
    ans = "No";
  }else{
    for(int i=0; i<N/2; i++){
      if(S[i] != S[N/2+i]){
        ans = "No";
        break;
      }
      if(i == N/2-1) ans = "Yes";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t A, B;
	std::cin >> A >> B;

	int64_t ans = std::lcm(A, B);

	std::cout << ans << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int arr[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>arr[i][j];
        }
    }

    int dp[n][3];

    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];

    for(int i=1;i<n;i++){

        dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=arr[i][2]+max(dp[i-1][1],dp[i-1][0]);

    }

    int ans=max(dp[n-1][0],dp[n-1][1]);
    ans=max(ans,dp[n-1][2]);
    cout<<ans;
}


Measured memory_bytes: 5836
# D
N = int(input())

al = [chr(ord('a') + i) for i in range(26)]

def dfs(S, i):
    if len(S) == N:
        yield S
        return
    for j in range(i):
        for w in dfs(S + al[j], i):
            yield w
    for w in dfs(S + al[i], i + 1):
        yield w

for w in dfs('', 0):
    print(w)

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

using namespace std;

struct DATA{
  int value;
  int bridge;
};

bool Compare(const DATA&, const DATA&);

int main(){
  int i, n, v, b, sum, giveup;
  DATA onedata;
  vector<DATA> data;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<n; ++i){
      cin >> v >> b;
      onedata.value = v;
      onedata.bridge = b;
      data.push_back(onedata);
    }

    sort(data.begin(), data.end(), Compare);

    for(i=0, sum=0, giveup=0; i<n; ++i){
      sum += data[i].value;
      if(sum > data[i].bridge){
	giveup = 1;
	break;
      }
    }

    if(giveup == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;

    data.clear();
  }

  return 0;
}

bool Compare(const DATA& x, const DATA& y){
  if(x.bridge == y.bridge)
    return (x.value <= y.value);
  else
    return (x.bridge < y.bridge);
}

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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> a(m);
  for (int i = 0; i < m; i ++) {
    cin >> a.at(i);
  }

  int tmp = 0;
  for (int i = 0; i < m; i ++) {
    if (a.at(i) > x) {
      tmp = i; //xより前のコストの個数
      break;
    }
  }

  int ans = 0;
  if (tmp >= m / 2) {
    ans = m - tmp;
  } else {
    ans = tmp;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> A(n + 1);
    rrep(i, n) {
        cin >> A[i];
    }
    vector<ll> check(n + 1, 0);
    check[1] = 1;
    vector<ll> ans;
    ll x = 1;
    ans.push_back(1);
    ll key;
    while(true) {
        x = A[x];
        if(check[x] == 1) {
            key = x;
            break;
        }
        else check[x] = 1;
        ans.push_back(x);
    }
    ll res;
    vector<ll> c;
    ll cnt = ans.size();
    rep(i, cnt) {
        if(ans[i] != key) {
            k--;
            if(k == 0) {
                res = ans[i + 1];
                cout << res << endl;
                return 0;
            }
        } else {
            forr(j, i, cnt) c.push_back(ans[j]);
            break;
        }
    }

    cnt = c.size();
    ll a = k % cnt;
    cout << c[a] << endl;
    
    return 0;
}

Measured memory_bytes: 10740
from collections import defaultdict

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

def main():
    num = int(input())
    data = [list(map(int, input().split())) for i in range(num)]
    data.sort(key=lambda x: x[1])
    now_time = 0

    flg = 1
    for i in range(num):
        if now_time + data[i][0] <= data[i][1]:
            now_time += data[i][0]
        else:
            flg = 0
            break
    if flg:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()



Measured memory_bytes: 88024
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long t = 0;
		long ans = 0;
		if (k % 2 == 0) {
			t = n / k;
			ans += (t * t * t);
			t = ((n*2) / k +1)/2;
			ans += (t * t * t);
		} else {
			t = n / k;
			ans += (t * t * t);
		}
 
		System.out.println(ans);
 
	}
}

Measured memory_bytes: 21972
#include <stdio.h>

int main(void) {
	int a, b;
	char op;
	int ans;
	
	while (1) {
		scanf("%d %c %d", &a, &op, &b);
		
		if (op == '?') break;
		
		switch(op) {
			case '+': ans = a + b; break;
			case '-': ans = a - b; break;
			case '*': ans = a * b; break;
			case '/': ans = a / b; break;
		}
		
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

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

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	vector<int> v( n );
	rep( i, n ) cin >> v[i];

	ll counter = 0;
	reps( i, n - 2 )
	{
		int t1 = v[i - 1];
		int t2 = v[i];
		int t3 = v[i + 1];
		if ( ( t2 > t1 ) && ( t2 < t3 ) )
		{
			counter++;
		}
		else if ( ( t2 > t3 ) && ( t2 < t1 ) )
		{
			counter++;
		}
	}

	cout << counter << endl;

	return ( 0 );
}


Measured memory_bytes: 384
while line = gets
  n=line.chomp.split(" ").map(&:to_i).first
  
  hash = {}
  flg = true
  prev = false
  n.times do |i|
    s = gets.chomp
    if hash[s]
      flg = false
    end
    if prev and s[0] != prev
      flg = false
    end
    prev = s[-1]
    hash[s] = true
  end
  puts flg ? "Yes" : "No"
  
end

Measured memory_bytes: 3836
// #include <bits/stdc++.h>
#include <iostream>
#include <ctime>
#include <vector>
#include <algorithm>

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

using namespace std;
using ll = long long;


void solve() {
    int len, qry;
    cin >> len >> qry;

    string s;
    cin >> s;
    int ara[len+3] = {0};

    for (int i = 1; i < len; ++i) {
        if(s[i] == 'C' && s[i-1] == 'A') {
            ara[i]++;
        }
        // ara[i] += ara[i-1]
    }

    for (int i = 1; i < len+3; ++i) {
        ara[i]+= ara[i-1];
        // cout << ara[i] << " ";
    }
    // cout << endl;

    while(qry--) {
        int l, r;
        cin >> l >> r;
        cout << ara[r-1] - ara[l-1] << endl;
        
    }



}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

#ifndef ONLINE_JUDGE
    double st = clock();
    // freopen("input.txt", "r", stdin);
#endif

    solve();

#ifndef ONLINE_JUDGE
    // cerr <<"\ntime = " <<  (clock() - st)/CLOCKS_PER_SEC << endl;
#endif 
    return 0;
}

Measured memory_bytes: 1488
/* ****mittal21**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
#define N  100005
std::vector<ll> a[N];
ll vis[N];
void dfs(ll node)
{
  vis[node]=1;
  for(auto i:a[node])
  if(!vis[i])
  dfs(i);
}
void solve()
{
   ll n,m;
   cin>>n>>m;
   ll cnt=0;
   for(int i=0;i<m;i++)
   {
    ll x,y;
    cin>>x>>y;
    a[x].pb(y);
    a[y].pb(x);
   }
   for(int i=1;i<=n;i++)
   {
     if(!vis[i])
     {
        dfs(i);
        cnt++;
     }
   }
   cout<<cnt-1;
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 11088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String numbers[] = br.readLine().split(" ");
		int N = Integer.parseInt(numbers[0]);
		int A = Integer.parseInt(numbers[1]);
		int B = Integer.parseInt(numbers[2]);
		int trainCost = N * A;
		if (trainCost < B) {
			System.out.println(trainCost);
		} else
			System.out.println(B);
	}

}

Measured memory_bytes: 22612
s = input()
def check(u):
    for i in range(len(u)):
        if u[i] != u[len(u) - i - 1]:
            return False
    return True
if check(s) and check(s[:len(s) // 2]) and check(s[len(s) // 2 + 1:]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
using Tree = vector<pair<int, int>>;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(3 * n);
    for (int i = 0; i < 3 * n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    for (int i = 0; i < 2 * n; i += 2)
    {
        ans += a[i + n];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
n = int(input())
lia = list(map(int,input().split()))
lib = list(map(int,input().split()))

ans = 0

for i in range(n):
    a = min(lia[i],lib[i])
    ans += a
    lib[i] -= a
    b = min(lia[i+1],lib[i])
    ans += b
    lia[i+1] -= b

print(ans)


Measured memory_bytes: 18624
#include<stdio.h>

int seach(int A[], int n, int key){
  int i = 0;
  A[n] = key;
  while(A[i] != key)i++;
  return i != n;
}

int main(){
  int i,n,A[10000+1],q,key,sum = 0;

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

  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&key);
    if(seach(A,n,key))sum++;
  }
  printf("%d\n",sum);

  return 0;
}



Measured memory_bytes: 2100
#include <stdio.h>
#include <algorithm>
#include <tuple>
#include <vector>
#include <set>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n, x[100010], y[100010];
int link[100010], s[100010];
vector<int> a[100010], b[100010];
set<int> c[100010];

void init() {
	for (int i = 1; i <= 1e5; i++)
		link[i] = i, s[i] = 1;
}
int root(int x) {
	if (link[x] == x)
		return x;
	return (link[x] = root(link[x]));
}
ll unite(int a, int b) {
	a = root(a), b = root(b);
	if (a == b)
		return 0;
	if (c[a].size() < c[b].size())
		swap(a, b);
	int same = 0;
	for (int v : c[b])
		same += c[a].find(v) != c[a].end();
	ll count = ((ll)c[a].size() - same) * s[b] + ((ll)c[b].size() - same) * s[a];
	link[b] = a;
	s[a] += s[b];
	c[a].insert(c[b].begin(), c[b].end());
	c[b].clear();
	return count;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d %d", x + i, y + i);
		a[x[i]].emplace_back(y[i]);
		b[y[i]].emplace_back(x[i]);
		c[y[i]].emplace(x[i]);
	}
	ll count = 0;
	init();
	for (int i = 1; i <= 1e5; i++)
		for (int v : b[i]) {
			for (int w : a[v])
				count += unite(i, w);
			a[v].clear();
		}
	printf("%lld\n", count);
}

Measured memory_bytes: 19072
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++){
      for(int j = i - 1, jump = 0; j  >= 0 && jump < k; j--, jump++){
        dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
      }
    }
    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>

using namespace std;
#define INF 2e9 + 9
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}


vector<vector<int>> to;
vector<int> flag;
vector<int> c;

Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};



int main(void) {
    string s;
    cin >> s;
    Int miner = 1000;
    for (Int i = 0; i + 2 < s.size();i++){
        Int z;
        z = 100 * (Int)(s.at(i)-'0') + 10 *(Int)(s.at(i+1)-'0') + (Int)(s.at(i+2)-'0');
        miner = min(abs(z-753),miner);
    }
    cout << miner << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] N = S.toCharArray();
		boolean n= false;
		for(int i = 0;i < N.length;i++) {
			for(int k = i+1;k < N.length;k++) {
				if(N[i] == N[k])n=true;
			}
		}
		if(n==false)System.out.println("yes");
		else System.out.println("no");
	}
 
}

Measured memory_bytes: 24020
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

signed main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    s.push_back('#');
    int ans = 0;
    for (int i=0; i<n; i++) {
        if (s[i] != s[i+1]) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

const int INF = 100000000;

int calc(const std::vector<std::pair<int, int>> &states, int a, int b, int c) {
  int aa = 0, bb = 0, cc = 0;
  int a_count = -1, b_count = -1, c_count = -1;
  for (auto state : states) {
    if (state.second == 1) { // a
      a_count++;
      aa += state.first;
    } else if (state.second == 2) { // b
      b_count++;
      bb += state.first;
    } else if (state.second == 3) { // c
      c_count++;
      cc += state.first;
    }
  }
  if (a_count == -1 || b_count == -1 || c_count == -1)
    return INF;
  return std::abs(a - aa) + 10 * a_count + std::abs(b - bb) + 10 * b_count +
         std::abs(c - cc) + 10 * c_count;
}

int solve(std::vector<std::pair<int, int>> &states, int idx, int a, int b,
          int c) {
    if (idx == states.size())
        return calc(states, a, b, c);
    int cand = INF;
    for (int i = 0; i < 4; i++) {
        cand = std::min(cand, solve(states, idx+1, a, b, c));
        states[idx].second++;
        if(i == 3) states[idx].second = 0;
    }
    return cand;
}

int main() {
  int n, a, b, c;
  std::cin >> n >> a >> b >> c;
  std::vector<std::pair<int, int>> kadomatsu(n);
  for (int i = 0; i < n; i++) {
    std::cin >> kadomatsu[i].first;
    kadomatsu[i].second = 0;
  }
  std::cout << solve(kadomatsu, 0, a, b, c) << std::endl;
}

Measured memory_bytes: 256
from itertools import accumulate
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
S = input()[:-1]

white = S.count('.')
L = [0]*N
for i, c in enumerate(S):
    if c == ".":
        L[i] = 1
L = [0]+list(accumulate(L))
# print(white)
# print(L)
if white == N or white == 0:
    ans = 0
else:
    ans = float('inf')
    for i in range(N+1):
        b = i-L[i]
        w = L[-1]-L[i]
        #print("{} times b:{} w:{}".format(i, b, w))
        ans = min(ans, b+w)
print(ans)


Measured memory_bytes: 14576
#include<stdio.h>
#define REP(i,n) for(int i=0;i<(int)n;i++)

int main(){
  int k;
  int num[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  scanf("%d",&k);
  printf("%d",num[k-1]);
  return 0;
}

Measured memory_bytes: 128
let n, m, g, c = Scanf.scanf " %d %d" @@ fun a b -> a, b, Array.make a [], ref 0
let f v u = g.(v - 1) <- u - 1 :: g.(v - 1)
let es = Array.init m @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> f a b; f b a; [a - 1; b - 1]
let rec h v e vs = vs.(v) <- true; incr c; List.(iter (fun u -> if not (vs.(u) || mem v e && mem u e) then h u e vs) g.(v))
let _ = Array.(fold_left (fun b e -> let vs = make n false in c := 0; h 0 e vs; if !c < n then b + 1 else b) 0 es) |> Printf.printf "%d\n"

Measured memory_bytes: 2432
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int X;
	std::cin >> X;
	for (auto i : boost::irange(1, 1001))
	{
		auto x = X - 100 * i;
		auto max = 5 * i;
		if (0 <= x && x <= max)
		{
			std::cout << 1 << std::endl;
			return;
		}
	}
	std::cout << 0 << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256