akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define sz size()
#define pb push_back
#define mp make_pair
#define ALL(X) (X).begin(),(X).end()

using namespace std;

const int INF = 1000000000;
const double eps = 1e-8;

vector<int> tetlist(const int n)
{
	vector<int> ary;
	int i = 1;
	while(1)
	{
		if(i*(i+1)*(i+2)/6 > n)
			break;
		else
		{
			ary.pb(i*(i+1)*(i+2)/6);
		  i++;
		}
	}
	return ary;
}

vector<int> search(const int n)
{
	vector<int> ary(n+1,INF);
	const vector<int> tet = tetlist(n);
	const int len = tet.size();
	ary[0] = 0;
	FOR(i,1,n+1)
	{
		REP(j,len)
		{
			if(tet[j] > i)
				break;
			else
				ary[i] = min(ary[i],ary[i-tet[j]]+1);
		}
	}
	return ary;
}

vector<int> tetlist_o(const int n)
{
	vector<int> ary;
	int i = 1;
	while(1)
	{
		if(i*(i+1)*(i+2)/6 > n)
			break;
		else if(((i*(i+1)*(i+2)/6) % 2) == 1)
			ary.pb(i*(i+1)*(i+2)/6);
		i++;
	}
	return ary;
}

vector<int> search_o(const int n)
{
	vector<int> ary(n+1,INF);
	const vector<int> tet = tetlist_o(n);
	const int len = tet.size();
	ary[0] = 0;
	FOR(i,1,n+1)
	{
		REP(j,len)
		{
			if(tet[j] > i)
				break;
			else
				ary[i] = min(ary[i],ary[i-tet[j]]+1);
		}
	}
	return ary;
}

int main(void) {
  vector<int> a1 = search(1000000);
  vector<int> a2 = search_o(1000000);
  while(1)
  {
  	int n;
  	cin>>n;
  	if(!n)break;
  	cout<<a1[n]<<' '<<a2[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 8784
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

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

int n,x,cnt;

int imain(){
  cnt = 0;

  rep(i,1,n+1) rep(j,i+1,n+1) rep(k,j+1,n+1){
    if(i+j+k == x)cnt++;
  }
  cout << cnt << endl;

  return 0;
}

int main(){
  for(;;){
    cin >> n >> x;
    if(n == 0 && x==0)break;
    imain();
  }
  return 0;
}



Measured memory_bytes: 3088
s = list(input())

digits = len(s)
s.reverse()
dp = [ [0] * 13 for i in range(digits)]
# dp[i][j] は i+1桁目までで13で割った余りがjのものを格納する
mod = 10 ** 9 + 7
power = 1

for i in range(digits):
    if s[i] == '?':
        for j in range(10):
            if i == 0:
                dp[i][j] += 1
            else:
                amari = (j * power) % 13
                for k in range(13):
                    dp[i][(k+amari)%13] = (dp[i][(k+amari)%13] + dp[i-1][k]) % mod
    else:
        val = int(s[i])
        if i == 0:
            dp[i][val] += 1
        else:
            amari = (val * power)% 13
            for k in range(13):
                dp[i][(k+amari)%13] = (dp[i][(k+amari)%13] + dp[i-1][k]) % mod
    power = (power * 10) % 13
print(dp[digits-1][5])

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

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

using ll = long long;

using namespace std;

struct UnionFind {
	vector<int> d;
	UnionFind(int n = 0) : d(n, -1) {}
	int find(int x) {
		if (d[x] < 0)return x;
		return d[x] = find(d[x]);
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -d[find(x)]; }
};


const int MOD = 1000000007;

ll powmod(ll a, ll n) {
	ll x = 1;
	while (n > 0) {
		if (n & 1) {
			x = (x * a) % MOD;
		}
		a = (a * a) % MOD;
		n >>= 1;
	}
	return x % MOD;
}

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

	ll ans = 0;
	
	ans = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);
	ans %= MOD;
	ans = (ans + MOD) % MOD;
	cout << ans << endl;

	return 0;
}






Measured memory_bytes: 3600
n,x,y = (int(x) for x in input().split())
x-=1
y-=1
middle=(y+x)/2
list=[[0 for i in range(n)]for j in range(n)]
for i in range(n-1):
    for j in range(i+1,n):
        if i<=x and j<=x:
            list[i][j] = j-i
        elif j==middle:
            list[i][j] = j-i
        elif i==middle:
            list[i][j] = j-i
        elif i<=x and j>=x and j<=middle:
            list[i][j] = j-i
        elif i<=x and j>=middle and j<=y:
            list[i][j] = (x-i) + 1 + (y-j)
        elif i<=x and j>=middle and j>=y:
            list[i][j] = (x-i) + 1 + (j-y)
        elif i>=x and i<=middle and j<=middle:
            list[i][j] = j-i
        elif i>=x and i<=middle and j>=middle and j<=y:
            list[i][j] = min(j-i, i-x+y-j+1)
        elif i>=x and i<=middle and j>=y:
            list[i][j] = i-x + j-y + 1
        elif i>=middle and j<=y:
            list[i][j] = j-i
        elif i>=middle and j>=y:
            list[i][j] = j-i
        elif i>=y and j>=y:
            list[i][j] = j-i
dic={}
for i in range(n-1):
    for j in range(i+1,n):
        if list[i][j] not in dic:
            dic[list[i][j]]=1
        else:
            dic[list[i][j]]+=1
for i in range(1,n):
    if i not in dic:
        print(0)
    else:
        print(dic[i])



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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<int> bit(41, 0);
    rep(i, n) {
        ll a;
        cin >> a;
        for (int i = 40; i >= 0; i--) {
            if (a & (1ll << i)) bit[i]++;
        }
    }
    ll x = 0;
    ll ans = 0;
    for (int i = 40; i >= 0; i--) {
        bool setone = false;
        ll toadd = 1ll << i;
        if (bit[i] <= n / 2) {
            if (x + toadd <= k) {
                x += toadd;
                ans += toadd * (n - bit[i]);
                setone = true;
            }
        }
        if (!setone) ans += toadd * bit[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
     
     
    public class Main {
        public static void main(String[] args) {
     
            Scanner sc = new Scanner(System.in);
            int x = sc.nextInt();
            int y = sc.nextInt();
            int z = sc.nextInt();

            System.out.println(z);
            System.out.println(x);
            System.out.println(y);
        }
    }

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


int main() {
        int n = 6;
        int ti[5] = {};
        for(int i = 0; i < n; i++) {
                int tmp;
                cin >> tmp;
                ti[tmp]++;
        }
        for(int i = 1; i <= 4; i++) if(ti[i] == 0 || ti[i] == 3) {
                cout << "NO" << endl;
                return 0;
        }
        cout<< "YES" << endl;
        return 0;
}

Measured memory_bytes: 256
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy


#X = str(input()).split()
#a = [int(x) for x in input().split()]


NM = str(input()).split()
N = int(NM[0])
M = int(NM[1])
KS = []
ans = 0
count = [0]*M
count2 = 0


for i in range(M):
  KS.append([int(x) for x in input().split()])

P = [int(x) for x in input().split()]

for i in range(2**N):
  for j in range(M):
    for k in range(KS[j][0]):
      if((i >> KS[j][k+1]-1) & 1):
        #print(i)
        #print(j)
        count[j]+=1
    if(count[j]%2==P[j]):
      count2+=1
    count[j]= 0
  if(count2==M):
    ans+=1
  count2=0









print(ans)


Measured memory_bytes: 43628
#include<iostream>
using namespace std;
int main() {
	long long l;
	cin >> l;
	long long num = 1;
	for (int i = 0; ; i++){
		if (num > l){
			cout << i << endl;
			break;
		}
		else{
			num *= 2;
		}
	}
}

Measured memory_bytes: 3088
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

//Push!!
public class Main{

	int[][] dist;
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int[][] move = {{-1,0},{0,1},{1,0},{0,-1}};
		for(;;){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if((w|h)==0)break;
			int[][] map = new int[h][w];
			int si = 0, sj = 0, ci = 0, cj = 0;
			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				map[i][j] = sc.nextInt();
				if(map[i][j]==4){
					si = i; sj = j;
					map[i][j] = 0;
				}
				if(map[i][j]==2){
					ci = i; cj = j;
					map[i][j] = 0;
				}
			}
			dist = new int[w*h][w*h];
			for(int[]a:dist)Arrays.fill(a, 1<<29);
			dist[si*w+sj][ci*w+cj] = 0;
			PriorityQueue<int[]> q = new PriorityQueue<int[]>(w, new Comparator<int[]>() {
				public int compare(int[] o1, int[] o2) {
					return dist[o1[0]][o1[1]]-dist[o2[0]][o2[1]];
				}
			});
			q.add(new int[]{si*w+sj, ci*w+cj});
			int ans = -1;
			while(!q.isEmpty()){
				int[] a = q.poll();
				si = a[0]/w; sj = a[0]%w;
				ci = a[1]/w; cj = a[1]%w;
				if(map[ci][cj]==3){
					ans = dist[a[0]][a[1]];
					break;
				}
				for(int k=0;k<4;k++){
					int ni = si+move[k][0];
					int nj = sj+move[k][1];
					if(0<=ni&&ni<h&&0<=nj&&nj<w){
						if(ni==ci&&nj==cj){
							int i = ci+move[k][0], j = cj+move[k][1];
							if(0<=i&&i<h&&0<=j&&j<w&&map[i][j]!=1&&dist[a[0]][a[1]]+1<dist[ni*w+nj][i*w+j]){
								dist[ni*w+nj][i*w+j] = dist[a[0]][a[1]]+1;
								q.add(new int[]{ni*w+nj, i*w+j});
							}
						}
						else if(map[ni][nj]!=1){
							if(dist[a[0]][a[1]]<dist[ni*w+nj][a[1]]){
								dist[ni*w+nj][a[1]] = dist[a[0]][a[1]];
								q.add(new int[]{ni*w+nj, a[1]});
							}
						}
					}
				}
			}
			System.out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
priority_queue<int>q;
int k,ans,a;
int main(){
	int n;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		q.push(a); 
	}
	for(int i=1;i<=k;i++){
		ans+=q.top();
		q.pop();
	}
	printf("%d\n",ans);
	return 0;
	}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<long long int> a(n),b(n),c(n);
	for(int i = 0;i<n;i++)
		cin >> a[i];
	for(int i = 0;i<n;i++)
		cin >> b[i];
	for(int i =0;i<n;i++)
		cin >> c[i];
	sort(a.begin(),a.end());
	sort(c.begin(),c.end());
	long long int ans = 0;
	for(int i = 0;i<n;i++)
	{
		auto tmp1 = lower_bound(a.begin(),a.end(),b[i]) - a.begin();
		auto tmp2 = c.end() - upper_bound(c.begin(),c.end(),b[i]);
		ans += 1ll*tmp1*tmp2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
typedef long long LL;
using namespace std;

int main()
{
	//freopen("data_in.txt", "r", stdin);
	int n = 0;
	cin >> n;
	vector<int> vt(n);
	for (int i = 0; i < n; ++i) cin >> vt[i];
	int res = 0;
	int i = 1;
	while(i < n) {
		if (vt[i] == vt[i - 1]) {
			res++;
			i += 2;
		}
		else ++i;
	}
	cout << res;
	return 0;
}

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

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

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
const int INF = 1001001001;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


struct Sieve {
  int n;
  vector<int> f, primes;
  //初期化、fの中にnまでの素数
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  //xが素数（fの中にある）かを判断
  bool isPrime(int x) { return f[x] == x;}
  //xを素因数分解
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  //素因数分解したものを、)vector<P> (値、数)にする
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


int main() {
  ll n,m;
  cin>>n>>m;
  ll ans=1;

  for(ll i=1;i*i<=m;i++){
    if (m%i==0){
      if(i*n<=m) ans=max(ans,i);
      if(n*m/i<=m)ans=max(ans,m/i);
    }

  }
  if (n==1)ans=m;
  cout<<ans;

}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    ll ans = 0;
    vector <vector <ll> > dp(n + 1, vector <ll> (2, -1e18));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        for (int was = 0; was < 2 && was <= a[i]; was++)
        {
            ll x = a[i] - was;
            for (int cur = 0; cur < 2 && cur <= a[i]; cur++)
            {
                dp[i + 1][cur] = max(dp[i + 1][cur], dp[i][was] + (x - cur) / 2 + cur);
            }
        }
    }
    cout << dp[n][0] << '\n';
}


Measured memory_bytes: 6144
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        int swap = 0;
        for (int i = 0; i < n-1; i++) {
            for (int j = n-1; j > i; j--) {
                if (a[j] < a[j-1]) {
                    int tmp = a[j];
                    a[j] = a[j-1];
                    a[j-1] = tmp;
                    swap++;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            if (i > 0) System.out.print(' ');
            System.out.print(a[i]);
        }
        System.out.println("");
        System.out.println(swap);
    }
}


Measured memory_bytes: 26316
n = int(input())
listA = list(map(int, input().split()))
a = sum(listA)
b = 0
c = 0
d = 0
listB = []
for i in range(n):
    b = b + listA[i]
    c = a-b
    d = abs(b-c)
    listB.append(d)
print(min(listB))



Measured memory_bytes: 3060
#include <stdio.h>
#include <inttypes.h>

uint64_t gcd(uint64_t a, uint64_t b) {
	while (b > 0) {
		uint64_t r = a % b;
		a = b;
		b = r;
	}
	return a;
}

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

int main(void) {
	uint64_t A, B, C, D;
	uint64_t maaya, sumipe;
	if (scanf("%" SCNu64 "%" SCNu64 "%" SCNu64 "%" SCNu64, &A, &B, &C, &D) != 4) return 1;
	maaya = B - ((B / C) + (B / D) - (B / lcm(C, D)));
	sumipe = (A - 1) - (((A - 1) / C) + ((A - 1) / D) - ((A - 1) / lcm(C, D)));
	printf("%" PRIu64 "\n", maaya - sumipe);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int a, b;

signed main() {
	cin >> a >> b;
	cout << a * b << endl;
}

Measured memory_bytes: 3636
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
//#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<list>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint moA=1e9+7;
const llint moB=1e9+9;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	//10,5,5,3,3,2,2,2,2
	int n,i;cin>>n;
	vector<int>S(n);
	for(i=0;i<n;i++){cin>>S[i];}
	SO(S);
	llint ans=0;
	deque<pair<int,llint>>que;
	que.push_back(mp(n,1));
	while(que.size()){
		int a=que.front().fir;
		llint b=que.front().sec;
		que.pop_front();
		ans+=a*b;
		int ma=(a+1)/2,ba=a/2;
		if(ma>1&&que.size()>0&&que.back().fir==ma){que.back().sec+=b;}
		else if(ma>1){que.push_back(mp(ma,b));}
		
		if(ba>1&&que.size()>0&&que.back().fir==ba){que.back().sec+=b;}
		else if(ba>1){que.push_back(mp(ba,b));}
	}
	for(i=0;i<n-1;i++){cout<<S[i]<<" ";}cout<<S[n-1]<<endl;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4656
MAX_V = 10 ** 5


def main():
    n = int(input())
    v = list(map(int, input().split()))

    odd, even = [0] * (MAX_V+1), [0] * (MAX_V+1)
    for i in range(n):
        if i % 2:
            odd[v[i]] += 1
        else:
            even[v[i]] += 1

    no, ne = [i for i in range(MAX_V+1)], [i for i in range(MAX_V+1)]
    no.sort(key=lambda val: odd[val], reverse=True)
    ne.sort(key=lambda val: even[val], reverse=True)

    if no[0] == ne[0]:
        print(min(n-odd[no[0]]-even[ne[1]], n-even[ne[0]]-odd[no[1]]))
    else:
        print(n-odd[no[0]]-even[ne[0]])


if __name__ == '__main__':
    main()



Measured memory_bytes: 17836
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      String S = sc.nextLine();
      char c ;
      char[] data = new char[4];
      for(int i = 0; i<4;i++){
        c = S.charAt(i);
        data[i] = c;
      }

      for(int i  = 0;i<3;i++){
        if(data[i]==data[i+1]){
          System.out.println("Bad");
          System.exit(0);
        }
      }
        System.out.println("Good");
                   }
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define tii tuple<int,int,int>
signed main(){
  int S;
  cin>>S;
  int ans=1;
  bitset<100000> A;
  A.set(S);
  while(1){
    ans++;
    if(S%2==0){
      S/=2;
      }
    else{
      S=3*S+1;
      }
    if(A.test(S)){
      cout<<ans<<endl;
      break;
      }
    A.set(S);
    }
}

Measured memory_bytes: 256
nums=[int(e) for e in input().split()]
if nums[0]>=0 and nums[1]>=0 and nums[2]>=0 and nums[3]>=0:
    print(nums[1]*nums[3])
elif nums[0]>=0 and nums[1]>=0 and nums[2]<0 and nums[3]>=0:
    print(nums[1]*nums[3])
elif nums[0]>=0 and nums[1]>=0 and nums[2]<0 and nums[3]<0:
    print(nums[0]*nums[3])
elif nums[0]<0 and nums[1]>=0 and nums[2]>=0 and nums[3]>=0:
    print(nums[1]*nums[3])
elif nums[0]<0 and nums[1]>=0 and nums[2]<0 and nums[3]>=0:
    if abs(nums[0])*abs(nums[2]) > abs(nums[1])*abs(nums[3]):
        print(nums[0]*nums[2])
    elif abs(nums[0])*abs(nums[2]) <= abs(nums[1])*abs(nums[3]):
        print(nums[1]*nums[3])
elif nums[0]<0 and nums[1]>=0 and nums[2]<0 and nums[3]<0:
    print(nums[0]*nums[2])
elif nums[0]<0 and nums[1]<0 and nums[2]>=0 and nums[3]>=0:
    print(nums[1]*nums[2])
elif nums[0]<0 and nums[1]<0 and nums[2]<0 and nums[3]>=0:
    print(nums[0]*nums[2])
elif nums[0]<0 and nums[1]<0 and nums[2]<0 and nums[3]<0:
    print(nums[0]*nums[2])


Measured memory_bytes: 9272
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;
/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

vi f(int n){
	vi divs ;
	for(int i = 1 ; i*i <= n ; i++){
		if(n%i == 0){
			divs.pb(i) ;
			if(n/i != i) divs.pb(n/i) ;
		}
	}
	sort(all(divs)) ;
	return divs ;
}

void solve(){
	int n ;
	cin >> n ;
	vi x = f(n) ;
	vi y = f(n-1) ;
	int cnt = sz(y)-1 ;
	for(int i = 1 ; i < sz(x) ; i++){
		int num = x[i] ;
		int nn = n ;
		while(nn%num == 0) nn/= num ;
		cnt += (nn%num == 1) ;
	}
	cout << cnt ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  long A, B, count, sub, ans = 1000;
  for(int i = 1; i <= sqrt(N); i++){
    if(N % i == 0){
      A = N / i;
      B = i;
      sub = 0;
      count = 0;
      while(A != 0){
        sub++;
        A /= 10;
      }
      while(B != 0){
        count++;
        B /= 10;
      }
      count = max(sub, count);
      ans = min(ans, count);
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(void){
	int A,B;

	cin >> A >> B;

	if(A+B < A-B){
		if(A-B < A*B)
			cout << A*B << endl;
		else
			cout << A-B << endl;

	}else if(A*B < A+B){
		cout << A+B << endl;
	}else{
		cout << A*B << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a, b,i,a1=0,b1=0;
	for (i = 0; i < 4; i++){
		scanf("%d", &a);
		a1 += a;
	}
	for (i = 0; i < 4; i++){
		scanf("%d", &b);
		b1 += b;
	}
	if (a>b){
		printf("%d\n", a1);
	}
	else if (a < b){
		printf("%d\n", b1);
	}
	else
		printf("%d\n", a1);
}

Measured memory_bytes: 1020
n=int(input())
x=[]
f_l_checker=True
x.append(input())
for i in range(1,n):
    x.append(input())
    if f_l_checker:
        if x[i][0]==x[i-1][-1]:
            for j in range(i):
                if x[i]==x[j]:
                    f_l_checker=False
        else:
            f_l_checker=False
if f_l_checker:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();

		if (a * b % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}

}


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

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

using namespace std;

int main()
{
  ll K;
  vector<ll> num(3, 0);
  for (auto i = 0; i < 3; i++){
    cin >> num[i];
  }
  cin >> K;
  vector<vector<ll>> cakes(num.size());
  for (auto i = 0; i < 3; i++) {
    cakes[i] = vector<ll>(num[i]);
    for (auto j = 0; j < num[i]; j++)
      cin >> cakes[i][j];
    // sort(cakes[i].begin(), cakes[i].end(), std::greater<ll>());
  }
  vector<ll> best;
  vector<ll> bestXY;
  for (auto x : cakes[0])
    for (auto y : cakes[1])
      bestXY.push_back(x + y);
  sort(bestXY.begin(), bestXY.end(), greater<ll>());
  for (auto i = 0; i < min((ll)bestXY.size(), K); i++) {
    for (auto z : cakes[2])
      best.push_back(bestXY[i] + z);
  }
  sort(best.begin(), best.end(), greater<ll>());

  for (auto i = 0; i < min((ll)best.size(), K); i++)
      cout <<best[i] << endl;
  return 0;
}


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

int main()
{
  int n, k;
  std::cin >> n >> k;

  std::vector<int> p(n);
  for (auto& itr: p)
  {
    std::cin >> itr;
  }
  std::sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < k; ++i)
  {
    ans += p[i];
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int32_t main(){
    fast;
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    if(n%2){
        int ans=0;
        for(int i=1;i<=n-2;i+=2)
            ans+=a[i];
        int sum[n+1];
        sum[n]=a[n];
        for(int i=n-2;i>=1;i-=2)
            sum[i]=sum[i+2]+a[i];
        sum[n-1]=a[n-1];
        for(int i=n-3;i>=1;i-=2)
            sum[i]=max(sum[i+2],sum[i+3])+a[i];
        int curr=0;
        int i;
        for(i=3;i<=n;i+=2)
        {
            ans=max(ans,max(sum[i],sum[i-1])+curr);
            curr+=a[i-2];
        }
        cout<<ans;
    }
    else{
        int sum[n+1];
        int ans=0;
        sum[n]=a[n];
        for(int i=n-2;i>=1;i-=2)
            sum[i]=sum[i+2]+a[i];
        sum[n-1]=a[n-1];
        for(int i=n-3;i>=1;i-=2)
            sum[i]=max(sum[i+2],sum[i+3])+a[i];
        ans=max(sum[1],sum[2]);
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 6684
def nib(x):
    left = 0
    right = len(L[:length])
    mid = (left + right) // 2
    while 1:
        if mid == 0 or (L[mid] >= x and x > L[mid-1]):
            break
        if L[mid] > x:
            right = mid
        elif x > L[mid]:
            left = mid
        mid = (left + right) // 2
    return mid

N = int(input())
A = [int(input()) for _ in range(N)]
L = [0 for _ in range(N)]
L[0] = A[0]
length = 1
for i in range(1, N):
    if L[length-1] < A[i]:
        L[length] = A[i]
        length += 1
    else:
        L[nib(A[i])] = A[i]
print(length)


Measured memory_bytes: 10968
from collections import deque
class csr:
    __slots__ = ['start','elist']
    def __init__(self,N,edges):
        self.start = [0]*(N+1)
        self.elist = [0]*len(edges)
        for e in edges:
            self.start[e[0]+1] += 1
        for i in range(1,N+1):
            self.start[i] += self.start[i-1] 
        counter = self.start[:]
        for e in edges:
            self.elist[counter[e[0]]] = e[1]
            counter[e[0]] += 1

class scc_graph:
    def __init__(self,N):
        self.N = N
        self.edges = []
    
    def add_edge(self,v,w):
        self.edges.append((v,w))

    def scc_ids(self):
        g = csr(self.N,self.edges)
        now_ord = group_num = 0
        visited = deque()
        low = [0]*self.N
        order = [-1]*self.N
        ids = [0]*self.N
        parent = [-1]*self.N
        stack = deque()
        for i in range(self.N):
            if order[i] == -1:
                stack.append(i)
                stack.append(i)
                while stack:
                    v = stack.pop()
                    if order[v] == -1:
                        low[v] = order[v] = now_ord
                        now_ord += 1
                        visited.append(v)
                        for i in range(g.start[v],g.start[v+1]):
                            to = g.elist[i]
                            if order[to] == -1:
                                stack.append(to)
                                stack.append(to)
                                parent[to] = v
                            else:
                                low[v] = min(low[v],order[to])
                    else:
                        if low[v] == order[v]:
                            while True:
                                u = visited.pop()
                                order[u] = self.N
                                ids[u] = group_num
                                if u == v:
                                    break
                            group_num += 1
                        if parent[v] != -1:
                            low[parent[v]] = min(low[parent[v]],low[v])
        for i,x in enumerate(ids):
            ids[i] = group_num-1-x

        return group_num,ids
    
    def scc(self):
        group_num,ids = self.scc_ids()
        groups = [[] for _ in range(group_num)]
        for i,x in enumerate(ids):
            groups[x].append(i)
        return groups
    
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
N,M = map(int,readline().split())
ab = list(map(int,read().split()))
sg = scc_graph(N)

it = iter(ab)
for a,b in zip(it,it):
    sg.add_edge(a,b)

scc = sg.scc()
print(len(scc))
for group in scc:
    print(str(len(group))+' '+' '.join(map(str,group)))


Measured memory_bytes: 214276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
//#define _GLIBCXX_DEBUG

vector<int> prime(int N) {
  vector<bool> a(N, true);
  for(int i=1; i<sqrt(N); i++) {
    if(a[i]) for(int k=2; (i+1)*k-1<N; k++) a[(i+1)*k-1] = false;
  }
  vector<int> p;
  rep(i, N) if(a[i]) p.push_back(i+1);
  return p;
}
  

signed main() {
  int N; cin >> N;
  vector<int> P = prime(N);
  
  int ans = 1;
  for(int p : P) {
    if(p == 1) continue;
    int n = N;
    int a = 0;
    while(n > 1) {
      n /= p;
      a += n;
    }
    a %= 1000000007;
    ans *= a+1;
    ans %= 1000000007;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll x,y;
	cin>>x>>y;
	if((y>=2*x)&&(4*x>=y)&&((4*x-y)%2==0)&&((y-2*x)%2==0)) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {

    int n, m, x, y, xtemp, ytemp;
    scanf("%d %d %d %d", &n, &m, &x, &y);

    int xmax = -101;
    int ymin = 101;
    for (int i = 0; i < n; i++) {
        scanf("%d", &xtemp);
        if (xmax < xtemp) {
            xmax = xtemp;
        }
    }

    for (int j = 0; j < m; j++) {
        scanf("%d", &ytemp);
        if (ytemp < ymin) {
            ymin = ytemp;
        }
    }

    //printf("%d %d %d %d", x, y, xmax, ymin);

    if ((xmax > x) && (ymin <= y) && (xmax + 1 <= ymin)) {
        puts("No War");

    } else {
        puts("War");

    }

    return 0;

}

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

int main() {
    string S;
    cin >> S;
    string ans = "AC";

    if(S[0] != 'A') ans = "WA";

    int count = 0;
    for(int i = 1; i < S.size(); ++i) {
        if(isupper(S[i])) {
            if(i == 1 || i == S.size() - 1 || S[i] != 'C') ans = "WA";
            ++count;
        }
    }

    if(count != 1) ans = "WA";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

N = int(input())

prime_counts = defaultdict(int)

for i in range(2, N + 1):
    n = i
    for p in prime_counts:
        while True:
            if n % p == 0:
                prime_counts[p] += 1
                n = n // p
            else:
                break
    if n > 1:
        prime_counts[n] += 1

d = 1
for c in prime_counts.values():
    d *= (1 + c)
print(d % (10 ** 9 + 7))

Measured memory_bytes: 9348
#include<iostream>
#include<iomanip>
#include<cstdio>
using namespace std;

int main() {
	int a, b, d, r;
	double f;
	cin >> a >> b;
	d = a / b;
	r = a%b;
	f = (double)a / b;
	cout << d << " " << r << " " << fixed << setprecision(8) << f << endl;

}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 ll a;
 cin>>a;
 cout<<a+a*a+a*a*a<<endl;

return 0;
}



Measured memory_bytes: 3652
#include <iostream>

int main()
{
  int a, b;
  std::cin >> a >> b;
  
  bool evenA = a % 2 == 0;
  bool evenB = b % 2 == 0;
  
  if(evenA || evenB)
  {
     std::cout << "Even";
  }
  else
  {
    std::cout << "Odd";
  }
}

Measured memory_bytes: 256
from bisect import bisect_left as bl
INF = 10 ** 20

def main():
  
  w, h = map(int, input().split())
  n = int(input())
  
  xlst = []
  ylst = []
  appx = xlst.append
  appy = ylst.append
  for i in range(n):
    x, y = map(int,input().split())
    appx(x)
    appy(y)
  
  sorted_xlst = sorted(xlst)
  sorted_ylst = sorted(ylst)
  accx = accy = 0
  cum_sum_xlst = []
  cum_sum_ylst = []
  appx = cum_sum_xlst.append
  appy = cum_sum_ylst.append

  for i in range(n):
    accx += sorted_xlst[i]
    accy += sorted_ylst[i]
    appx(accx)
    appy(accy)
  
  if n % 2:
    clx = crx = sorted_xlst[n // 2]
    cly = cry = sorted_ylst[n // 2]
  else:
    clx = sorted_xlst[n // 2 - 1]
    crx = sorted_xlst[n // 2]
    cly = sorted_ylst[n // 2 - 1]
    cry = sorted_ylst[n // 2]
  plx = bl(sorted_xlst, clx)
  prx = bl(sorted_xlst, crx)
  ply = bl(sorted_ylst, cly)
  pry = bl(sorted_ylst, cry)


  
  ans = ansx = ansy = INF
  
  for i in range(n):
    xi = xlst[i]
    yi = ylst[i]

    if xi <= clx:
      cx = crx
      px = prx
    else:
      cx = clx
      px = plx
    if yi <= cly:
      cy = cry
      py = pry
    else:
      cy = cly
      py = ply
  
    dx = xi - cx
    if dx < 0:
      dx = -dx

    if px:
      csx = cum_sum_xlst[px - 1]
      xlen = (accx - csx * 2 - cx * (n - px * 2)) * 2 - dx
    else:
      xlen = (accx - cx * n) * 2 - dx
 
    dy = yi - cy
    if dy < 0:
      dy = -dy
   
    if py:
      csy = cum_sum_ylst[py - 1]
      ylen = (accy - csy * 2 - cy * (n - py * 2)) * 2 - dy
    else:
      ylen = (accy - cy * n) * 2 - dy
    
    tlen = xlen + ylen

    if ans > tlen:
      ans = tlen
      ansx = cx
      ansy = cy
    elif ans == tlen:
      if ansx > cx:
        ansx = cx
        ansy = cy
      elif ansx == cx:
        if ansy > cy:
          ansy = cy 
  
  print(ans)
  print(ansx, ansy)

main()


Measured memory_bytes: 25180
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll B, ll mod){
  if (B == 0) return 1;
  else{
    if (B % 2 == 0){
      return Pow(A * A % mod, B / 2, mod) % mod;
    }else{
      return A * Pow(A * A % mod, B / 2, mod) % mod;
    }
  }
}

ll nCr(ll N, ll C, ll mod){
  ll ans = 1; C = min(C, N - C);
  for (ll i = 1; i <= C; i++){
    ans *= N - i + 1; ans %= mod;
    ans *= Pow(i, mod - 2, mod); ans %= mod;
  }
  return ans;
}

int main(){
  string S; cin >> S;
  int x, y; cin >> x >> y;
  int X = 0;
  for (int i = 0; i < S.length(); i++){
    if (S[i] == 'F') X++;
    else break;
  }
  S = S.substr(X);

  vector <bool> DPX(2e5), DPY(2e5);

  DPX[1e5 + X] = true;
  DPY[1e5] = true;
  bool flagx = true; int cnt = 0;

  int MX = 1e5 + X, mx = 1e5 + X;
  int MY = 1e5, my = 1e5;
  for (int i = 0; i < S.length() + 1; i++){
    if (i < S.length() && S[i] == 'F'){
      cnt++;
    }else{
      vector <bool> now(2e5);
      if (flagx == true){
        int M = MX, m = mx;
        for (int j = mx; j <= MX; j++){
          if (DPX[j] == true){
            now[j + cnt] = true;
            now[j - cnt] = true;
            M = max(M, j + cnt);
            m = min(m, j - cnt);
          }
        }
        MX = M; mx = m;
        DPX = now;
        flagx = false;
        cnt = 0;
      }else{
        int M = MY, m = my;
        for (int j = my; j <= MY; j++){
          if (DPY[j] == true){
            now[j + cnt] = true;
            now[j - cnt] = true;
            M = max(M, j + cnt); m = min(m, j - cnt);
          }
        }
        MY = M; my = m;
        DPY = now;
        flagx = true;
        cnt = 0;
      }
    }
  }
  
  if (DPX[1e5 + x] == true && DPY[1e5 + y] == true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 384
//
//  main.cpp
//  20190801lesson
//
//  Created by Priscilla Leang on 8/1/19.
//  Copyright 漏 2019 Priscilla Leang. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int f = 0, m = 0;
    string s;
    bool b1 = false;
    bool b2 = false;
    bool b3 = false;
    cin >> s;
    //first condition
    if (s[0] =='A'){
        b1 = true;
    }
    //second condition
    for (int i = 2; i<s.length() - 1; i++){
        if (s[i] == 'C'){
            f++;
        }
    }
    if (f == 1){
        b2 = true;
    }
    //third condition
    for (int i = 1; i<s.length(); i++){
        for (int j = 97; j<= 122; j++){
            if (s[i] == j){
                m++;
            }
        }
    }
    if (m == s.length() - 2){
        b3 = true;
    }
    if (b1 == true && b2 == true && b3 == true){
        cout << "AC";
    }
    else {
        cout <<"WA";
    }
    return 0;
}

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

using namespace std;

int root[4001];
int del[4001][4001]={};
int p;
vector<pair<int,int> > graph[4001];
int find(int x){
	if(x != root[x]){
		root[x]=find(root[x]);
	}
	return root[x];
}

void union_set(int x,int y){
	x=find(x);
	y=find(y);
	if(x!=y){
		root[x]=y;
	}
	return;
}

void dfs(int x,int y,int z){
	del[p][x] = z;
	for(int i=0;i<graph[x].size();i++){
		if(graph[x][i].first==y)continue;
		dfs(graph[x][i].first,x,max(z,graph[x][i].second));
	}
}

int main(){
	for(int i=0;i<4001;i++){
		root[i] = i;
	}
	int n,m,q,a,b,s,t,c;
	long long ans=0;
	long long sum=0;
	vector<pair<long long,pair<int,int> > > node,node2;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		pair<long long,pair<int,int> > tmp;
		cin >> a >> b >> c;
		tmp = make_pair(c,make_pair(a,b));
		node.push_back(tmp);
	}
	sort(node.begin(),node.end());
	for(int i=0;i<node.size();i++){
		if(find(node[i].second.first)!=find(node[i].second.second)){
			sum += node[i].first;
			union_set(node[i].second.first,node[i].second.second);
			node2.push_back(node[i]);
			graph[node[i].second.first].push_back(make_pair(node[i].second.second,node[i].first));
			graph[node[i].second.second].push_back(make_pair(node[i].second.first,node[i].first));
		}
	}
	for(p=1;p<=n;p++){
		dfs(p,-1,-1);
	}
	cin >> q;
	for(int i=0;i<q;i++){
		cin >> s >> t;
		ans = sum-del[s][t];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 70504
#include <iostream>
#include <string.h>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	char S[4096];
	memset(S,'\0',4096);
	int i=0;
	while (N!=0){
		int D=N%(-2);
		N/=(-2);
		if (D<0){
			D=-D;
			N+=D;
		}
		S[i++]='0'+D;

	}
	int sLen=strlen(S);
	if (sLen==0){
		cout<<0;
	}else{
		for (int i=sLen-1;i>=0;i--){
			cout<<S[i];
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))

const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL<<62);
const int iinf = (1<<30);

string s;

int main(){
    cin >> s;
    int a = s[1] - '0' + (s[0] - '0')*10;
    int b = s[3] - '0' + (s[2] - '0')*10;
    if (a <= 12 && a && b <= 12 && b) rc("AMBIGUOUS");
    if (a <= 12 && a) rc("MMYY");
    if (b <= 12 && b) rc("YYMM");
    rc("NA");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <random>
#include <utility>
//#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1ll<<61 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
void chmax(ll &a,ll b){	if(a<b) a = b ;}
void chmin(ll &a,ll b){ if(a>b) a = b ;}

int main(){
	ll n,a,b,c,d ;
	cin >> n >> a >> b >> c >> d ;
	if(a>b) swap(a,b) ;
	if((b-a+d-1)/d>n-1){
		YorN(0) ;
		return 0 ;
	}
	ll cnt = 0 ;
	ll num = a ;
	while(num<=b){
		cnt++ ;
		num += d ;
	}
	if((n-1-cnt)&1){
		cnt-- ;
		num -= d ;
		YorN(num+(n-1-cnt)/2*(d-c)>=b) ;
	}else{
		if(num-cnt*(d-c)<=b) YorN(1) ;
		else{
			num -= cnt*(d-c) ;
			YorN(num-(n-1-cnt)/2*(d-c)<=b) ;
		}
	}
}


Measured memory_bytes: 3612