akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
#define MAX 10000
#define NIL -1
using namespace std;

struct Node{int parent, left, right;};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
    if(u == NIL) return;
    D[u] = d;
    setDepth(T[u].left, d + 1);
    setDepth(T[u].right, d + 1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if(T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
    if(T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
    return H[u] = max(h1, h2);
}

int getSibling(int u){
    if(T[u].parent == NIL) return NIL;
    if(T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
    if(T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;
    return NIL;
}

void print(int u){
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getSibling(u));
    int deg = 0;
    if(T[u].left != NIL) deg++;
    if(T[u].right != NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);

    if(T[u].parent == NIL){
        printf("root\n");
    }else if(T[u].left == NIL && T[u].right == NIL){
        printf("leaf\n");
    }else{
        printf("internal node\n");
    }
}

int main(){
    int v, l, r, root = 0;
    scanf("%d", &n);

    for(int i = 0; i < n; i++) T[i].parent = NIL;

    for(int i = 0; i < n; i++){
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if(l != NIL) T[l].parent = v;
        if(r != NIL) T[r].parent = v;
    }

    for(int i = 0; i < n; i++){
        if(T[i].parent == NIL) root = i;
    }

    setDepth(root, 0);
    setHeight(root);

    for(int i = 0; i < n; i++) print(i);

    return 0;
}


Measured memory_bytes: 2740
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 505
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;
int sum[maxn];
int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int x,a;
    cin >> x >> a;
    printf("%d\n",x < a ? 0 : 10);

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

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

int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int count=0;
    rep(i, a+1){
        rep(j, b+1){
            rep(k, c+1)
            if(x == 500*i + 100*j + 50*k) count++;

        }
    }
    out(count);
}

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

int main(){
  	int w,a,b;
	cin>>w>>a>>b;
	if(b+w<a)cout<<a-b-w<<endl;
  	else if(a+w<b)cout<<b-a-w<<endl;
  	else cout<<"0"<<endl;
  	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main (String[] args){
	
		Scanner sc = new Scanner(System.in);
		
		int gyou = sc.nextInt();
		int retu = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		int all = gyou * retu;
		int black = (h * retu) + ((gyou - h) * w);
		
		System.out.println(all - black);

	}
	
}

Measured memory_bytes: 22868
#include<iostream>
using namespace std;
typedef long long ll;

ll sum(ll l,ll r){
    return (l+r)*(r-l+1)/2;
}

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

    ll ans=0;
    for(int i=k;i<=n+1;i++){
        ll l=sum(0,i-1);
        ll r=sum(n-i+1,n);
        ans+=r-l+1;
        ans%=1000000007;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3552
#include <stdio.h>

int main()
{
    int d;

    scanf("%d", &d);

    if (d == 25) {
        puts("Christmas");
    } else if (d == 24) {
        puts("Christmas Eve");
    } else if (d == 23) {
        puts("Christmas Eve Eve");
        //puts("Emperor's Birthday");
    } else if (d == 22) {
        puts("Christmas Eve Eve Eve");
    }

    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long int

int n;
int a[200005], c[200005];
vector<int> dv[200005];
vector<int> v;
bool f[200005];
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 1 ; i <= n ; i ++)
		cin >> a[i];
	
	for(int i = 1 ; i <= n ; i ++)
		for(int j = i ; j <= n ; j += i)
			dv[j].push_back(i);
	for(int i = n ; i >= 1 ; i --){
		if(a[i]^(c[i]&1)){
			v.push_back(i);
			for(int u: dv[i])
				c[u] ++;
		}
	}
	cout << v.size() << endl;
	for(int u: v) cout << u << " "; 
}

Measured memory_bytes: 37880
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

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

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

/*   nCr % mod

const int N = 2000099;
ll fact[N];
ll finv[N];
ll inv[N];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < N;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

unordered_set<ll> divisors(ll X) {
  unordered_set<ll> divs;
  for(ll i = 1; i*i <= X;i++) {
    if(X % i == 0) {
      divs.insert(i);
      divs.insert(X/i);
    }
  }

  divs.erase(1);
  return divs;
}

int N, K, C;
string S;
int dpl[1<<20], dpr[1<<20], dp[1<<20];

int main() {

//  freopen("input.in","r",stdin);
//  freopen("output.out","w",stdout);

  cin >> N >> K >> C >> S;
  for(int i = 0;i < N;i++) {
    if(S[i] == 'x' ) dpl[i] = (i == 0 ? 0 : dpl[i-1]);
    else {
      dpl[i] = (i == 0 ? 0 : dpl[i-1]);
      dpl[i] = max(dpl[i], 1 + (i-C-1 >= 0 ? dpl[i-C-1] : 0));
    }

    int j = i;
    i = N-1-i;
    if(S[i] == 'x') dpr[i] = (i == N-1 ? 0 : dpr[i+1]);
    else {
      dpr[i] = (i == N-1 ? 0 : dpr[i+1]);
      dpr[i] = max(dpr[i], 1 + (i+C+1 <= N-1 ? dpr[i+C+1] : 0));
    }

    i = j;
  }

  for(int i = 0;i < N;i++) {
    if(S[i] == 'x') continue;
    int x = (i-C-1 >= 0 ? dpl[i-C-1] : 0);
    int y = (i+C+1 <= N-1 ? dpr[i+C+1] : 0);

    if(x+y+1 >= K) dp[i] = 1;
  }

  int val = 0;
  for(int i = 0;i <= C;i++) {
    val += dp[i];
  }

  for(int i = 0;i < N;i++) {
    int x = (i-C-1 >= 0 ? dpl[i-C-1] : 0);
    int y = (i+C+1 <= N-1 ? dpr[i+C+1] : 0);

    if(x + y == K-1 and S[i] == 'o' and val == 1) {
      cout << i+1 << endl;
    }

    if(i+C+1 < N) val += dp[i+C+1];
    if(i-C >= 0) val -= dp[i-C];
  }

  return 0;
}


Measured memory_bytes: 6660
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

t=list(ss())

for i in range(len(t)):
    if t[i]=="?":
        t[i]="D"
print("".join(t))

Measured memory_bytes: 76660
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int BUF = 200005;
const int MOD = 1000000007;
const int INF = 1<<30;


int nVal, nPick;
int val[BUF];

void read() {
    cin >> nVal >> nPick;
    for (int i = 0; i < nVal; ++i) {
        cin >> val[i];
    }
}


void work() {
    int nNeg = 0, nZero = 0, nPos = 0;
    int neg[BUF], pos[BUF];

    for (int i = 0; i < nVal; ++i) {
        if (val[i] < 0) {
            neg[nNeg++] = val[i];
        } else if (val[i] > 0) {
            pos[nPos++] = val[i];
        } else {
            ++nZero;
        }
    }

    sort(neg, neg + nNeg);
    sort(pos, pos + nPos);

    long double posLogSum[BUF];
    posLogSum[0] = logl(pos[0]);
    for (int i = 1; i < nPos; ++i) {
        posLogSum[i] = posLogSum[i - 1] + logl(pos[i]);
    }
    
    long double maxV = -INF;
    int nNegPickMax = -1;
    long double cur = 0;
    for (int nNegPick = 0; nNegPick <= min(nNeg, nPick); nNegPick += 2) {
        if (nNegPick) {
            cur += logl(fabs(neg[nNegPick - 1]));
            cur += logl(fabs(neg[nNegPick - 2]));
        }
        
        int nRemainPick = nPick - nNegPick;
        if (nRemainPick > nPos) {
            continue;
        }
        
        long double sum = (nPos == 0 ? 0 : posLogSum[nPos - 1]) - (nRemainPick == nPos ? 0 : posLogSum[nPos - 1 - nRemainPick]);
        if (maxV < cur + sum) {
            maxV = cur + sum;
            nNegPickMax = nNegPick;
        }
    }
    
    if (nNegPickMax != -1) {
        int ans = 1;
        for (int i = 0; i < nNegPickMax; ++i) {
            ans = 1LL * ans * (MOD + neg[i]) % MOD;
        }
        for (int i = 0; i < nPick - nNegPickMax; ++i) {
            ans = 1LL * ans * pos[nPos - 1 - i] % MOD;
        }
        cout << ans << endl;
        return;
    } else if (nZero) {
        cout << 0 << endl;
        return;
    }

    
    reverse(neg, neg + nNeg);

    long double minV = INF;
    
    cur = logl(fabs(neg[0]));
    for (int nNegPick = 1; nNegPick <= min(nNeg, nPick); nNegPick += 2) {
        if (nNegPick > 1) {
            cur += logl(fabs(neg[nNegPick - 1]));
            cur += logl(fabs(neg[nNegPick - 2]));
        }
        
        int nRemainPick = nPick - nNegPick;

        if (nRemainPick > nPos) {
            continue;
        }
        
        long double sum = nRemainPick == 0 ? 0 : posLogSum[nRemainPick - 1];
        if (minV > cur + sum) {
            minV = cur + sum;
            nNegPickMax = nNegPick;
        }
    }

    int ans = 1;
    for (int i = 0; i < nNegPickMax; ++i) {
        ans = 1LL * ans * (MOD + neg[i]) % MOD;
    }
    for (int i = 0; i < nPick - nNegPickMax; ++i) {
        ans = 1LL * ans * pos[i] % MOD;
    }
    cout << ans << endl;
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 8236
N = int(input())
t = []
x = []
y = []
for i in range(N):
  t1, x1, y1 = map(int, input().split())
  t.append(t1)
  x.append(x1)
  y.append(y1)

flg = 1
for i in range(N):
        if x[i]+y[i] > t[i]:
            flg = 0
        elif (x[i]+y[i])%2 != t[i]%2:
            flg = 0
print("Yes" if flg == 1 else "No")

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

const int INF = 1e9 ;
const int maxN = 1010; 
const int MOD = 1e9 + 7;
int tot,n;
int prime[maxN*10]; //记录质数
int b[maxN * 100]; //标记i 是否为质数 
ll a[maxN][maxN];
const int L = 10000;
void check()
{
	tot = 0;
	for(int i=2;i<=L;i++)
	{
		if(b[i] == 0)
		{
			prime[++tot] = i;
			for(int j=2;i*j<=L;j++)
			{
				b[i*j] = 1;	
			}	
		}	
	} 
} 
vector<pii> l[maxN];
ll lc[maxN];
int lcnt;
vector<pii> r[maxN];
ll rc[maxN]; 
int rcnt;
int main()
{
	scanf("%d",&n);
	int cnt=0;
	check();
	for(int i=1;i<=n;i++)
	{
		int k = 1;
		l[++cnt].push_back(pii(i,1)); 
		while(1)
		{
			int tx = i-k;
			int ty = 1+k;
			if(tx<1 || tx>n || ty<1 || ty>n)
				break;
			l[cnt].push_back(pii(tx,ty));
			k++;
		}
	}
	for(int j=2;j<=n;j++)
	{
		int k = 1;
		l[++cnt].push_back(pii(n,j)); 
		while(1)
		{
			int tx = n-k;
			int ty = j+k;
			if(tx<1 || tx>n || ty<1 || ty>n)
				break;
			l[cnt].push_back(pii(tx,ty));
			k++;
		}
	}
	lcnt = cnt;
	cnt = 0;
	for(int j=1;j<=n;j++)
	{
		int k=1;
		r[++cnt].push_back(pii(n,j));
		while(1)
		{
			int tx = n-k;
			int ty = j-k;
			if(tx<1 || tx>n || ty<1 || ty>n)
				break;
			r[cnt].push_back(pii(tx,ty));
			k++;
		}
	}
	for(int i=n-1;i>=1;i--)
	{
		int k = 1;
		r[++cnt].push_back(pii(i,n));
		while(1)
		{
			int tx = i-k;
			int ty = n-k;
			if(tx<1 || tx>n || ty<1 || ty>n)
				break;
			r[cnt].push_back(pii(tx,ty));
			k++;	
		} 
	}
	rcnt = cnt;
	cnt = 0;
	for(int i=1;i<=lcnt;i+=2)
	{
		lc[i] = prime[++cnt]; 
	}
	for(int j=2;j<=lcnt;j+=2)
	{
		lc[j] = lc[j-1]*lc[j+1];
	}
	if(n%2 == 1)
	{
		for(int i=1;i<=rcnt;i+=2)
		{
			rc[i] = prime[++cnt]; 
		}
		for(int j=2;j<=rcnt;j+=2)
		{
			rc[j] = rc[j-1]*rc[j+1];
		}	
	}
	else
	{
		for(int i=2;i<=rcnt;i+=2)
		{
			rc[i] = prime[++cnt]; 
		}
		rc[1] = rc[2];
		rc[rcnt] = rc[rcnt-1];
		for(int j=3;j<rcnt;j+=2)
		{
			rc[j] = rc[j-1]*rc[j+1];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			a[i][j] = 1ll; 
	} 
	for(int i=1;i<=lcnt;i++)
	{
		for(int j=0;j<l[i].size();j++)
		{
			int tx = l[i][j].first;
			int ty = l[i][j].second;
			a[tx][ty] *= lc[i];
		}
	}
	for(int i=1;i<=rcnt;i++)
	{
		for(int j=0;j<r[i].size();j++)
		{
			int tx = r[i][j].first;
			int ty = r[i][j].second;
			a[tx][ty] *= rc[i];
			if((tx+ty)%2==1)
				a[tx][ty] += 1;
		}
	}
	if(n==2)
	{
		a[1][2] += 30;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			printf("%lld",a[i][j]);
			if(j<n) printf(" ");
		}
		printf("\n");
	} 
    return 0;
}

Measured memory_bytes: 14592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AOJ.Codes
{
    //問題の名称... ALDS1_3_A:   Elementary data structures
    //問題文のURL... http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A&lang=jp
    //所要時間... AAA
    //学んだこと... AAA
    //教室内の大まかな着席位置... {左，中央，右} x {前，中央，奥}

    class ElementaryDataStructures
    {
        static void Main(string[] args)
        {
            //読み込み
            var x = Console.ReadLine().Split().ToArray();

            //計算
            var S = new Stack<int>();

            foreach (var item in x)
            { // 入力がある限り読み込む
                if (item == "+")
                {
                    var i1 = S.Pop();
                    var i2 = S.Pop();
                    S.Push(i1 + i2);
                }
                else if (item == "-")
                {
                    var i1 = S.Pop();
                    var i2 = S.Pop();
                    S.Push(i2 - i1);
                }
                else if (item == "*")
                {
                    var i1 = S.Pop();
                    var i2 = S.Pop();
                    S.Push(i1 * i2);
                }
                else
                {
                    S.Push(int.Parse(item));
                }
            }

            //出力
            Console.WriteLine(S.Pop());

            //Enterを押して終了
            Console.ReadLine();
        }


    }
}



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

const int maxn = 2e5+5, M = 1e9+7;
int n;
void madd(int& a, int b) {
    a += b;
    if (a >= M) a -= M;
}
int mult(int a, int b) {
    return (1LL*a*b) % M;
}
int msub(int a, int b) {
    madd(a,M-b);
    return a;
}
int modexp(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b&1) res = mult(res,a);
        a = mult(a,a);
        b >>= 1;
    }
    return res;
}
int inverse(int x) {
    return modexp(x,M-2);
}

vector<int> adj[maxn];
int sz[maxn];
void dfs(int i, int p) {
    sz[i] = 1;
    for (int j: adj[i]) {
        if (j == p) continue;
        dfs(j,i);
        sz[i] += sz[j];
    }
}

int e2[maxn], i2[maxn];

int f(int i, int p) {
    int res = 0;
    for (int j: adj[i]) {
        if (j == p) continue;
        madd(res,f(j,i));
    }
    int pr = 1;
    int s = n-1;
    pr = msub(pr,i2[s]);
    //cout << i << ": ";
    for (int j: adj[i]) {
        if (j == p) {
            int sj = n-sz[i];
            //cout << sj << ' ';
            pr = msub(pr,mult(i2[s-sj],
                         mult(msub(e2[sj],1),i2[sj])));
        }
        else {
            //cout << sz[j] << ' ';
            pr = msub(pr,mult(i2[s-sz[j]],
                         mult(msub(e2[sz[j]],1),i2[sz[j]])));
        }
    }
    //cout << '\n';
    pr = mult(pr,i2[1]);
    madd(res,pr);
    return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        int a, b; cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    e2[0] = 1;
    for (int i = 1; i < maxn; i++) {
        e2[i] = mult(e2[i-1],2);
    }
    i2[0] = 1;
    i2[1] = inverse(2);
    for (int i = 2; i < maxn; i++) {
        i2[i] = mult(i2[i-1],i2[1]);
    }
    dfs(1,1);
    f(1,1);
    cout << f(1,1) << '\n';
}



Measured memory_bytes: 24704
#include<iostream>
using namespace std;
int power_two(int n){
  int ctr=0;
  while(n%2==0){
    ctr+=1;
    n/=2;
  }
  return ctr;
}
int main(){
  int n;
  cin>>n;
  int a[n];
  int res =0;
  for(int i=0;i<n;i++){
    cin>>a[i];
  	res+=power_two(a[i]);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int  MOD = 1e9 + 7;
uint64_t inverseModp(uint64_t a, uint64_t p) {
    assert(p < (1ull << 63));
    assert(a < p);
    assert(a != 0);
    uint64_t ex = p-2, result = 1;
    while (ex > 0) {
        if (ex % 2 == 1) {
            result = (result*a) % p;
        }
        a = (a*a) % p;
        ex /= 2;
    }
    return result;
}


uint32_t nCrModp(uint32_t n, uint32_t r, uint32_t p)
{
    assert(r <= n);
    if (r > n-r) r = n-r;
    if (r == 0) return 1;
    if(n/p - (n-r)/p > r/p) return 0;
    
    uint64_t result = 1; //intermediary results may overflow 32 bits
    
    for (uint32_t i = n, x = 1; i > r; --i, ++x) {
        if( i % p != 0) {
            result *= i % p;
            result %= p;
        }
        if( x % p != 0) {
            result *= inverseModp(x % p, p);
            result %= p;
        }
    }
    return 0;
}


int main(){
    int n;
    cin >> n;
    rep(i,50001){
        if ((double)i*1.08 < (double)n+0.5 && (double)i*1.08 >= (double)n){
            cout << i; rn 0;
        }
        if ((double)i*1.08 >= (double)n+0.5 && (double)i*1.08 < (double)n + 1){
            cout << i; rn 0;
        }
    }
    cout << ":(";
    rn 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 *
 * @author 97797
 */
public class Main {
    
    public static void main(String[] args) {
        System.out.println(new Main().run(args, System.in));
    }
    public String run(String[] args, InputStream in) {
        String result = null;
        try {
            
            BufferedReader reader = new BufferedReader(new InputStreamReader(in));
            int N = Integer.parseInt(reader.readLine());
            
            List<Integer> list = reader.lines()
                    .flatMap(s -> Stream.of(
                            s.replaceAll("\\s+", " ").split(" ")))
                    .limit(N).map(Integer::parseInt)
                    .map(n -> n / 400)
                    .sorted()
                    .collect(Collectors.toList());
            long c1 = list.stream()
                    .filter(n -> n <8)
                    .distinct().count();
            long c2 = list.stream()
                    .filter(n -> n >= 8)
                    .count();
            long min = (c1 == 0) ? 1 : c1;
//            long max = (c1 + c2) > 8 ? 8 : (c1 + c2);
            long max = (c1 + c2);
            result = String.valueOf(min) +" "+ String.valueOf(max);
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        return result;
    }
}


Measured memory_bytes: 26708
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string x; cin >> x;
    ll ans = 0; ll sidx = 0;
    REP(i, x.size()){
        if(x[i] == 'S'){
            sidx++;
        }
        else{
            if(sidx > 0){
                ans++; sidx--;
            }
        }
    }
    cout << (x.size()-2*ans) << endstr;
    return 0;
}


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

const int Maxn = 100005;
const int Inf = 1000000007;

int n, k;
int a[Maxn];
int res = Inf;

int main()
{
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int pos = lower_bound(a, a + n, 0) - a;
	for (int i = 0; i <= k && pos + i <= n; i++) {
		int j = k - i;
		if (pos - j >= 0) {
			int A = j == 0? 0: -a[pos - j];
			int B = i == 0? 0: a[pos + i - 1];
			res = min(res, A + B + min(A, B));
		}
	} 
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <climits>

typedef long long ll;
using namespace std;

ll MOD = 1e9+7;

int main() {
    ll h, w, n;
    cin >> h >> w >> n;
    vector<ll> vec(h);
    ll many = (n == 1e9 ? 1: n+1);
    for(int i = 0; i < w; i++){
        cout << n << " ";
    }
    for(int i = 0; i < h-w; i++){
        cout << many << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2048
n = int(input())
x = input()
x_popcnt = x.count('1')
one_popcnt = x_popcnt - 1
zero_popcnt = x_popcnt + 1

one_mod = 0
zero_mod = 0
for b in x:
    if one_popcnt != 0:
        one_mod = (one_mod*2 + int(b)) % one_popcnt
    zero_mod = (zero_mod*2 + int(b)) % zero_popcnt

f = [0]*220000
popcnt = [0]*220000
for i in range(1, 220000):
    popcnt[i] = popcnt[i//2] + i % 2
    f[i] = f[i % popcnt[i]] + 1

onepow2 = [1]*220000
if one_popcnt != 0:
    for i in range(1, 220000):
        onepow2[i] = 2*onepow2[i-1] % one_popcnt
zeropow2 = [1]*220000
for i in range(1, 220000):
    zeropow2[i] = 2*zeropow2[i-1] % zero_popcnt
for i in range(n-1, -1, -1):
    if x[n-1-i] == '1':
        if one_popcnt != 0:
            nxt = one_mod
            nxt -= onepow2[i]
            nxt %= one_popcnt
            print(f[nxt]+1)
        else:
            print(0)
    if x[n-1-i] == '0':
        nxt = zero_mod
        nxt += zeropow2[i]
        nxt %= zero_popcnt
        print(f[nxt]+1)


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

int main() {
  long n, sum = 0;
  cin >> n;
  
  for(long i = 1; i <= n; i++){
    if(i % 3 == 0 || i % 5 == 0)
      continue;
    else
      sum += i;
  }
  
  cout << sum << endl;
  
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int ans = 0;
    if (a + b >= c - 1) {
      System.out.println(b + c);
      return;
    } else {
      System.out.println(1 + b * 2 + a);
      return;
    }
  }

}


Measured memory_bytes: 23764
s = input()
t = input()
cand = []
if len(s) < len(t):
  print('UNRESTORABLE')
else:
  for i in range(len(s)-len(t)+1):
    if s[i] != t[0] and s[i] != '?':
      continue
    else:
      for j in range(len(t)):
        if s[i+j] != t[j] and s[i+j] != '?':
          break
        elif j == (len(t)-1):
          cand.append(i)
  if len(cand) > 0:
    result = max(cand)
    S = s[:result]+t+s[result+len(t):]
    S = S.replace('?','a')
    print(S)
  else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
import sys
s = list(input())
for i in range(len(s)):
    if s[i] == 'L':
        if i%2 == 0:
            print('No')
            sys.exit()
    elif s[i] == 'R':
        if i %2 == 1:
            print('No')
            sys.exit()
print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e8);
const int mod = 16714589;
const int N = 2e6 + 555; // TL MB
const double PI = acos(-1.0);
double eps = 1e-6;

// {l, r}

int n;
void solve(){      
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;
	int res = 0;
	res += min(k, a);
	k -= min(k, a);
	k -= min(k, b);
	res -= min(k, c);
	cout << res;
}	// 0 1 2 2 3 3


 
 
int main()
{
	Red;
	//freopen("input.txt", "r", stdin);s
	//freopen("output.txt", "r", stdin);
  	int T = 1; 
 	//cin >> T; 
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
    return 0;
}

Measured memory_bytes: 3648
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var k = Number(lines[0]);
 var s = lines[1].split('');
 var len = s.length;

 if(len > k){
   s = s.slice(0,k);
   console.log(s.join('') + '...');
 }else{
   console.log(s.join(''));
 }
});

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

int n;
vector<set<pair<int, int>>> g;
vector<bool> seen;
vector<int> ans;

void dfs(int src, int dst, int weight)
{
    if (seen[dst]) return;

    seen[dst] = true;
    ans[dst] = (weight % 2 == 0 ? ans[src] : 1 - ans[src]);

    for (auto& e: g[dst]) {
        int n_dst = e.first; int n_weight = e.second;
        dfs(dst, n_dst, n_weight);
    }
}

int main()
{
    cin >> n;
    g.resize(n), seen.resize(n, false), ans.resize(n, 0);
    for (int i = 0; i < n - 1; i++) {
        int u, v, w; cin >> u >> v >> w; u--, v--;
        g[u].insert({v, w}), g[v].insert({u, w});
    }

    ans[0] = 0;
    dfs(0, 0, 0);
    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 15360
#include<bits/stdc++.h>
#define EPS (1e-8)
#define N_MAX 200005
using namespace std;
typedef double ll;

int N;
ll R,x[N_MAX],y[N_MAX];
bool used[N_MAX];

struct node{
  vector<ll> Point;
  int l,r;
  node(){}
  node(vector<ll> a){Point=a,l=r=-1;}
};

const int K=2;// K:テヲツャツ。テ・ツ?εヲツ閉ー
int D;// D:テ」ツ?敕」ツ?ョテヲツ卍づ」ツ?ォテ」ツつステ」ツδシテ」ツδ暗」ツ?凖」ツつ凝・ツ淞コテヲツコツ姪」ツ?ョテヲツャツ。テ・ツ??
vector<vector<ll> > P;// テ」ツ?敕」ツつ古」ツ?榲」ツつ古」ツ?ョティツヲツ?ァツエツ?」ツ?ッK+1テ・ツ??Kテ・ツ?凝」ツ?ョテヲツャツ。テ・ツ?ε」ツ?ョテァツ閉ェテ・ツ渉キテッツシツ凝、ツサツ佚」ツ?妥」ツ?淌」ツ??umber)
vector<node> G;

bool compare(const vector<ll> &A,const vector<ll> &B){return A[D]<B[D];}

int make_tree(int depth,int l,int r){
  if(l>r)return -1;
  D=depth%K;
  sort(P.begin()+l,P.begin()+r+1,compare);
  int m=(l+r)/2,res=G.size();
  G.push_back(node(P[m]));

  int vl=make_tree(depth+1,l,m-1);
  int vr=make_tree(depth+1,m+1,r);

  G[res].l=vl; G[res].r=vr;
  return res;
}

vector<int> num;// searchテ」ツ?ァティツヲツ凝」ツ?、テ」ツ?妥」ツつ凝」ツ?禿」ツ?ィテ」ツ?古」ツ?ァテ」ツ?催」ツ?淌ァツつケテ」ツ?ョnumberテ」ツつ津」ツ??」ツつ古」ツつ?

void search(int x,int depth,vector<ll> &L,vector<ll> &R){
  bool f=true;
  for(int i=0;i<K;i++)
    if(G[x].Point[i]<L[i]||R[i]<G[x].Point[i])f=false;

  if(f)num.push_back(G[x].Point[K]);

  D=depth%K;
  if(G[x].Point[D]<=R[D]&&G[x].r!=-1)search(G[x].r,depth+1,L,R);
  D=depth%K;
  if(L[D]<=G[x].Point[D]&&G[x].l!=-1)search(G[x].l,depth+1,L,R);
}

int main(){
  
  cin>>N>>R;
  
  P.resize(N);
  
  for(int i=0;i<N;i++){
    
    scanf("%lf %lf",&x[i],&y[i]);
    
    P[i].resize(K+1);
    
    P[i][K]=i;
    P[i][0]=x[i],P[i][1]=y[i];
  }
  
  make_tree(0,0,P.size()-1);
 
  int ans=0;
  for(int i=0;i<N;i++){
    
    if(used[i])continue;
    
    vector<ll> L2(K),R2(K);
    
    L2[0]=x[i]-R-EPS;
    R2[0]=x[i]+R+EPS;
    
    L2[1]=y[i]-R-EPS;
    R2[1]=y[i]+R+EPS;
    
    num.clear();
    
    search(0,0,L2,R2);
    
    for(int j=0;j<num.size();j++) used[num[j]]=1;
    
    ans++;
  }
  
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 31472
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        h: usize,
        w: usize,
        c: [Chars; h],
    };
    for i in 0..h {
        for j in 0..w {
            print!("{}", c[i][j]);
        }
        println!();
        for j in 0..w {
            print!("{}", c[i][j]);
        }
        println!();
    }
}


Measured memory_bytes: 2212
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#define LL long long
#define M 200020
using namespace std;
namespace IO{
	const int BS=(1<<20); int Top=0;
	char Buffer[BS],OT[BS],*OS=OT,*HD,*TL,SS[20]; const char *fin=OT+BS-1;
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS-1,stdin);} return (HD==TL)?EOF:*HD++;}
	void flush(){fwrite(OT,1,OS-OT,stdout);}
	void Putchar(char c){*OS++ =c;if(OS==fin)flush(),OS=OT;}
	void write(int x){
		if(!x){Putchar('0');return;} if(x<0) x=-x,Putchar('-');
		while(x) SS[++Top]=x%10,x/=10;
		while(Top) Putchar(SS[Top]+'0'),--Top;
	}
	int read(){
		int nm=0,fh=1; char cw=Getchar();
		for(;!isdigit(cw);cw=Getchar()) if(cw=='-') fh=-fh;
		for(;isdigit(cw);cw=Getchar()) nm=nm*10+(cw-'0');
		return nm*fh;
	}
}
using namespace IO;
int ans,n,m,A[M],B[M],C[M],D[M],f[M],sz[M];
int fd(int x){return x==f[x]?x:f[x]=fd(f[x]);}
int main(){
	n=read();
	for(int i=1;i<=n;i++) C[i]=A[i]=read(),A[n+1]^=A[i];
	for(int i=1;i<=n;i++) D[i]=B[i]=read(),B[n+1]^=B[i];
	n++,C[n]=A[n],D[n]=B[n],sort(C+1,C+n+1),sort(D+1,D+n+1);
	for(int i=1;i<=n;i++) if(C[i]!=D[i]){write(-1),Putchar('\n'),flush();return 0;}
	m=unique(C+1,C+n+1)-(C+1); for(int i=0;i<=m+2;i++) f[i]=i,sz[i]=1;
	for(int i=1;i<=n;i++){
		ans+=(A[i]!=B[i]&&i<n);
		A[i]=lower_bound(C+1,C+m+1,A[i])-C;
		B[i]=lower_bound(C+1,C+m+1,B[i])-C;
		int x=fd(A[i]),y=fd(B[i]); if(x!=y) f[x]=y,sz[y]+=sz[x];
	}
	for(int i=1;i<=n;i++) ans+=(fd(i)==i&&sz[fd(i)]>1);
	if(A[n]!=B[n]||sz[fd(A[n])]>1) ans--;
	write(ans),Putchar('\n'),flush(); return 0;
}

Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> p;
bool cmp(p a,p b)
{
	if(a.fi==b.fi) return a.se<b.se;
	else return a.fi<b.fi;
}
p par[100007];
int a,n,cur,ans[100007];
signed main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		par[i]=mp(a,i+1);
		cur=max(cur,a);
	}
	par[n]=mp(0,0);
	sort(par,par+n+1,cmp);
	int mn=1e9+7;
	for(int i=n-1;i>=0;i--)
	{
//		cout<<par[i+1].fi<<" "<<par[i+1].se<<endl;
		if(par[i].fi!=cur)
		{
			int x=par[i+1].fi,y=par[i+1].se;
			mn=min(mn,y);
			ans[mn]+=(cur-par[i].fi)*(n-i);
			cur=par[i].fi;
		}
	}
	for(int i=1;i<=n;i++)
	{
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 5948
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=4005,mod=1e9+7;
ll n,k,fac[N+2],inv[N+2],ans;
ll qpow(ll x,ll k)
{
	ll ret=1;
	while(k)
	{
		if(k&1) ret*=x,ret%=mod;
		x*=x; x%=mod; k>>=1;
	}
	return ret;
}
ll C(ll x,ll y)
{
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
	cin>>n>>k;
	fac[0]=1;
	for(int i=1;i<=N;i++) fac[i]=fac[i-1]*i%mod;
	inv[N]=qpow(fac[N],mod-2);
	for(int i=N-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	
	for(int i=1;i<=k;i++){
		ll ans=0,m=n-k-i+1;
//		cout<<m<<' ';
		if(m>=0) 
		  ans=C(k-1,i-1)*C(m+i,m)%mod;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long l;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SONI ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const int maxn=5e5+15;
const int maxm=5000+15;
const int mod=1e9+9;
const int inf=0x3f3f3f3f;
const int MOD=1000000007;

void min_self(ll& a,ll b)
{
    a=min(a,b);
}

int main()
{
    SONI;
    int n,W;
    cin>>n>>W;
    vector<ll>  weight(n),value(n);
    for(int i=0;i<n;i++)
    {
        cin>>weight[i]>>value[i];
    }
    ll sum_value=0;
    for(int i=0;i<n;i++)
    {
        sum_value+=value[i];
    }
    
    vector<ll> dp(1+sum_value,inf);
    dp[0]=0;
    for(int item=0;item<n;item++)
    {
       
        for(int v_already = sum_value-value[item];v_already>=0;v_already--)
        {
            min_self(dp[v_already+value[item]],dp[v_already]+weight[item]);
        }
    }
    
    ll answer=0;
    for(int i=0;i<=sum_value;i++)
    {
        if(dp[i]<=W)
        answer=max(answer,ll(i));
    }
    cout<<answer;
    return 0;
}

Measured memory_bytes: 1024
n,m = list(map(int, input().split()))
sc = [list(map(int, input().split())) for _ in range(m)]

ans = [-1]*n
c1 = [-2]*n

an1 = 1
for s,c in sc:
    if s == 1 and c == 0 and n > 1:
        an1 = -1
        break
    else:
        if c1[s-1] > -2 and ans[s-1] != c:
            an1 = -1
            break
        else:
            c1[s - 1] += 1
            ans[s - 1] = c

if an1 == 1:
    for i,n1 in enumerate(ans):
        if n1 == -1:
            if i == 0:
                if n > 1:
                    ans[i] = 1
                else:
                    ans[i] = 0
            else:
                ans[i] = 0
    print("".join(list(map(str, ans))))
else:
    print(an1)

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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int arr[3][3];
    int n =3, q, x;
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cin >> arr[i][j];
        }
    }
    bool vis[3][3];
    memset(vis, false, sizeof(vis));
    cin >> q;
    while(q--){
        cin >> x;
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                if(arr[i][j] == x)
                    vis[i][j] = true;
            }
        }
    }
    bool flag = false;
    if( vis[0][0] && vis[0][1] && vis[0][2] ||
        vis[1][0] && vis[1][1] && vis[1][2] ||
        vis[2][0] && vis[2][1] && vis[2][2] ||

        vis[0][0] && vis[1][0] && vis[2][0] ||
        vis[0][1] && vis[1][1] && vis[2][1] ||
        vis[0][2] && vis[1][2] && vis[2][2] ||

        vis[0][0] && vis[1][1] && vis[2][2] ||
        vis[0][2] && vis[1][1] && vis[2][0]
       )
        flag = true;
    puts(flag? "Yes": "No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int A;
int B;
int X;
int main(){
  rd(X);
  rd(A);
  rd(B);
  X -= A;
  X %= B;
  wt_L(X);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int A, B, X;
// {
//   rd(X,A,B);
//   X -= A;
//   X %= B;
//   wt(X);
// }


Measured memory_bytes: 256
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;

public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a,b,x;
		a = sc.nextDouble();
		b = sc.nextDouble();
		x = sc.nextDouble();
		
		double ans = Math.atan( (b- (x/ (a*a)))* (2.0/a));
		if(a*(Math.sin(ans)) > (b*(Math.cos(ans))))
		{
			ans = Math.atan(a*b*b/ (2.0*x)) ;

		}
		ans = Math.toDegrees(ans);
// 		ans *= 18000;
// 		ans /= 314.15926535;
	    System.out.println(ans);
	}
}


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

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

    int answer = 0;
    for (auto c : s)
    {
        if (c == '1')
            answer++;
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
#include<iostream>

#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
using namespace std;

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

typedef pair<int, int> pii;



int main() {
	
	int a,b;
	

	cin >> a>>b;
	
	
	 cout <<max(a*b,max(a-b,a+b))  << endl;
	
	



	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static class Node {
        int parent, left, right;
        Node() {
            this.left = -1;
            this.right = -1;
        }
    }
    public static int MAX = 100005;
    public static int n;
    public static Node[] T = new Node[MAX];

    public static void preParse(int u) {
        if(u == -1) return;
        System.out.print(" " +u);
        preParse(T[u].left);
        preParse(T[u].right);
    }

    public static void inParse(int u) {
        if(u == -1) return;
        inParse(T[u].left);
        System.out.print(" " + u);
        inParse(T[u].right);
    }

    public static void postParse(int u) {
        if(u == -1) return;
        postParse(T[u].left);
        postParse(T[u].right);
        System.out.print(" " + u);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        int v = 0;
        int l = 0;
        int r = 0;
        int root = 0;

        for(int i = 0; i < n; i++) {
            T[i] = new Node();
            T[i].parent = -1;
        }

        for(int i = 0; i < n; i++) {
            v = sc.nextInt();
            l = sc.nextInt();
            r = sc.nextInt();

            T[v].left = l;
            T[v].right = r;
            if(l != -1) T[l].parent = v;
            if(r != -1) T[r].parent = v;
        }
        for(int i = 0; i < n; i++) {
            if(T[i].parent == -1) root = i;
        }

        System.out.println("Preorder");
        preParse(root);
        System.out.println();
        System.out.println("Inorder");
        inParse(root);
        System.out.println();
        System.out.println("Postorder");
        postParse(root);
        System.out.println();
    }
}



Measured memory_bytes: 26832
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int getSum(const vec<int, 2>& sum, int i, int j, int K) {
  int b1 = sum[i][j];
  int b2 = sum[i][2 * K] - sum[i][j + K];
  int b3 = sum[i + K][j + K] - sum[i + K][j] - sum[i][j + K] + sum[i][j];
  int b4 = sum[2 * K][j] - sum[i + K][j];
  int b5 = sum[2 * K][2 * K] - sum[2 * K][j + K] - sum[i + K][2 * K] +
           sum[i + K][j + K];
  return b1 + b2 + b3 + b4 + b5;
}

void sum2d(vec<int, 2>& sum) {
  int H = sum.size(), W = sum[0].size();
  for (int i = 1; i < H; i++)
    for (int j = 1; j < W; j++)
      sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
}

int main() {
  int N, K;
  while (cin >> N >> K) {
    vec<int, 2> sumB = make_v(2 * K + 1, 2 * K + 1, 0);
    vec<int, 2> sumW = make_v(2 * K + 1, 2 * K + 1, 0);
    int blackCount = 0, whiteCount = 0;
    for (int i = 0; i < N; i++) {
      int x, y;
      char c;
      cin >> x >> y >> c;
      x %= 2 * K;
      y %= 2 * K;
      if (c == 'B') {
        ++blackCount;
        ++sumB[x + 1][y + 1];
      } else {
        ++whiteCount;
        ++sumW[x + 1][y + 1];
      }
    }
    sum2d(sumB);
    sum2d(sumW);
    int res = 0;
    for (int i = 0; i <= K; i++) {
      for (int j = 0; j <= K; j++) {
        int score1 =
            getSum(sumB, i, j, K) + (whiteCount - getSum(sumW, i, j, K));
        res = max(res, score1);
        int score2 =
            getSum(sumW, i, j, K) + (blackCount - getSum(sumB, i, j, K));
        res = max(res, score2);
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 31616
n,m,c = map(int, input().split())
bl = list(map(int, input().split()))

res = 0
for _ in range(n):
    al = list(map(int, input().split()))
    s = c + sum([al[i]*bl[i] for i in range(m)])
    if s>0:
        res += 1
print(res)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

string s;

int main (){
  cin>>s;
  ll n=s.size();
  ll a=0;
  ll b=0;
  for(ll i=0;i<n;i++){
    if(s[i]=='0')a++;
    else b++;
  }
  ll ans=min({a,b});
  ans=ans*2;
  cout<<ans<<endl;
}


Measured memory_bytes: 512