akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

struct edge {
    ll from, to, cost;
};

int main()
{
    int N, M;
    cin >> N >> M;

    vector<edge> G(M);
    vector<ll> dist(N, INF);

    rep(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        G[i] = {a - 1, b - 1, -c};
    }

    dist[0] = 0;
    bool flag = true;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < (int)G.size(); j++) {

            struct edge e = G[j];

            if (dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                if (i == N-1 && e.to == N-1) {
                    cout << "inf" << endl;
                    return 0;
                } 
            }
        }
    }

    cout << -dist[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
h=[int(x) for x in input().split()]
# N=4
# h=[10, 30, 40, 20]
dp=[0]*N
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
    
    tmp1=abs(h[i]-h[i-1])+dp[i-1]
    tmp2=abs(h[i]-h[i-2])+dp[i-2]
    dp[i]=min(tmp1,tmp2)

print(dp[N-1])

Measured memory_bytes: 13980
n = int(input()) 
X = [[int(i) for i in input().split()] for i in range(n)] 

from collections import Counter
def cal_diff(x1, x2):
    return (x1[0] - x2[0], x1[1] - x2[1])

if n != 1:
  hoge = [cal_diff(x1, x2) for x1 in X for x2 in X if x1 != x2]
  minus = Counter(hoge).most_common(1)[0][1]
  ans = n - minus
  print(ans)
elif n == 1:
  print(1)


Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long a[3*n];
  for(int i=0;i<3*n;i++){
    cin>>a[i];
  }
  sort(a,a+(3*n));
  long long sum=0;
  for(int i=3*n-2;i>=n;i-=2){
    sum+=a[i];
  }
  cout<<sum<<endl;
  return(0);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=1;i<=n;++i)
#define debug(i) cout<<#i<<":"<<i<<endl;

struct node
{
    string s;
    int val,id;
}a[105];
bool cmp(node a,node b)
{
    if(a.s==b.s) return a.val>b.val;
    return a.s<b.s;
}
int main()
{
    int n;
    cin>>n;
    rep(i,n) cin>>a[i].s>>a[i].val,a[i].id=i;
    sort(a+1,a+1+n,cmp);
    rep(i,n) cout<<a[i].id<<endl;
}


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

using namespace std;

int main() {
	int n, a;
	cin >> n >> a;
	vector<long long int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	vector< vector<long long int> > dd(2600, vector<long long int>(55, 0));

	for (long long int i = 0; i < n; i++) {
		vector< vector<long long int> > dd2(2600, vector<long long int>(55, 0));
		for (long long int j = 0; j < 2501; j++) {
			for (long long int k = 0; k < 51; k++) {
				if (dd[j][k] > 0 && j+d[i] < 2501) {
					dd2[j][k] += dd[j][k];
					dd2[j+d[i]][k+1] += dd[j][k];
				}
			}
		}
		dd2[d[i]][1]++;
		dd = dd2;
	}
	long long int cc = 0;

	for (int i = 0; i < 2501; i++) {
		for (int j = 0; j < 51; j++) {
			if (i == a*j) {
				cc += dd[i][j];
			}
		}
	}
	cout << cc << endl;
	return 0;
}

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

map<int,int> m;
vector<int> v;

int main(){
    int n,ans;
    cin>>n;
    for(register int i=1;i<=n;++i){
        int x;
        cin>>x;
        if(m[x]==0) v.push_back(x);
        ++m[x];
    }
    for(register int i=0;i<v.size();++i) if(m[v[i]]>=v[i]) ans+=m[v[i]]-v[i]; else ans+=m[v[i]];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N,A,x[50];
  cin>>N>>A;
  for (int i(0);i<N;i++) cin>>x[i];
  for (int i(0);i<N;i++) x[i]-=A;
  ll dp[50][5001]={0};
  dp[0][2499]=1;
  dp[0][x[0]+2499]+=1;
  for (int i(0);i<N-1;i++){
    for (int j(0);j<=5000;j++){
      if (dp[i][j]!=0){
        dp[i+1][j] += dp[i][j];
        dp[i+1][j+x[i+1]] += dp[i][j];
      }
    }
  }
  cout << dp[N-1][2499] -1  << endl;
  return 0;
}



Measured memory_bytes: 2176
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    if(n % 3 == 0){
        map<int, int> m;
        rep(i, n){
            m[a[i]]++;
        }
        vector<int> b;
        for(P p : m){
            if(p.second % (n / 3)){
                cout << "No" << endl;
                return 0;
            }
            rep(i, p.second / (n / 3)){
                b.push_back(p.first);
            }
        }
        if((b[0] == (b[1] ^ b[2])) || (b[1] == (b[2] ^ b[0])) || (b[2] == (b[0] ^ b[1]))){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        return 0;
    }

    rep(i, n){
        if(a[i] != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 5760
A, B, K = [int(x) for x in input().split()]

def main():
    ans = []

    a_end = min(A + K, B + 1)
    for i in range(A, a_end):
        ans.append(i)
    
    b_start = max(A, B - K + 1)
    for i in range(b_start, B + 1):
        ans.append(i)
    ans = sorted(set(ans))
    
    for a in ans:
        print(a)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
from sys import stdin
def stdinput():
    return stdin.readline().strip()

def main():
    A = list(map(convert, stdinput().split()))
    frame = []
    while len(A) > 0:
        frame.append(A.pop())
        while can_calc(frame):
            v1 = frame.pop()
            v2 = frame.pop()
            op = frame.pop()
            if op == '+':
                frame.append(v1 + v2)
            elif op == '-':
                frame.append(v1 - v2)
            elif op == '*':
                frame.append(v1 * v2)
    print(*frame)

OPERANTS = ('+', '-', '*')
def convert(a):
    if a in OPERANTS:
        return a
    else:
        return int(a)

def can_calc(s):
    if len(s) < 3:
        return False
    else:
        return s[-3] in OPERANTS and type(s[-2]) is int and type(s[-1]) is int

if __name__ == '__main__':
    main()


Measured memory_bytes: 5604
#include <stdio.h>
#include <string.h>

int main() {
    char s[4];
    scanf("%s", s);

    if((s[0]==s[1] && s[0]==s[2])
            || (s[1] == s[2] && s[1] == s[3])
            ){
        printf("Yes");
    }else {
        printf("No");        
    }
    
    return 0;
    
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ll n,sum=0,m;
    cin>>n;
    m=n;
    while(n!=0){
        sum+=n%10;
        n/=10;
    }
    if(m%sum==0) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
S = str(input())

s = {
    "SUN":7,
    "MON":1,
    "TUE":2,
    "WED":3,
    "THU":4,
    "FRI":5,
    "SAT":6
}

for k,v in s.items():
    if k == S:
        num = 7 - v 
        if num == 0:
            print(7)
        else:
            print(num)

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, T b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, T b){
    if (b < a){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp
ll Max=-1e9,Min=1e9+1;

int main(){
    int a,b,d,x,y=0,z,m,k,w,l_sum=0,r_sum=0,ans=0;
    string s,t;
    bool count=false,ok=false;
    cin >> s; 
    rep(i,s.size()){
        if(s[i]=='C'){
            count = true;
        }
        else if(s[i]=='F' && count){
            ok = true;
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
    return 0;
}

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

int main(){
    long long int x;
    cin >> x;
    long long int range = 0;
    for(int i=0; i<1e9; i++){
        range += i;
        if(range >= x){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	fss := make([][10]int, n)
	for i := range fss {
		for j := range fss[i] {
			fmt.Scan(&fss[i][j])
		}
	}
	pss := make([][11]int, n)
	for i := range pss {
		for j := range pss[i] {
			fmt.Scan(&pss[i][j])
		}
	}

	max := -1000000009
	for mask := 1; mask < 1<<10; mask++ {
		sum := 0
		for i, fs := range fss {
			cnt := 0
			for j := 0; j < 10; j++ {
				if mask&(1<<uint(j)) > 0 && fs[j] == 1 {
					cnt++
				}
			}
			sum += pss[i][cnt]
		}
		if sum > max {
			max = sum
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 640
import heapq
def main():
    N, M = map(int, input().split())
    A = list(int(x)*-1 for x in input().split())
    heapq.heapify(A)

    for _ in range(M):
        a = (heapq.heappop(A)*-1)//2
        heapq.heappush(A,a*-1)

    print(sum(A)*-1)

if __name__ == '__main__':
    main()

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
int dx[4] = { 0,  0, 1, -1 };
int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int n, m; cin >> n >> m;
	vi a(n), b(n), c(m), d(m);
	rep(i, n) cin >> a[i] >> b[i];
	rep(i, m) cin >> c[i] >> d[i];

	rep(i, n) {
		ll min_dis = inf;
		int key = -1;

		rep(j, m) {
			ll dis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (min_dis > dis) {
				min_dis = dis;
				key = j + 1;
			}
		}
		cout << key << endl;
	}
}


Measured memory_bytes: 256
s = input()

def get_unbalanced(s):
    for i in range(len(s) - 1):
        for j in range(i + 1, i + 3):
            if j < len(s) and s[i] == s[j]:
                return (i + 1, j + 1)
    return (-1, -1)


print(*get_unbalanced(s))


Measured memory_bytes: 71592
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,x;cin >> n >> x;
  vector<ll> v(n);
  rep(i,n){
    cin >> v[i];
  }
  ll ans = 0;
  if(v[0] > x){
    ans = v[0]-x;
    v[0] = x;
  }
  rep(i,n-1){
    if(v[i]+v[i+1]>x){
      ans += v[i+1] - (x-v[i]);
      v[i+1] = x - v[i];
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

void solve()
{
	string s;
	cin >> s;
	ll c = 0;
	ll ans = 0;
	for (int i = 0; i < s.length(); ++i)
	{
		if (s[i] == 'R')c++;
		else {c = 0;}
		ans = max(ans, c);
	}
	ans = max(ans, c);
	cout << ans << endl;
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin >> T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

ll mine[51][51];
char ch[51][51];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll H,W;
  cin >> H >> W;
  rep(i,H){
    string a; cin >> a;
    rep(j,a.size()){
      ch[i][j]=a[j];
    }
  }
  rep(i,H)rep(j,W){
    if(ch[i][j]=='#') {
      mine[i][j]=100;
      FOR(m,-1,2)FOR(n,-1,2){
	if(i+m<0)continue;
	if(j+n<0)continue;
	if(i+m > 50) continue;
	if(j+n>50)continue;
	mine[i+m][j+n]++;
      }
    }
    
  }

  rep(i,H){
    rep(j,W){
      if(mine[i][j]>90)cout << '#' ;
      else cout << mine[i][j] ;
    }
    cout << endl;
  }
  

  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll N;
vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    if (a[i] % 2 == 0 && !(a[i] % 3 == 0 || a[i] % 5 ==0)) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, Q, q[21234], a[21234], b[21234];
char c[21234];
string S;
vector<set<int>> pos('z' - 'a' + 1);

int main() {

	cin >> N >> S >> Q;
	rep(i, Q) {
		cin >> q[i];
		if (q[i] == 1) cin >> a[i] >> c[i];
		if (q[i] == 2) cin >> a[i] >> b[i];
	}

	rep(i, S.size()) {
		pos[S[i] - 'a'].insert(i);
	}

	rep(i, Q) {
		if (q[i] == 1) {
			pos[S[a[i] - 1] - 'a'].erase(pos[S[a[i] - 1] - 'a'].find(a[i] - 1));
			pos[c[i] - 'a'].insert(a[i] - 1);
			S[a[i] - 1] = c[i];
		}
		else {
			int cnt = 0;
			rep(t, 'z' - 'a' + 1) {
				auto itr = pos[t].lower_bound(a[i] - 1);
				if (itr != pos[t].end() && *itr < b[i]) cnt++;
			}
			cout << cnt << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 24452
var n,i,s:Longint;a:array[1..100000]of Integer;b:array[1..100000]of boolean;
begin
	read(n);
	for i:=1 to n do read(a[i]);
	s:=1;
	b[1]:=true;
	for i:=1 to n do begin
		s:=a[s];
		if b[s] then break;
		b[s]:=true;
		if s=2 then begin
			writeln(i);
			exit;
		end;
	end;
	writeln(-1);
end.

Measured memory_bytes: 640
import collections
from math import factorial
A = int(input())
listA = []
total = 0
listB = {}
for i in range(A):
    B = list(input())
    B.sort()
    listA.append("".join(B))
for i in listA:
    if i in listB:
        listB[i] += 1
        total += listB[i]-1
    else:
        listB[i] = 1
print(total)

Measured memory_bytes: 19728
#include <iostream>

using namespace std;

int main()
{
    char str[4];
    bool flag = true;
    cin >> str;

    for (int i = 0; i < 3; i++)
    {
        if (str[i] == str[i + 1]){
            flag = false;
            break;
        }
    }
    if (flag)
        cout << "Good" << endl;
    else
        cout << "Bad" << endl;
}

Measured memory_bytes: 256
program sample
	implicit none
    integer :: i,j,k,l,m
    integer(8) :: x,y,z
    real(8) :: a(4),b(4)
    
    read(*,*) x,y,z
    
    if (x<=z .and. z<=y) then
    	write(*,*) 'Yes'
    else if (z<=x .and. y<=z) then
    	write(*,*) 'Yes'
    else
    	write(*,*) 'No'
    end if
    stop
end program sample

Measured memory_bytes: 2768
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	double x, y, z = 0;
	ll memo2[10004] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);
	cin >> a;
	for (int i = 0; i < a; i++)
	{
		cin >> x;
		cin >> s;
		if (s == "JPY")
		{
			z += x;
		}
		else
		{
			z += x*380000.0;
		}

	}
	//cout << z << endl;

	cout << setprecision(15) << z << endl;

	//cout << ans << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 256
n = int(input())
a = [int(s) for s in input().split()]

a.sort()
alice = 0
bob = 0
for i in range(n):
    if i % 2 == 0:
        alice += a[n-1-i]
    elif i % 2 == 1:
        bob += a[n-1-i]

print(alice - bob)


Measured memory_bytes: 61880
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
//# define M_PI           3.14159265358979323846264338327950288

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

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

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.

int main() {
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
	int n;
	cin>>n;
	LL sum = 0;
	int ma = 0;
	int a;
	rep(i,0,n){
		cin>>a;
		sum += a;
		ma = max(ma, a);
	}
	sum -= ma/2;
	cout<<sum;
  	return 0;
}

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

using namespace std;

using int64 = long long;

// Represents a line y = a x + b.
struct Line {
  int64 a, b;
};

// Supports two queries.
// AddLine():
//   Adds ax + b to the set. It's assumed that a is strictly decreasing.
// GetMin():
//   Gets min { a x + b } for a given x. It's assumed that x is strictly
//   increasing.
class ConvexHullTrickMonotic {
 private:
  deque<Line> lines;

  // Returns ture if l2 doesn't take a minimum for {l1, l2, l3} on any x.
  // It's assumed that l1.a > l2.a > l3.a.
  bool Check(const Line& l1, const Line& l2, const Line& l3) {
    return (l2.a - l1.a) * (l3.b - l2.b) >= (l2.b - l1.b) * (l3.a - l2.a);
  }

  int64 F(const Line& l1, int64 x) {
    return l1.a * x + l1.b;
  }

 public:
  void AddLine(const Line& query_line) {
    while (lines.size() >= 2 &&
        Check(lines[lines.size() - 2], lines.back(), query_line)) {
      lines.pop_back();
    }
    lines.push_back(query_line);
  }

  int64 GetMin(int64 x) {
    if (lines.empty()) return INT64_MIN;
    while (lines.size() >= 2 && F(lines[0], x) >= F(lines[1], x)) {
      lines.pop_front();
    }
    return F(lines[0], x);
  }
};

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

  int n;
  int64 c;
  cin >> n >> c;
  vector<int64> hs(n);
  for (int i = 0; i < n; i++) cin >> hs[i];
  
  ConvexHullTrickMonotic cht;
  vector<int64> dp(n);
  cht.AddLine(Line({-2 * hs[0], hs[0] * hs[0] + dp[0]}));
  for (int i = 1; i < n; i++) {
    int64 min_cost = cht.GetMin(hs[i]);
    int64 fixed_cost = hs[i] * hs[i] + c;
    dp[i] = min_cost + fixed_cost;
    cht.AddLine(Line({-2 * hs[i], hs[i] * hs[i] + dp[i]}));
  }
  cout << dp[n - 1] << endl;
}


Measured memory_bytes: 5632
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a==1&&b==1&&c==0||a==0&&b==0&&c==1){
printf ("Open\n");
}
else{
printf ("Close\n");
}
return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <iomanip>
using namespace std;
typedef long long ll;
int INF=1<<29;

int main(){
    ios::sync_with_stdio(false);
	double N,tmp=0,sum=0;
	cin>>N;
	vector<double> t(N),v(N);
	for(int i=0;i<N;i++){
		cin>>t[i];
		sum+=t[i];
		t[i]+=tmp;
		tmp=t[i];
	}
	for(int i=0;i<N;i++) cin>>v[i];
	vector<double> table(sum*2+1);

	//table初期化
	for(double i=1;i<=sum;i++) table[i]=(i-1)*1+0.5;
	for(double i=sum*2;i>=sum+1;i--) table[i]=(sum*2-i)*1+0.5;

	//本題
	for(int i=0;i<N;i++){
		if(i!=0){
			//基
			for(double j=t[i-1]*2+1;j<=t[i]*2;j++){
				table[j]=min(table[j],2*v[i]);
			}
			//左
			for(double j=t[i-1]*2;j>=1;j--){
				table[j]=min(table[j],2*v[i]+(t[i-1]*2-j)*1+0.5);
			}
			//右
			for(double j=t[i]*2+1;j<=table.size();j++){
				table[j]=min(table[j],2*v[i]+(j-(t[i]*2+1))*1+0.5);
			}
		}else if(i==0){
			for(double j=1;j<=t[i]*2;j++){
				table[j]=min(table[j],2*v[i]);
			}
			//右
			for(double j=t[i]*2+1;j<=table.size();j++){
				table[j]=min(table[j],2*v[i]+(j-(t[i]*2+1))*1+0.5);
			}
		}
	}

	double ans=0;
	for(int i=1;i<table.size();i++){
		ans+=table[i];
	}
	ans/=4;
	cout<<fixed<<ans;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, k: i64,
        a: [i64; n],
    }
    let mut dp = vec![0; 1 << n];
    for bits in 0..1 << n {
        let mut sum = 0;
        for i in 0..n {
            if (bits & 1 << i) != 0 {
                sum += a[i];
            }
        }
        dp[bits] = if sum == k { 1 } else { 0 };
    }
    for i in 0..n {
        for bits in 0..1 << n {
            if (bits & 1 << i) != 0 {
                continue;
            }
            dp[bits | 1 << i] += dp[bits];
        }
    }
    let mut mi = n;
    for bits in 0usize..1 << n {
        let bc = n - bits.count_ones() as usize;
        if dp[bits] == 0 {
            mi = min(mi, bc);
        }
    }
    puts!("{}\n", mi);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 5124
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#define ll long long 
#define fr(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define inf (1<<31)
#define xx first
#define yy second

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	int h,w;
	cin>>h>>w;
	char a[h][w];
	fr(i,h){
	    fr(j,w){
	        cin>>a[i][j]    ;
	    }
	}
	int x,y,f=1;
	x=0,y=0;
	a[0][0]='.';
	while(f && !(x==h-1 && y==w-1)){
	    if(x==h-1){
	        a[x][y+1]='.';
	        y++;
	    }    
	    else if(y==w-1){
	        a[x+1][y]='.';
	        x++;
	    }    
	    else{
	        if(a[x+1][y]=='#'){
	            a[x+1][y]='.'; 
	            x++;
	        }
	        else if(a[x][y+1]=='#'){
	             a[x][y+1]='.';
	             y++;
	        }
	        else
	            f--;
	       
	    }
//	    cout<<x<<' '<<y;
	}    
	int l=0;    
	    fr(i,h){
	        fr(j,w){
	            if(a[i][j]!='.'){
	             //   cout<<a[i][j];
	                l--;
	            }
	           // cout<<endl;    
	        }
	    }
	 if(l)
	    cout<<"Impossible";
	 else
	    cout<<"Possible";
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] v = new int[123456];
        for(int i = 0;i < 123456;i++){
            v[i] = 1;
        }
        int p = 3;
        while(true){
            if(p*p > 246912){
                break;
            }else{
                if(v[(p-1)/2] == 0){
                    p += 2;
                }else{
                    int t = p*p;
                    while(t < 246912){
                        v[(t-1)/2] = 0;
                        t += 2*p;
                    }
                    p += 2;
                }
            }
        }
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}else if(n == 1){
				System.out.println(1);
				continue;
			}
			int count = 0;
			int s = (n%2 == 0)?n/2:(n+1)/2;
			for(int i = s;i < n;i++){
				if(v[i] == 1){
					count++;
				}
			}
			System.out.println(count);
		}
	}
}

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

int main(){
    int n, m;
    cin >> n >> m;
    int64_t h[n];
    int a[n];
    int b[n];
    for(int i=0; i<n; i++){
        cin >> h[i];
    }
    int dame[n];
    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i];

        if(h[a[i]-1] <= h[b[i]-1]){
            dame[a[i]-1] = 1;
        }
        if(h[a[i]-1] >= h[b[i]-1]){
            dame[b[i]-1] = 1;
        }
    }

    int p=0;

    for(int i=0; i<n; i++){
        if(dame[i]!=1) p++;
        //cout << dame[i] << endl;

    }

    cout << p << endl;

}

Measured memory_bytes: 5576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * メインクラス
 *
 */
public class Main {

	/**
	 * メインメソッド
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {

		// ============================================================
		// 標準入力を変数に設定
		// ============================================================

		// 標準入力を取得
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		long s = Integer.parseInt(br.readLine());

		List<Long> sums = new ArrayList<Long>();

		boolean ok = true;
		long i = 0;
		sums.add(s);
		while (ok) {

			i++;

			s = calc(s, i);

			if (sums.contains(s)) {
				System.out.println(i + 1);
				return;
			} else {
				sums.add(s);
			}

		}

	}

	static long calc(long num, long i) {

		if (num % 2 == 0) {
			return num / 2;

		} else {
			return num * 3 + 1;
		}

	}
}

Measured memory_bytes: 23252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] strs = br.readLine().split(" ");
		int[] inputData = new int[n];
		for (int i = 0; i < n; i++) {
			inputData[i] = Integer.parseInt(strs[i]);
		}
		int swapCnt = bubbleSort(inputData, n);
		printArray(inputData);
		System.out.println(swapCnt);

	}

	public static int bubbleSort(int[] A, int N) {
		int swapCnt = 0;
		int flag = 1;
		while (flag == 1) {
			flag = 0;
			for (int i = N - 1; i > 0; i--) {
				if (A[i] < A[i - 1] ) {
					int temp = A[i];
					A[i] = A[i - 1];
					A[i - 1] = temp;
					swapCnt++;
					flag = 1;
				}
			}
		}
		return swapCnt;
	}

	public static void printArray(int[] target) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < target.length; i++) {
			sb.append(target[i]);
			if (i < target.length - 1) {
				sb.append(" ");
			}
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 24412
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979

//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    int N;
    cin >> N;
    int a = 6, b = 9;
    vector<int> D = {1};
    while(a <= N){
        D.push_back(a);
        a *= 6;
    }
    while(b <= N){
        D.push_back(b);
        b *= 9;
    }
    int s = D.size();
    vector<vector<int>> dp(s + 10, vector<int>(N + 10, INF));
    rep(j, 0, N + 1) dp.at(0).at(j) = j;
    rep(i, 0, s - 1){
        rep(n, 0, N + 1){
            dp.at(i + 1).at(n) = min(dp.at(i).at(n), dp.at(i + 1).at(n));
            if (n >= D.at(i + 1)){
                dp.at(i + 1).at(n) = min(dp.at(i + 1).at(n - D.at(i + 1)) + 1, dp.at(i + 1).at(n));
            }
        }
    }
    cout << dp.at(s - 1).at(N) << endl;
}

Measured memory_bytes: 9216
import sys

n = int(input())
s = input()
e = [0] * n
w = [0] * (n + 1)
e[0] = 1 if s[0] == 'E' else 0
w[0] = 0
w[1] = 1 if s[0] == 'W' else 0
for i in range(1, n):
    if s[i] == 'E':
        e[i] = e[i - 1] + 1
        w[i + 1] = w[i]
    else:
        e[i] = e[i - 1]
        w[i + 1] = w[i] + 1
min = sys.maxsize
for i in range(n):
    if min > e[-1] - e[i] + w[i]:
        min = e[-1] - e[i] + w[i]
print(min)

Measured memory_bytes: 17552
def lucas(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    if table[n-1] != 0:
        t1 = table[n-1]
    else:
        table[n-1] = lucas(n-1)
        t1 = table[n-1]
    if table[n-2] != 0:
        t2 = table[n-2]
    else:
        table[n-2] = lucas(n-2)
        t2 = table[n-2]
    return t1 + t2


def main():
    n = int(input())
    print(lucas(n))
    

if __name__ == '__main__':
    table = [0 for _ in range(86)]
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

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

  vector<int> p(n,0);
  for(int i=0; i<n; i++){
    cin >> p[i];
  }

  int ans = 0;
  for(int i=1; i<n-1; i++){
    if( p[i-1] < p[i] && p[i] < p[i+1] ) ans += 1;
    if( p[i-1] > p[i] && p[i] > p[i+1] ) ans += 1;
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	a,b = readline() |> split |> parseMap
	if a+b==15
		println("+")
	elseif a*b == 15
		println("*")
	else
		println("x")
	end
end

main()

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

#define PI acos(-1)
#define int long long int
#define pb push_back
#define mp make_pair
#define pi pair<string, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 100001
#define MAXL 20
#define mod 998244353

signed main()
{
  int x, n;
  cin >> x >> n;
  set<int> s;
  for (int i = 0; i < n; i++)
  {
    int k;
    cin >> k;
    s.insert(k);
  }
  int l = x, r = x;
  while (1)
  {
    if (s.find(l) == s.end())
    {
      cout << l << endl;
      return 0;
    }
    if (s.find(r) == s.end())
    {
      cout << r << endl;
      return 0;
    }
    r++;
    l--;
  }
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#define N 40
#define NILL -1

typedef struct{
  int p;
  int l;
  int r;
}Node;
  
Node A[N];
int n,B[N],C[N];

  
int rec(int x,int y){
  B[x] = y;
  if(A[x].r != NILL) rec(A[x].r,y + 1);
  if(A[x].l != NILL) rec(A[x].l,y + 1);
}

int Getb(int x){
  if(A[x].p== NILL) return NILL;
  if(A[A[x].p].l!=x&&A[A[x].p].l!=NILL)
    return A[A[x].p].l;
  if(A[A[x].p].r!=x&&A[A[x].p].r!=NILL)
    return A[A[x].p].r;
  return -1;
}

int Geth(int x){
  int a=0,b=0;
  if(A[x].l != NILL) a=Geth(A[x].l)+1;
  if(A[x].r != NILL) b=Geth(A[x].r)+1;
  return C[x]=(a>b ? a : b);
}

  
  

int main(){
  int i,j,d,v,c,l,r,n,op;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    A[i].p = A[i].l = A[i].r = NILL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&d,&op);
    A[v].l = d;
    A[v].r = op;
    if(d != -1) A[d].p=v;
    if(op != -1) A[op].p=v;
  }
  for(i=0;i<n;i++){
    if(A[i].p == -1) r=i;
  }

  rec(r,0);
  

  for(i=0;i<n;i++){
    int deg=0;
    if(A[i].l!=-1) deg++;
    if(A[i].r!=-1) deg++;
    
    Geth(i);
 
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,A[i].p,Getb(i),deg,B[i],C[i]);
    if(A[i].p == -1) printf("root\n");
    else if(A[i].l == -1 && A[i].r == -1 ) printf("leaf\n");
    else printf("internal node\n");

  }
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <queue>
#include <cmath>

using namespace std;

struct vertex{
	double x;
	double y;
};

void printqueue(queue<vertex*> q){
	while (!q.empty()){
		cout << "(" << q.front()->x << "," << q.front()->y << "), ";
		q.pop();
	}
	cout << endl;
}

void printans(queue<vertex*> q){
	while (!q.empty()){
		cout << q.front()->x << " " << q.front()->y << endl;
		q.pop();
	}
}

int pow(int n, int p){
	int t = 1;
	for (int i=0; i<p; i++){
		t *= n;
	}
	return t;
}

void fractal(vertex* v1, vertex* v2, vertex* v3, vertex* left, vertex* right){
	double x1;
	double x2;
	double y1;
	double y2;
	x1 = left->x;
	y1 = left->y;
	x2 = right->x;
	y2 = right->y;

	v1->x = x1*2/3 + x2/3;
	v1->y = y1*2/3 + y2/3;

	v3->x = x1/3 + x2*2/3;
	v3->y = y1/3 + y2*2/3;

	v2->x = (x1+x2)/2 + sqrt(3)/6 * (y1-y2);
	v2->y = (y1+y2)/2 + sqrt(3)/6 * (x2-x1);
}

int main(){

	int n;
	cin >> n;

	queue<vertex*> q;
	vertex* tmp;
	tmp = new vertex;
	tmp->x = 0;
	tmp->y = 0;
	q.push(tmp);

	tmp = new vertex;
	tmp->x = 100;
	tmp->y = 0;
	q.push(tmp);

	vertex* tmp1;
	vertex* tmp2;
	vertex* v1;
	vertex* v2;
	vertex* v3;

	for (int i=0; i<n; i++){
		tmp1 = q.front();
		q.pop();
		for (int j=0; j<pow(4,i); j++){
			tmp2 = q.front();
			q.pop();
			v1 = new vertex;
			v2 = new vertex;
			v3 = new vertex;
			fractal(v1,v2,v3,tmp1,tmp2);
			q.push(tmp1);
			q.push(v1);
			q.push(v2);
			q.push(v3);
			tmp1 = tmp2;
		}
		q.push(tmp2);
	}

	printans(q);


	return 0;
}


Measured memory_bytes: 3400
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n;
deque<int> ans;

int main()
{
	cin >> n;
	for (int i = 0;i < n;i++) {
		int a;
		cin >> a;

		if (i % 2) {
			ans.push_front(a);
		}
		else {
			ans.push_back(a);
		}
	}

	if (n % 2) {
		deque<int>::reverse_iterator ritr;
		for (ritr = ans.rbegin();ritr != ans.rend();ritr++) {
			cout << *ritr << " ";
		}
		cout << endl;
	}
	else {
		deque<int>::iterator itr;
		for (itr = ans.begin();itr != ans.end();itr++) {
			cout << *itr << " ";
		}
		cout << endl;
	}

	return 0;
}


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

using namespace std;

class Solution {
public:
	void solve() {
		string s;
		cin >> s;
		int Q;
		cin >> Q;
		int rev = 0;
		string s1, s2;
		for(int q=0; q < Q; q++){
			int t;
			cin >> t;
			if(t == 1){
				rev = 1-rev;
			}else{
				int k;
				string a;
				cin >> k >> a;
				k--;
				if(k == rev)s1 += a;
				else s2 += a;
			}
		}
		reverse(s1.begin(), s1.end());
		s = s1 + s + s2;
		if(rev)reverse(s.begin(), s.end());
		cout << s << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<math.h>
using namespace std ;
using ll = long long ;

ll sum(ll a,ll b){
    if(b==0||b==1) return -1 ;
    ll sum = 0 ;
    while(a>0){
        sum += a%b ;
        a /= b ;
    }
    return sum ;
}

int main(){
    ll n,s ;
    cin >> n >> s ;
    if(n==s){
        cout << n+1 << endl ;
        return 0 ;
    }
    for(ll i=2;i<=sqrt(n);i++){
        if(sum(n,i)==s){
            cout << i << endl ;
            return 0 ;
        }
    }
    for(ll i=sqrt(n);i>0;i--){
        if(sum(n,(n-s)/i+1)==s){
            cout << (n-s)/i+1 << endl ;
            return 0 ;
        }
    }
    cout << -1 << endl ;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  string atc, s, con;
  cin >> atc >> s >> con;
  
  cout << 'A' << s.at(0) << 'C' << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int[] v = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		for(int i=0;i<m;i++) {
			int b = sc.nextInt();
			for(int j=0;j<n;j++) {
				if (a[j] <= b) {
					v[j]++;
					break;
				}
			}
		}
		int maxi = -1;
		int max = 0;
		for(int i=0;i<n;i++) {
			if (v[i] > max) {
				maxi = i;
				max = v[i];
			}
		}
		System.out.println(maxi + 1);
	}

}

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

int main () {
  ll x;
  cin >> x;
  ll money = 100;
  int ans = 0;
  while(money < x) {
    money *= 1.01;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;

  double MAX = -INF;
  int answ = 0;
  int anss = 0;
  REP(i,31){
    int water = i*100;
    REP(j,i*E+1){
      int sugar = j;
      if(water+sugar>F) break;
      //Ax+By=i Cz+Dw=j
      int flag = 0;
      REP(k,i/A+2){
        if((i-A*k)%B==0&&(i-A*k)/B>=0){
          flag=1;
        }
      }
      int flag2 = 0;
      REP(k,j/C+2){
        if((j-C*k)%D==0&&(j-C*k)/D>=0){
          flag2=1;
        }
      }
      if(flag==1&&flag2==1){
        if(MAX*(i+j)<j){
          double z = i+j;
          MAX = j/z;
          answ = i*100;
          anss = j;
        }
      }
    }
  }

  cout << answ+anss << " " << anss << endl;
} 

Measured memory_bytes: 3628