akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
int t[102];
int v[102];
int s[102];
double dp[201][201];

bool check(int k,int j,int x,int s,double c){
   double a=abs(c-k);
   double b=abs(c-j);
   if(a+b>x)return false;
   return true;
}

double func(int k,int j,int x,int s){
   if(s<k||s<j)return -1e9;
   if(abs(k-j)>x)return -1e9;
   {
      double lb=min(k,j);
      double ub=s+0.0000000000001;
      for(int i=0;i<30;i++){
         double c=(lb+ub)/2;
         if(check(k,j,x,s,c)){
            lb=c;
         }else{
            ub=c;
         }
      }
      double a=abs(lb-k);
      double b=abs(lb-j);
      double d= x-a-b;
      return d*lb+a*(lb+k)/2+b*(lb+j)/2;
   }
}

int main(){
    cin>>N;
    REP(i,N){
        cin>>t[i];
    }
    REP(i,N){
        cin>>v[i];
    }
    REP(i,201){
        REP(j,201){
            dp[i][j]=-1e9;
        }
    }
    dp[0][0]=0;
    REP(i,N){
        REP(j,201){
            REP(k,201){
                dp[i+1][j]=max(dp[i+1][j],dp[i][k]+func(k,j,t[i],v[i]));
            }
        }/*
        REP(j,101){
            cout<<dp[i+1][j]<<endl;
        }
        cout<<endl<<endl;*/
    }
    cout<<fixed<<setprecision(12)<<dp[N][0]<<endl;
    return 0;
}

Measured memory_bytes: 512
#累積和を求めてbisect
# 初期入力
from itertools import accumulate
import bisect
import sys
input = sys.stdin.readline
N,M,K = (int(i) for i in input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
acuum_A =list(accumulate(A))
acuum_B =list(accumulate(B))

#Aを優先に読む場合、Bは何冊読めるか
ans =[]
a =bisect.bisect_right(acuum_A,K)
remainder =K -acuum_A[a-1]
b =bisect.bisect_right(acuum_B,remainder)
ans.append(a+b)

#⇒Aを減らしたらBが何冊読めるか
for i in range(1,N+M):
    ai =a -i
    if ai -1 >=0:
        remainder =K -acuum_A[ai-1]
    else:
        remainder =K
    b =bisect.bisect_right(acuum_B,remainder)
    ans.append(ai+b)
    #print(ai,b,end=" ")
#print()
print(max(ans))

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

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int a, cnt=0;
    for(int i=0;i<n;i++){
        cin >> a;
        if(a%2==1){cnt++;}
    }
    if(cnt%2==0){cout << "YES" << endl;}
    else{cout << "NO" << endl;}
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t {}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr int64_t inf = 0xde0b6b43b9aca00;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n, k;
  cin >> n >> k;

  vector <ll> h (n);
  rep (i, n) cin >> h [i];

  sort (ALL (h));

  auto ans = inf;
  for (size_t i = 0; i + k - 1 < n; ++ i)
  {
    ans = min (ans, h [i + k - 1] - h [i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <queue>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<vector<int>> E(N);
    vector<int> cnt(N, 0);
    vector<int> ans(N, -1);

    int a, b;
    for(int i = 0; i < N - 1; i++){
        cin >> a >> b;
        E[a - 1].push_back(b - 1);
        E[b - 1].push_back(a - 1);
        cnt[a - 1]++;
        cnt[b - 1]++;
    }

    vector<int> c(N);
    for(int i = 0; i < N; i++){
        cin >> c[i];
    }

    if(N == 1){
        cout << 0 << endl;
        cout << c[0] << endl;
        exit(0);
    }

    sort(c.begin(), c.end());
    long long sum = 0;
    for(int i = 0; i < N - 1; i++){
        sum += c[i];
    }

    queue<int> q;
    for(int i = 0; i < N; i++){
        if(cnt[i] == 1){
            q.push(i);
        }
        cnt[i]--;
    }

    int index = 0;
    while(!q.empty()){
        int temp = q.front();
        q.pop();

        ans[temp] = c[index];
        index++;

        for(int i = 0; i < (int)E[temp].size(); i++){
            int next = E[temp][i];
            cnt[next]--;
            if(cnt[next] == 0){
                q.push(next);
            }
        }
    }

    cout << sum << endl;
    for(int i = 0; i < N; i++){
        cout << ans[i];
        if(i != N - 1){
            cout << " ";
        }
        else{
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if((abs(a-c)<=d)||(abs(a-b))<=d && abs(b-c)<=d)cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main()
{
    string s;
    while(cin>>s)
    {
        int ans=0;
        for(int i=0;i<s.size();i++)
        {
            if(s[i]=='1')
                ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <optional>
#include <utility>
#include <vector>
#include <atcoder/all>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif






int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);

    int t; std::cin >> t;
    while(t--) std::cout << "ACL";
    std::cout << '\n';
    
    
    return 0;
}

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

int main(int argc, char* argv[]) {
  using std::cin;
  using std::cout;
  using std::vector;
  
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; ++i) {
    cin >> l[i];
  }
  std::sort(l.begin(), l.end());
  int sum = 0;
  for (int i = 0; i < n - 1; ++i) {
    sum += l[i];
  }
  cout << ((sum > l[n - 1]) ? "Yes" : "No");

  return 0;
}


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

bool a[10];
int n, s;
int sum;
int count;
int ans;

void bfs(int i);

int main() {
  while (1) {
    cin >> n >> s;
    if (!n && !s) break;

    for (int i=0; i<10; i++) a[i] = false;
    sum = 0;
    ans = 0;
    count = 0;
    bfs(0);
    cout << ans << endl;
  }
}

void bfs(int i) {
  if (sum+i < s && count < n-1 && i<9) {
    a[i] = true;
    sum += i;
    ++count;
    bfs(i+1);
    a[i] = false;
    sum -= i;
    --count;
  } else if (sum+i == s && count == n-1) {
    ans++;
  } else if (sum+i > s) {
    return;
  }

  if (i<9) {
    bfs(i+1);
  }

  return;
}

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

using namespace std;
using ll = long long;

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

    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;
    for(int i = l; i <= r; ++i) {
        if(i % d == 0) ans++;
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std; 
int n,m,a;
double s,x;
int main(){
    cin>>n>>m;	
    for(int i=1;i<=n;i++)
    {
    	a=i;
    	s=1;
    	while(a<m)
    	{
    		a*=2;
    		s*=0.5;
		}
		x+=s/n;
	}
	printf("%2.12f",x);
	return 0;
} 

Measured memory_bytes: 256
from collections import deque

class Dice():
    def __init__(self, seq):
        self.v = deque([seq[5], seq[4], seq[0], seq[1]])
        self.h = deque([seq[3], seq[0], seq[2], seq[5]])

    def lotate(self, direction):

        if   direction == "E":
            self.h.rotate()
            self.v[2] = self.h[1]
            self.v[0] = self.h[3]

        elif direction == "W":
            self.h.rotate(-1)
            self.v[2] = self.h[1]
            self.v[0] = self.h[3]

        elif direction == "N":
            self.v.rotate(-1)
            self.h[1] = self.v[2]
            self.h[3] = self.v[0]

        elif direction == "S":
            self.v.rotate()
            self.h[1] = self.v[2]
            self.h[3] = self.v[0]

        else:
            pass

    def disp_top_face(self):
        return self.v[2]

    def disp_front_face(self):
        return self.v[3]

    def disp_back_face(self):
        return self.v[1]

    def disp_right_face(self):
        return self.h[2]

    def disp_left_face(self):
        return self.h[0]

    def disp_bottom_face(self):
        return self.h[3]

if __name__ == "__main__":

    param = input().split(" ")

    seq = [int(a) for a in param]
    d1 = Dice(seq)

    param = input().split(" ")

    seq = [int(a) for a in param]
    d2 = Dice(seq)

    top1 = d1.disp_top_face()
    front1 = d1.disp_front_face()

    flag = 1

    while(flag):

        for _ in range(4):

            d2.lotate("S")

            if d2.disp_top_face() == top1:
                flag = 0
                break

        if flag :
            d2.lotate("E")

    for _ in range(4):

        if d1.disp_front_face() == d2.disp_front_face():
            break

        d2.lotate("E")
        d2.lotate("S")
        d2.lotate("W")

    # print(str(d2.disp_top_face()) + " " + str(d1.disp_top_face()))
    # print(str(d2.disp_front_face()) + " " + str(d1.disp_front_face()))
    # print(str(d2.disp_bottom_face()) + " " + str(d1.disp_bottom_face()))
    # print(str(d2.disp_back_face()) + " " + str(d1.disp_back_face()))
    # print(str(d2.disp_left_face()) + " " + str(d1.disp_left_face()))
    # print(str(d2.disp_right_face()) + " " + str(d1.disp_right_face()))

    if d2.disp_bottom_face() == d1.disp_bottom_face() and \
       d2.disp_front_face() == d1.disp_front_face() and \
       d2.disp_left_face() == d1.disp_left_face() and \
       d2.disp_right_face() == d1.disp_right_face() and \
       d2.disp_back_face() == d1.disp_back_face():
       print("Yes")
    else:
       print("No")



Measured memory_bytes: 6028
import sys

def main():
    input = sys.stdin.readline
    S = str(input().strip())

    cnt_01 = 0
    cnt_10 = 0
    for i in range(len(S)):
        s = S[i]

        if i % 2 == 0:
            if s != '0':
                cnt_01 += 1
            else:
                cnt_10 += 1
        else:
            if s != '0':
                cnt_10 += 1
            else:
                cnt_01 += 1

    return min(cnt_01, cnt_10)


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100000;

int N;
ll C;
ll x[MAX_N], v[MAX_N];
ll memo1[MAX_N + 1], memo2[MAX_N + 1], memo3[MAX_N + 1], memo4[MAX_N + 1];

int main(){
	cin >> N >> C;
	for(int i = 0; i < N; i++) cin >> x[i] >> v[i];
	
	fill(memo1, memo1 + N + 1, 0LL);
	fill(memo2, memo2 + N + 1, 0LL);
	fill(memo3, memo3 + N + 1, 0LL);
	fill(memo4, memo4 + N + 1, 0LL);
	
	for(int i = 0; i < N; i++) memo1[i + 1] = memo1[i] + v[i];
	for(int i = 0; i < N; i++) memo2[i + 1] = memo2[i] + v[N - i - 1];
	for(int i = 0; i < N; i++) memo3[i + 1] = memo3[i] + v[i];
	for(int i = 0; i < N; i++) memo4[i + 1] = memo4[i] + v[N - i - 1];

	for(int i = 0; i < N; i++) memo1[i + 1] -= x[i];
	for(int i = 0; i < N; i++) memo2[i + 1] -= C - x[N - i - 1];
	for(int i = 0; i < N; i++) memo3[i + 1] -= 2 * x[i];
	for(int i = 0; i < N; i++) memo4[i + 1] -= 2 * (C - x[N - i - 1]);
	
	for(int i = 0; i < N; i++) memo1[i + 1] = max(memo1[i], memo1[i + 1]);
	for(int i = 0; i < N; i++) memo2[i + 1] = max(memo2[i], memo2[i + 1]);
	for(int i = 0; i < N; i++) memo3[i + 1] = max(memo3[i], memo3[i + 1]);
	for(int i = 0; i < N; i++) memo4[i + 1] = max(memo4[i], memo4[i + 1]);

	ll ans1 = 0LL, ans2 = 0LL;
	for(int i = 0; i < N + 1; i++){
		ans1 = max(ans1, memo1[i] + memo4[N - i]);
		ans2 = max(ans2, memo2[i] + memo3[N - i]);
	}
	cout << max(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>


int main(){

  int x,y,tmp,d;

  scanf("%d%d",&x,&y);
  
  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }
  
  d = x % y;
  while(d!=0){
    x = y;
    y = d;
    d = x % y;
  }
  printf("%d\n",y);

  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<long long> v;
    long long y;
    long long x[n];
    for(int i = 0; i < n; i++){
        cin >> y;
        x[i] = y;
        v.push_back(x[i]);
    }
    sort(v.begin(), v.end());
    long long a = v[n/2 - 1];
    long long b = v[n/2];
    for(int i = 0; i < n; i++){
        if(x[i] <= a){
            cout << b << endl;
        } else {
            cout << a << endl;
        }
    }
    return 0;
}


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

int main(){
	int A,B;

	cin>>A>>B;

	if((A==1 && B==2) || (A==2 && B==1)){
		cout<<"3"<<endl;
		exit(0);
	}
	if((A==1 && B==3) || (A==3 && B==1)){
		cout<<"2"<<endl;
		exit(0);
	}
	if((A==2 && B==3) || (A==3 && B==2)){
		cout<<"1"<<endl;
		exit(0);
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
	return *(int *)b - *(int *)a;
}

int main(void)
{
	int i, j, k;
	int ii[1000];
	int min, max;
	int len, flg;
	int cnt=0, maxcnt;
	int N,M;
  scanf("%d %d", &N,&M);
	for (i = 0; i < N; i++)
	{
		scanf("%d\n", &ii[i]);
		cnt += ii[i];
    }
  	qsort(ii, N, sizeof(int), compare_int);
//      printf("cnt %d M%d %d ii%d\n",cnt,M,cnt /4/M,ii[M-1]);
	if(cnt > ii[M-1]*4*M){
      printf("No\n");
      return 0;
    }
	printf("Yes\n");
  	return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
  string S, T;
  cin >> S >> T;
  
  bool ret = (S.size() +1 == T.size() && T.find(S) == 0);
  string s = ret ? "Yes" : "No";
  
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2904>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string s; cin >> s;
    int cnt = 0;
    for(auto c:s){
        if(c == 'L'){
            cnt--;
        }else{
            cnt++;
        }
        if(cnt == 4){
            res++;
        }
        cnt%=4;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



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

int LEN = 100010;

int main(){
	char S[LEN];
	cin >> S;
	int p;
	bool kanou = false;
	for(int i=0; i<LEN; i++){
		if(S[i] == 0){
			p = i-1;
			break;
		}
	}
	while(true){
		if(p>=6 && S[p-6]=='d' && S[p-5]=='r' && S[p-4]=='e' && S[p-3]=='a'
			 && S[p-2]=='m' && S[p-1]=='e' && S[p] == 'r') p-=7;
	    else if(p>=5 && S[p-5]=='e' && S[p-4]=='r' && S[p-3]=='a'
			 && S[p-2]=='s' && S[p-1]=='e' && S[p] == 'r') p-=6;
		else if(p>=4 && S[p-4]=='d' && S[p-3]=='r' && S[p-2]=='e' &&
				 S[p-1]=='a' && S[p] == 'm') p-=5;
		else if(p>=4 && S[p-4]=='e' && S[p-3]=='r'
			 && S[p-2]=='a' && S[p-1]=='s' && S[p] == 'e') p-=5;
		else break;
		if(p==-1){
			kanou = true;
			break;
		}
	}
	cout << (kanou ? "YES" : "NO") << endl;
}

Measured memory_bytes: 384
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

template <size_t T> using BS = bitset<60>;
template <size_t T> using Matrix = V<BS<T>>;

template <size_t Row, size_t Col>
tuple<Matrix<Col>, ll> gauss_elim(Matrix<Col> mat) {
    ll fcnt = 0;
    ll upper_row = 0;
    for(ll col = Col - 1; 0 <= col; col--) {
    // for(ll col = 0; col < Col; col++) {
        ll row = -1;
        for(ll r = upper_row; r < mat.size(); r++) {
            if(mat[r].test(col)) {
                row = r;
                break;
            }
        }
        if(row == -1) {
            fcnt++;
            continue;
        }
        swap(mat[upper_row], mat[row]);
        for(ll r = 0; r < mat.size(); r++) {
            if(r == upper_row) continue;
            if(!mat[r].test(col)) continue;
            mat[r] ^= mat[upper_row];
        }
        upper_row++;
    }
    auto rank = Row - fcnt;
    return make_tuple(mat, rank);
}

const size_t max_n = 1e5;
const size_t bit = 60;

int main() {
    ll N;
    cin >> N;
    V<ll> A(N);
    ull xor_sum = 0;
    for(auto &&ele : A) {
        cin >> ele;
        xor_sum ^= ele;
    }

    ull ans = 0;
    for(ll i = 0; i < bit; i++) if((xor_sum >> i) & 1) ans += (1ll << i);
    
    Matrix<bit> mat(max_n);
    for(ll i = 0; i < N; i++) for(ll j = 0; j < bit; j++) if(!((xor_sum >> j) & 1) && ((A[i] >> j) & 1)) mat[i].set(j, 1);

    tie(mat, ignore) = gauss_elim<max_n, bit>(mat);

    ull val = 0;
    for(auto &&ele : mat) val ^= ele.to_ullong();
    ans += 2 * val;

    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 string s,t,u;
  cin >> s >> t;
  ll a,b;
  cin >> a >> b;
  cin >> u;
  if(u==s) a--;
  else b--;
  cout << a << " " << b << endl;
  
  
}

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

int main() {
  int N,Z=0;
  cin>>N;
  vector<int> p(N);
  vector<int> q(N);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    p[i]=a;
    q[i]=a-1;
  }
  vector<int> ans;
  for(int i=0;i<N;i++){
    for(int j=N-1;j>=0;j--){
      if(q[j]==j){
        ans.push_back(p[j]);
        Z++;
        for(int k=j;k<N;k++){
          q[k]++;
        }
        q[j]=-200;
        break;
      }
    }
  }
  if(Z!=N){
    cout<<"-1"<<endl;
  }
  else{
    for(int i=N-1;i>=0;i--){
      cout<<ans[i]<<endl;
    }
  }
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

double x, h;

int main()
{
  while(~scanf(" %lf %lf", &x, &h) && x && h){
    printf("%.15f\n", x * x + 4 * x * sqrt(h * h + x * x / 4.0) / 2.0);
  }

  return 0;
}

Measured memory_bytes: 1232
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let x: i32 = sc.read();
    let l: Vec<i32> = sc.vec(n);
    let mut d: i32 = 0;
    let mut ans: i32 = 1;
    for l in l.into_iter() {
        d += l;
        if d <= x {
            ans += 1;
        }
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4352
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,ans=0,tmp=0;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<ll>());
  if(n%2==0){
    for(int i=0;i<n/2;i++){
      ans += 2*a[i];
      ans -= 2*a[n-1-i];
    }
    ans -= a[n/2-1];
    ans += a[n/2];
  }else{
    for(int i=0;i<n/2;i++){
      tmp += a[i]*2;

    }
    tmp -= a[n/2];
    tmp -= a[n/2+1];
    for(int i=n/2+2;i<n;i++){
      tmp -= a[i]*2;
    }

    for(int i=0;i<n/2-1;i++){
      ans += a[i]*2;
    }
    ans += a[n/2-1];
    ans += a[n/2];
    for(int i=n/2+1;i<n;i++){
      ans -= a[i]*2;
    }
    ans = max(tmp,ans);
  }
  cout << ans << endl;
}


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

int main() {
	int n,w,cnt1=0,cnt2=0;
	cin>>n;
	vector<bool>f(8);

	for(int i=0;i<n;i++){
		cin>>w;
		if(w>=3200){
			cnt2++;
		}else if(w>=2800 && w<=3199 && f.at(7)==false){
			cnt1++;
			f.at(7)=true;
		}else if(w>=2400 && w<=2799 && f.at(6)==false){
			cnt1++;
			f.at(6)=true;
		}else if(w>=2000 && w<=2399 && f.at(5)==false){
			cnt1++;
			f.at(5)=true;
		}else if(w>=1600 && w<=1999 && f.at(4)==false){
			cnt1++;
			f.at(4)=true;
		}else if(w>=1200 && w<=1599 && f.at(3)==false){
			cnt1++;
			f.at(3)=true;
		}else if(w>=800  && w<=1199 && f.at(2)==false){
			cnt1++;
			f.at(2)=true;
		}else if(w>=400  && w<=799  && f.at(1)==false){
			cnt1++;
			f.at(1)=true;
		}else if(w>=1    && w<=399  && f.at(0)==false){
			cnt1++;
			f.at(0)=true;
		}
	}

	if(n!=cnt2){
		cout<<cnt1<<" "<<cnt1+cnt2<<endl;
	}else{
		cout<<1<<" "<<cnt2<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
x, y =map(int, input().split())
if abs(x) == abs(y):
	print(1)
	exit()
if y > x:
	if x*y >= 0:
		print (y-x)
		exit()
	if abs(y)-abs(x) < y-x:
		print (abs(abs(y)-abs(x))+1)
		exit()
	else:
		print (y-x)
		exit()
if x > y:
	if x*y > 0:
		print (abs(abs(x)-abs(y))+2)
	else:
		print (abs(abs(x)-abs(y))+1)

Measured memory_bytes: 3188
import itertools

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

permutations = list(itertools.permutations([i for i in range(1, N + 1)]))
# print(permutations)
print(abs(permutations.index(P) - permutations.index(Q)))


Measured memory_bytes: 13680
#include <iostream>
#include <algorithm>
using namespace std;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
int main() {
    int N;
    cin >> N;
    int v[N];
    for (int i=0; i<N; i++)
        cin >> v[i];
    sort(v, v + SIZE_OF_ARRAY(v));
    double a = (v[0] + v[1]) / 2.0;
    for (int i=2; i<N; i++) {
        a = (a + v[i]) / 2.0;
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N,L[100],L_l,L_s,i;
  	
  	i=0;
  	L_l = L_s=0;  
  	scanf("%d",&N);
	for(i=0;i<N;i++){
    	scanf("%d",&L[i]);
      	L_s+=L[i];
      if(L_l < L[i]){
      	L_l = L[i];
      }
    }
  if(2*L_l < L_s){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    reverse(All(a));
    int dp[d5];
    dp[0]=0;
    for(int i=1;i<n;i++){
        if(a[i-1]<=a[i])dp[i]=dp[i-1]+1;
        else dp[i]=0;
    }
    int res=0;
    for(int i=0;i<n;i++)res=max(dp[i],res);
    cout<<res<<endl;
}

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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a


using ll = long long;

int main() {
    IN(int, a);
    IN(int, b);
    if (a < b) {
        REP(i, b) cout << a;
    }else{
        REP(i, a) cout << b;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int x_max,y_max;
	int course[17][17];
	int putterns[17][17];
	int x,y;
	int result;
	while(1) {
		scanf("%d%d",&x_max,&y_max);
		if(x_max==0 && y_max==0)break;
		for(y=0;y<y_max;y++) {
			putterns[y][0]=0;
			for(x=1;x<=x_max;x++) {
				scanf("%d",&course[y][x]);
				putterns[y][x]=0;
			}
			putterns[y][x]=0;
		}
		for(x=1;x<=x_max;x++) {
			putterns[y_max][x]=1;
			putterns[y_max+1][x]=1;
		}
		for(x=1;x<=x_max;x++) {
			if(course[y_max-1][x]==1)putterns[y_max-1][x]=0;
			else putterns[y_max-1][x]=1;
		}
		for(y=y_max-2;y>=0;y--) {
			for(x=1;x<=x_max;x++) {
				switch(course[y][x]) {
					case 1:
						putterns[y][x]=0;
						break;
					case 2:
						putterns[y][x]=putterns[y+2][x];
						break;
					default:
						putterns[y][x]=putterns[y+1][x];
						if(course[y+1][x-1]!=2) {
							putterns[y][x]+=putterns[y+1][x-1];
						}
						if(course[y+1][x+1]!=2) {
							putterns[y][x]+=putterns[y+1][x+1];
						}
						break;
				}
			}
		}
		for(x=1,result=0;x<=x_max;x++)result+=putterns[0][x];
		printf("%d\n",result);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;
ll n,m;
ll a[100009];
ll s[100009];

bool judge(ll mid){
  ll cnt=0;
  rep(i,n){
    int l=-1,r=n;
    while(r-l>1){
      int j=(l+r)/2;
      if(a[i]+a[j]>mid){
        l=j;
      }
      else{
        r=j;
      }
    }
    cnt+=r;
  }

  return cnt<m;
}

int main(){
  cin>>n>>m;
  rep(i,n){
    cin>>a[i];
  }
  sort(a,a+n,greater<>());
  rep(i,n){
    s[i+1]=s[i]+a[i];
  }

  ll l=-1,r=lINF;
  while(r-l>1){
    ll mid=(l+r)/2;
    if(judge(mid)){
      r=mid;
    }
    else{
      l=mid;
    }
  }

  ll cnt=0,ans=0;
  rep(i,n){
    int nl=-1,nr=n;
    while(nr-nl>1){
      int j=(nl+nr)/2;
      if(a[i]+a[j]>r){
        nl=j;
      }
      else{
        nr=j;
      }
    }
    ans+=a[i]*nr+s[nr];
    cnt+=nr;
  }
  ans+=r*(m-cnt);

  cout<<ans<<endl;

  return(0);
}


Measured memory_bytes: 1792
import java.io.*;
import java.io.IOException;
import java.util.*;

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        long X;
        X = sc.nextLong();
        solve(X);
    }

    static void solve(long X){
        long year = 0;
        long m = 100;
        while(m < X) {
            m =(long)(m * 1.01);
            year++;
        }
        System.out.println(year);
    }



    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            return nn();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


Measured memory_bytes: 32856
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
using namespace std;
int main(){
   int n;
   cin >> n;
   bool ans = true;
   vector<string> w(n);
   set<string> s;
   rep(i,n){
        cin >> w.at(i);
        s.insert(w.at(i));
   }
   for(int i=0;i<n-1;++i){
       if(w[i].back() != w[i+1].front()) ans = false;
   }
   if(s.size() != n) ans = false;
   if(ans) cout << "Yes" << endl;
   else cout << "No" << endl;
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vll xs(n);
    forn(i, n) cin>>xs[i];
    sort(all(xs));
    reverse(all(xs));
    int ans=0;
    ll sum=accumulate(all(xs), 0ll);
    ll hi = xs[0];
    for (int i=0; i<n; i++) {
        sum -= xs[i];
        if (2*(xs[i]+sum)>=hi) {
            hi=xs[i];
            ans++;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1024
import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;

bool solve() {
  readln;
  int[] a = readln.chomp.split.to!(int[]);
  for(int i=0; i<a.length; i++) {
    if(a[i]%2==0) {
      if(a[i]%3==0 || a[i]%5==0) continue;
      else return false;
    }
  }
  return true;
}

void main() {
  if(solve) writeln("APPROVED");
  else writeln("DENIED");
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli a, b;
    cin>>a>>b;
    a-=2*b;
    out((a<0?0:a));
}

Measured memory_bytes: 3604
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc164
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc164C();
			Console.Out.Flush();

        }

        public static void solve_abc164C()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            Dictionary<string, int> dic = new Dictionary<string, int>();
            int cnt = 0;
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                if (!dic.ContainsKey(s))
                {
                    dic.Add(s, 0);
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }

        public static void solve_abc164B()
        {
            int[] abcd = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int a = abcd[0];
            int b = abcd[1];
            int c = abcd[2];
            int d = abcd[3];
            if ((c + b - 1) / b <= (d + a - 1)/ d)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        public static void solve_abc164A()
        {
            int[] sw = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            if (sw[1] >= sw[0])
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }
        }
    }
}


Measured memory_bytes: 50900
N = int(input())
A = list(map(int, input().split()))

count = 0
flag = False
l = [abs(i) for i in A]
if 0 in A:
  pass
else:
  for j in A:
    if j < 0:
      count += 1
  if count % 2 == 0:
    pass
  else:
    flag = True
    
if flag:
  print(sum(l)-min(l)*2)
else:
  print(sum(l))

Measured memory_bytes: 14412
N = int(input())

d = {}
ans = []

for i in range(N):
    S = input()
    d.setdefault(S,0)
    d[S] += 1

max = max(d.values())
for key in d.keys():
    if d[key] == max:
        ans.append(key)
        
ans = sorted(ans)

for word in ans:
    print(word)

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

int main() {
  int N, M;
  cin >> N >> M;
  if (N >= M) cout << 0 << endl;
  else {
    vector<int> X(M), L(M - 1);
    for (int i = 0; i < M; i++) cin >> X.at(i);
    sort(X.begin(), X.end());
    for (int i = 0; i < M - 1; i++) L.at(i) = X.at(i + 1) - X.at(i);
    sort(L.begin(), L.end());
    reverse(L.begin(), L.end());
    int S = 0;
    for (int i = 0; i < N - 1; i++) S += L.at(i);
    cout << X.at(M - 1) - X.at(0) - S << endl;
  }
}

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

struct node{
	int num;
	node *parent,*left,*right;
};
node *root,*NIL;

void print_inorder(node *x){
	if(x==NIL) return ;
	print_inorder(x->left);
	printf(" %d",x->num);
	print_inorder(x->right);
	return ;
}

void print_preorder(node *x){
	if(x==NIL) return ;
	printf(" %d",x->num);
	print_preorder(x->left);
	print_preorder(x->right);
	return ;
}

void insert(int a){
	node *x=root,*y=NIL;
	node *z=new node();
	z->num=a;z->left=NIL;z->right=NIL;
	while(x!=NIL){
		y=x;
		if(z->num < x->num) x=x->left;
		else x=x->right;
	}
	z->parent=y;
	if(y==NIL) root=z;
	else {
		if(z->num < y->num) y->left=z;
		else y->right=z;
	}
	return ;
}

int main(){
	int n;
	cin>>n;
	string s;
	int a;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s[0]=='i') cin>>a,insert(a);
		else{
			print_inorder(root);
			printf("\n");
			print_preorder(root);
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 26700
#include<stdio.h>

int main(){
	int n,b,f,r,v,i,j,k,member[4][3][10] = {0};

	for(i = 0; i < 4; i++){
	  for(j = 0; j < 3; j++){
	    for(k = 0; k < 10; k++){
			member[i][j][k] = 0;
		}
	  }
	}
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		member[b-1][f-1][r-1] += v;
	}
	for(i = 0; i < 4; i++){
	  for(j = 0; j < 3; j++){
	    for(k = 0; k < 10; k++){
		  printf(" %d",member[i][j][k]);
		}
		printf("\n");
	  }
	  if(i != 3){
	    n = 0;
	  while(n < 20){
	    printf("#");
	    n++;
	  }
	  printf("\n");
	  }
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  vl a(3);
  cin >> n;
  rep(i, 3) cin >> a[i];
  vl l(n);
  rep(i, n) cin >> l[i];
  ll ans = 1e18;
  rep(i, pow(4, n)) {
    vl sum(4, 0), num(4, 0);
    ll k = i;
    rep(j, n) {
      sum[k % 4] += l[j];
      num[k % 4]++;
      k /= 4;
    }
    ll now = 0;
    bool ok = true;
    rep(j, 3) {
      if(num[j] == 0) ok = false;
      now += abs(sum[j] - a[j]);
      now += (num[j] - 1) * 10;
    }
    if(ok) ans = min(ans, now);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4084
using System;

namespace ConsoleApp1
{

    class Program
    {
        public static int H;
        static void Main()
        {
            H = int.Parse(Console.ReadLine());
            int[] A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            buildMaxHeap(A);
            Console.WriteLine(" " + string.Join(" ", A));
        }
        private static void Maxheapfy(int[] A, int i) 
        {
            int largest = i;
            int l = (i + 1) * 2 - 1;
            int r = (i + 1) * 2;
            if (l < H && A[l] > A[i])
                largest = l;
            if (r < H && A[r] > A[largest])
                largest = r;
            
            if(largest != i)
            {
                int temp = A[i];
                A[i] = A[largest];
                A[largest] = temp;
                Maxheapfy(A, largest);
            }
        }
        private static void buildMaxHeap(int[] A) { 
            for(int i = H/2; i >= 0; i--)
            {
                Maxheapfy(A, i);
            }
        }
    }
}



Measured memory_bytes: 74032
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    if(a < b) {
        YES(a+v*t >= b+w*t);
    } else {
        YES(a-v*t <= b-w*t);
    }
}


Measured memory_bytes: 3656
n, w = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]

for i in range(n):
    for j in range(w + 1):
        if j < s[i][1]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - s[i][1]] + s[i][0])
print(dp[n][w])



Measured memory_bytes: 25520
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <sstream>
#include <math.h>
#include <map>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i=0; i<n; ++i){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  int sum;
  for(int i=0; i<n-1; ++i){
    sum +=a[i];
  }
  if(sum>a[n-1]){
    cout << "Yes" << endl;}
  else{
    cout << "No" << endl;}
}

Measured memory_bytes: 256