akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}
void zero(int a[], int n){
    for(int i = 0; i < n; i++) a[i] = 0;
}

int main(){
    int n; cin >> n;
    int a[n]; inarray(a,n-1);

    int ans[n]; zero(ans, n);

    for(int i = 0; i < n-1; i++){
        ans[a[i]-1]++;
    }

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

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

using namespace std;

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

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

int dir[] = { 1,0,-1,0,1 };

void Search(vector<vector<int>>&field, int y, int x, int gy, int gx, int step, int &ans) {
	if (y == gy && x == gx) {
		ans = min(ans, step);
		return;
	}
	if (step > ans)return;
	if (step > 10)return;
	for (int i = 0; i < 4; i++) {
		int ny = y, nx = x;
		while (ny >= 0 && ny < H&&nx >= 0 && nx < W) {
		//	cout << ny << " " << nx << endl;
			if (ny == gy && nx == gx) {
				ans = min(ans, step);
				return;
			}
			if (ny + dir[i] < 0 || ny + dir[i] >= H || nx + dir[i + 1] < 0 || nx + dir[i + 1] >= W) {
				ny += dir[i];
				nx += dir[i + 1];
				break;
			}
			if (field[ny + dir[i]][nx + dir[i + 1]] != 1) {
				ny += dir[i];
				nx += dir[i + 1];
			}
			else {
				break;
			}
		}
		if (ny == y && nx == x)continue;
		if (ny >= 0 && ny < H&&nx >= 0 && nx < W) {
			field[ny + dir[i]][nx + dir[i + 1]] = 0;
			Search(field, ny, nx, gy, gx, step + 1, ans);
			field[ny + dir[i]][nx + dir[i + 1]] = 1;
		}
	}
}

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

	while (cin >> W >> H, H) {
		vector<vector<int>>field(H, vector<int>(W));
		for (auto &i : field)for (auto &j : i)cin >> j;
		int sy, sx;
		int gy, gx;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (field[i][j] == 2)sy = i, sx = j;
				if (field[i][j] == 3)gy = i, gx = j;
			}
		}
		int ans = 100;
		Search(field, sy, sx, gy, gx, 1, ans);
		if (ans == 100)ans = -1;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3228
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <cstdio>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main()
{
	ll a, b;
	cin >> a >> b;
	a = (a + 11) % 13;
	b = (b + 11) % 13;
	if (a > b)
	{
		cout << "Alice" << endl;
	}
	else if (b > a)
	{
		cout << "Bob" << endl;
	}
	else
	{
		cout << "Draw" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
N, M = map(int, input().split())
count = 0

def nCr(n, r):
  return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))

if N > 1:
  count += nCr(N, 2)
if M > 1:
  count += nCr(M, 2)

print(count)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		sc.close();

		int m = 45;
		int[] cnt = new int[m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				cnt[j] += a[i] >> j & 1;
			}
		}

		long[] dp0 = new long[m];
		long[] dp1 = new long[m];
		for (int j = m - 2; j >= 0; j--) {
			int bit = 0;
			int c = cnt[j];
			if (n - cnt[j] > cnt[j]) {
				bit = 1;
				c = n - cnt[j];
			}
			long b = 1L << j;
			if ((k & b) >> j == 1) {
				dp0[j] = dp0[j + 1] + (n - cnt[j]) * b;
				if (bit == 0) {
					dp1[j] = Math.max(dp0[j + 1], dp1[j + 1]) + c * b;
				} else {
					dp1[j] = dp0[j + 1] + cnt[j] * b;
					if (dp1[j + 1] > 0) {
						dp1[j] = Math.max(dp1[j], dp1[j + 1] + c * b);
					}
				}
			} else {
				dp0[j] = dp0[j + 1] + cnt[j] * b;
				if (dp1[j + 1] > 0) {
					dp1[j] = dp1[j + 1] + c * b;
				}
			}
		}
		System.out.println(Math.max(dp0[0], dp1[0]));
	}
}


Measured memory_bytes: 56820
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;
vector<bool> ban(10, false);
bool f(int x){
    while(x > 0){
        if(ban[x%10]) return false;
        x /= 10;
    }
    return true;
}
int main(void){
    int n, k;
    cin >> n >> k;
    for(int i=0;i<k;i++){
        int d;
        cin >> d;
        ban[d] = true;
    }
    for(int i=n;;i++){
        if(f(i)){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int i,j,n,m,b[200][200];
char a[200][200];
int main(){
    cin>>n>>m;
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
            cin>>a[i][j];
    for(i=0;i<n;i++)
        for(j=0;j<m;j++)
            if(a[i][j]=='#'){
                b[i-1][j-1]++; b[i][j-1]++; b[i-1][j]++;
                b[i+1][j+1]++; b[i][j+1]++; b[i+1][j]++;
                b[i+1][j-1]++; b[i-1][j+1]++;
            }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            if(a[i][j]=='#') cout<<'#';
            else cout<<b[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  V<ll> v(n);
  rep(i,0,n)cin>>v[i];


  map<ll,int> ma;
  rep(i,0,n)ma[v[i]]++;

  set<ll> se;
  for(auto&& i:ma){
    if(i.sc<=1){
      se.insert(i.fs);
    }
  }

  for(auto&& i:ma){
    ll now=i.fs*2;
    while(now<=1000010){
      if(se.count(now))se.erase(now);
      now+=i.fs;
    }
  }

  cout<<siz(se)<<ENDL;


}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?


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

int main() {
  int n,x,y;
  cin >> n;
  x = 1;
  y= 0;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  int s = 0;
  
  while(x<=n){
    s = a.at(s);
    if(s == 2){
      y++;
      break;
    }
    s--;
    x++;
  }
  
  if(y > 0 || s == 2){
    cout << x << endl;
  }
  else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << ((a + b) * h) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#include <bits/stdc++.h>
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a,T b){a=max(a,b);}
template<typename T> inline void minimize(T &a,T b){a=min(a,b);}
template<typename T> inline bool middle(T a,T b,T c){return b<=a && a<=c;}
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
inline void outputVI(VI x){REP(i,SI(x)){cout << three(i," ","") << x[i];}OUT("");}
const int SIZE1=5*1e5+1000;
const int SIZE2=5010;
const int SIZE3=400;
const int SIZE=SIZE1;
const LL p=7+1e9;
const LL INF=1LL<<60;
const long double EPS=1e-7;
string s;
ut N,M,K,X,L,Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE],nums[SIZE],maps[SIZE2][SIZE2],answer=zero;
 
////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////
void init(){
 
}
int A[SIZE];
LL solve(){
	cin >> N >> K;
	int c=0;
	REP(i,N){
		cin >> A[i];
		if(A[i]==1) c=i;
	}
	if(N==K) cout << 1 << endl;
	else cout << (N-1+K-2)/(K-1) << endl;
	return 0;
}
signed main(){
	solve();
	return 0;
}

Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std;
int a;
int main()
{
    cin>>a;
    for(int i=0;;i++)
    {
        if((1<<i)==a){cout<<(1<<i)<<endl;return 0;}
        if((1<<i)>a){cout<<(1<<(i-1))<<endl;return 0;}
    }
    return 0;
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    string s; cin >> s;
    
    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
        p("Bad");
    }else{
        p("Good");
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  map<string, long> mp;
  string S;
  for(int i = 0; i < N; i++){
	cin >> S;
    mp[S]++;
  }
  cout << "AC x "  << mp["AC"]<< endl;
  cout << "WA x "  << mp["WA"]<< endl;
  cout << "TLE x "  << mp["TLE"]<< endl;
  cout << "RE x "  << mp["RE"]<< endl;
  return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
  ll n,ans=0;cin>>n;
  set<string> s;
  rep(i,0,n){
    string a;
    cin>>a;
    s.insert(a);
  }
  auto ite=s.begin();
  while(ite!=s.end()){
    ans++;ite++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 19148
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
int a,b;
int main(){
	cin>>a>>b;
	cout<<max(a+b,max((a<<1)-1,(b<<1)-1));
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (INT_MAX/2-1)
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

int main(){
  int N,K;
  string s;
  cin>>N>>K>>s;
  s[K-1]=(s[K-1]-('A'-'a'));
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
board = [list(input()) for _ in range(H)]
ans = [[0 for _ in range(W)] for _ in range(H)]
c = 1
for x in range(W):
    for y in range(H):
        if board[y][x] == "#":
            ans[y][x] = c
            for xi in range(x+1, W):
                if board[y][xi] == ".":
                    ans[y][xi] = c
                else:
                    break
            for xi in range(0, x)[::-1]:
                if board[y][xi] == ".":
                    ans[y][xi] = c
                else:
                    break
            c += 1
for x in range(W):
    for y in range(H):
        if ans[y][x] == 0:
            tmp = [y]
            for yi in range(y+1, H):
                if ans[yi][x] == 0:
                    tmp.append(yi)
                else:
                    #tmp.append(yi)
                    for yii in tmp:
                        ans[yii][x] = ans[yi][x]
                    break
            for yi in range(0, y)[::-1]:
                if ans[yi][x] == 0:
                    tmp.append(yi)
                else:
                    #tmp.append(yi)
                    for yii in tmp:
                        ans[yii][x] = ans[yi][x]
                    break

for i in range(H):
    print(" ".join(map(str, ans[i])))

Measured memory_bytes: 7892
let rec foldn n f v = if n = 0 then v else foldn (n-1) f (f v)
let () =
  let n, k = Scanf.scanf "%d %d" (fun n k -> n, k) in
  foldn n (fun a -> min (2*a) (a+k)) 1 |> Printf.printf "%d\n"


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int MOD = 998244353, N = 4005;
int c[N][N];

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

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

    for (int i = 1; i < N; i++) {
    	for (int j = 1; j < N; j++) {
    		c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;
    	}
    }

    int k, n;
    cin >> k >> n;

    

    for (int i = 2; i <= 2 * k; i++) {
    	ll ans = 0;

    	int ct = 0;
    	for (int j = 1; j <= k; j++) {
    		if (i - j <= k && j < i - j) {
    			ct++;
    		}
    	}

    	// cout << ct << "\n";

    	ll p = 1;
    	for (int j = 0; j <= min(ct, n); j++) {
    		if (i % 2 == 0) {
    			for (int h = 0; h < 2; h++) {
    				if (n - j - h + k - ct * 2 + j - 2 >= 0)
    					ans = (ans + c[ct][j] * p % MOD * c[n - j - h + k - ct * 2 + j - 2][n - j - h]) % MOD;
    			}
    		}
    		else {
    			// cout << n - j + k - ct * 2 + j << "\n";
    			// cout << n - j + k - ct * 2 + j << "\n";
    			ans = (ans + c[ct][j] * p % MOD * c[n - j + k - ct * 2 + j - 1][n - j]) % MOD;
    		}
    		p = p * 2 % MOD;
    	}

    	cout << ans << "\n";
    }



    return 0;   
}

Measured memory_bytes: 62976
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0;i < n; i++) {
            a[i] = sc.nextInt();
        }

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0;i< n; i++) {
            map.put(a[i], i);
        }
       Arrays.sort(a);
      

        for (int i : a) {
            System.out.print(map.get(i) +1 + " ");
        }
    }
}


Measured memory_bytes: 70048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, d;
  in2(a, b);
  in2(c, d);
  while(true){
    c -= b;
    if(c < 1){
      out("Yes");
      memi;
      return 0;
    }
    a -= d;
    if(a < 1){
      out("No");
      memi;
      return 0;
    }
  }
}

Measured memory_bytes: 3636
parseint(x) = parse(Int, x)

function main()
    n = readline() |> chomp |> parseint
    b = map(parseint, readline() |> chomp |> split)
    ans = 0
    for i = 1:n
        if i == 1
            ans += b[1]
        elseif i == n
            ans += b[n-1]
        else
            ans += min(b[i], b[i-1])
        end
    end
    println(ans)
end

main()

Measured memory_bytes: 167088
#include <stdarg.h>
#include <stdio.h>

long long max(int len, ...) {
    long long i, _max, num;
    va_list ap;
    va_start(ap, len);

    _max = va_arg(ap, long long);
    for (i = 1; i < len; i++) {
        num = va_arg(ap, long long);
        if (num > _max)
            _max = num;
    }
    va_end(ap);
    return _max;
}

int main(void) {
    int i, j, N, MAXW, w[110], v[110];
    long long dp[110][100010] = {0LL};
    scanf("%d%d", &N, &MAXW);
    for (i=1;i<=N;i++) {
        scanf("%d%d", &w[i], &v[i]);
    } 

    for (i=1;i<=N;i++) {
    for (j=0;j<=MAXW;j++) {
        if (j - w[i] >= 0) {
            dp[i][j] = max( 2, dp[i-1][j-w[i]] + v[i], dp[i][j] );
        }
        dp[i][j] = max( 2, dp[i-1][j], dp[i][j] );
    }}

    printf("%lld\n", dp[N][MAXW]);
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> b(n - 1);
    rep(i, n - 1) cin >> b[i];
    vector<int> a(n);
    a[0] = b[0];
    for (int i = 1; i <= n - 2; i++)
    {
        a[i] = min(b[i], b[i - 1]);
    }
    a[n - 1] = b[n - 2];
    int ans = 0;
    rep(i, n) ans += a[i];
    cout << ans << endl;

    return 0;
}


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

public class Program
{

	public void Proc()
	{
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int height = inpt[0];
        int width = inpt[1];
        int itemCount = int.Parse(Reader.ReadLine());
        int[] blocks = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int colIdx = 0;
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < height; i++) {
            int[] line = new int[width];
            for (int j = 0; j < width; j++) {
                line[j] = colIdx + 1;
                blocks[colIdx]--;
                if(blocks[colIdx]<=0) {
                    colIdx++;
                }
            }
            if(i%2>0) {
                line = line.Reverse().ToArray();
            }
            ans.AppendLine(string.Join(" ", line));
        }
        Console.Write(ans.ToString());
    }



    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


3 5
5
1 2 3 4 5


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 13396
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        String S = sc.next();
        long sum = 0;
        long R = 0;
        long G = 0;
        long B = 0;
        for(int i = 0; i < N; i++){
            if(S.charAt(i) == 'R'){
                R++;
            }else if(S.charAt(i) == 'G'){
                G++;
            }else{
                B++;
            }
        }
        sum = R*G*B;
        for(int i = 1; i <= N; i++){
            for(int j = i+1; j <= N; j++){
                int k = 2*j-i;
                if(k <= N){
                    if(S.charAt(i-1) == S.charAt(j-1) || 
                        S.charAt(k-1) == S.charAt(j-1) ||  
                        S.charAt(i-1) == S.charAt(k-1)
                    ){
                        
                    }else{
                        sum--;
                    }
                }
            }
        }
        System.out.println(sum);
    }
} 

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

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    int an = a.size()-1;
    int bn = b.size()-1;
    if(a[an]==b[0] && b[bn]==c[0]) cout << "YES";
    else cout << "NO";
}

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

int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;

  int T1 = H1 * 60 + M1;
  int T2 = H2 * 60 + M2;

  cout << T2 - K - T1 << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;
int main()
{
	int r;
	int m=0;
	int z=0;
	int o=0;
	int k=0;
	int t;
	string s;
	cin>>s;	
	
	if(s[0]=='A'&&(s.length()-1)!='C')
	m=1;
	for(int i=2;i<(s.length()-1);i++)
	{	
		if(s[i]=='C')
		z++;
	}
	for(int i=1;i<=26;i++)
	{
		if(s[1]=='A'+i)
		o=1;
		
	}
	for(int i=2;i<=(s.length()-1);i++)
	 	for(int j=1;j<=26;j++)
	 	{
	 		if(s[i]=='A'+j)
	 		k++;
		 }

//	AC:m=1z=1,o=0,k=1
	if(m==1&&z==1&&o==0&&k==1)
	cout<<"AC";
	else cout<<"WA";
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin >> n;
    mp mi;
    rep(i, n){
        int a;
        cin >> a;
        mi[a]++;
    }

    ll ans = 0;
    for (auto& p : mi) {
        if(p.second >= p.first){
            ans += p.second - p.first;
        }else{
            ans += p.second;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4736
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

char c;

int main() {
    fast_io; cout_precision;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

const lint mod=1e9+7;

int main()
{
	int N;
	string S[3];

	cin >> N;
	cin >> S[1] >> S[2];

	lint ans;
	if(S[1][0]==S[2][0])
		ans=3;
	else
		ans=6;
	for(int i=0;;)
	{
		if(S[1][i]==S[2][i])
		{
			if(i==N-1)
				break;
			ans*=2;
			i++;
		}
		else
		{
			if(i==N-2)
				break;
			if(S[1][i+2]!=S[2][i+2])
				ans*=3;	
			i+=2;
		}
		ans%=mod;
	}

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



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

const int N = 1E5 + 10;

int t[N], n, c, k;

int main() {
  scanf("%d%d%d", &n, &c, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", t + i);
  }
  sort(t + 1, t + 1 + n);
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    int pt = i, cnt = 1;
    while(cnt <= c && pt <= n && t[pt] - t[i] <= k) {
      pt++, cnt++;
    }
    ans++;
    i = pt - 1;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ps push_back
#define fi first
#define so second
#define mod 1000000007
int r,s,p;
    string m;
int gain(char a,char b)
{
    if(a=='r' && b=='s') return r;
    if(a=='p' && b=='r') return p;
    if(a=='s' && b=='p') return s;
    return 0;
}

signed main()
{
    int i,j,n,k;
    cin>>n>>k;
    cin>>r>>s>>p>>m;
    int dp[n][3];
    /*for(i=0;i<k;i++)
    {
        mx =
        dp[i][0] = gain('r',m[i]);
        dp[i][1] = gain('p',m[i]);
        dp[i][2] = gain('s',m[i]);
    }*/
    int ans=0;
    for(i=0;i<k;i++)
    {
       for(j=i;j<n;j+=k)
       {
           if(j<k)
           {
               dp[j][0] = gain('r',m[j]);
               dp[j][1] = gain('s',m[j]);
               dp[j][2] = gain('p',m[j]);
           }
           else
           {
               dp[j][0] = max(dp[j-k][1],dp[j-k][2])+gain('r',m[j]);
               dp[j][1] = max(dp[j-k][0],dp[j-k][2])+gain('s',m[j]);
               dp[j][2] = max(dp[j-k][1],dp[j-k][0])+gain('p',m[j]);
           }
       }
       j-=k;
       ans+=max(max(dp[j][1],dp[j][2]),dp[j][0]);
    }
    cout<<ans;
}


Measured memory_bytes: 2816
#include "bits/stdc++.h"


using namespace std;

int gcd(int a,int b){
    if(a<b) swap(a,b);
    if(a%b==0){
        return b;
    }else{
        return gcd(b,a%b);
    }
}


int main(){
    int N,X;
    cin >>N >> X;
    vector<int> a(N);
    vector<int> vec(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }

    for(int i=0;i<N;i++){
        vec[i]=abs(a[i]-X);
    }
    sort(vec.begin(),vec.end());
    int c=vec[0];

    for(int i=0;i<N-1;i++){
        c=gcd(c,vec[i+1]);
    }

    cout << c << endl;


    return 0;
    
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




int main(){
  ll N;
  cin >> N;
  string s;
  ll ac=0,wa=0,tl=0,re=0;
  FOR(i,0,N){
    cin >> s;
    if(s=="AC"){
      ac++;
    }else if(s=="WA"){
      wa++;
    }else if(s=="TLE"){
      tl++;
    }else{
      re++;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tl << endl;
  cout << "RE x " << re << endl;

}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long W = in.nextLong();
		long H = in.nextLong();
		long x = in.nextLong();
		long y = in.nextLong();
		System.out.println(String.format("%.9f", (double) W * H / 2));
		System.out.println(x * 2 == W && y * 2 == H ? 1 : 0);
		in.close();
	}

}

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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<int> a(n << 1);
  range(i, 0, n) {
    cin >> a[i] >> a[i + n];
  }
  vector<int> id(2 * n);
  iota(id.begin(), id.end(), 0);
  sort(id.begin(), id.end(), [&](int x, int y){return a[x] < a[y];});
  long long res = 0;
  range(i, 0, n) res += a[i];
  long long cur = 0;
  range(i, 0, n) cur += a[i + n];
  res = min(res, cur);
  vector<pair<int, int>> p(n, make_pair(-1, -1));
  range(i, 0, 2 * n) {
    if(id[i] < n) p[id[i]].first = i;
    else p[id[i] - n].second = i;
  }
  vector<long long> pref(2 * n + 1);
  range(i, 1, 2 * n + 1) pref[i] = pref[i - 1] + a[id[i - 1]];
  for(auto s : p) {
    int u = s.first, v = s.second;
    int j = n;
    while(true) {
      int c = (u < j) + (v < j);
      if(c == j - n) break;
      j++;
    }
    cur = pref[j];
    if(u < j) cur -= a[id[u]];
    if(v < j) cur -= a[id[v]];
    res = min(res, cur);
  }
  cout << res;
  return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int n;
char resp[7];
char ask(int x){
    printf("%d\n",x);
    fflush(stdout);
    scanf("%s",resp);
    return resp[0];
}
int main(){
    scanf("%d",&n);
    char at_zero=ask(0);
    if(at_zero=='V')return 0;
    int l=0;
    int r=n-1;
    while(l<r){
        int m=(l+r)/2;
        char at_m=ask(m);
        if(at_m=='V')return 0;
        if(m%2==0){
            if(at_m==at_zero)l=m+1;
            else r=m;
        }
        else{
            if(at_m!=at_zero)l=m+1;
            else r=m;
        }
    }
    ask(l);
    return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
long long x;
long long solve(long long x)
{
    if (x==0LL) return 0LL;
    if (x==1LL) return 1LL;
    return 2LL*solve(x/2)+1;
}
int main()
{
    scanf("%lld",&x);
    printf("%lld\n",solve(x));
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {
  int p, l, r;
};

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

void print(int u) {
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if (T[u].p == NIL)
    cout << "root, ";
  else if (T[u].l == NIL)
    cout << "leaf, ";
  else
    cout << "internal node, ";
  cout << "[";
  int i = 0, c;
  for (c = T[u].l; c != NIL; c = T[c].r) {
    if (i) cout << ", ";
    cout << c;
    i++;
  }
  cout << "]" << endl;
}

int rec(int u, int p) {
  D[u] = p;
  if (T[u].r != NIL) rec(T[u].r, p);
  if (T[u].l != NIL) rec(T[u].l, p + 1);
}

int main() {
  int i, j, d, v, c, l, r;
  cin >> n;
  for (int i = 0; i < n; i++) {
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
  }
  for (int i = 0; i < n; i++) {
    cin >> v >> d;
    for (int j = 0; j < d; j++) {
      cin >> c;
      if (j == 0)
        T[v].l = c;
      else
        T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for (int i = 0; i < n; i++) {
    if (T[i].p == NIL) r = i;
  }
  rec(r, 0);

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


Measured memory_bytes: 7708
import copy

n=int(input())

x = list(map(int,input().split()))

x2 = copy.copy(x)

x2.sort()

ans = [x2[n//2-1],x2[n//2]]

for xx in x:
    if xx <= ans[0]:
        print(ans[1])
    else:
        print(ans[0])

Measured memory_bytes: 104404
n = int(input())
A = [int(input()) for i in range(5)]
# L = [0] * 6
# L[0] = n

# ans = 0
# for i in range(5):
#     time = -(-L[i]//A[i])
#     ans += time
#     L[i], L[i+1] = 0, L[i]+L[i+1]
#     print("t", time)
#     print(L)
#     for j in range(i+1, 5):
#         print(j)
#         time = max(0, time-1)
#         saigo = min(A[j-1], L[j]) # 最後の1分でL[j]にたどり着いた人数

#         mem = L[j] - saigo  # L[j+1]に移動し得る人数
        
#         L[j], L[j+1] = saigo + mem - min(mem, time*A[j]), min(mem, time*A[j])+L[j+1]
#         print(L)

    
# print(ans)

time = -(-n//min(A))
print(time + 4)


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>

using int64 = long long;

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

    int64 A, B, C;
    std::cin >> A >> B >> C;

    std::cout << std::min(C, A + B + 1) + B << std::endl;

    return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
    string a, b = "";
    cin >> a >> b;
    string ans = "";
    double n = sqrt(stoi(a + b));
    int buf = n;
    if (n == buf)
    {
        ans = "Yes";
    }
    else
    {
        ans = "No";
    }
    
    COUT(ans);
    return 0;
}

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

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

fn main() {
    let n = read::<usize>();
    let mut ab = vec![(0, 0); n];
    let mut cd = vec![(0, 0); n];
    for i in 0..n {
        ab[i] = (read::<usize>(), read::<usize>());
    }
    for i in 0..n {
        cd[i] = (read::<usize>(), read::<usize>());
    }

    ab.sort();
    cd.sort_by_key(|k| k.1);

    let mut ans = vec![vec![]; n];
    for i in 0..n {
        for j in (0..n).rev() {
            if ab[j].0 < cd[i].0 && ab[j].1 < cd[i].1 {
                if ans[j] == vec![] {
                    ans[j].push(i);
                    break;
                }
            }
        }
    }
    let mut cnt = 0;
    for i in 0..n {
        if ans[i] != vec![] {
            cnt+=1;
        }
    }
    println!("{:?}", cnt);
}

Measured memory_bytes: 4352
children,candy = gets.chomp.split(" ").map(&:to_i)
wa = gets.chomp.split(" ").map(&:to_i)
want = wa.sort
count = 0
point = 0

for i in 0..children - 2
  if count + want[i] <= candy
    point += 1
    count += want[i]
  end
end

if count + want[children - 1] == candy
  point += 1
end


print point


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<int>> C(10 ,vector<int>(10));

    rep(i,10) {
        rep(j,10) {
            cin >> C[i][j];
        }
    }

    int V = 10;

    rep(k,V) {
        rep(i,V){
            rep(j,V) {
                C[i][j] = min(C[i][j], C[i][k]+C[k][j]);
            }
        }
    }

    ll ans = 0;

    rep(i,H*W){
        int a;
        cin >> a;

        if (a!=-1) {
            ans += C[a][1];
        }

    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
//#include <bits/stdc++.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m,k; cin >> n >> m >> k;
    vint a(n),b(m);
    vint as(n+1,0),bs(m+1,0);
    rep(i,n) cin >> a[i], as[i+1]=as[i]+a[i];
    rep(i,m) cin >> b[i], bs[i+1]=bs[i]+b[i];

    int res=0;
    rep(i,n+1){
        if(k-as[i]>0){
            auto itr=upper_bound(all(bs),k-as[i]);
            int tmp=i+distance(bs.begin(),itr)-1;
            chmax(res,tmp);
        }else if(as[i]<=k){
            chmax(res,i);
        }
    }
    cout<<res<<endl;


}

Measured memory_bytes: 9516
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine(ri() ^ 1);
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 27544
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	StringBuilder output = new StringBuilder();
	int n;
	node nodes[];
	int id,left,right;
	
	public void input() {
		n = sc.nextInt();
		nodes = new node[n];
		for(int i=0; i<n; i++) nodes[i] = new node(); 
	}
	
	public void solve() {
		for(int i=0; i<n; i++) {
			id = sc.nextInt();
			//left,rightはidの子
			left = sc.nextInt();
			right = sc.nextInt();
			//左右それぞれ、子があった場合は親にidを設定する
			if(left != -1) {nodes[left].parent = id;}
			if(right != -1) {nodes[right].parent = id;}
			//入力された子を二分木に登録する
			nodes[id].left = left;
			nodes[id].right = right;
			//兄弟の設定
			//left,rightが共に存在していないと兄弟とはいえない
			if(left != -1 && right != -1) {
				nodes[left].sibling = right;
				nodes[right].sibling = left;
			}
		}
		for(int i=0; i<n; i++) {nodes[i].height = height(i);}
		int root = 0;
		while(nodes[root].parent != -1) {root = nodes[root].parent;}
		depth(root,0);
	}
	
	public void depth(int id, int d) {
		int left = nodes[id].left;
		int right = nodes[id].right;
		if(left != -1) depth(left, d+1);
		if(right != -1) depth(right, d+1);
		nodes[id].depth = d;
	}
	public int height(int id) {
		if(id == -1) return -1;
		int left = nodes[id].left;
		int right = nodes[id].right;
		nodes[id].height = Math.max(height(left), height(right)) + 1;
		return nodes[id].height;
	}
	public void output() {
		for(int i=0; i<n; i++) {
			int num = 0;
			if(nodes[i].left != -1) num++;
			if(nodes[i].right != -1) num++;
			//節点番号
			output.append("node ").append(Integer.toString(i));
			//親
			output.append(": parent = ").append(Integer.toString(nodes[i].getParent()));
			//兄弟
			output.append(", sibling = ").append(Integer.toString( nodes[i].sibling ) );
			//子の数
			output.append(", degree = ").append(Integer.toString(num) );
			//深さ
			output.append(", depth = ").append( Integer.toString(nodes[i].depth) );
			//高さ
			output.append(", height = ").append( Integer.toString(nodes[i].height) ).append(", ");
			//節点の種類
			if(nodes[i].getParent() == -1) {output.append("root\n");}
			else if(num == 0) {output.append("leaf\n");}
			else {output.append("internal node\n");}
		}
		System.out.print( output.toString() );
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.solve();
		obj.output();
	}
}

class node{
	int parent; //親
	int left,right; //parentの子
	int sibling; //兄弟
	int depth;
	int height;
	node(){
		parent = -1;
		left = right = sibling = -1;
	}
	public int getParent() {return parent;}
	public void setParent(int parent) {this.parent = parent;}
}



Measured memory_bytes: 26160
#include <cstdio>
#include <list>

using namespace std;

bool check(list<int>& A, list<int>::iterator s, int m) {
    if (s == A.end()) {
        return false;
    }
    if (*s > m) {
        return false;
    }
    if (*s == m) {
        return true;
    }
    bool r = check(A, next(s), m - *s);
    if (r == true) return true;
    r = check(A, next(s), m);
    return r;
}

int
main(void)
{
    int n, q;
    list<int> A;
    scanf("%d", &n);
    for (int i; i<n; i++) {
        int v; scanf("%d", &v);
        A.push_back(v);
    }
    A.sort();

    scanf("%d", &q);
    for (int i; i<q; i++) {
        int m; scanf("%d", &m);
        list<int>::iterator li = A.begin();
        bool f = check(A, li, m);
        if (f)
            printf("yes\n");
        else
            printf("no\n");
        
    }
}


Measured memory_bytes: 2688
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var (
		s string
	)
	fmt.Scan(&s)

	a, _ := strconv.Atoi(string(s[0]))
	b, _ := strconv.Atoi(string(s[1]))
	c, _ := strconv.Atoi(string(s[2]))
	d, _ := strconv.Atoi(string(s[3]))

	if a+b+c+d == 7 {
		fmt.Printf("%d+%d+%d+%d=7\n",a, b, c, d)
	} else if a+b+c-d == 7 {
		fmt.Printf("%d+%d+%d-%d=7\n",a, b, c, d)
	} else if a+b-c-d == 7 {
		fmt.Printf("%d+%d-%d-%d=7\n",a, b, c, d)
	} else if a-b-c-d == 7 {
		fmt.Printf("%d-%d-%d-%d=7\n",a, b, c, d)
	} else if a+b-c+d == 7 {
		fmt.Printf("%d+%d-%d+%d=7\n",a, b, c, d)
	} else if a-b+c+d == 7 {
		fmt.Printf("%d-%d+%d+%d=7\n",a, b, c, d)
	} else if a-b+c-d == 7 {
		fmt.Printf("%d-%d+%d-%d=7\n",a, b, c, d)
	} else if a-b-c+d == 7 {
		fmt.Printf("%d-%d-%d+%d=7\n",a, b, c, d)
	}
}


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

using namespace std;

#define MAX_N 205
#define MAX_R 10
#define MAX_M 50000

#define int long long

int N, M, R;
int RR[MAX_R];
int A[MAX_M], B[MAX_M], C[MAX_M];

int dist[MAX_N][MAX_N];

void input()
{
  for (size_t i = 0; i < MAX_N; i++) {
    for (size_t j = 0; j < MAX_N; j++) {
      dist[i][j] = 114514191981036436;
    }
    dist[i][i] = 0;
  }
  cin >> N >> M >> R;
  for (size_t r = 0; r < R; r++) {
    cin >> RR[r]; RR[r]--;
  }
  for (size_t m = 0; m < M; m++) {
    cin >> A[m] >> B[m] >> C[m]; A[m]--; B[m]--;
    dist[A[m]][B[m]] = dist[B[m]][A[m]] = C[m];
  }
}

bool used[MAX_R];
int H[MAX_R];
int solve(int depth = 0)
{
  if(depth == R) {
    int ret = 0;
    for (int i = 0; i < R-1; i++) {
      ret += dist[H[i]][H[i+1]];
    }
    return ret;
  } else {
    int ret = 114514191936436;
    for (size_t i = 0; i < R; i++) {
      if(!used[i]) {
        used[i] = true;
        H[depth] = RR[i];
        ret = min(ret, solve(depth+1));
        used[i] = false;
      }
    }
    return ret;
  }
}

signed main()
{
  memset(used, 0, sizeof(used));
  input();

  for (size_t k = 0; k < N; k++) {
    for (size_t i = 0; i < N; i++) {
      for (size_t j = 0; j < N; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  cout << solve() << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int H,W,N,row=0,col=0,res;
	cin>>H>>W>>N;
	if(H>W)swap(H,W);
	if(N<=H*W){
		if(N%W==0)res=N/W;
		else res=N/W+1;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
 
using namespace std;
 
#define deb(x) cout << #x << " " << x << endl;
 
typedef long long ll;
const ll mod = 1000000007;
 
#define For(i,n) for(int i=0;i<n;i++)
 
 
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t,i,n,j,sum;
    sum=0;
    cin>>t>>n;
    For(i,n){
        cin>>j;
        sum+=j;
    }
    if(sum>=t)
        cout<<"Yes";
    else 
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstring>
using namespace std;
const int mx = 2020;
int dp[mx][mx],cw[mx][mx],cb[mx][mx],w[mx],b[mx];
char col[10];
int main()
{
    int n,a,cont1=1,cont2=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            dp[i][j]=100000000;
    for(int i=1;i<=2*n;i++){
        scanf("%s",col);
        scanf("%d",&a);
        if(col[0]=='W')
            w[a]=i;
        else
            b[a]=i;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<i;j++)
            if(w[j]>w[i])
                cw[i][0]++;
        for(int j=1;j<=n;j++){
            cw[i][j]=cw[i][j-1];
            if(w[i]<b[j])
                cw[i][j]++;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<i;j++)
            if(b[j]>b[i])
                cb[0][i]++;
        for(int j=1;j<=n;j++){
            cb[j][i]=cb[j-1][i];
            if(b[i]<w[j])
                cb[j][i]++;
        }
    }
    dp[0][0]=0;
    int c1=0,c2=0;
    for(int i=1;i<=n;i++){
        c1+=cw[i][0];
        c2+=cb[0][i];
        dp[i][0]=c1;
        dp[0][i]=c2;
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            dp[i][j]=min(dp[i-1][j]+cw[i][j],dp[i][j-1]+cb[i][j]);
    printf("%d\n",dp[n][n]);
    return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    ll x, y, z; cin >> x >> y >> z;
    x -= z;
    cout << x / (y + z) << endl;
}


Measured memory_bytes: 384