akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <queue>

using namespace std;

short int mem[16777216];

int solve(int a[24][24],int *c,int depth){
	int max=0;
	int tmp=0;
	int est=0;
	int xsum,ysum;
	int (*copy)[24] = new int[24][24];
	int *cpy = new int[24];
	/*for(int i=0;i<24;i++){
		cout << c[i] << " ";
	}
	cout << endl;*/
	int d,e;
	max = depth;
	for(int x=0;x<24-1;x++){
		for(int y=x+1;y<24;y++){
			//a[x],a[y]が全部０か？
			xsum=0;ysum=0;
			for(int z=0;z<24;z++){ xsum+=a[x][z]; ysum+=a[y][z];}
			d=0;
			for(int z=0;z<24;z++){ if(c[z]>0)d++;}
			if(d<2) return depth;
			//a[x],a[y]が全部0でかつ，xとyの色は一緒なのか？
			if(c[x]==c[y] && xsum==0 && ysum==0 && c[x]!=0){
				//配列をコピーする
				for(int i=0;i<24;i++){
					for(int j=0;j<24;j++) copy[i][j]=a[i][j];
				}
				//コピーした配列で選ばれたxとyを取り除く
				for(int i=0;i<24;i++){
					copy[i][x]=0;
					copy[i][y]=0;
					cpy[i]=c[i];
				}
				cpy[x]=0;
				cpy[y]=0;
				d=0;
				for(int i=0;i<24;i++){
					if(cpy[i]!=0){
					e=1;
					for(int j=0;j<i;j++){
						e*=2;
					}
					d+=e;
					}
				}
				if(mem[d]==-1){
					tmp=solve(copy,cpy,depth+1);
					mem[d]=tmp;
				}else{
					tmp=mem[d];
				}
				if(tmp>=12) return 12;
				if(max<tmp){
					max=tmp;
				}
			}
		}
	}
	
	delete []copy;
	delete cpy;
	return max;
}

bool on(int x1,int y1,int r1,int x2,int y2,int r2){
	bool result;
	int dx,dy;
	int dis;
	int mindis;
	result=false;
	
	dx=(x1-x2);
	dy=(y1-y2);
	mindis=r1+r2;

	dis=sqrt(dx*dx+dy*dy);

	if(dis<mindis) result=true;
	
	return result;
}

int main(void){
	int n;
	int xs[24];
	int ys[24];
	int rs[24];
	int cs[24];
	int onTable[24][24];



	while(true){
		//データを初期化
		for(int i=0;i<24;i++){
			xs[i]=-1;
			ys[i]=-1;
			rs[i]=0;
			cs[i]=0;
			for(int j=0;j<24;j++) onTable[i][j]=0;
		}

		//枚数を入力
		cin >> n;
		if(n==0) break;

		for(int i=0;i<n;i++){
			cin >> xs[i];
			cin >> ys[i];
			cin >> rs[i];
			cin >> cs[i];
		}
		
		//行列を作成
		for(int i=1;i<n;i++){
			for(int j=i-1;j>=0;j--){
				if(on(xs[i],ys[i],rs[i],xs[j],ys[j],rs[j])){
					onTable[i][j]=1;
				}
			}
		}
		//行列を表示
	/*	for(int i=0;i<n;i++){
			printf("%2d:",i);
			for(int j=0;j<n;j++){
				cout << onTable[i][j] << " ";
			}
			cout << endl;
		}
*/
		for(int i=0;i<16777216;i++){
			mem[i]=-1;
		}
		cout << solve(onTable,cs,0)*2 << endl;

	}
	return 0;
}

Measured memory_bytes: 34084
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll mod = 1e9+7;
const ll INF = 2e9;
const double PI = 3.1415926535;

char s[500001];
ll dat[2000000];
ll n;
int qa[20000];
void segtree_init(ll n_){
    n = 1; while(n < n_)n *= 2; //要素数を2のべき乗に
    for(int i = 0;i < 2 * n - 1;i++)dat[i] = 0;
}
void segtree_update(ll k, ll a){
    k += n-1; dat[k] = a;
    while(k > 0){
        k = (k-1)/2;
        dat[k] = dat[k*2+1] | dat[k*2+2];
    }
}
int query(int a, int b, int k, int l, int r){
    //[a, b)を知りたくていま[l, r)である節点kを見ている
    if(r <= a || b <= l)return 0; //求めたい範囲と被らない
    if(a <= l && r <= b)return dat[k]; //全て求めたい範囲に含まれている
    int vl = query(a, b, k*2+1, l, (l+r)/2);
    int vr = query(a, b, k*2+2, (l+r)/2, r);
    return vl | vr;
}

int main(void){
    ll n_; cin >> n_; cin >> s; ll q; cin >> q;
    segtree_init(n_);
    for(int i = 0;i < n_;i++){
        ll num = s[i] - 'a';
        num = 1 << num;
        segtree_update(i, num);
    }
    //for(int i = 0;i < n;i++)cout << dat[i] << endl;
    int ind = 0;
    for(int i = 0;i < q;i++){
        ll a; cin >> a;
        if(a == 1){
            ll b; char c; cin >> b >> c; b--;
            ll num = c - 'a';
            num = 1 << num;
            segtree_update(b, num);
        }else{
            ll b, c; cin >> b >> c; b--; c;
            int qu = query(b, c, 0, 0, n);
            int ans = 0;
            while(qu > 0){
                ans += qu % 2;
                qu /= 2;
            }
            qa[ind] = ans;
            ind++;
        }
    }
    for(int i = 0;i < ind;i++)cout << qa[i] << endl;
	return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> bool chmax(T& t, const U& u) { if (t < u) { t = u; return 1; } return 0; }
template<class T, class U> bool chmin(T& t, const U& u) { if (t > u) { t = u; return 1; } return 0; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	string S; cin >> S;
	bool ok = 1;
	if (S.size() % 2 != 0) {
		ok = 0;
	}
	string t = "hi";
	rep(i, S.size()) {
		if (S[i] != t[i % 2]) {
			ok = 0;
		}	
	}
	puts(ok ? "Yes" : "No");
	return 0;
}

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

//https://atcoder.jp/contests/abc089/tasks/abc089_d

using P=pair<int,int>;

int h, w, d, q, c[90000];
P s[90000];

int main() {
	cin >> h >> w >> d;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) {
			int a;
			cin >> a;
			a--;
			s[a] = make_pair(i, j);
		}
	for (int i = d; i < h * w; i++)
		c[i] = c[i - d] + abs(s[i].first - s[i - d].first)
				+ abs(s[i].second - s[i - d].second);
	cin >> q;
	while (q--) {
		int l, r;
		cin >> l >> r;
		l--, r--;
		cout << c[r] - c[l] << endl;
	}

}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;

bool check(int x){
	if(x<0||x>26)return false;
	return true;
}

int main(){
	string S;
	cin>>S;
	if(S[0]!='A'||(check(S[1]-'a')==false)){
		cout<<"WA"<<endl;
	}else{
		bool c=false;
		bool e=false;
		for(int i=2;i<S.size()-1;i++){
			if(S[i]=='C'){
				if(c==true)e=true;
				c=true;
			}else{
				int x=S[i]-'a';
				if(check(x)==false)e=true;
			}
		}
		int x=S[S.size()-1]-'a';
		if(check(x)==false)e=true;
		//cout<<c<<" "<<e<<endl;
		if(c==true&&e==false){
			cout<<"AC"<<endl;
		}else{
			cout<<"WA"<<endl;
		}
	}
	return(0);
}

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

int main()
{
  int N,X,Y;
  cin >> N >> X >> Y;
  int A = min(X,Y);
  int B = X + Y - N;
  if( B <= 0) B = 0;
  cout << A << endl; 
  cout << B << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;


    
int main(){
    int d,n;
    cin>>d>>n;
    if(n<=99){
        cout<<n*(int)pow(100,d)<<endl;
    }else{
        cout<<101*(int)pow(100,d)<<endl;
    }
    return 0;
}

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

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

    vector<string> vec;
    for (long long i = 0; i < n; i++) {
        string str;
        cin >> str;

        // 
        sort(str.begin(), str.end());
        vec.push_back(str);
    }

    sort(vec.begin(), vec.end());
    vector<long long> num(n);
    for (long long i = 1; i < n; i++) {
        if (vec[i - 1] == vec[i]) {
            num[i] = num[i - 1] + 1;
            num[i - 1] = 0;
        }
    }

    long long res = 0;
    for (long long i = 0; i < n; i++) {
        res += (num[i] + 1) * num[i] / 2;
    }

    cout << res << endl;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n, x, t; cin >> n >> x >> t;

    int sum = 0, cnt = 0;
    while(1){
        cnt++;
        sum += x;
        if(n <= sum){
            cout << cnt * t << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3632
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9;

int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	int low = (n-1)/a + 1,high = n-a+1;
	if(b < low || b > high)return puts("-1"),0;
	int cl=0,nc=n;
	for(int i=1;i<=n;i+=a){
		int na = i+a;
		if(nc-a+1 >= b){
			for(int j=nc-a+1;j<=nc;j++)printf("%d ",j);
			-- b;
			nc -= a;
		}else{
			for(int j=b;j<=nc;j++)printf("%d ",j);
			if(--b)for(int j=b;j>=1;j--)printf("%d ",j);
			break; 
		}
	}
	puts("");

	return 0;
}


Measured memory_bytes: 2176
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		int N=sc.nextInt();
		int M=sc.nextInt();

		Shop[] shop=new Shop[N];

		for(int i=0;i<N;i++) {
			shop[i]=new Shop();
			shop[i].price=sc.nextLong();
			shop[i].stock=sc.nextInt();
		}

		Arrays.sort(shop);

		int now_Drink=0;
		int Drink_count=0;
		long ans=0;


		for (int i=0;i<N;i++){

			now_Drink=shop[i].stock;

			if(M < Drink_count+now_Drink) {
				now_Drink=(M-Drink_count);
			}

			ans+=(now_Drink*shop[i].price);
			Drink_count+=now_Drink;

			if(Drink_count==M) break;

        }

		System.out.println(ans);

		sc.close();
	}

}


class Shop implements Comparable<Shop>{
	Long price;
	int stock;

	@Override
	public int compareTo(Shop s) {
		long x=this.price-s.price;
		if(x > 0) return 1;
		else if(x == 0) return 0;
		else return -1;
	}
}

Measured memory_bytes: 96668
#pragma warning(disable:4996)
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<time.h>
#include<iomanip>
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989

using namespace std;
typedef unsigned long long ull;


int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8) {
		cout << "Yay!";
		return 0;
	}
	cout << ":(";
	return 0;
}

/*
*/

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for(int i = 0; i < N; i++){
  cin >> A.at(i);
  }
  for(int i = 0; i < N; i++){
  B.at(A.at(i)-1) = i+1;
  }
   for(int i = 0; i < N; i++){
  cout << B.at(i) << endl;
  }
}


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

const int MOD = 2019;
int main(){
    ll L, R; cin >> L >> R;
    if(R - L >= MOD){
        cout << 0 << endl;
        return 0;
    }
    L %= MOD;
    R %= MOD;
    if(R < L) cout << 0 << endl;
    else{
        int ans = MOD;
        for(int i = L; i < R; i++){
            for(int j = i + 1; j <= R; j++){
                ans = min(ans, i * j % MOD);
            }
        }
        cout << ans << endl;
    }
    

}

Measured memory_bytes: 768
A, B, M = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]
b = [int(v) for v in input().split()]

m = []
for i in range(M):
    m.append([int(v) for v in input().split()])

a_min = min(a)
b_min = min(b)
s_min = a_min + b_min

for w in m:
    ai, bi, ci = w
    tmp_min = a[ai-1] + b[bi-1] - ci
    if tmp_min < s_min:
        s_min = tmp_min
        
print(s_min)


Measured memory_bytes: 32500
#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=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    rep(i,n){
        if((i+1) % 2 == 1 && a[i] % 2 == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
#include<stdio.h>
#define N 500001
int n;
int parent(int i){
  return i/2;

}
int left(int i){
  return 2*i;

}

int right(int i){
  return 2*i+1;

}

void maxHeapify(int* A,int i){
  int l = left(i),r = right(i),largest,tmp;;
  if(l<=n && A[l]>A[i])largest = l;
  else largest = i;
  if(r<=n&&A[r]>A[largest])largest=r;
  if(largest != i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(A,largest);
  }

}
void buildMaxHeap(int* A){
  int i;
  for(i=n/2;i>=1;i--){
    maxHeapify(A,i);
  }
  
}



int main(){
  int heap[N];
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%d",&heap[i]);

  buildMaxHeap(heap);

  for(i=1;i<=n;i++)printf(" %d",heap[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 2552
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,x;
    cin >> a >> b >> x;
    if(x>=a&&x<=a+b){
        puts("YES");
    }else{
        puts("NO");
    }
 
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext())
		{
			int n = sc.nextInt();
			if(n==0)
				return;
			int ans =0;
			int sum=0;
			int g=0;
			while(n-->0)
			{
				sum=sc.nextInt()+sc.nextInt()+sc.nextInt();
				g= sc.nextInt();

				if(sum>160 || g>25)
				{
					continue;
				}
				else if(sum<=60 && g<=2)
				{
					ans+=600;
					continue;
				}
				else if(sum<=80 && g<= 5)
				{
					ans+=800;
					continue;
				}
				else if(sum<=100 && g<=10)
				{
					ans+=1000;
					continue;
				}
				else if(sum<=120 && g<=15)
				{
					ans+=1200;
					continue;
				}
				else if(sum<=140 && g<=20)
				{
					ans+=1400;
					continue;
				}
				else if(sum<=160 && g<=25)
				{
					ans+=1600;
					continue;
				}

			}
			System.out.println(ans);
		}

	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
int main() {
	long double d, e;
	while (cin >> d >> e&&d != 0 && e != 0) {
		long double sum = 1000000000;
		for (int i = 0; i <= ceil(d / 2); i++) {
			long double sum2 = sqrt(i*i + (d - i)*(d - i));
			sum2 = sum2 - e;
			if (sum2 < 0) sum2 = 0 - sum2;
			sum = min(sum, sum2);
		}
		printf("%LF\n", sum);
	}
}

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

using std::ios_base;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::fixed;

using std::vector;
using std::string;
using std::stack;
using std::queue;
using std::deque;
using std::map;
using std::set;
using std::unordered_map;
using std::unordered_set;

using std::tuple;
using std::make_tuple;
using std::pair;
using std::make_pair;

using std::sort;
using std::reverse;
using std::nth_element;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

const int MAXN = 100000;
const int INF = 1e9;
const int MOD = 1e9+7;
const int64_t L_INF = 4e18;

int h, w;
string s[12];
int perm[12];
bool eq[12][12];
bool can[1 << 12];

bool equal(int c1, int c2) {
    for (int i = 0; i < h; i++)
        if (s[perm[i]][c1] != s[perm[h - i - 1]][c2])
            return false;
    return true;
}

bool check() {
    for (int c = 0; c < w; c++)
        memset(eq[c], 0, sizeof eq[c]);
    memset(can, 0, sizeof can);
    
    for (int c1 = 0; c1 < w; c1++) {
        for (int c2 = c1; c2 < w; c2++) {
            if (equal(c1, c2)) {
                eq[c1][c2] = eq[c2][c1] = true;
            }
        }
    }

    can[0] = true;
    for (int mask = 0; mask < (1 << w); mask++) {
        if (__builtin_popcount(mask) & 1)
            continue;
        if (!can[mask])
            continue;
        for (int c1 = 0; c1 < w; c1++) {
            if (mask & (1 << c1))
                continue;
            for (int c2 = c1 + 1; c2 < w; c2++) {
                if (mask & (1 << c2))
                    continue;
                if (eq[c1][c2])
                    can[mask | (1 << c1) | (1 << c2)] = true;
            }
        }
    }

    if (w & 1) {
        for (int c = 0; c < w; c++) {
            if (eq[c][c] && can[((1 << w) - 1) ^ (1 << c)]) {
                return true;
            }
        }
        return false;
    }

    return can[(1 << w) - 1];
}

void get_all(int i) {
    if (i == h / 2) {
        if (check()) {
            cout << "YES\n";
            exit(0);
        }
        return;
    }

    for (int k = i + 1; k < h - i; k++) {
       std::swap(perm[k], perm[h - i - 1]);
       get_all(i + 1);
       std::swap(perm[k], perm[h - i - 1]);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        cin >> s[i];
        perm[i] = i;
    }
    
    if (h & 1) {
        get_all(0);
        for (int i = 0; i < h / 2; i++) {
            std::swap(perm[i], perm[h / 2]);
            get_all(0);
        }
    } else {
        get_all(0);
    }
    cout << "NO\n";

    #ifdef LOCAL
        cerr << "\n== " << 1.0 * clock() / CLOCKS_PER_SEC << " sec.\n";
    #endif
    return 0;
}

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

int main(){
    long long N;
    long long A_list[114514];
    long long pos[114514] = {0};
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A_list[i];
    }
    for(int i=0; i<N; i++){
        if((N-1-A_list[i])%2!=0){
            cout << 0;
            return EXIT_SUCCESS;
        }else{
            pos[(N-1-A_list[i])/2]++;
        }
    }
    if(N%2 == 0){
        for(int i=0; i<N/2; i++){
            if(pos[i] != 2){
                cout << 0;
                return EXIT_SUCCESS;
            }
        }
        long long x = 1;
        for(int i=0; i<N/2; i++){
            x %= 1000000000+7;
            x *= 2;
        }
        x %= 1000000000+7;
        cout << x;
        return EXIT_SUCCESS;
    }else{
        for(int i=0; i<N/2; i++){
            if(pos[i] != 2){
                cout << 0;
                return EXIT_SUCCESS;
            }
        }
        if(pos[N/2] != 1){
            cout << 0;
            return EXIT_SUCCESS;
        }
        long long x = 1;
        for(int i=0; i<N/2; i++){
            x %= 1000000000+7;
            x *= 2;
        }
        x %= 1000000000+7;
        cout << x;
        return EXIT_SUCCESS;
    }
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    int N, A, B; cin >> N >> A >> B;
    string S; cin >> S;

    int res = 0;
    int fores = 1;

    for(int i = 0; i < N; ++i) {
        if(S[i] == 'c') {
            cout << "No" << endl;
        } else if(S[i] == 'a') {
            if(res < A + B) {
                cout << "Yes" << endl;
                res++;
            } else {
                cout << "No" << endl;
            }
        } else if(S[i] == 'b') {
            if(res < A + B && fores <= B) {
                cout << "Yes" << endl;
                res++;
            } else {
                cout << "No" << endl;
            }
            fores++;
        }
    }
}

Measured memory_bytes: 896
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	int N;
	cin>>N;
	vector<int> ans(N+1,0);
	for(int x=1;x<=sqrt(N);x++){
		for(int y=1;y<=sqrt(N);y++){
			for(int z=1;z<=sqrt(N);z++){
				if(x*x+y*y+z*z+x*y+y*z+z*x<=N){
					ans[x*x+y*y+z*z+x*y+y*z+z*x]++;
				}
			}
		}
	}
	for(int i=1;i<ans.size();i++){
		cout<<ans[i]<<'\n';
	}
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

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

  string a,b,c;
  cin >> a >> b >> c;
  cout << (char)toupper(a.front()) << (char)toupper(b.front()) << (char)toupper(c.front()) << LF;

  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int[] i = Arrays.stream(line.split(" ")).mapToInt(Integer::parseInt)
                                                .toArray();
        if (i[0] < i[1]) {
            System.out.println("a < b");
        } else if (i[0] > i[1]) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 32096
#include <stdio.h>

int main(void) {
	const char* asumi_kana[] = {
		"sat", "sun", "mon", "tue", "wed", "thu", "fri"
	};
	const int start_day = 9;
	int X;
	int diff;
	if (scanf("%d", &X) != 1) return 1;
	if (X < start_day) {
		diff = (7 - (start_day - X) % 7) % 7;
	} else {
		diff = (X - start_day) % 7;
	}
	printf("%s\n", asumi_kana[diff]);
	return 0;
}



Measured memory_bytes: 2136
#include<iostream>
#include<string>
using namespace std;
int main(){
  int N,K,X,Y;
  cin>>N>>K>>X>>Y;

  if(N>K){
  int ans=K*X+(N-K)*Y;
  cout<<ans<<endl;
  }
  else{
    int ans=N*X;
    cout<<ans<<endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 256
n=int(input())
def f(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x
fdict={}
for i in range(1,n+1):
    fdict[i]=0
for x in range(1,n):
    if f(x,1,1)>n:
        break
    for y in range(x,n):
        if f(x,y,1)>n:
            break
        for z in range(y,n):
            if f(x,y,z)>n:
                break
            if x==y and y==z:
                fdict[f(x,y,z)]+=1
            elif x==y or y==z or z==x:
                fdict[f(x,y,z)]+=3
            else:
                fdict[f(x,y,z)]+=6
for N in range(1,n+1):
    print(fdict[N])

Measured memory_bytes: 9580
#include "bits/stdc++.h"

using namespace std;
using int64 = long long int;

constexpr int MaxN = 200000 + 10;
int A[MaxN];

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

	unordered_map<int, int> m;

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

	int64 allAns = 0;
	for (auto &p : m)
	{
		int64 value = p.second;
		allAns += value * (value - 1) / 2;
	}

	for (int i = 0; i < n; i++)
	{
		int64 count = m[A[i]];
		int64 newCount = count - 1;
		int64 ans = allAns - count * (count - 1) / 2 + newCount * (newCount - 1) / 2;
		cout << ans << endl;
	}
}

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

map <char, char> mp;

int main() {
	string s, t; cin >> s >> t;
	int l = s.size(), ok = 1;
	for (int i = 0; i < l; i ++) mp[s[i]] = t[i];
	
	for (char a = 'a'; a <= 'z'; a ++)
		for (char b = 'a'; b <= 'z'; b ++)
			if (mp.count(a) == 0 || mp.count(b) == 0 || a == b) continue;
			else if (mp[a] == mp[b]) { 
				cout << "No\n"; return 0;
			}
	for (int i = 0; i < l; i ++) s[i] = mp[s[i]]; 
	if (s == t) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}


Measured memory_bytes: 776
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007



int main() {
	int n;
	cin >> n;
	while (n>=0) {
		if ((n % 7) == 0) {
			cout << "Yes" << endl;
			return 0;
		}
		n -= 4;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())

if not A <= B:
    print(0)
    exit()
if N == 1:
    if A == B:
        print(1)
    else:
        print(0)
    exit()
if N == 2:
    print(1)
    exit()

ans = (N-2)*(B-A) + 1
print(ans)

Measured memory_bytes: 3060
N = int(input())
points_list = [list(map(int,input().split())) for _ in range(N)]
flag = True
for i in range(N):
    if i == 0:
        dis = points_list[i][1] + points_list[i][2]
        if points_list[i][0] % dis == 0:
            p = dis
        else:
            flag = False
            break
    else:
        dis = (points_list[i][1] + points_list[i][2]) - p
        if dis == 0:
            if (points_list[i][0] - points_list[i-1][0]) % 2 == 0:
                p = points_list[i][1] + points_list[i][2]
            else:
                flag = False
                break
        elif points_list[i][0] - points_list[i-1][0] >= dis:
            if (points_list[i][0] - points_list[i-1][0]) % dis == 0 or (points_list[i][0] - points_list[i-1][0] - dis) % 2 == 0:
                p = points_list[i][1] + points_list[i][2]
                continue
                if abs(points_list[i][1] - points_list[i-1][1]) <= (points_list[i][0] - points_list[i-1][0]) and abs(points_list[i][2] - points_list[i-1][2]) <= (points_list[i][0] - points_list[i-1][0]):
                    continue
                else:
                    flag = False
                    break
            else:
                flag = False
                break
        else:
            flag = False
            break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27300
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void yes() { cout << "POSSIBLE" << endl; }
void no() { cout << "IMPOSSIBLE" << endl; }
void yesOrNo(bool flg) {
  if (flg)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
}

void solve(ll N, ll M, std::vector<ll> a, std::vector<ll> b) {
  set<ll> x, y, z;

  rep(i, M) {
    if (a.at(i) == 1) {
      x.insert(b.at(i));
    }
    if (b.at(i) == N) {
      y.insert(a.at(i));
    }
  }

  set_intersection(all(x), all(y), inserter(z, z.end()));

  yesOrNo(!z.empty());
}

int main() {
  ll N;
  scanf("%lld", &N);
  ll M;
  scanf("%lld", &M);
  std::vector<ll> a(M);
  std::vector<ll> b(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
  }
  solve(N, M, std::move(a), std::move(b));
  return 0;
}


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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int A[3], K;
	
	cin >> A[0] >> A[1] >> A[2] >> K;
	
	sort(A, A+3);
	
	cout << A[0] + A[1] + A[2] * pow(2, K);
	
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
la, lxy = [], []
for i in range(n):
  a = int(input())
  la.append(a)
  xy = []
  for j in range(a):
    xy.append(list(map(int, input().split())))
  lxy.append(xy)

lb = []
for i in range(2**n):
  lb += [str(bin(i))[2:].zfill(n)]
lc = [sum(int(j) for j in i) for i in lb]
lc, lb = zip(*sorted(zip(lc, lb), reverse=True))
lb = [[int(j) for j in i] for i in lb]

for l in lb:
  ok = 1
  for i in range(n):
    a = la[i]
    for j in range(a):
      x, y = lxy[i][j]
      if l[i] == 1 and l[x-1] != y:
        ok = 0
        break
  if ok:
    print(sum(int(k) for k in l))
    break
else:
  print(0)

Measured memory_bytes: 12924
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using uint = unsigned  int;

using namespace std;

vector<vector<ll>> G(8);
vector<ll> c(1 << 9);
ll solve(uint v,vector<bool> didVisit){
    bool isAllVisit = true;
    for(int i = 0; i < didVisit.size(); i++){
        if(didVisit[i] == false){
            isAllVisit = false;
        }
    }
    if(isAllVisit){
        return 1;
    }else{
        ll sum = 0;
        for(int i = 0; i < G[v].size(); i++){
            ll nextId = G[v][i];
            if(didVisit[nextId]){
                continue;
            }
            didVisit[nextId] = true;
            sum += solve(nextId,didVisit);
            didVisit[nextId] = false;
        }
        return sum;
    }
}
int main() {
    ll N,M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<bool> didVisit = vector<bool>(N);
    for(int i = 0; i < N; i++){
        didVisit[i] = false;
    }
    didVisit[0] = true;
    cout << solve(0,didVisit) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<bool> ng(1001000,false);
    map<int, int> cnt;
    rep(i,N){
        cin >> A[i];
        cnt[A[i]]++;
    }
    sort(all(A));
    int ans = 0;
    rep(i,N){
        if(!ng[A[i]]){
            if(cnt[A[i]] == 1)++ans;
            for(int k = 1; k*A[i] < 1000100; ++k){
                ng[k*A[i]] = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

void count()
{
	int N;

	cin >> N;
	int data[100000];
	fill_n(data, 100000, 0);
	for (int i = 0; i < N; i++)
	{
		cin >> data[i];
	}
	sort(data, data + N);
	int cnt = 0;
	int meyasu = 0;
	int kazoe = 0;
	while (meyasu < N)
	{
		int kazoe = 0;
		int handan = data[meyasu];
		while (meyasu < N && handan == data[meyasu])
		{
			meyasu++;
			kazoe++;
		}
		cnt += kazoe % 2;
	}
	
	cout << cnt << endl;

}


int main()
{
	count();
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int N;
vector<ll> visited(100005,-1);
vector<vector<pair<int,ll>>> G(100005);

void dfs(int v, ll w){
  for(auto nv: G[v]){
    if(visited[nv.first] != -1){
      continue;
    }
    visited[nv.first] = w + nv.second;
    dfs(nv.first,visited[nv.first]);
  }
}

int main(){
  cin >> N;
  for(int i=0; i<N-1; i++){
    int a,b,v;
    cin >> a >> b >> v;
    a--;
    b--;
    G[a].push_back(make_pair(b,v));
    G[b].push_back(make_pair(a,v));
  }
  visited[0] = 0;
  dfs(0,0);
  vector<int> ans;
  for(int i=0; i<N; i++){
    ans.push_back(visited[i]%2);
  }
  for(int m: ans){
    cout << m << endl;
  }
  return 0;
}


Measured memory_bytes: 9980
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
using namespace std;
typedef long long int ll;

int N,M,R;
int d[210][210];
bool used[10];
int r[10];
ll ans;

void dfs(int cnt,int las,int dist){
	if(cnt==R){
		if(ans>dist)ans=dist;
		return;
	}
	for(int i=0;i<R;i++){
		if(!used[i]){
			used[i]=true;
			if(las==-1)dfs(cnt+1,i,0);
			else dfs(cnt+1,i,dist+d[r[las]][r[i]]);
			used[i]=false;
		}
	}
}

int main(){
	cin >> N >> M >> R;
	for(int i=0;i<210;i++){
		for(int j=0;j<210;j++){
			if(i!=j)d[i][j]=1e9;
		}
	}
	for(int i=0;i<R;i++){
		cin >> r[i]; r[i]--;
	}
	for(int i=0;i<M;i++){
		int a,b,c;
		cin >> a >> b >> c;
		a--;b--;
		if(d[a][b]>c){
			d[a][b]=d[b][a]=c;
		}
	}
	for(int k=0;k<N;k++){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				if(d[i][j]>d[i][k]+d[k][j]){
					d[i][j]=d[i][k]+d[k][j];
				}
			}
		}
	}
	ans=1e9;
	dfs(0,-1,0);
	cout << ans << endl;
	return 0;
}

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

using namespace std;
int main()
{
	int N,X,m[110],ans = 0;
	cin >> N >> X;
	ans += N;
	for(int i=0; i<N; i++){
		cin >> m[i];
		X -= m[i];
	}
	sort(m,m+N);
	while(X>=m[0]){
		X -= m[0];
		ans++;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;

ll k;
ll MOD(int a){
	if(a%k==0) return 0;
	else return a;
}
 
vector<pair<int, ll> > path[100005];
int par[100005];
int dep[100005];
ll cst[100005];
void dfs(int a){
	for(int i=0; i<path[a].size(); i++){
		int d=path[a][i].first;
		if(d==par[a]) continue;
		par[d]=a;
		dep[d]=dep[a]+1;
		cst[d]=path[a][i].second;
		dfs(d);
	}
}
ll add[100005];
 
struct query{
	char t;
	ll a, b;
};
query qry[100005];
 
bool used[100005];
int cnt[100005];
int cntdfs(int a){
	cnt[a]=used[a];
	for(int i=0; i<path[a].size(); i++){
		int d=path[a][i].first;
		if(d!=par[a]) cnt[a]+=cntdfs(d);
	}
	return cnt[a];
}
int ming_par[100005];
ll ming_cst[100005];
int ming_bef[100005];
 
int main(){
	int n;
	cin >> n >> k;
	for(int i=0; i<n-1; i++){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		path[a].push_back(make_pair(b, c));
		path[b].push_back(make_pair(a, c));
	}
	par[0]=dep[0]=cst[0]=0;
	dfs(0);
 
	int q;
	cin >> q;
	for(int i=0; i<q; i++){
		string str;
		ll a, b;
		cin >> str >> a >> b;
		qry[i]={str[0], a, b};
	}
 
	for(int i=0; i<n; i++) add[i]=0;
	 
	int sq=(int)(sqrt(q));
	for(int i=0; i<sq; i++){
		int s=i*sq, t=(i+1)*sq;
		if(i==sq-1) t=q;
		 
		used[0]=true;
		for(int j=1; j<n; j++) used[j]=false;
		for(int j=s; j<t; j++){
			if(qry[j].t=='a') 
				used[qry[j].a]=true;
			else
				used[qry[j].a]=used[qry[j].b]=true;
		}
		cntdfs(0);
		for(int j=1; j<n; j++) 
			if(0<cnt[j] && cnt[j]<cnt[par[j]])
				used[par[j]]=true;
 
		for(int j=1; j<n; j++){
			if(!used[j]) continue;
			ming_cst[j]=0;
			if(used[par[j]]){
				ming_par[j]=par[j];
			}else{
				int p=par[j];
				while(!used[par[p]]){
					ming_cst[j]+=MOD(cst[p]+add[p]+add[par[p]]);
					p=par[p];
				}
				ming_bef[j]=p;
				ming_par[j]=par[p];
			}
		}
		 
		for(int j=s; j<t; j++){
			if(qry[j].t=='a'){
				add[qry[j].a]+=qry[j].b;
			}else{
				int s=qry[j].a, t=qry[j].b;
				ll ans=0;
				while(s!=t){
					if(dep[s]<dep[t]) swap(s, t);
					int p = ming_par[s];
					if(dep[s]-dep[p]>1){
						int q = ming_bef[s];
						ans+=MOD(add[s]+add[par[s]]+cst[s]);
						ans+=MOD(add[q]+add[par[q]]+cst[q]);
						ans+=ming_cst[s];
					}else{
						ans+=MOD(add[s]+add[p]+cst[s]);
					}
					s=p;
				}
				printf("%lld\n", ans);
			}
		}
	}
}

Measured memory_bytes: 21660
//Created by Aminul on 7/25/2020.

import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args)throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt(), k = in.nextInt();
        double a[] = new double[n];
        for (int i = 0; i < n; i++) {
            a[i] = log(in.nextInt());
        }
        double sum = 0;
        for (int i = 0; i < k; i++) {
            sum += a[i];
        }

        for(int i = k; i < n; i++) {
            double currSum = sum + a[i] - a[i - k];
            if(currSum > sum) pw.println("Yes");
            else pw.println("No");
            sum = currSum;
        }
          
        pw.close();
    }

    static void debug(Object...obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

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

namespace Programminng
{
    class AOJ_Volume0033
    {
        private static int[] value = new int[10];
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                for (int j = 0; j < 10; j++)
                {
                    value[j] = int.Parse(s[j]);
                }
                Console.WriteLine(dfs(0,0,0));
            }
        }

        private static string dfs(int left, int right, int i)
        {
            if (i == 10) return "YES";
            if (left < value[i])
            {
                return dfs(value[i], right, i + 1);
            }
            if (right < value[i])
            {
                return dfs(left, value[i], i + 1);
            }

            return "NO";
        }
    }
}

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

int main( int argc, char *argv[] )
{
int A;
int B;
int C;

	cin >> A;
	cin >> B;
	cin >> C;
	if( A - B == B - C )
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define endl "\n"
#define int long long
#define F first
#define S second
#define B begin
#define E end
#define RB rbegin
#define RE rend
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const int INF = 1e9 + 1;
const double EPS = 1e-10;
const ll P = 1e9 + 7;
const int Q = 47;
 
using namespace std;
 
void hello()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
 
void show(vector<int>& arr)
{
    for (auto i : arr)
        cout << i << endl;
    cout << endl;
}
void show(vector<vector<int>>& arr)
{
    for (auto i : arr)
        show(i);
    cout << endl;
}


signed main()
{
    hello();
    
    int n;
    cin >> n;
    vector <int> res(n);
    for (int i = 1; i <= 100; ++i)
        for (int j = 1; j <= 100; ++j)
            for (int k = 1; k <= 100; ++k)
                if (i * i + j * j + k * k + i * j + j * k + i * k <= n)
                    res[i * i + j * j + k * k + i * j + j * k + i * k - 1]++;
    show(res);
}

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

int a[111111];
int main() {
	int n;
	cin >> n;
	long b = 0;
	for (int i = 0; i < n; i++)
		scanf("%d", a + i), b += i & 1 ? -a[i] : a[i];
	for (int i = 0; i < n; i++) {
		cout << b << ' ';
		b = a[i] * 2 - b;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1664
n=input()

if len(n)==1:
    print(int(n))
elif len(n)==2:
    print(9)
elif len(n)==3:
    print(10+int(n)-100)
elif len(n)==4:
    print(909)
elif len(n)==5:
    print(910+int(n)-10000)
else:
    print(90909)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, m, k;
	std::cin >> n >> m >> k;
	int r = std::max(n, m);
	std::cout << (k + r - 1) / r << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y; cin >> x >> y;
    rep (a, 100) {
        int b = x - a;
        if (b < 0) break;
        if (2 * a + 4 * b == y) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
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; }

const long long INF = 1e18;
int n, m;
struct xydata {
    long long x; long long y;
};
vector<xydata> student(55);
vector<xydata> check(55);

int main() {
    cin >> n >> m;
    for(int i = 0; i < n; ++i) {
        cin >> student.at(i).x >> student.at(i).y;
    }
    for(int i = 0; i < m; ++i) {
        cin >> check.at(i).x >> check.at(i).y;
    }

    for(int i = 0; i < n; ++i) {
        long long lenmin = INF;
        int nomin = 0;
        for(int j = 0; j < m; ++j) {
            long long jlen = abs(student.at(i).x - check.at(j).x) + abs(student.at(i).y - check.at(j).y);
            if(jlen < lenmin) {
                lenmin = jlen;
                nomin = j;
            }
        }
        cout << nomin+1 << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double x = sc.nextDouble();
    double s = x / a;

    if (a * b / 2 >= s) {
      double a1 = 2 * s / b;
      System.out.println(Math.toDegrees(Math.atan(b/a1)));
    } else {
      double ex = a * b - s;
      double h = 2 * ex / a;
      System.out.println(Math.toDegrees(Math.atan(h/a)));
    }
  }

}


Measured memory_bytes: 25172
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = Array(N) { listOfInt() }
    val R = Array(N) { BooleanArray(N) }
    for (k in 0 until N)
    for (h in 0 until N) for (w in 0 until N) {
        if (A[h][w] > A[h][k] + A[k][w]) {
            return println(-1)
        }
        if (A[h][w] == A[h][k] + A[k][w] && A[h][k] > 0 && A[k][w] > 0)
            R[h][w] = true
    }
    var ans = 0L
    for (h in 0 until N) for (w in h + 1 until N) {
        if (!R[h][w]) ans += A[h][w]
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(D: Int = 0) = listOfString().map { Integer.parseInt(it) + D }
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map { it.toDouble() }


Measured memory_bytes: 47584