akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//file stream
#define output(name) freopen(name,"w",stdout)
#define input(name) freopen(name,"r",stdin)
//functions
#define pb(x)  push_back(x)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
// pair
#define xx first
#define yy second
#define mp(x,y) make_pair(x,y)
//input
#define sc1(n) cin>>n
#define sc2(n,m) cin>>n>>m
#define sc3(n,m,k) cin>>n>>m>>k
#define sc4(n,m,k,l) cin>>n>>m>>k>>l
#define SCN     scanf
//output 1 var
#define pr1(n) cout<<n<<endl
#define pd1(n,pre) printf("%.*f",pre,n)
//output 2 var
#define pr2(n,m) cout<<n<<" "<<m<<endl
#define pd2(n,m,pre) printf("%.*f %.*f",pre,n,pre,m)
//inputs 3 var less important
#define pr3(n,m,l) cout<<n<<" "<<m<<" "<<l<<endl
#define pr4(n,m,l,k) cout<<n<<" "<<m<<" "<<l<<" "<<k<<endl
//output misc
#define nline() putchar(10)
#define space() putchar(' ')
#define pch(c) putchar(c)
#define tcase(i) printf("Case %d:",i)
#define PRF     printf
#define dbg()   printf("-----------")
//loop
#define fr0(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define fri(i,ini,limit,inc) for(i=ini;i<=limit;i+=(inc))
#define frd(i,ini,limit,dec) for(i=ini;i>=limit;i-=(dec))
//to compile in codeblocks , c++ flag must be off
//additional, only work if compiled with gcc compiler
#define frf(c, it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define frr(c, it) for(typeof((c).rbegin()) it = (c).rbegin(); it != (c).rend(); it++)
//memory reset
#define set0(x) memset(x,0,sizeof x)
#define setn1(x) memset(x,-1,sizeof x)
#define setinf(x) memset(x,125,sizeof x)
//misc
#define SZ(v)   ((int) (v).size())
#define all(v)  (v).begin(), (v).end()
//bit operation single variable
#define On(x,i)  (x|=(1<<(i)))
#define Off(x,i) (x&= ~(1<<(i)))
#define isOn(x,i) (x&(1<<(i)))
#define Toggle(x,i) (x^=(1<<(i)))
#define tmod(x,i)  (x&(~(-1<<i)))
//bit operation array
//data type
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

//constant
const double EPS = 1e-9;
int i,j,k,l,m,n;
double a,b;
int main()
{
    sc2(a,b);
    pd1(a*b/(a+b),10);
    return 0;
}





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

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

#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()

const int MN = 131072;

int d[MN];
pii ch[2][MN];
int N;
vector<pll> vec[MN];

void dfs(int v, ll x)
{
	if (d[v] == 0) {
		vec[v].eb(0LL, 0LL);
		return ;
	}
	int a = ch[0][v].fi, c1 = ch[0][v].se;
	int b = ch[1][v].fi, c2 = ch[1][v].se;
	dfs(a, x);
	dfs(b, x);

	if ((int)vec[a].size() == 0 || (int)vec[b].size() == 0) return ;

	if (vec[a].size() > vec[b].size()) {
		swap(a, b);
		swap(c1, c2);
	}

	int i = 0, i2 = 0;

	vector<pll> v1, v2;

	for (pll &p : vec[a]) { //a,b
		ll c = x - c1 - c2 - p.se;

		while (i+1 < vec[b].size() && vec[b][i+1].fi <= c) {
			++i;
		}

		if (vec[b][i].fi <= c) {
			v1.eb(p.fi + c1, vec[b][i].se + c2);
		}
	}

	for (pll &p : vec[a]) { //b,a
		ll c = x - c1 - c2 - p.fi;

		while (i2 < vec[b].size() && vec[b][i2].se > c) {
			++i2;
		}

		if (i2 < vec[b].size()) {
			v2.eb(vec[b][i2].fi + c2, p.se + c1);
		}
	}

	vector<pll> res;
	i = i2 = 0;

	while (i != (int)v1.size() || i2 != (int)v2.size()) {
		if (i == (int)v1.size()) res.eb(v2[i2++]);
		else if (i2 == (int)v2.size()) res.eb(v1[i++]);
		else {
			if (v1[i] < v2[i2]) res.eb(v1[i++]);
			else res.eb(v2[i2++]);
		}
	}

	for (pll &p : res) {
		if (vec[v].size() == 0 || vec[v].back().se > p.se) {
			vec[v].eb(p);
		}
	}
}

bool f(ll x)
{
	rep(i, MN) vec[i].clear();
	dfs(0, x);
	return (int)vec[0].size() > 0;
}

int main() {
	cin >> N;

	rep(i, N-1) {
		int a, v;
		cin >> a >> v;
		--a;
		ch[d[a]++][a] = mp(i + 1, v);
	}

	ll ng = -1, ok = 1e11;

	while (ok - ng > 1) {
		ll m = (ok + ng) / 2;
		if (f(m)) {
			ok = m;
		} else {
			ng = m;
		}
	}

	cout << ok << endl;

	return 0;
}

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

N = int(input())
A = [int(v) for v in input().split()]
p = sum(A)
L = [0] * (N + 1)

for i in range(N):
    L[i + 1] = L[i] + A[i]

ans = 10 ** 18
for i in range(N - 1):
    t = L[i + 1] - L[0]

    ans = min(ans, abs(t - p + t))

print(ans)


Measured memory_bytes: 23792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdlib>
#include <set>
#include <queue>
using namespace std;

#define X first
#define Y second
#define Mod 1000000007
#define N 100010
#define M 101

typedef long long ll;

const int INF=1<<30;

vector<int> g[N];
int color[N];
ll c1,p,q;

bool Dfs(int x,int c,int &cnt)
{
	cnt++; color[x]=c; bool flag=true;
	for (int i=0,y;i<g[x].size();i++)
	{
		y=g[x][i];
		if (!color[y] && !Dfs(y,3-c,cnt)) flag=false;
		else if (color[x]==color[y]) flag=false;
	}
	return flag;
}

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	int n,m,x,y; scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for (int i=1;i<=n;i++) if (!color[i])
	{
		int sz=0; 
		bool flag=Dfs(i,1,sz);
		if (sz==1) c1++;
		else
		{
			if (flag) q++;
			else p++;
		}
	}
	ll ans=c1*c1+2*c1*(n-c1)+p*p+2*p*q+2*q*q;
	printf("%lld\n",ans);
	
	return 0;
}

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

int main(){
	string s;
    cin >> s;
	int cnt = 0;
	int mc = 0;
	int len = s.size();
	rep(i,len){
		if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
			cnt++;
			mc = max(cnt,mc);
		}else cnt = 0;
	}
	cout << mc << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a: usize,
        b: usize,
        c: usize
    }
    let d: usize = 1000000007;
    let mut stair: Vec<usize> = vec![0; 2 * n];
    stair[0] = 1;
    for i in 1..2 * n {
        stair[i] = stair[i - 1] * i % d;
    }
    let stair_i: Vec<usize> = stair.iter().map(|x| inv_m(*x, d)).collect();
    let mut ans = 0;
    let mut apow: Vec<usize> = vec![1; n + 1];
    let mut bpow: Vec<usize> = vec![1; n + 1];
    let pa = a * inv_m(a + b, d) % d;
    let pb = b * inv_m(a + b, d) % d;
    for i in 1..n + 1 {
        apow[i] = apow[i - 1] * pa % d;
        bpow[i] = bpow[i - 1] * pb % d;
    }
    for k in n..2 * n {
        ans += stair[k] * stair_i[k - n] % d * (apow[n] * bpow[k - n] % d + apow[k - n] * bpow[n] % d) % d;
        ans %= d;
    }
    ans = ans * stair_i[n - 1] % d;
    ans = ans * 100 % d * inv_m(100 - c, d) % d;
    println!("{}", ans);
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}

fn inv_m(n: usize, d: usize) -> usize {
    pow_m(n, d - 2, d)
}


Measured memory_bytes: 10492
#include <iostream>
#include <string> 
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

void z_algorithm(string& S,vector<int>& A)
{
    int sz = (int)S.size();
    A.resize(sz);
    A[0] = S.size();
    int i = 1, j = 0;
    while (i < S.size()) {
    while (i+j < S.size() && S[j] == S[i+j]) ++j;
    A[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
        while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
    i += k; j -= k;
}

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    vector<int> a,b;
    z_algorithm(s,a);
    
    reverse(s.begin(),s.end());
    z_algorithm(s,b);
    int ma = -1;
    for(int i=n/3-2;i<n/2+2;i++){
        if(i<=0||i>=n)continue;
        int tmp = n-2*i;
        if(a[i]==n-i&&b[i]==n-i&&tmp>0&&(n-3*(tmp))/2>0&&(n-3*(tmp))%2==0){
            ma = max(ma,tmp);
        }
    }
    // for(int i=0;i<n;i++){
    //     cout << a[i] << " ";
    // }
    // cout << endl;
    // for(int i=0;i<n;i++){
    //     cout << b[i] << " ";
    // }
    // cout << endl;
    
    if(ma==-1){
        cout << "mitomerarenaiWA" << endl;
    }else{
        int x = ma;
        int y = (n-3*ma)/2;
        printf("Love ");
        for(int i=0;i<x+y;i++){
            printf("%c",s[n-i-1]);
        }
        printf("!\n");
        //cout << x << " " << y << " " << n << endl;
    }
    return 0;
}



Measured memory_bytes: 11824
/*

	TRY_TO_BE8T_ME

*/
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define FIO ios::sync_with_stdio(0);
ll gcd(ll a,ll b){while(a&&b)a>b?a%=b:b%=a;return a+b;}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
int main() 
{
	FIO;
	ll i,j,k,c=0,n,m,d=0;
	string s;
	cin>>s;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='+')
			c++;
		else if(s[i]=='-')
			c--;
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
typedef struct{
    int x,y;
}queue;
queue q[100000];

int h,w,b[60][30],head,teil,f[30][30];

void foo(int tx,int ty){
    int i,dx[]={1,-1,0,0},dy[]={0,0,-1,1},nx,ny;
    int kx[]={tx,tx-1,tx,tx},ky[]={2*ty,2*ty,2*ty-1,2*ty+1};
    rep(i,4){
        if(b[ky[i]][kx[i]])continue;
        nx=tx+dx[i];
        ny=ty+dy[i];
        if(0<=ny&&ny<h&&0<=nx&&nx<w){
            if(f[ny][nx]==-1||f[ny][nx]>f[ty][tx]+1){
                f[ny][nx]=f[ty][tx]+1;
                teil++;
                q[teil].x=nx;
                q[teil].y=ny;
            }
        }
    }
}

int main(void){
    int i,j,sx,sy,gx,gy,tx,ty;
    while(w=in()){
        h=in();
        getchar();
        rep(i,2*h-1){
            if(i%2){
                rep(j,w)b[i][j]=in();
            }
            else{
                rep(j,w-1)b[i][j]=in();
            }
        }
        MEMSET(q);
        head=teil=0;
        memset(f,-1,sizeof(f));
        f[0][0]=1;
        sx=sy=0;
        gx=w-1;
        gy=h-1;
        q[head].x=sx;
        q[head].y=sy;
        while(head<=teil){
            tx=q[head].x;
            ty=q[head].y;
            head++;
            foo(tx,ty);
        }
        print(f[gy][gx]!=-1?f[gy][gx]:0);
    }
    return 0;
}


Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
    cin >> s;
    for(int i=0;i<s.size()-1;++i) {
        if(s[i]=='A'&&s[i+1]=='C') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

using namespace std;

int main(){
  int X, ans=1;

  cin >> X;

  for(int i = 2; i <= X; i++){
    int t = i;
    if(X < t*t) break;
    while(t <= X) t *= i;
    t /= i;
    if(ans < t) ans = t;
    
  }

  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
//author : 'Amit Singh Sansoya @amit3200'
//it was all meant to happen as i was all talk!
#include<bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> happiness,dp;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		vector<int> dummy;
		for(int j=0;j<3;j++){
			int data;
			cin>>data;
			dummy.push_back(data);
		}
		happiness.push_back(dummy);
	}
	dp.resize(n+1,vector<int>(3,0));
	dp[0][0]=happiness[0][0];
	dp[0][1]=happiness[0][1];
	dp[0][2]=happiness[0][2];
	for(int i=1;i<n;i++){
		dp[i][0]=happiness[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=happiness[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=happiness[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<*max_element(dp[n-1].begin(),dp[n-1].end());
}

Measured memory_bytes: 11440
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
using namespace std;
const int N = 100010;
map<string,int> m;
void work(string s){
	cout<<s<<" x "<<m[s]<<endl;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		string s;
		cin>>s;
		m[s]++;
	}
	work("AC");
	work("WA");
	work("TLE");
	work("RE");
	return 0;
}

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

int main (){
  int a,b;
  
  cin>>a>>b;
  
  int c=a*b;
  
  if(c%2==0){
    cout<<"Even"<<endl;
  }
  else{
    cout<<"Odd"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, m, a, b, fact[N], inv[N], ans;

inline int mult (int a, int b) {
   return 1ll * a * b % mod;
}

inline int add (int a, int b) {
   a += b;
   if (a >= mod) a -= mod;
   return a;
}

inline int binpow (int a, int b) {
   int res = 1;
   while (b) {
      if (b & 1) res = mult (res, a);
      a = mult (a, a);
      b >>= 1;
   }
   return res;
}

inline int C (int n, int k) {
   return mult (fact[n], mult (inv[k], inv[n - k]));
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     
                                      
inline void Solve () {
   cin >> n >> m >> a >> b;
   fact[0] = inv[0] = 1;
   for (int i = 1; i <= n + m; i ++) {
      fact[i] = mult (fact[i - 1], i);
      inv[i] = binpow (fact[i], mod - 2);
   }
   for (int down = 0; down < n - a; down ++) {
      ans = add (ans, mult (C (b - 1 + down, down), C (n + m - 2 - b - down, m - 1 - b)));
   } 
   cout << ans;
}                                     

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
// cin >> tt;                                                                                
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


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

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

typedef long long                LL;
typedef vector < int >           VI;
typedef pair < int,int >         II;
typedef vector < II >            VII;

#define MOD                      1000000007
#define EPS                      1e-12
#define N                        200100
#define PB                       push_back
#define MP                       make_pair
#define F                        first 
#define S                        second
#define ALL(v)                   v.begin(),v.end()
#define SZ(a)                    (int)a.size()
#define FILL(a,b)                memset(a,b,sizeof(a))
#define SI(n)                    scanf("%d",&n)
#define SLL(n)                   scanf("%lld",&n)
#define PLLN(n)                  printf("%lld\n",n)
#define PIN(n)                   printf("%d\n",n)
#define REP(i,j,n)               for(LL i=j;i<n;i++)
#define PER(i,j,n)               for(LL i=n-1;i>=j;i--)
#define endl                     '\n'
#define fast_io                  ios_base::sync_with_stdio(false);cin.tie(NULL)

#define FILEIO(name) \
  freopen(name".in", "r", stdin); \
  freopen(name".out", "w", stdout);
 
inline int mult(int a , int b) { LL x = a; x *= LL(b); if(x >= MOD) x %= MOD; return x; }
inline int add(int a , int b) { return a + b >= MOD ? a + b - MOD : a + b; }
inline int sub(int a , int b) { return a - b < 0 ? MOD - b + a : a - b; }
LL powmod(LL a,LL b) { if(b==0)return 1; LL x=powmod(a,b/2); LL y=(x*x)%MOD; if(b%2) return (a*y)%MOD; return y%MOD; }



int main() {
  int a,b;cin >> a >> b;
  a = (a + b) % 24;
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * B - Buffet
 * 料理は全部食べるので、満足度は最終的に全て足すことになる。
 *
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // ビュッフェでの料理の種類数
        int n = sc.nextInt();
//        System.out.println( "n : " + n );

        // 食べた順番
        int[] a = new int[n];
//        int addCount = 0;
        for( int i = 0; i < n; i++ ) {
//            System.out.println( "i : " + i );
            a[i] = sc.nextInt();
//            System.out.println( "a[" + i + "]" + a[i] );
        }

        // 満足度
        int point = 0;
        int[] b = new int[n];
        for( int j = 0; j < n; j++ ) {
           b[j] = sc.nextInt();
           point += b[j];
//           System.out.println( "b[" + j + "]" + b[j] );
        }
//        System.out.println( "point! : " + point );

        // 追加満足度
        int[] c = new int[n - 1];
        for( int k = 0; k < ( n -1 ); k++ ) {
           c[k] = sc.nextInt();
//           System.out.println( "c[" + k + "]" + c[k] );
        }

        for( int l = 0; l < n; l++ ) {
//            System.out.println("l : " + l);
//            System.out.println("a[l] : " + a[l]);
//            int current = (a[l] + 1 );
//            System.out.println("a[l] - 1 : " + ( a[l] - 1 ));
//            point += b[( a[l] - 1 )];
//            System.out.println("compare : " +  (n > (l+1)));
//            System.out.println("compare2 : " +( ( a[l] + 1 ) == a[( l + 1 )] ));
//            System.out.println("compare3 : " +( a[l] + 1 ));
//            System.out.println("compare4 : " + a[( l + 1 )] );
            if(  ( l + 1 ) < n && ( a[l] + 1 ) == a[( l + 1 )] ) {
//                System.out.println( "c[( l + 1 )] : " + c[( l + 1 )] );
                point += c[a[l] - 1];
            }
//            System.out.println( "point : " + point );
        }
        System.out.println( point );
     }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for(int i = 1; i <= n; i++) cin >> a[i];

  vector<int> b(n + 1, 0); // 0初期化
  vector<int> ans;
  for(int i = n; i > 0; i--) {
    int tmp = i;
    int count = 0;
    tmp += i;
    while(tmp <= n) {
      if(b[tmp] == 1) count++;
      tmp += i;
    }
    if(count % 2 == 0 && a[i] == 1) {
      b[i] = 1;
      ans.push_back(i);
    } else if(count % 2 == 1 && a[i] == 0){
      b[i] = 1;
      ans.push_back(i);
    }
  }
  cout << ans.size() << endl;
  for(int i = 0; i < ans.size(); i++) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var abc = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var a = abc[0];
        var b = abc[1];
        var c = abc[2];

        Console.WriteLine(Math.Max(c - (a - b), 0));
    }
}


Measured memory_bytes: 13268
#include<cstdio>

int n;

int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int k,p;
        scanf("%d %d",&k,&p);
        int a=k%p;
        if(a==0)a=p;
        printf("%d\n",a);
    }
    
}

Measured memory_bytes: 1024
from sys import stdin
import math
    
def calc(n,k):

    p = 0
    _range = n

    if k == 1:
        return 1

    #dice
    if n >= k:
        p += (n-k+1)/n
        _range = k - 1
    
    for i in range(1, _range + 1):
        x = math.ceil(math.log2(k/i))
        p += 1/n * 0.5 ** x

    return p

def main():
    n,k = [int(x) for x in stdin.readline().rstrip().split()]
    ans = calc(n,k)
    print('{:.11f}'.format(ans))
    
if __name__=='__main__':
    main()

Measured memory_bytes: 3064
h, w, m = map(int, input().split())
r = [0] * (h+1)
c = [0] * (w+1)
bomb = []
for _ in range(m):
    hi, wi = map(int, input().split())
    r[hi] += 1
    c[wi] += 1
    bomb.append([hi, wi])

hmax = max(r)
wmax = max(c)

cnt = 0
ret = 1
for i in range(1, h+1):
    if r[i] == hmax:
        cnt += 1
ret *= cnt

cnt = 0
for i in range(1, w+1):
    if c[i] == wmax:
        cnt += 1

ret *= cnt

for i in range(m):
    hi, wi = bomb[i]
    if r[hi] == hmax and c[wi] == wmax:
        ret -= 1

if ret == 0:
    print(hmax + wmax - 1)
else:
    print(hmax + wmax)


Measured memory_bytes: 58964
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  int p[n]; REP(i,n) cin >> p[i];

  int ans = 0;
  for (int i = 1; i < n-1; i++) {
    int tmp[3] = { p[i-1], p[i], p[i+1] };
    sort(tmp, tmp+3);
    if (tmp[1] == p[i]) ans++;
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=1e9+7;
const ll inf=2e14;
const ll ms=(2e5) +5;

int main()
{
    idfc;
    set<int> ss;
    for(int i=0;i<3;i++)
    {
        int e;
        cin>>e;
        ss.insert(e);
    }
    if(ss.size()==2)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
m=998244353
D=[[0]*(d+1)for _ in range(c+1)]
D[a][b]=1
for i in range(a,c+1):
 for j in range(b,d+1):
  D[i][j]+=(D[i][j-1]*i+D[i-1][j]*j-D[i-1][j-1]*(i-1)*(j-1))%m
print(D[c][d])

Measured memory_bytes: 133604
import java.util.ArrayList;
import java.util.IntSummaryStatistics;
import java.util.List;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int cntStudent = 0;

			while ((cntStudent = sc.nextInt()) != 0) {
				List<Integer> datalist = new ArrayList<>();
				IntStream.range(0, cntStudent).forEachOrdered(i -> datalist.add(sc.nextInt()));
				IntSummaryStatistics summary = datalist.stream()
						.mapToInt(num -> num.intValue()).summaryStatistics();

				long cnt = summary.getCount();
				double avg = summary.getAverage();
				double variance = 0.0;
				for (int num : datalist) {
					variance += Math.pow((double)num -avg, 2);
				}

				System.out.println(Math.sqrt(variance / cnt));
			}
		}
	}
}


Measured memory_bytes: 35044
import java.util.*

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val n = scanner.nextInt()
	val pa = mutableListOf<Int>()
	val na = mutableListOf<Int>()
	for(i in 0..n-1){
		val a = scanner.nextInt()
		if (a>=0) pa.add(a) else na.add(a)
	}
	pa.sort()
	na.sort()
	val seq = mutableListOf<Pair<Int, Int>>()
	if (pa.size==0){
		if (na.size>2) {
			seq.add(Pair(na[na.size - 1], na[na.size - 2]))
			pa.add(na[na.size - 1] - na[na.size - 2])
			na.removeAt(na.size - 1)
			na.removeAt(na.size - 2)
		}else {
			println(na[1]-na[0])
			println("${na[1]} ${na[0]}")
			System.exit(0)
		}
	}else if (na.size==0){
		if (pa.size>2){
			seq.add(Pair(pa[0], pa[1]))
			na.add(pa[0]-pa[1])
			pa.removeAt(1)
			pa.removeAt(0)
		}else {
			println(pa[1]-pa[0])
			println("${pa[1]} ${pa[0]}")
			System.exit(0)
		}
	}
	for (i in 1..na.lastIndex){
		seq.add(Pair(pa.last(), na[i]))
		pa[pa.lastIndex] -= na[i]
	}
	for (i in 0..pa.lastIndex-1){
		seq.add(Pair(na[0], pa[i]))
		na[0] -= pa[i]
	}
	seq.add(Pair(pa.last(), na[0]))
	println(pa.last()-na[0])
	seq.forEach { println("${it.first} ${it.second}") }

}

Measured memory_bytes: 75404
N = int(input())
 
def make_devision(n):
  lst = []
  for i in range(1, int(n**0.5) + 1):
    if n % i == 0:
      lst.append(i)
      if i != n // i:
        lst.append(n // i)
  return lst
 
def calc(n, k):
  if n % k == 0:
    return calc(n // k, k)
  elif n < k:
    return n
  else:
    return calc(n % k, k)
 
ans = make_devision(N-1)
 
for i in make_devision(N):
  if i == 1:
    continue
  if calc(N, i) == 1:
    ans.append(i)
    
print(len(ans)-1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define sz(v) (int)v.size()
#define pb push_back

using namespace std;
int a,b;
int main(){
    cin >> a >> b;
    cout << (((a*b)&1)? "Odd" : "Even") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<ll>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 117117117

int main()
{
    int N;
    cin >> N;
    vector<ll> a(N);
    rep(i,N){
        cin >> a[i];
	}
    int size=N;
    int size_minus;
    rsort(a);
    while(size>1){
        size_minus=0;
        rep(i,size-1){
            a[i]=a[i]%a[size-1];
            if(a[i]==0){
                size_minus++;
			}
		}
        rsort(a);
        size-=size_minus;
	}
    cout << a[0] << endl;

}

Measured memory_bytes: 3992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = NextInt();
            var list = IntList();
            var maximam = list.Max();

            Console.WriteLine($"{maximam} {list.Aggregate((prev, now) => Math.Abs(maximam / 2d - now) <= Math.Abs(maximam / 2d - prev) ? now : prev)}");
        }
    }

    class MyMath {
        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 20832
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	匹配括号 左减右>=0
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<ceil(log2(double(n)))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define IT iterator
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
vector<int> s1,s2;
map<int,int> m1,m2;
bool cmp1(int a,int b){
	return m1[a]>m1[b];
}
bool cmp2(int a,int b){
	return m2[a]>m2[b];
}
int main(){
	int n,a[100001];
	cin>>n;
	rb(i,1,n) cin>>a[i];
	
	rb(i,1,n){
		if(i%2==1){
			if(m1[a[i]]==0){
				s1.push_back(a[i]);
			}
			m1[a[i]]++;
		}
		else{
			if(m2[a[i]]==0){
				s2.push_back(a[i]);
			}
			m2[a[i]]++;
		}
	}
	s1.push_back(-1);
	s2.push_back(-1);
	int len1=s1.size(),len2=s2.size();
	sort(s1.begin(),s1.end(),cmp1);
	sort(s2.begin(),s2.end(),cmp2);
	if(s1[0]!=s2[0]){
		cout<<n-m1[s1[0]]-m2[s2[0]];
	}
	else{
		cout<<min(n-m1[s1[0]]-m2[s2[1]],n-m1[s1[1]]-m2[s2[0]]);
	}
	return 0;
}

Measured memory_bytes: 5752
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int a[60],b[60],c[60],d[60];
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<m;i++){
        cin>>c[i]>>d[i];
    }
    
    for(int i=0;i<n;i++){
        int min=INF;
        int minp=0;  
        for(int j=0;j<m;j++){
            if(abs(a[i]-c[j])+abs(b[i]-d[j])<min){
                minp=j;
                min=abs(a[i]-c[j])+abs(b[i]-d[j]);
            }

        }
        cout<<minp+1<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

vector<vector<int>> G;
vector<bool> seen;
vector<int> ans;

void dfs(int v, int p = -1) {
  seen[v] = true;
  EACH(nv, G[v]) {
    if (seen[nv]) continue;
    if (nv == p) continue;
    ans[nv] += ans[v];
    dfs(nv, v);
  }
}

void solve(istream& cin, ostream& cout) {
  int n, q;
  cin >> n >> q;
  G.resize(n);
  seen.assign(n, false);
  ans.assign(n, 0);
  REP(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  REP(i, q) {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0);
  REP(i, n) {
    cout << ans[i] << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int k, s; scanf("%d%d", &k, &s);
	int ans = 0;
	for (int i = 0; i <= k; ++i) {
		for (int j = 0; j <= k; ++j) {
			if (s-i-j <= k && s-i-j >= 0) ++ans;
		}
	}
	printf("%d", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>

int main() {

    int a,b;
    
    scanf("%d %d", &a, &b);
    
    double ab = (double)(a+b)/2;
    
    printf("%d",(int)ceil(ab));
    
    return 0;

}


Measured memory_bytes: 128
n = gets.to_i
ary = gets.strip.split.map(&:to_i)
a = []
b = []
ary.sort.reverse.each_with_index do |k, i|
  if i == 0
    a << k
  elsif i.even?
    a << k
  else
    b << k
  end
end
puts a.inject(&:+) - b.inject(&:+)


Measured memory_bytes: 1788
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int Debt = 100000;
		Debt= ratecal(N,Debt);
		System.out.println(Debt);
	}

	public static int ratecal(int N, int Debt ){
		
		while(N > 0){
			Debt = (int)(Debt * 1.05);
			if(Debt % 1000 > 0 ){
				Debt = ((Debt/1000) + 1) * 1000;
			}
			else {
				Debt = (Debt/1000) * 1000;
			}
			N--;
		}
		
		return Debt;
	}
}

Measured memory_bytes: 25740
//Binary Search Tree I
#include <iostream>

using namespace std;

class Node {
public:
    int key;
    Node *parent = nullptr, *left = nullptr, *right = nullptr;

    Node(int key): key(key) {};
};

class Tree {
public:
    Node *root = nullptr;

    void insert(int k) {
        Node *x = root, *y = nullptr;
        while(x != nullptr) {
            y = x;
            if(k <= x->key) x = x->left;
            else x = x->right;
        }

        Node *z = new Node(k);
        z->parent = y;
        if(y == nullptr) root = z;
        else if(k <= y->key) y->left = z;
        else y->right = z;
    };
};

void inOrder(Node *u) {
    if(u == nullptr) return;
    inOrder(u->left);
    cout << " " << u->key;
    inOrder(u->right);
}

void preOrder(Node *u) {
    if(u == nullptr) return;
    cout << " " << u->key;
    preOrder(u->left);
    preOrder(u->right);
}

int main() {
    Tree T;

    int n;
    cin >> n;
    for(int i=0; i<n; i++) {
        string opr;
        int key;
        cin >> opr;
        if(opr == "insert") {
            cin >> key;
            T.insert(key);
        }
        if(opr == "print") {
            inOrder(T.root);
            cout << endl;
            preOrder(T.root);
            cout << endl;
        }
    }
}



Measured memory_bytes: 26592
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

void print(std::vector<long long> readVec){
    int sz = readVec.size();
    for(int i = 0; i < sz; ++i){
        std::cout << readVec.at(i);
        if(sz - 1 == i){
            std::cout << std::endl;
        }else{
            std::cout << " ";
        }
    }
}

long long comb(long long a, long long b){
    long long write = 1;
    for(long long i = 0; i < b; ++i){
        write *= a - i;
    }
    for(long long i = 1; i <= b; ++i){
        write /=  i;
    }

    return write;
}

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

    std::vector<long long> a(n);
    for(int i = 0; i < n; ++i){
        std::cin >> a.at(i);
    }

    std::sort(a.begin(), a.end(), std::greater<long long>());
    
    std::map<long long, long long> map;
    for(int i = 1; i < n; ++i){
        map.insert(std::make_pair(std::abs(a.at(0) - a.at(i) * 2), a.at(i)));
    }

    std::cout << a.at(0) << " " << map.begin()->second << std::endl;

    return 0;
}

Measured memory_bytes: 7296
class UnionFindVerSize():
    def __init__(self, N):
        self._parent = [n for n in range(0, N)]
        self._size = [1] * N

    def find_root(self, x):
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x])
        return self._parent[x]

    def unite(self, x, y):
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        return self._size[self.find_root(x)]

    def is_same_group(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans

import sys

input = sys.stdin.readline

N,Q = map(int,input().split())

uf = UnionFindVerSize(N)

for _ in range(Q):
    t,u,v = map(int,input().split())

    if t == 0:
        uf.unite(u-1,v-1)
    else:
        print(int(uf.is_same_group(u-1,v-1)))

Measured memory_bytes: 81900
N,M,C = [int(i) for i in input().split()]
B_list = [int(i) for i in input().split()]
ok_count = 0
for i in range(N) :
    A_list = [int(i) for i in input().split()]
    tmp_sum = 0
    for m in range(M) :
        tmp_sum += A_list[m] * B_list[m]
    
    tmp_sum += C
    if (tmp_sum > 0) :
        ok_count += 1

print(ok_count)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int out = 0;
        for(int i = 1; i < n; i++){
            int mod = n % i;
            int div = n / i;
            if(mod == 0){
                div--;
            }
            out+=div;
        }
        System.out.println(out);
    }
}


Measured memory_bytes: 35692
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using b10 = bitset<10>;

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

int main() {
  int d, g;
  cin >> d >> g;

  vi p(d), c(d);
  rep(i, d) cin >> p[i] >> c[i];
  
  int n_min = 1 << 10;
  // i -> solve completely
  rep(i, 1 << d) {
    int n = 0;
    int total = 0;

    b10 solved; 
    b10 will_solve(i);
    
    // 1. solve all of p[i] problems
    rep(j, d) {
      if (!will_solve.test(j)) continue;

      solved.set(j, 1);

      rep(k, p[j]) {
        n++;
        total += (j + 1) * 100;
        if (k == p[j] - 1) total += c[j];
      }
    }

    if (total >= g) n_min = min(n_min, n);
    if (n >= n_min) continue;

    // 2. solve all or halfway through 
    for (int j = d - 1; j >= 0; j--) {
      if (solved.test(j)) continue;

      solved.set(j, 1);

      rep(k, p[j]) {
        n++;
        total += (j + 1) * 100;
        if (k == p[j] - 1) total += c[j];
        
        if (total >= g) n_min = min(n_min, n);
        if (n >= n_min) break;
      }

      if (n >= n_min) break;
    }
  }

  cout << n_min << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;


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

  std::vector<ll> p(n);
  rep(i,n) cin >> p.at(i);

  ll number,count=0;
  for(ll i=0;i<n-1;i++){
    number=p.at(i);
    if(number==i+1){
      p.at(i)=p.at(i+1);
      p.at(i+1)=number;
      count++;
      i++;
    }
  }

  if(p.at(n-1)==n){
    number=p.at(n-1);
    p.at(n-1)=p.at(n-2);
    p.at(n-2)=number;
    count++;
  }
  cout << count << endl;


  }


Measured memory_bytes: 4068
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
    int a,b,c;
    while(~scanf("%d%d%d",&a,&b,&c))
    {
    	if(abs(a-b)<abs(a-c))
    	printf("A\n");
    	else
    	printf("B\n");
	} 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a[100001];

int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	
	for(int i=1;i<=n;i++){
		if(a[i]==0){
			cout<<0<<endl;
			return 0;
		}
	}
	
	long long prod=1;
	for(int i=1;i<=n;i++){
		if(a[i]<=1000000000000000000/prod)
			prod*=a[i];
		else{
			cout<<-1<<endl;
			return 0;
		}
	}
	
	cout<<prod<<endl;
	return 0;
}

Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}
template <class T> void print(T a){ cout << a << endl;};
vector<string> Yes = {"No", "Yes"};


int dfs(vlint tmp, int n, int m, int q, vlint a, vlint b, vlint c, vlint d){
    if (Size(tmp) == n+1){
        int ret = 0;
        rep(i, q){
            if (tmp[b[i]] - tmp[a[i]] == c[i]) ret += d[i];
        }
        return ret;
    }
    int t = tmp.back();
    int ret = 0;
    tmp.pb(t-1);
    rep(i, m - t + 1){
        tmp.back()++;
        chmax(ret, dfs(tmp, n, m, q, a, b, c, d));
    }
    return ret;
}

int main(){
    INT(n, m, q);
    vlint a(q), b(q), c(q), d(q);
    rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    int ans = dfs({1}, n, m, q, a, b, c, d);
    print(ans);
}

    



Measured memory_bytes: 3656
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a <= 5)
		printf("0");
	else {
		if (6 <= a && a <= 12)
			printf("%d", b / 2);
		else {
			if (13<=a)
				printf("%d", b);
		}
	}
	return 0;

}

Measured memory_bytes: 128