akhauriyash/Code-Regression huggingface dataset:
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const int maxn = 105;

int n, m, ans;
int f[maxn][maxn * maxn];

inline int add(int a, int b){return (a + b) % INF;}
inline void uadd(int &a, int b){(a += b) %= INF;}
inline int mul(int a, int b){return (1ll * a * b) % INF;}
inline void umul(int &a, int b){a = mul(a, b);}

inline int qpow(int a, int b){
	int ret = 1;
	for(; b; b >>= 1){
		if(b & 1){
			umul(ret, a);
		}
		umul(a, a);
	}
	return ret;
}

int main(){
	scanf("%d%d", &n, &m);
	f[n][0] = 1;
	for(int i = n; i > 0; --i) FOR(j, 0, maxn * maxn) if(f[i][j] >= 0){
		REP(k, 0, m){
			if(k > i){
				if(f[i - 1][j] < 0)
					f[i - 1][j] = 0;
				uadd(f[i - 1][j], f[i][j]);
				continue;
			}
			if(j + (j + k) / i < maxn * maxn){
				uadd(f[i - 1][j + (j + k) / i], f[i][j]);
			}
		}
	}
	//for(int i = n; i >= 0; --i) FOR(j, 0, maxn * maxn) if(f[i][j])
		//printf("dp[%d][%d] = %d\n", i, j, f[i][j]);
	FOR(j, 0, maxn * maxn) if(f[0][j] >= 0)
		uadd(ans, mul(f[0][j], j));
	ll res = 0;
	res = mul(n, mul((m * (m + 1) / 2), qpow(m + 1, n - 1)));
	//printf("%d %d %d\n", res, ans, (res - ans + INF) % INF);
	printf("%d\n", (res - ans + INF) % INF);
	return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define f first
#define s second

int fj[8][8] = {4, 1, 4, 1, 2, 1, 2, 1};

int main(){
  // make table
  for(int i = 1 ; i < 8 ; i++){
    for(int j = 0 ; j < 8 ; j++){
      int t = j+1;
      if(t == 8) t = 0;
      fj[i][j] = fj[i-1][t];
    }
  }
  
  int p[8], tmp[8];
  int Count[8];
  while(cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]){
    for(int i = 0 ; i < 8 ; i++){
      for(int j = 0 ; j < 8 ; j++) tmp[j] = p[j];
      int cnt = 0;
      for(int j = 0 ; j < 8 ; j++){
	tmp[j] -= fj[i][j];
	tmp[j] = max(0, tmp[j]);
	cnt += tmp[j];
      }
      Count[i] = cnt;
    }
    
    pair<int, string> check[8];
    for(int i = 0 ; i < 8 ; i++){
      string tmp = "";
      for(int j = 0 ; j < 8 ; j++){
	tmp += fj[i][j]+'0';
      }
      check[i].f = Count[i];
      check[i].s = tmp;
    }
    sort(check, check+8);
    
    for(int i = 0 ; i < 8 ; i++){
      if(i != 7) cout << check[0].s[i] << ' ';
      else cout << check[0].s[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1212
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int N;
int c[100010];

int dp[2][2][5002];

int main()
{
    N = in();

    rep(i, N - 1) {
        c[i+1] = in();
    }

    rep(i, 2) rep(j, 2) rep(k, N / 2 + 1) dp[i][j][k] = inf; 
    dp[0][0][0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= min(i, N / 2); ++j) {
            dp[(i + 1) & 1][0][j + 1] = min(dp[i & 1][0][j], dp[i & 1][1][j] + c[i]);
            dp[(i + 1) & 1][1][j] = min(dp[i & 1][1][j], dp[i & 1][0][j] + c[i]);
        }

        dp[(i + 1) & 1][0][0] = inf;
    }

    printf("%d\n", min(dp[0][0][N / 2], dp[0][1][N / 2]));
}

Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  string s, t;
  cin >> s >> t;
  rep(i,sz(s)){
    if(i==sz(s)-1&&sz(t)==sz(s)-1){
      print(s[i]);
      break;
    }
    cout<<s[i]<<t[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(1, n):
  if a[i] - a[i-1] == 1:
    ans += c[a[i-1]-1]
print(ans)
  

Measured memory_bytes: 3060
n, q = map(int, input().split())
s = input()

n_ac = [0]*(n+1)
for i in range(1, n):
    if s[i-1] == 'A' and s[i] == 'C':
        n_ac[i+1] = n_ac[i] + 1
    else:
        n_ac[i+1] = n_ac[i]
# print(n_ac)
        
for _ in range(q):
    l, r = map(int, input().split())
    print(n_ac[r] - n_ac[l])

Measured memory_bytes: 6188
#include<cstdio>
int N = 1000000007;
int main(void) {
    int n;
    long long k;
    scanf("%d %lld", &n, &k);
    int arr[n], arr1[n], arr2[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
        arr1[i] = 0, arr2[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (arr[i] < arr[j]) {
                arr2[j]++;
            }else if(arr[i]>arr[j]){
                arr1[i]++, arr2[i]++;
            }
        }
    }
    long long answer = 0;
    long long b = k*(k-1)/2%N;
    for(int i=0;i<n;i++){
        answer = (answer+k*arr1[i])%N;
        answer = (answer+b*arr2[i])%N;
    }
    printf("%lld", answer);
}

Measured memory_bytes: 128
// luogu-judger-enable-o2

//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<bits/stdc++.h>


#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
#pragma comment(linker, "/STACK:1024000000,1024000000");  
using namespace std;
int mod=1e9+7;
const int maxn=5008;
long long dp[maxn][maxn];int siz[maxn];
vector<int> v[maxn];int n;
long long g[maxn];long long st[maxn];
void dfs(int x,int p)
{
	siz[x]=1;dp[x][1]=1;
	for(int i=0;i<v[x].size();i++)
	{
		int t=v[x][i];if(t==p) continue;
		dfs(t,x);
		for(int j=siz[x];j>=0;--j)
		{
			st[j]=dp[x][j];dp[x][j]=0;
		}
		for(int j=siz[x];j>=0;--j)
		{
			for(int k=siz[t];k>=0;--k)
			{
				long long op=(long long)st[j]*(long long)dp[t][k]%(long long)mod;
				dp[x][j+k]+=op;
				dp[x][j+k]%=mod;
			}
		}siz[x]+=siz[t];
	}
	for(int j=0;j<=siz[x];j+=2)
	{
		dp[x][0]-=(int)(g[j]*(long long)dp[x][j]%(long long)mod);
		dp[x][0]%=mod;
	}
}
int main()
{
	cin>>n;
	g[0]=1;
	for(int i=2;i<=n+1;i+=2)
		g[i]=g[i-2]*(long long)(i-1)%(long long)mod;
	for(int i=1;i<n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		v[x].push_back(y);v[y].push_back(x);
	}
	dfs(1,0);
	cout<<(-dp[1][0]%mod+mod)%mod;
}

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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>

int main(){
	fast;
	int n,m;
	cin>>n>>m;
	map<int,int> mm;
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		for(int j=0;j<k;j++){
			int xx;
			cin>>xx;
			mm[xx]++;
		}
	}
	int ans=0;
	for(auto i:mm){
		if(i.second==n){
			ans+=1;
		}	
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)

if k == 1 && n == 1
  puts 'YES'
elsif k>=n
  puts 'NO'
else
  # 4 => 3
  # 5 => 4
  # 6 =>
  if n % 2 == 0
    if k > (n / 2)
      puts 'NO'
    else
      puts 'YES'
    end
  else
    if k > (n / 2) + 1
      puts 'NO'
    else
      puts 'YES'
    end
  end
end


Measured memory_bytes: 3836
x1, x2, x3, x4, x5 = map(int,input().split())
if (x1 == 0):
    print(1)
elif(x2 == 0):
    print(2)
elif(x3 == 0):
    print(3)
elif(x4 == 0):
    print(4)
elif(x5 == 0):
    print(5)


Measured memory_bytes: 9172
// Problem : 
// 			B - Splatter Painting
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Grand Contest 012
// URL : https://atcoder.jp/contests/agc012/tasks/agc012_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

int N, M, Q;
vector<int> graph[100005];
int vis[20][100005];
int nd[100005], d[100005], clr[100005];

void dfs(int n, int d, int c){
	if(vis[d][n]){
		return;
	}
	vis[d][n] = c;
	if(!d){
		return;
	}
	for(int e : graph[n]){
		dfs(e, d-1, c);
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N >> M;
	for(int i = 1; i<=M; i++){
		int a, b;
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	cin >> Q;
	for(int i = 1; i<=Q; i++){
		cin >> nd[i] >> d[i] >> clr[i];
	}
	for(int q = Q; q; q--){
		dfs(nd[q], d[q], q);
	}
	for(int i = 1; i<=N; i++){
		int mx = 0;
		for(int k = 0; k<=10; k++){
			mx = max(vis[k][i], mx);
		}
		cout << clr[mx] << "\n";
	}
}

Measured memory_bytes: 14520
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> K;
	int cnt = 7;
	int sum = 0;
	for (int i = 0; i < 100000000; i++) {
		sum += cnt;
		cnt *= 10;
		cnt %= K;
		sum %= K;
		if (sum == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 3612
for _ in range(4):
    a,b = map(int,input().split()) #標準入力
    if a == 1:print(b * 6000) #s席なら6000をかける
    if a == 2:print(b * 4000) #A席なら4000をかける
    if a == 3:print(b * 3000) #B席なら3000をかける
    if a == 4:print(b * 2000) #C席なら2000をかける


Measured memory_bytes: 5592
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	
	int n = read.to!int;
	int a = read.to!int - 1;
	int b = read.to!int - 1;
	int c = read.to!int - 1;
	int d = read.to!int - 1;
	
	bool[] s = readln.chomp.to!(char[]).map!(x => x == '#').array;
	
	string ans = "Yes";
	
	foreach(i; a + 1 .. d){
		if(s[i] && s[i + 1]) ans = "No";
	}
	
	if(c < d){
		ans.writeln;
		return;
	}
	
	bool f2 = 0;
	foreach(i; b - 1 .. d){
		if(! s[i] && ! s[i + 1] && ! s[i + 2]) f2 = 1;
	}
	
	if(! f2) ans = "No";
	
	ans.writeln;
	return;
}



/*

A<B<C<Dの場合

AからDまでに2連続の岩があれば×
それ以外は○

A<B<D<Cの場合

AからDまでに2連続の岩があれば×
BからDまでに3連続の土地がなければ×
それ以外は○


*/



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

int main(){
    int N;  cin >> N;
    vector<int> v(N);
    for(int i=0; i<N; i++)  cin >> v[i];
    int j = 1;
    int ans = 0;
    for(int i=0; i<N; i++){
        if(v[i] != j)   ans++;
        else    j++;
    }
    if(ans==N)  ans = -1;
    cout << ans;
}

Measured memory_bytes: 4048
//
//  main.cpp
//  abc专用
//
//  Created by 张伟 on 2018/9/23.
//  Copyright © 2018年 张恺. All rights reserved.
//

#include <iostream>
#include <stdio.h>
using namespace std;
int main(int argc, const char * argv[]) {
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int a[10000],b[10000];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int j=0;j<m;j++){
        cin>>b[j];
    }
    for(int z=-100;z<=100;z++){
    bool yn=false;
    if(x>=z){
        yn=true;
    }
    if(z>y){
        yn=true;
    }
        for(int i=0;i<n;i++){
            if(a[i]>=z){
                yn=true;
            }
        }
        for(int j=0;j<m;j++){
            if(b[j]<z){
                yn=true;
            }
        }
        if(yn==false){
            printf("No War");
            return 0;
        }
    }
    printf("War");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if (x1 == 0) {
    cout << 1 << endl;
  }
  if (x2 == 0) {
    cout << 2 << endl;
  }
  if (x3 == 0) {
    cout << 3 << endl;
  }
  if (x4 == 0) {
    cout << 4 << endl;
  }
  if (x5 == 0) {
    cout << 5 << endl;
  }
}

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

using namespace std;

const int MaxN = 205;
const int oo = 1e9;

int n, m;
int NodeCol[MaxN], NodeRow[MaxN];
vector<int> g[MaxN];
int c[MaxN][MaxN];
int S, T;
int f[MaxN][MaxN];
int dist[MaxN];
int id, cl[MaxN];
queue<int> q;

int BFS()
{
    for (int i = 1; i <= T; ++i)
    {
        dist[i] = oo;
    }
    q.push(S);
    dist[S] = 0;
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        for (auto &v : g[u])
        {
            if (dist[v] == oo && f[u][v] < c[u][v])
            {
                dist[v] = dist[u] + 1;
                q.push(v);
            }
        }
    }
    return (dist[T] < oo);
}

int FindPath(int u, int val)
{
    if (u == T)
    {
        return val;
    }
    if (cl[u] == id)
    {
        return 0;
    }
    cl[u] = id;
    for (auto &v : g[u])
    {
        if (cl[v] != id && dist[v] == dist[u] + 1)
        {
            if (c[u][v] > f[u][v])
            {
                if (int delta = FindPath(v, min(val, c[u][v] - f[u][v])))
                {
                    f[u][v] += delta;
                    f[v][u] -= delta;
                    return delta;
                }
            }
        }
    }
    return 0;
}

int MaxFlow()
{
    id = 0;
    int mf = 0;
    while (BFS())
    {
        int delta = 1;
        do
        {
            ++id;
            delta = FindPath(S, oo);
            mf += delta;
        } while (delta > 0);
    }
    return mf;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        NodeRow[i] = i;
    }
    for (int j = 1; j <= m; j++)
    {
        NodeCol[j] = n + j;
    }
    S = n + m + 1;
    T = n + m + 2;
    char ch;
    int xS, yS, xT, yT;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> ch;
            if (ch == 'o')
            {
                int u = NodeRow[i], v = NodeCol[j];
                g[u].push_back(v);
                g[v].push_back(u);
                c[u][v] = c[v][u] = 1;
            }
            if (ch == 'S')
            {
                xS = i, yS = j;
                int u = NodeRow[i], v = NodeCol[j];
                g[S].push_back(u);
                g[S].push_back(v);
                g[u].push_back(S);
                g[v].push_back(S);
                c[S][u] = oo;
                c[S][v] = oo;
            }
            if (ch == 'T')
            {
                xT = i, yT = j;
                int u = NodeRow[i], v = NodeCol[j];
                g[T].push_back(u);
                g[T].push_back(v);
                g[u].push_back(T);
                g[v].push_back(T);
                c[u][T] = oo;
                c[v][T] = oo;
            }
        }
    }
    if (xS == xT || yS == yT)
    {
        cout << -1;
        return 0;
    }
    cout << MaxFlow();
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define m_p make_pair
#define pb push_back 
#define ppb pop_back
#define f first
#define s second
#define pii pair<int,int>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define double long double
const double pi=3.14159265358979;
int lim=1e12;
const   int  mod=1e9+7;
int foobar=0;
//freopen("filename","r", stdin);
int takemod(int a,int mod){return ((a%mod)+mod)%mod;}
//int  bs(int  a[], int  l, int  r, int  x){if(r>=l){ int  mid=(l+r)/2;if(a[mid]==x)return mid;else if(a[mid]>x)return bs(a,l,mid-1,x); else return bs(a,mid+1,r,x);}return -1;}
int  power(int  b, int  p){if(p==0)return 1;else if(p%2==0){int q=power(b,p/2);return ((q)*(q));}else return ((b)*(power(b,p-1)));}
int  powerm(int  b, int  p){if(p==0)return 1;else if(p%2==0){int q=powerm(b,p/2);return ((q%mod)*(q%mod))%mod;}else return ((b%mod)*(powerm(b,p-1)%mod))%mod;}
bool isprime( int  n){if(n==1)return false;if(n==2 or n==3)return true; int  lim=sqrt(n); int  i=2;while(i<=lim){if(n%i==0)return false; i++;}return true;}
vector< int > factors( int  n){vector< int > a;a.pb(1); int  lim=sqrt(n),i=2;while(i<=lim){if(n%i==0){a.pb(i);if(i!=n/i)a.pb(n/i);}i++;}if(n!=1)a.pb(n);sort(a.begin(),a.end());return a;}
vector<pii> pf_with_count(int  b){ pii p;vector<pii>pf;int  count=0;while(b%2==0){b/=2;count++;}if(count>0){p.f=2;p.s=count;pf.pb(p);}int i=3;while(i<=sqrt(b)){count=0;while(b%i==0){b/=i;count++;}if(count>0){p.f=i;p.s=count;pf.pb(p);}i+=2;}if(b>2) {p.f=b;p.s=1;pf.pb(p);}return pf;}
int  bs_t_i(string s){int  l=strtoull(s.c_str(),NULL,2);return l;}
string  i_to_bs(int  n){string s = bitset< 4 >( n ).to_string();return s;}

signed main()
{
   ios;
  int n;
  cin>>n;
 double a[n];
 int i=0;
 while(i<n)
 {
  cin>>a[i];
  i++;
 }
 double sum=0;
 sort(a,a+n);
 sum=(a[0]+a[1])/2;
 i=2;
 while(i<n)
 {
   sum=(sum+a[i])/2;
   i++;
 }
 cout<<sum;


}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define el endl
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define sz size()
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define nn " " 
#define bg begin()
#define en end()
#define mod 1000000007
using namespace std;

vector<ll> dp[100];
ll knap(ll c,ll w[],ll v[],ll i)
{
    if(i-1<0)
       return 0;
    if(dp[i-1][c]!=-1)
        return dp[i-1][c];
    if(w[i-1]>c)
        dp[i-1][c]=knap(c,w,v,i-1);
    else
    {
        dp[i-1][c]=max(v[i-1]+knap(c-w[i-1],w,v,i-1),knap(c,w,v,i-1));
    }
    return dp[i-1][c];
    
}
int main()
{
    ll i,j;
    for(i=0;i<100;i++)
    {
        for(j=0;j<100001;j++)
            dp[i].pb(-1);
    }
    ll n,c;
    cin>>n>>c;
    ll w[n],v[n];
    for(i=0;i<n;i++)
        cin>>w[i]>>v[i];
    cout<<knap(c,w,v,n);
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  string s;
  cin >> s;
  int n=s.length();
  if(n%2){
    for(int i=n/2+1;i<n;i++){
      if(s[i]!=s[n/2]||s[n-i-1]!=s[n/2]){
        cout << i << endl;
        return 0;
      }
    }
    cout << n << endl;
  }else{
    for(int i=n/2;i<n;i++){
      if(s[i]!=s[n/2]||s[n-i-1]!=s[n/2]){
        cout << i << endl;
        return 0;
      }
    }
    cout << n << endl;
  }
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int dp[1 << 23], dpn[1 << 23];

int main(void){
  for(;;){
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0){return 0;}
    int b[n][m];
    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < m ; j++){
        char c;
        cin >> c;
        if (c == '1') { b[i][j] = 1; } else { b[i][j] = 0; }
      }
    }
    if(n < m){ /* nが小さい場合: 総当たりで行く */
      int use[m];
      int max = -1;
      for(int bi = 0 ; bi < (1 << n) ; bi++){
        int kind = 0;
        for(int j = 0 ; j < m ; j++){ use[j] = 0; }
        for(int i = 0 ; i < n ; i++){
          if((bi & (1 << i)) != 0){
            kind++;
            for(int j = 0 ; j < m ; j++){
              if(b[i][j] == 1){ use[j] = use[j] + 1 ; }
            }
          }
        }
        if(kind > max){
          bool ok = true;
          for(int j = 0 ; j < m ; j++){
            if(use[j] % 2 == 1){ok = false;}
          }
          if(ok){ max = kind; }
        }
      }
      cout << max << endl;
    }else{ /* mが小さい場合: 各材料が余っているか否かでbit-dp */
      for(int bj = 0 ; bj < (1 << m) ; bj++){
        dp[bj] = -1;
      }
      dp[0] = 0;
      for(int i = 0 ; i < n ; i++){
        int buse = 0;
        for(int j = 0 ; j < m ; j++){
          buse = buse * 2 + b[i][j];
        }
        for(int bj = 0 ; bj < (1 << m) ; bj++){
          dpn[bj] = dp[bj];
        }
        for(int bj = 0 ; bj < (1 << m) ; bj++){
          if(dp[bj] != -1 && dp[bj] + 1 > dp[bj ^ buse]){ dpn[bj ^ buse] = dp[bj] + 1; }
        }
        for(int bj = 0 ; bj < (1 << m) ; bj++){
          dp[bj] = dpn[bj];
        }
      }
      cout << dp[0] << endl;
    }
  }
}



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

int main(){
  int K, A, B;
  cin >> K >> A >> B;
  int fix = K;
  while (K < A){
    K += fix;
  }
  if (K <= B){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	int N; cin >> N;
	double A[101];
	for (int i = 0; i < N; ++i)cin >> A[i];
	double B[101];
	for (int i = 0; i < N; ++i) {
		B[i] = 1 / A[i];
	}
	double sum = 0;
	for (int i = 0; i < N; ++i) {
		sum += B[i];
	}
	cout << fixed << setprecision(15) << 1 / sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==1)
	{
		cout<<"Hello World"<<endl;
	}
	if(n==2)
	{
		int a,b;
		cin>>a>>b;
		cout<<a+b<<endl;
	}
 } 

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long

#define MOD 998244353
#define FACT_MAX 1000000

LL fact[FACT_MAX];

class Combinatrics{
private:
  long long mod = MOD;
  int fact_max = FACT_MAX;
public:
  Combinatrics(){
    fact[0]=1;
    for(int i=1;i<fact_max;i++)
      fact[i] = (fact[i-1]*i)%mod;
  }
  
  long long power(long long n, long long e){
    long long ret = 1;
    long long b = n;
    while(e){
      if(e%2!=0)
	ret*=b;
      ret%=mod;
      b*=b;
      b%=mod;
      e/=2;
    }
    return ret;
  }

  long long inv(long long n){
    return power(n,mod-2);
  }

  long long div(long long n1,long long n2){
    return n1*power(n2,mod-2)%mod;
  }
  
  long long nck(int n,int k){
    if(k>n || k<0) return 0;
    if(k==n || k==0) return 1;
    return (fact[n]*inv(fact[n-k])%mod)*inv(fact[k])%mod;
  }
};

#define BITN 300
int Rank(std::vector<std::bitset<BITN>> &a){
  int rnk=0;
  int n=a.size();
  int m=BITN;
  vector<int> where (m, -1);
  for (int col=0, row=0; col<m && row<n; ++col) {
    for (int i=row; i<n; ++i)
      if (a[i][col]) {
	swap (a[i], a[row]);
	break;
      }
    if (! a[row][col])
      continue;
    where[col] = row;

    for (int i=0; i<n; ++i)
      if (i != row && a[i][col])
	a[i] ^= a[row];
    ++row;
    rnk=row;
  }
  return rnk;
}

int main(){
  int n,m;
  cin>>n>>m;
  vector<bitset<300>> a(n);
  int tmp;
  REP(i,n){
    REP(j,m){
      cin>>tmp;
      a[i][j]=(tmp==1);
    }
  }
  int rnk = Rank(a);
  Combinatrics c;
  cout<<(MOD+c.power(2LL,(LL)(n+m-1))-c.power(2LL,(LL)(n+m-rnk-1)))%MOD<<endl;
  return 0;
}


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

int main(){
  int N,Y;
  cin >> N >> Y;
  bool a=false;
  for(int i=0;i<N+1;i++){
    for(int j=0;j<N+1;j++){
      if(10000*i+5000*j+1000*(N-i-j)==Y && (N-i-j)>=0){
        cout << i << " " << j << " " << N-i-j << endl;
        a=true;
        break;
      }
    }
    if(a){
      break;
    }
  }
  if(!a){
    cout << -1 << " " << -1 << " " << -1 << " " << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int n,a,b;
  cin>>n>>a>>b;
 
	
    if(a%n==0 || b%n==0)
     cout<<"OK\n";
    else
    {
    	
      if(b/n - a/n >0)
           cout<<"OK\n";
      else
          cout<<"NG\n";
	}
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    string s;
    cin >> s;
    bool good = s[2] == s[3] && s[4] == s[5];
    cout << (good ? "Yes" : "No");
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int n, w;
int weight[105] = {}, value[105] = {};

int dp[105][10005] = {};

int main(){
    ull a,b,k;
    set<ull> s;

    cin>>a>>b>>k;
    for(ull i=a; i<a+k; i++){
        if(i <= b) s.insert(i);
    }
    for(ull i=b; i>b-k; i--){
        if(i >= a) s.insert(i);
    }

    for(auto x : s){
        cout<< x <<endl;
    }

    
}

Measured memory_bytes: 256
#include <stdio.h>

#define NMAX 30
#define NMAX_PRIME1000 169

int comp_int(const void *a, const void *b);
int make_prime1000(int *prime1000);
int check_prime(int target, int nprime1000, int *prime1000);

int main(){
   int i, j;
   int num_in, input[NMAX], max_input, output[NMAX];
   int nprime1000=0, prime1000[NMAX_PRIME1000];
   nprime1000=make_prime1000(prime1000);
   num_in=0; max_input=0;
   while(scanf("%d",input+num_in)==1){
      if(input[num_in]>max_input) max_input=input[num_in];
      output[num_in]=0;
      ++num_in;
   }
   for(i=2;i<=max_input;i++){
      if(check_prime(i,nprime1000,prime1000)==0){
         for(j=0;j<num_in;j++){
            if(input[j]>=i) output[j]+=1;
         }
      }
   }
   for(j=0;j<num_in;j++) printf("%d\n",output[j]);
   return 0;
}

int make_prime1000(int *prime1000){
   int i, j, tmp, nprime1000, check[1000];
   for(i=2;i<1000;i++) check[i]=0;
   for(i=2;i<1000;i++){
      if(check[i]!=0) continue;
      for(j=2;j<500;j++){
         tmp=i*j;
         if(tmp>=1000) break;
         check[tmp]=1;
      }
   }
   nprime1000=0;
   for(i=2;i<1000;i++){
      if(check[i]==0){
         prime1000[nprime1000]=i;
         ++nprime1000;
      }
   }
   return nprime1000;
}

int check_prime(int target, int nprime1000, int *prime1000){
   int i;
   for(i=0;i<nprime1000;i++){
      if(prime1000[i]>=target) break;
      if(target%prime1000[i]==0) goto non_prime;
   }
   return 0;
non_prime:
   return 1;
}

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


auto solve() {
    int N, K;
    cin >> N >> K;
    vi h(N);
    for (auto &&e: h) cin >> e;

    const ll LINF = 1ll << 60;
    vll dp(N, LINF);
    dp[0] = 0;
    REP(i, N) {
        FOR(j, 1, K + 1) {
            if (i - j >= 0)
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    return dp[N - 1];
}


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

    cout << solve() << endl;
//    solve();

    return 0;
}


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

using namespace std;
int main()

{
    int n;
    cin>>n;
    float sum=0;

    for(int i=1;i<=n;i++){
        if(i%2==1){
            sum++;
        }
    }
    static_cast<float>(sum);
    cout<<sum/n<<endl;

return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<bool>	vb;



void solve(){
    ll h,w,counter;
    cin >> h >> w >> counter;
    ll grid[h][w];
    ll tot = 0;
    rep(i,0,h){
        rep(j,0,w){
            char c;
            cin >> c;
            if(c == '.') grid[i][j] = 0;
            else grid[i][j] = 1;
            
            if(grid[i][j] == 1) tot++;

        }
    }
    ll ans = 0;
    ll h1 = 1,w1 = 1;
    rep(i,0,h) h1 *= 2;
    rep(i,0,w) w1 *= 2;
    vector<vb> vis;
    rep(i,0,h1){
        rep(j,0,w1){
            vis = vector<vector<bool>>(h,vector<bool> (w,false)); 
            ll p = 0,temp = 0;
            while(p <= 6){
                if(((i >> p) & 1)){
                    rep(k,0,w){
                        if(!vis[p][k] && grid[p][k] == 1){
                            vis[p][k] = true;
                            temp++;
                        }
                    }
                }
                p++;
            }
            p = 0;
            while(p <= 6){
                if(((j >> p) & 1)){
                    rep(k,0,h){
                        if(!vis[k][p] && grid[k][p] == 1){
                            vis[k][p] = true;
                            temp++;
                        }
                    }
                }
                p++;
            }
            if((tot - temp) == counter) ans++;

        }
    }
    cout << ans;
}

int main(){
	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}

}

Measured memory_bytes: 3600
from collections import defaultdict
import sys
input = lambda: sys.stdin.readline().rstrip()

M = 998244353
B = pow(10, 18, M)
N = int(input())

def geometric_mod(a, r, m, n):
  x = a
  for i in range(n):
    yield x
    x = (x*r)%m

BB = list(geometric_mod(1, B, M, N+2))

def ext_euc(a, b):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, b
  while z1 != 1:
    d, m = divmod(z2,z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1, y1

def inv_mod(a, b, m):
  x, y = ext_euc(a, m)
  return (x * b % m)

def mex(s):
  for i in range(N+1):
    if i not in s:
      return i

def calc_grundy(e):
  g = {}
  sum_g = defaultdict(int)
  sum_g[0] = inv_mod(B-1, pow(B, N+1, M)-B, M)
  for i in range(N, 0, -1):
    if i not in e:
      continue
    m = mex({g.get(j, 0) for j in set(e[i])})
    if m:
      g[i] = m
      sum_g[g[i]] = (sum_g[g[i]] + BB[i]) % M
      sum_g[0]  = (sum_g[0] - BB[i]) % M

  return sum_g

def read_edge():
  M = int(input())
  e = defaultdict(list)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].append(b)
  return e

def solve(N, edge):
  sum_g = list(map(calc_grundy, edge))
  ret = 0
  for gx, sx in sum_g[0].items():
    for gy, sy in sum_g[1].items():
      gz = gx^gy
      sz = sum_g[2][gz]
      if sz:
        ret = (ret + sx*sy*sz) % M
  return ret


edge = [read_edge() for i in range(3)]

print(solve(N, edge))

Measured memory_bytes: 65276
n, m = map(int, input().split())
routes = [[] for i in range(n+1)]
flag = False
for i in range(m):
  a, b = map(int, input().split())
  routes[a].append(b)
  routes[b].append(a)

for i in routes[1]:
  if n in routes[i]:
    flag = True

if flag:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 38320
class BinTree():
    def __init__(self):
        self.parent = -1
        self.left, self.right = -1, -1
        self.sib = -1
        self.dep, self.deg, self.h = 0, 0, 0
        self.state = "internal node"

    def set_node(self, nid, l, r):
        global root
        root -= {l, r}
        self.left, self.right = l, r
        self.deg = (l != -1) + (r != -1)
        if l != -1:
            left = trees[l]
            left.parent = nid
            left.sib = r
        if r != -1:
            right = trees[r]
            right.parent = nid
            right.sib = l

    def set_param(self):
        if self.parent != -1:
            self.dep = trees[self.parent].dep + 1
        if self.deg == 0:
            self.state = "leaf"
        if self.left != -1:
            left = trees[self.left]
            left.set_param()
            self.h = left.h + 1
        if self.right != -1:
            right = trees[self.right]
            right.set_param()
            if self.h <= right.h:
                self.h = right.h + 1
        if self.parent == -1:
            self.state = "root"

    def echo(self, nid):
        print('node {}: parent = {}'.format(nid, self.parent),
              'sibling = {}'.format(self.sib),
              'degree = {}'.format(self.deg),
              'depth = {}'.format(self.dep),
              'height = {}'.format(self.h),
              self.state, sep=', ')

n = int(input())
trees = [BinTree() for _ in range(n)]
root = set(range(n))
for _ in range(n):
    inp = list(map(int, input().split()))
    trees[inp[0]].set_node(*inp)
root = root.pop()
trees[root].set_param()
for i, tree in enumerate(trees):
    tree.echo(i)

Measured memory_bytes: 7860
#include <iostream>

using namespace std;

int main (){
  int health, n, sum = 0;
  cin >> health >> n;
  for (int i = 0; i < n; i++){
    int k;
    cin >> k;
    sum += k;
  }
  if (sum >= health){
    cout << "Yes\n";
  }
  else{
    cout << "No\n";
  }
  

}

Measured memory_bytes: 256
<?php
  $n = trim(fgets(STDIN));
  $s = trim(fgets(STDIN));
  $count = 0;
  for($i=1; $i<strlen($s)-1; $i++){
    if ($s[$i-1] == "A" && 
        $s[$i] == "B" && 
        $s[$i+1] == "C"){
      $count++;
    }
  }
  echo $count."\n";
  ?>

Measured memory_bytes: 4604
#include "bits/stdc++.h"
using namespace std;

int MOD = 1000000007;
static long long F[200010] = {}, RF[200010] = {};

long long Calc(int a, int b) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		long long x = Calc(a, b / 2);
		return (x * x) % MOD;
	}
	return (a * Calc(a, b - 1)) % MOD;
}

long long Comb(int a, int b) {
	long long x = F[a];
	x *= RF[b];
	x = x % MOD;
	x *= RF[a - b];
	return x % MOD;
}

int main() {
	int H, W, A, B;
	long long ans = 0;
	cin >> H >> W >> A >> B;
	F[0] = 1, RF[0] = 1;
	for (int i = 1; i <= H + W - 2; i++) {
		F[i] = (F[i - 1] * i) % MOD;
		RF[i] = (RF[i - 1] * Calc(i, MOD - 2)) % MOD;
	}
	for (int i = B; i < W; i++) {
		long long count = 1;
		count *= Comb(H - A - 1 + i, i);
		count = count % MOD;
		count *= Comb(W + A - 2 - i, A - 1);
		count = count % MOD;
		ans += count;
		ans = ans % MOD;
	}
	cout << ans;
}

Measured memory_bytes: 3328
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let s = read::<String>();

  let mut idx = s.len() - 1;
  while 0 < idx {
    let s_str = &s[0..idx];
    if s_str.len() % 2 == 0 {
      if &s[0..(idx / 2)] == &s[(idx / 2)..idx] {
        println!("{}", s_str.len());
        break;
      }
    }
    idx -= 1;
  }
}


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

long long n , a , b;

int main(){
	scanf("%lld %lld %lld" , &n , &a , &b);
	long long c = n / (a + b); n -= c * (a + b);
	printf("%lld" , c * a + min(n , a));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#define MAX 500

using namespace std;

int compute( int h[] , int n ){

  stack < pair<int,int> > st;
  h[n] = 0;
  
  int cmax = 0;
  for( int i = 0 ; i <= n ; i++ ){
    if( st.empty() || st.top().second < h[i] ){
      st.push( make_pair( i , h[i]) );
    }
    else if( st.top().second > h[i] ){
      int iback,jback;
      do{
	iback = st.top().first;
	jback = st.top().second;
	cmax = max( cmax , (i - iback) * jback ); 
	st.pop();
      }while( !st.empty() && st.top().second > h[i] );
      
      st.push( make_pair( iback , h[i] ) );
    }
  }
  return cmax;
}

int main(void){
  
  int h,w;
  char c[MAX][MAX];
  int C[MAX][MAX];

  while( cin >> h >> w , h || w ){
 
    for( int i = 0 ; i < h ; i++ ){
      for( int j = 0 ; j < w ; j++ ){
	cin >> c[i][j]; // 読み込み
      }
    }
    // ここから'*'だったら0,'.'なら1を入れる
    for( int j = 0 ; j < w ; j++ ){
      if( c[0][j] == '.' ) C[0][j] = 1;
      else C[0][j] = 0;
    }
    // ここから'*'だったら0,'.'ならその行の上の数+1を行う
    // すなわち、縦の長さがわかる
    for( int i = 1 ; i < h ; i++ ){
      for( int j = 0 ; j < w ; j++ ){
	if( c[i][j] == '*' ) C[i][j] = 0;
	else C[i][j] = C[i - 1][j] + 1;
      }
    }

    int ans = 0; 
    for( int i = 0 ; i < h ; i++ ){
      ans = max( ans , compute( C[i] , w ) );
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2416
import java.io.*;
import java.util.*;

public class Main {
  private static String solve(int n, int l, String[] ss) {
    Arrays.sort(ss);
    StringBuffer sb = new StringBuffer();
    for (String s : ss) {
      sb.append(s);
    }
    return sb.toString();
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int l = reader.nextInt();
    String[] ss = reader.next(n);
    out.println(solve(n, l, ss));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

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

int N, d[100001];

int main(){
    cin >> N;
    for(int i=0;i<N;i++)    cin >> d[i];

    sort(d, d+N);
    cout << d[N/2] - d[N/2-1] << endl;
}

Measured memory_bytes: 640