akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double EPS = 1e-9;
int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0 ,1, 1, 1, 0, -1, -1, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int sumMod(int a, int b){return 0LL + a + b > mod ? a + b - mod : a + b;}
int n;
double v[3010];
double dp[2][3010];
double f(int i, int tail){
    if(i == n){
        return 1;
    }
    double &ans = dp[i][tail];
    if(ans < 0){
        ans = 0;
        int head = n - tail;
        if(head > tail + 1)
            ans += f(i + 1, tail + 1) * (1.0 - v[i]);
    
        ans += f(i + 1, tail) * v[i];
    }
    return ans;
}
int main(){
    //FL;
    FIN;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> v[i];
    for(int i = n; i >= 0; i--){
        for(int tail = n - 1; tail >= 0; tail--){
            double &ans = dp[i & 1][tail];    
            if(i == n){
                ans = 1;
                continue;
            }
            ans = 0;
            ans += dp[(i + 1) & 1][tail] * v[i];
            int head = n - tail;
            if(head > tail + 1)
                ans += dp[1 & (i + 1)][tail + 1] * (1.0 - v[i]);
        }
    }
    
    cout << fixed << setprecision(9) << dp[0 & 1][0] << '\n';
    EjecuteTime;
    return 0;
}       

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

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


int main() {

int a,b,c;
cin >> a >> b >>c;

int num = 100*a + 10 *b +c;
if(num%4==0)cout << "YES" << endl;
else cout << "NO" << endl;
 
return 0;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

var (
	n, a, b, c int
	l          []int
)

const (
	A = iota
	B
	C
	D
)

func minTwo(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min(a ...int) int {
	if len(a) == 0 {
		return 0
	}
	if len(a) == 1 {
		return a[0]
	}
	result := a[0]
	for i := 1; i < len(a); i++ {
		result = minTwo(result, a[i])
	}
	return result
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func dfs(selects []int) int {
	if len(selects) == n {
		var mp int
		var sa, sb, sc int
		for i := 0; i < n; i++ {
			switch selects[i] {
			case A:
				if sa > 0 {
					mp += 10
				}
				sa += l[i]
			case B:
				if sb > 0 {
					mp += 10
				}
				sb += l[i]
			case C:
				if sc > 0 {
					mp += 10
				}
				sc += l[i]
			}
		}
		if sa == 0 || sb == 0 || sc == 0 {
			return 100000000
		}
		return abs(sa-a) + abs(sb-b) + abs(sc-c) + mp
	}
	return min(
		dfs(append(selects, A)),
		dfs(append(selects, B)),
		dfs(append(selects, C)),
		dfs(append(selects, D)),
	)
}

func main() {
	fmt.Scan(&n, &a, &b, &c)

	l = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&l[i])
	}

	fmt.Println(dfs(nil))
}


Measured memory_bytes: 512
n = int(input())
v = list(map(int, input().split()))

v = sorted(v)
# print(v)
while len(v) != 1:
    a = v.pop(0)
    b = v.pop(0)
    avg = (a+b)/2
    # print(a, b, avg)
    v.append(avg)
    v = sorted(v)

print(v[0])


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

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

long long int kaizyo(long long int hh){
    ll cmp=1;
    while(hh>1){
       cmp=(cmp*hh)%MOD;
        hh--;
    }
    return cmp;
}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a[10000000],b,c,cmpp=0,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

      cin>>n>>m;
      pos=kaizyo(n)%MOD;
      cmpp=kaizyo(m)%MOD;
      if(Abs(n,m)!=1&&Abs(n,m)!=0){
          Cout("0");
      }
      else{
          if(Abs(n,m)==1){
              Cout(pos*cmpp%MOD);
          }
          else{
              Cout(2*pos*cmpp%MOD);
          }
      }
return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>

using namespace std;
typedef long long ll;
#define MP make_pair

int main(void) {
    double l,tmp,ans;
    cin>>l;
    tmp=l/3;
    ans=pow(tmp,3);

    printf("%.6f\n",ans);

    
    
    return 0;
}

Measured memory_bytes: 256
io = STDIN
N=io.gets.to_i
ar=N.times.map{io.gets.chomp.split(//).sort.join}.sort
num= ar.chunk_while{|a,b|a==b}.map{|ar|ar.size}.select{|i|i>1}
def c(n)
  n*(n-1)/2
end
p num.inject(0){|s,i|s+c(i)}


Measured memory_bytes: 28904
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 505000;
char s[N];int n,f[27][N],jmp[20][N];
int main() {
	scanf("%s",s+1);n=strlen(s+1);
	per(j,n,1){
		f[s[j]-'a'][j]=j+1;
		rep(i,s[j]-'a'+1,26)f[i][j]=f[i-1][f[i-1][j]];
		rep(i,0,s[j]-'a'-1)f[i][j]=f[i][f[26][j]];
	}
	rep(i,1,n+1)jmp[0][i]=f[26][i];
	rep(j,1,19)rep(i,1,n+1)jmp[j][i]=jmp[j-1][jmp[j-1][i]];
	int q;read(q);while(q--){
		int l,r;read(l);read(r);
		per(i,19,0)if(jmp[i][l]&&jmp[i][l]-1<=r)l=jmp[i][l];
		printf("%s\n",l==r+1?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 93824
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();

            int p = s[0];
            int q = s[1];
            int r = s[2];

            WriteLine(
                p+q+r - Max(Max(p, q), r)
                );
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<map>
#include<string>
using namespace std;
int n, k;
string x[128];
map<string, bool> memo;
void solve(int cnt, string s, bool used[]){
  if(cnt == k){
    memo[s] = true;
    return;
  }
  for(int i = 0;i < n; i++){
    if(!used[i]){
      used[i] = true;
      solve(cnt + 1, s + x[i], used);
      used[i] = false;
    }
  }
}
int main(void){
  for( ; ; ){
    bool used[128] = {false};
    cin >> n >> k;
    if(!(n + k)) break;
    memo.clear();
    for(int i = 0;i < n; i++) cin >> x[i];
    solve(0, "", used);
    cout << memo.size() << endl;
  }
}


Measured memory_bytes: 1504
n, q = map(int, input().split())
ki = [[] for i in range(n)]
for i in range(n-1):
  a, b = map(int, input().split())
  a-=1
  b-=1
  ki[a].append(b)
  ki[b].append(a)
  
ans=[0]*n
vis=[False]*n

for i in range(q):
  p, x = map(int, input().split())
  p-=1
  ans[p]+=x

import queue
q = queue.Queue()
q.put(0)

while not q.empty():
  temp = q.get()
  vis[temp]=True
  for next in ki[temp]:
    if not vis[next]:
      ans[next]+=ans[temp]
      q.put(next)
ans = list(map(str, ans))
print(" ".join(ans))
    

Measured memory_bytes: 139412
/*Q-3---ATCODER-BEGINNER-#ROUND_177

*/

#include <bits/stdc++.h>
#define M 1000000007
#define endl '\n'
#define ll long long
using namespace std;

ll mod(ll x){ return ((x%M + M)%M);}
ll add(ll a,ll b){ return mod(mod(a)+mod(b));}
ll mul(ll a,ll b){ return mod(mod(a)*mod(b));}
ll sub(ll a,ll b){ return mod(mod(a)-mod(b));}
ll divide(ll a,ll b){ return mod(mod(a)/mod(b));}

ll findProductSum(ll arr[],ll n){ 
    ll sum{0};
    for(ll i=0;i<n;i++)
        sum=add(sum,arr[i]);

    ll ans{0};
    for(ll i=0;i<n-1;i++){
        sum=sub(sum,arr[i]);
        ans=add(ans,mul(arr[i],sum));
    }

    return ans;
} 

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll n{0};
	cin>>n;

	ll arr[n];
	for(ll i=0;i<n;i++)
		cin>>arr[i];

	cout<<(findProductSum(arr,n)%M)<<endl;

	return 0;
}



Measured memory_bytes: 5224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> a(4);
  for(int i =0;i<6;i++){
    int m;
    cin >>m;
    a.at(m-1)++;
  }
  int cnt =0;
  for(int i=0;i<4;i++){
    if( a.at(i)==2){
      cnt ++;
    }
  }
  cout << ( cnt ==2 ? "YES":"NO");
      
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll MOD = 1e9+7;
const ll N = 1e7+10;
ll f[N], rf[N];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(int i = 1; i < N; i++) f[i] = (f[i - 1] * i) % MOD;
    rf[N - 1] = inv(f[N - 1]);
    for(int i = N-2; i >= 0; i--) rf[i] = (rf[i + 1] * (i + 1)) % MOD;
}
ll C(int n, int k) {
    if(k < 0 || n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!^(-1)
    ll c = rf[k]; // = k!^(-1)
    ll bc = (b * c) % MOD;
    return (a * bc) % MOD;
}
ll p(int n, int k) {
    if (k < 0 || n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n - k]; // = (n-k)!^(-1)
    return (a * b) % MOD;
}
ll H(int n, int k) {
    if (n == 0 && k == 0) return 1;
    return C(n + k - 1, k);
}
ll mod_pow(ll x, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n & 1)
        {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

int main()
{
    init();
    int s;
    cin >> s;
    ll ans = 0;
    for(int i = 1; i <= 700; i++)
    {
        int num = 3 * i;
        if(num > s) break;
        int d = s - num;
        ll m = H(i, d);
        ans = (ans + m) % MOD;
    }
    cout << (ans+MOD)%MOD << endl;
}



Measured memory_bytes: 159880
l = input().split()
W = int(l[0])
H = int(l[1])
x = int(l[2])
y = int(l[3])
r = int(l[4])

if x-r<0:
    print('No')
elif y-r<0:
    print('No')
elif x+r>W:
    print('No')
elif y+r>H:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 5596
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for moe in range(a+1):
    for ray in range(b+1):
        for rei in range(c+1):
            sum= 500*moe + 100*ray + 50*rei
            if sum == x:
                ans +=1
print(ans)

Measured memory_bytes: 3060
while 1:
  input_a , op , input_b = map( str , raw_input().split() )
  a = int( input_a )
  b = int( input_b )
  if op == '+':
      print a + b
  elif op == '-':
      print a - b
  elif op == '*':
      print a * b
  elif op == '/':
      print a / b
  else:
      break

Measured memory_bytes: 6360
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;
int a[maxn],n,m,opt,x,y,tpp,z,val[maxn],kl,head[maxn],ind[maxn],sg[maxn];
struct line{int to,next,val;}q[maxn*2];
void pushline(int f,int t){ind[f]++,q[++kl].next=head[f];head[f]=kl;q[kl].to=t;q[kl].val=z;}
void dfs(int x,int fa)
{
	for(int p=head[x];int v=q[p].to;p=q[p].next)
	{
		if(v==fa)continue;
		dfs(v,x);
		sg[x]^=sg[v]+1;
	//	cout<<x<<" "<<sg[x]<<" "<<sg[v]<<endl;
		
	}
	//cout<<"fin"<<x<<" "<<sg[x]<<endl;
}
signed main()
{
	
	cin>>n;
	for(int i=1;i<n;i++){scanf("%d%d",&x,&y);pushline(x,y);pushline(y,x);}
	dfs(1,0);
	if(sg[1])cout<<"Alice";
	else cout<<"Bob";
	
	
}

Measured memory_bytes: 14924
n = int(input())
txy = [[int(i) for i in input().split()] for i in range(n)] 
txy.append([0,0,0])
txy.sort(key=lambda x:x[0])
ispossible="Yes"
for i in range(0,n):
    k = abs(txy[i+1][1]-txy[i][1])+abs(txy[i+1][2]-txy[i][2])
    if (k-txy[i+1][0]+txy[i][0])%2 or k>txy[i+1][0]-txy[i][0]:
        ispossible="No"
print(ispossible)


Measured memory_bytes: 21924
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
LL Q, H, S, D, n;
int main(){
	scanf("%lld%lld%lld%lld%lld", &Q, &H, &S, &D, &n);
	LL x1 = min(Q * 8, min(H * 4, min(S * 2, D))), x2 = min(Q * 4, min(H * 2, S));
	printf("%lld\n", x1 * (n >> 1) + x2 * (n & 1));
}

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

int A[3][3];
bool a[3][3];
bool bingo(){
    return
      (a[0][0] && a[0][1] && a[0][2]) ||
      (a[1][0] && a[1][1] && a[1][2]) ||
      (a[2][0] && a[2][1] && a[2][2]) ||
      
      (a[0][0] && a[1][0] && a[2][0]) ||
      (a[0][1] && a[1][1] && a[2][1]) ||
      (a[0][2] && a[1][2] && a[2][2]) ||
      
      (a[0][0] && a[1][1] && a[2][2]) ||
      (a[2][0] && a[1][1] && a[0][2]);
}

int main() 
{
  for(int i=0; i<3; i++) {
    for(int j=0; j<3; j++) {
      cin >> A[i][j];
    }
  }
  int n; cin >> n;
  int b;
  for (int i=0; i<n; i++) {
    cin >> b;
    for(int p=0; p<3; p++) {
      for(int q=0; q<3; q++) {
        if (A[p][q] == b) a[p][q] = true;
      }
    }
  }
  if (bingo()) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<int, ll> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 2e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

int n;
ll a, d;
vector<PLL> mon;
ll c[MAX_N];

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

    cin >> n >> d >> a;
    mon.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> mon[i].first >> mon[i].second;
    }

    sort(mon.begin(), mon.end());

    int i = 0;
    int j = 0;
    ll ans = 0LL;

    while (i < n) {
        while (j < n && mon[j].first <= mon[i].first+2*d) j++;
        ll need = max((mon[i].second- c[i]*a + a - 1) / a, 0LL);
        ans += need;
        c[i] += need;
        c[j] -= need;
        c[i+1] += c[i];
        i++;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1e9;
const long double EPS = 1e-10;

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

  vector<int> a(n, INF);
  if (s == INF) {
    rep(i, n) a[i] = 1;
  }
  rep(i, k) a[i] = s;

  rep(i, n) {
    if (i) cout << " ";
    cout << a[i];
  }
  cout << endl;




  
  return 0;
}

Measured memory_bytes: 1664
def main():
    string = input().split()
    island = int(string[0])
    dispute_num = int(string[1])
    disputes = []
    for i in range(dispute_num):
        string = input().split()
        disputes.append([int(string[0]), int(string[1])])
    disputes.sort()

    cut_count = 1
    left_cut = disputes[0][0]
    right_cut = disputes[0][1]
    for i in range(1, dispute_num):
        left = disputes[i][0]
        right = disputes[i][1]
        if( right_cut > left):
            left_cut = left
            if(right_cut > right):
                right_cut = right
        else:
            cut_count += 1
            right_cut = right
            left_cut = left

    print(cut_count)


if __name__ == "__main__":
    main()

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

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

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N;
  cin >> N;
  ll A[N+1], B[N];
  rep(i, N+1) cin >> A[i];
  rep(i, N) cin >> B[i];

  ll ans = 0;
  rep(i, N){
    ll kill = min(A[i], B[i]);
    A[i] -= kill;
    if(B[i] - kill > A[i+1]){
      kill += A[i+1];
      A[i+1] = 0;
    }
    else if(B[i] - kill > 0){
      A[i+1] -= B[i] - kill;
      kill = B[i];
    }
    ans += kill;
    // debug(A);
    // cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


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

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

if(S=="Sunny"){
  cout << "Cloudy" << endl;
}
else if(S=="Cloudy"){
  cout << "Rainy" << endl;
}
else{
  cout << "Sunny" << endl;
}
  
}

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

typedef long long int ll;

ll powk(ll a, ll n = 2){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}


int main()
{
    ll n;
    string c;
    cin >> n >> c;
    string bc = c;
    sort(c.begin(), c.end());

    ll ans = 0;
    for(ll i = 0;i < (ll)c.size();i++){
        if(bc[i] != c[i]){
            ans++;
        }
    }

    if(ans % 2 == 0){
        ans /= 2;
    }
    else{
        ans /= 2;
        ans++;
    }

    cout << ans;

    return 0;
}


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

int main(){
	int n,i;
	int a[100];
	
	cin>>n;
	
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=n-1;i>=0;i--){
		if(i!=n-1){
			cout<<" ";
		}
		cout<<a[i];
	}
	cout<<endl;
	return 0;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code

int main()
{
  int x = 0;
  int n;
  cin>>n;
  int ans = 0;
  string s;
  cin>>s;
  for(char a: s){
    if(a == 'I'){
      x++;
    }
    else x--;
    ans = max(ans, x);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int n,t;
  cin >> n >> t;
  vector<int> c(n);
  vector<int> Time(n);
  
  for(int i = 0;i < n;i++){
    cin >> c.at(i) >> Time.at(i);
  }
  int min = 1001; int cost = 0;
  for(int i = 0;i < n;i++){
    if(t >= Time.at(i)){
      cost = c.at(i);
      if(min > cost){
        min = cost;
      }
    }
  }
  if(min == 1001){
    cout << "TLE" << endl;
  }else{
    cout << min << endl;
  }
  
  return 0;
}

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

#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    int A, B;
    string ans;
    cin >> A >> B;
    
    if (A == 1) A = 14;
    if (B == 1) B = 14;

    if (A == B) ans = "Draw";
    else if (A > B) ans = "Alice";
    else ans = "Bob";

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;

using namespace std;

int main()
{
	int a,b;
	string s;
	bool f=true;
	int ans=0;
	
	cin>>a>>b;
	cin>>s;
	if(s[a]=='-'){
		for(int i=0;i<a+b+1;i++)
		{
			if(i!=a)
			{
				if(s[i]=='-')
				{
					f=false;
				}
			}
		}
	}else{
		f=false;
	}
	if(f==true)
	{
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
A = sorted(A)
Acount = 0
j = 0

Point = []

for i in range(N):

    while j != len(A):
        if A[j] == i + 1:
            Acount += 1
            j +=1
        else:
            break

    Point.append(K - Q + Acount)

    Acount = 0

    if Point[i] > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 11856
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 n,a,b;
  cin >> n >> a >> b;
  in6 ans = n/(a+b)*a;
  in6 check = n % (a+b);
  if(check >= a) ans += a;
  else ans += check;
  cout << ans;
  hinata;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;

/*
a_iの中で最大の値と、その半分に最も近い値を選べばよい。
*/
int n;
int a[100000];
int m, h;

int ab(int i) { if (i < 0) { return -i; } return i; }

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	m = 0;
	for (int i = 0; i < n; i++) {
		if (m < a[i]) { 
			m = a[i]; 
		}
	}
	h = -100;
	for (int i = 0; i < n; i++) {
		if (ab(m - h * 2) > ab(m - a[i] * 2) && m != a[i]) {
			h = a[i];
		}
	}
	printf("%d %d\n", m, h);

}

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

int main() {
  int A,B;
  cin >> A >> B;
  int total = 0;
  for(int i = A; i < B + 1; i++) {
    if(i % 10 == i / 10000 && i / 10 % 10 == i / 1000 % 10) {
      total += 1;
    }
    else {
      continue;
    }
  }
  cout << total << endl;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector <int> l;
    int tmp;
    rep(i, n){
        cin >> tmp;
        l.emplace_back(tmp);
    }
    sort(l.begin(), l.end(), greater<int>());
    int sum = 0;
    rep(i, k){
        sum+= l[i];
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);;
    cin.tie(0);
    cout.tie(0); 
ll n,m;
cin>>n>>m;
ll flag=0;
map<ll,ll> d,in;
for (int i = 0; i<m; ++i)
{
    ll s,c; 
    cin>>s>>c;
    if(in.find(s)==in.end())
    in[s]=c; 
else 
{
    if(in[s]!=c) 
        flag=1;
}

}
if(flag==1) 
{
    cout<<-1<<"\n";
    return 0;
}
string s="";
if(n==1) 
{
    if(in.find(1)==in.end())
    {
        cout<<0;
    }
    else 
        cout<<in[1];
    return 0;
}
for (int i = 1; i<=n; ++i)
{
    if(i==1) 
    {
      if(in.find(1)!=in.end()) 
      {
        if(in[1]==0) 
        {
            cout<<-1; 
            return 0;
        } 
        else 
            cout<<in[1];
      }
      else 
        cout<<1;
    continue;
    }
    if(in.find(i)==in.end()) 
    {
        cout<<0;
    }
    else 
        cout<<in[i];
}
return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

using namespace std;

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


int main(){
	
	int n;
	cin>>n;
	
	if(n==0)printf("%d\n",1);
	if(n==1)printf("%d\n",2);
	if(n==2)printf("%d\n",1);
	if(n>=3)printf("%d\n",0);
}

Measured memory_bytes: 1148
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
	double a, b, p, q, r, road, ans = 0;
	cin >> a >> b >> p >> q >> r;
	road = p * b;
	road -= (b - a) * q;
	ans += road / (q + r);
	cout << ans + b << endl;
	return 0;
}


Measured memory_bytes: 3280
#include<bits/stdc++.h>
#define x first
#define y second
#pragma GCC optimize(2)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3","sse2","sse")
#pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC diagnostic error "-std=c++14"
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;
typedef pair<char,char> PCC;
typedef long long LL;
const int N=8005;
const int M=1e6;
const int INF=0x3f3f3f3f;
const int MOD=1000000007;
int n,m;
int cnt1[26],cnt2[26];
int main()
{
    IOS;
    int a,b,c,d;
    while(cin>>a>>b>>c>>d){
        LL ans=0;
        if(a>=d) cout<<d<<endl;
        else{
            if(a+b>=d) cout<<a<<endl;
            else{
                LL f=d-(a+b);
                cout<<a-f<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3644
#include<cstdio>
#define maxn 100010
int val[maxn]; 
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&val[i]);
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(i!=n&&val[i]==i&&val[i+1]==i+1){
			cnt++;i++;
		}
		else if(val[i]==i)cnt++;
	}
	printf("%d",cnt);
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;

int main()
{
  ll k, a, b;
  cin >> k >> a >> b;
  ll result = 1;
  if(b - a > 2)
  {
    ll x = (k - (a - 1)) / 2;
    result += x * (b - a);
    result += k - (x * 2);
  }else{
    result += k;
  }
  cout << result << endl;
}


Measured memory_bytes: 256
using System;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int S = int.Parse(input);

            int h = S / 3600;
            int m = S % 3600 / 60;
            int s = S % 3600 % 60;


            Console.WriteLine(h + ":" + m + ":"+ s);
        }
    }
}

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define repi(i,n) for(int i=0;i<(int)(n);i++)
#define repd(i,n) for(int i=(int)(n);i>=0;i--)

int main()
{
    int N;
    cin >> N;
    vector<int> UP(N);
    vector<int> DOWN(N);
    repi(i,N){
        cin >> UP[i];
    }
    repi(i,N){
        cin >> DOWN[i];
    }
    int ans = 0;
    int sum = 0;
    repi(i,N){
        repi(j,i){
            sum+=UP.at(j);
        }
        sum += UP.at(i);
        for(int j=i;j<N;j++){
            sum+=DOWN.at(j);
        }
        ans = max(ans,sum);
        sum = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        if(A==B){
            System.out.println(C);
        }
        else if(A==C){
            System.out.println(B);
        }
        else{
            System.out.println(A);
        }
    }
}

Measured memory_bytes: 21844
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    A,B,K=map(int,input().split())
    l=[i for i in range(A,min(A+K,B+1))]+[i for i in range(B,max(B-K,A-1),-1)]
    l=list(set(l))
    l.sort()
    for a in l:
        print(a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
using namespace std;
template<class _T>inline void read(_T &_a)
{
    bool f=0; char _c=getchar(); _a=0;
    while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
    while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
    if(f) _a=-_a;
}

const int MAXN=1000002;
int n,m;

int main()
{
    read(n); read(m);
    printf("%d",n*m);

    return 0;
}

Measured memory_bytes: 3764
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int t[64];
int d[100100];
int n;

void Solve() {
	int h, w;
	cin >> h >> w;
	string t[10];
	for (size_t i = 0; i < h; i++)
	{
		cin >> t[i];
	}

	for (size_t i = 0; i < h - 1; i++)
	{
		for (size_t j = 0; j < w - 1; j++)
		{
			if (t[i + 1][j] == '#' &&
				t[i][j + 1] == '#') {
				cout << "Impossible" << endl;
				return;
			}
		}
	}
	cout << "Possible" << endl;
}


int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 6016
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    ll A,B,C;scanf ("%lld%lld%lld",&A,&B,&C);
    if (!(A&1)||!(B&1)||!(C&1)) puts("0");
    else printf ("%lld",min(A*B,min(B*C,A*C)));
    return 0;
}

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

int main() {
 int n;
 cin>>n;
 int a[n];
 for(int i=0;i<n;i++){
     cin>>a[i];
     if(a[i]%2==0){
     if(a[i]%3 ==0 || a[i]%5 ==0){
         //cout<<"DENIED"; return 0;
         continue;
     }
     else{
         cout<<"DENIED"; return 0;
     }
 }
 }
 cout<<"APPROVED";

 
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	x := readInt()

	sum := 0
	count := 0
	i := 1
	for {
		sum += i
		i++
		count++
		if sum >= x {
			break
		}
	}
	println(count)
}


Measured memory_bytes: 640
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using namespace std;
long long n;

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (x < a) {
		cout << "NO" << endl;
	}
	else if (a + b >= x) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;

	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> X(N);
    vector<ll> Y(N);
    rep(i, N) {
        ll x;
        cin >> x;
        X[i] = x;
        Y[i] = x;
    }

    sort(Y.begin(), Y.end());
    ll med_i = (Y.size() - 1) / 2;
    ll med = Y[med_i];

    rep(i, N) {
        if (med >= X[i]) {
            cout << Y[med_i + 1] << endl;
        } else {
            cout << med << endl;
        }
    }
}


Measured memory_bytes: 5376
#include<stdio.h>
#include<stdlib.h>

struct Node{
  struct Node *r;
  struct Node *l;
  struct Node *p;
  int key;
};

struct Node *root, *NIL;

void insert(int k){
  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;

  z = (struct Node *)malloc(sizeof(struct Node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) {
      x = x->l;
    }else{
      x = x->r;
    }
  }
  z->p = y;
  if(y == NIL){
    root = z;
  }else{
    if(z->key < y->key){
      y->l = z;
    }else{
      y->r = z;
    }
  }
}

void inorder(struct Node *u){
  if(u == NIL) return;
  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}
void preorder(struct Node *u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 25180
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_087
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            var cs = new int[3, 3];
            for(int i = 0; i < 3; i++)
            {
                int[] input = ReadInts();
                cs[i, 0] = input[0];
                cs[i, 1] = input[1];
                cs[i, 2] = input[2];
            }

            int a1 = cs[0, 0];
            int a2 = cs[1, 0];
            int a3 = cs[2, 0];
            int b1 = 0;

            for(int i = 1; i < 3; i++)
            {
                int bi = cs[0, i] - cs[0, 0];
                for(int j = 1; j < 3; j++)
                {
                    if (bi == cs[j, i] - cs[j, 0])
                    {
                        continue;
                    }
                    else
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }

            Console.WriteLine("Yes");
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
# ワーシャルフロイドで、各町間の最短距離の更新は200^3 = 8,000,000
# 訪れるべき町Rはたかだか8個なので、順番の全通りを試して8! = 約40000通り

import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall
from scipy.sparse import csr_matrix

N,M,R = map(int,input().split())
r = list(map(int,input().split()))
r = list(map(lambda x:x-1,r))

E = [[0 for j in range(N)] for i in range(N)]
for i in range(M):
  a,b,c = map(int,input().split())
  E[a-1][b-1] = c
  E[b-1][a-1] = c

E = np.array(E)
E = shortest_path(E,method = "FW")

# DFSですべての数を試す
stack = []
for i in range(len(r)):
  stack.append([r[i],[],0])
ans = 10 ** 18
while stack:
  v,visited,dist = stack.pop()
  if len(visited) != 0:
    dist += E[visited[-1]][v]
  visited2 = visited.copy()
  visited2.append(v)
  if len(visited2) == len(r):
    if dist < ans:
      ans = dist
    continue
  for i in range(len(r)):
    if r[i] not in visited2:
      stack.append([r[i],visited2,dist])
    
print(int(ans))

Measured memory_bytes: 18216
#include <iostream>

using namespace std;

int main()
{
    int n,coins=0;
    cin >> n;
    while (n>5){
        if (n>=500){
            coins+=1000;
            n-=500;
        }
        else if (n>=5){
            coins+=5;
            n-=5;
        }
    }
    cout << coins;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;

#define likely(expr) (__builtin_expect(!!(expr), 1))
#define unlikely(expr) (__builtin_expect(!!(expr), 0))

int Ans[100016];
int Now[100016];

int main() {
    int N;
    scanf("%d", &N);
    vector<pair<int, int> > A, B;
    for(int n=0; n<N; ++n) {
        int a;
        scanf("%d", &a);
        A.emplace_back(a, n);
    }
    for(int n=0; n<N; ++n) {
        int b;
        scanf("%d", &b);
        B.emplace_back(b, n);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    for(int n=0; n<N; ++n) {
        if(B[n].first<A[n].first) {
            printf("No\n");
            return 0;
        }
    }
    for(int n=1; n<N; ++n) {
        if(A[n].first<=B[n-1].first) {
            printf("Yes\n");
            return 0;
        }
    }
    for(int n=0; n<N; ++n) {
        Now[n] = n;
        Ans[B[n].second] = A[n].second;
    }
    for(int n=0; n<N-1; ++n) {
        if(Now[n]==Ans[n]) {
            printf("Yes\n");
            return 0;
        }
        int ans = Ans[n];
        int * Now2 = Now + n;
        for(int i=N-1-n; i; --i) {
            if unlikely(ans==Now2[i]) {
                Now2[i] = Now2[0];
                break;
            }
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 2676
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define se second
#define fi first
#define ss size()
#define pb push_back
#define mp make_pair
#define ins insert
#define ll long long
#define y1 y12313312312
#define endl '\n'
#define gcd __gcd
//#define int ll

using namespace std;
//using namespace __gnu_pbds;

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

const int N = 3e2 + 40, T = 4 * N, inf = 1e9 + 7;

int n, m, r, l, e, w, o, z, test, id, x, y;
int a[N], col[4];
double f, d[N][N][N];

void freop()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}

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

main()
{
    //freop();
    boos();
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        col[a[i]]++;
    }
    for (int k = 0; k <= col[3]; k++)
    {
        for (int j = 0; j <= col[2] + col[3]; j++)
        {
            for (int i = 0; i <= col[1] + col[2] + col[3]; i++)
            {

                if (i) d[i][j][k] += d[i - 1][j][k] * (double)i / (double)(i + j + k);
                if (j) d[i][j][k] += d[i + 1][j - 1][k] * (double)j / (double)(i + j + k);
                if (k) d[i][j][k] += d[i][j + 1][k - 1] * (double)k / (double)(i + j + k);
                if (i || j || k) d[i][j][k] += (double)n / (double)(i + j + k);
            }
        }
    }
    printf("%.9f", d[col[1]][col[2]][col[3]]);
}




Measured memory_bytes: 272384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!(w: chars);
    let mut num = vec![0; 26];
    for ch in w.iter() {
        num[*ch as usize - 'a' as usize] += 1;
    }
    for item in num.iter() {
        if item % 2 == 1 {
            println!("No",);
            return;
        }
    }
    println!("Yes",);
}


Measured memory_bytes: 4352