akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;



int main() {
  int N; cin >> N;
  vector<int>as;
  for (int i = 0; i < N-1; ++i) {
    int a; cin >> a;
    as.push_back(a);
  }

  //奇数　表か　表の個数
  int dp[2][2][10001];
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      for (int k = 0; k < 10000; ++k) {
        dp[i][j][k] = 99999;
      }
    }
  }
  dp[0][1][1] =0;

  for (int i = 0; i < N-1; ++i) {
    int from = i % 2;
    int to = !from;
    for (int j = 0; j < 2; ++j) {
      for (int k = 0; k < 10000; ++k) {
        dp[to][j][k] = 99999;
      }
    }
    for (int omote = 0; omote < 2; ++omote) {
      for (int k = 0; k < 10000; ++k) {
        if (omote) {
          dp[to][omote][k + 1] = min(dp[to][omote][k + 1], dp[from][omote][k]);
          dp[to][!omote][k] = min(dp[to][!omote][k], dp[from][omote][k] + as[i]);
        }
        else {
          dp[to][omote][k] = min(dp[to][omote][k], dp[from][omote][k]);
          dp[to][!omote][k + 1] = min(dp[to][!omote][k+1], dp[from][omote][k] + as[i]);
        }
      }
    }
  }
  int ans = min(dp[1][1][N/2],dp[1][0][N / 2]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3408
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

struct node {
    int val;
    node *l, *r;
    explicit node(int x) : val(x), l(nullptr), r(nullptr) {};
};
using state = string::const_iterator;

node* getnode (state &cur){
    node* ans = nullptr;
    if(*cur == '('){
        ans = new node(0);
        cur++;
        ans->l = getnode(cur);
        cur++;
        cur++;
        while(isdigit(*cur)){
            ans->val = (ans->val)*10 + *cur - '0';
            cur++;
        }
        cur++;
        cur++;
        ans->r = getnode(cur);
        cur++;
    }
    return ans;
}

void printnode(node* A, node* B){
    printf("(");
    if(A->l != nullptr && B->l != nullptr){
        printnode(A->l, B->l);
    }
    printf(")[");
    printf("%d", A->val+B->val);
    printf("](");
    if(A->r != nullptr && B->r != nullptr){
        printnode(A->r, B->r);
    }
    printf(")");
}

int main() {
    string s, t;
    cin >> s >> t;
    state a = s.begin(), b = t.begin();
    auto A = getnode(a), B = getnode(b);
    printnode(A, B);
    puts("");
    return 0;
}


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

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

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

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

int main()
{
  while(cin >> N, N){
    int x = 0;
    int y = 0;
    vii vec(N);
    vec[0] = mp(0, 0);
    rrep(i, 1, N){
      cin >> n >> d;
      vec[i] = mp(vec[n].first + dx[d], vec[n].second + dy[d]);
    }
    int lx = INF, rx = -INF;
    int ly = INF, ry = -INF;
    vrep(v, vec){
      minup(lx, v->first);  minup(ly, v->second);
      maxup(rx, v->first);  maxup(ry, v->second);
   }
    cout << rx - lx + 1 << ' ' << ry - ly + 1 << endl;
  }


  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <ctime>
#include <stdio.h>
#include <memory.h>
#include <sstream>
int main()
{
	int n;
	std::cin >> n;
	std::vector <int> v (n);
	for (int i = 0; i < n; i++)
		std::cin >> v[i];
	long long cnt = 0;
	for (int i = 0; i < n; i++)
	{
		cnt += v[i] / 2;
		v[i] %= 2;
		if (v[i])
		{
			int j = i + 1;
			if (j < n)
			{
				if (v[j])
				{
					v[j]--;
					v[i]--;
					cnt++;
				}
			}
		}
	}
	std::cout << cnt;
}

Measured memory_bytes: 640
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const ll INF=100000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
ll dat[30][200001]={};
map<ll,ll>mp;
int n;

void add(int c){
	dat[0][c]++;
	int s=1,h=c/2;
	while(s<=29){
		dat[s][h]=dat[s-1][h*2]+dat[s-1][h*2+1];
		s++;
		h/=2;
	}
}
ll sum(int h){
	int r=dat[0][h];
	int s=0;
	while(h>0){
		if(h%2>0)r+=dat[s][h-1];
		else r+=dat[s+1][(h-1)/2];
		h=(h-1)/2;
		++s;
	}
	return r;
}
ll b[200001]={};
ll c[200001]={};
int main() {
	ll n,k,a;
	cin>>n>>k;
	ll ans=0;
	cin>>a;
	b[0]=a-k;
	c[0]=a-k;
	rep(i,1,n){
		cin>>a;
		b[i]=b[i-1]+a-k;
		c[i]=c[i-1]+a-k;
	}
	sort(c,c+n);
	rep(i,0,n){
//		cout<<c[i]<<endl;
		mp[c[i]]=i;
	}
	ll d1;
	rep(i,0,n){
		d1=mp[b[i]];
		if(b[i]>=0)++ans;
		ans+=sum(d1);
//		cout<<b[i]<<" "<<ans<<endl;
		add(d1);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 61824
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long a = Long.parseLong(in.next());
            long b = Long.parseLong(in.next());

            long k = (a * a - b * b) / (2 * (a - b));
            if (Math.abs(a - k) == Math.abs(b - k)) {
                // 出力
                out.println(k);
            } else {
                out.println("IMPOSSIBLE");
            }

        }

    }
}



Measured memory_bytes: 35792
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int x,y,z; 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>x>>y>>z;
	cout<<z<<' '<<x<<' '<<y;
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	double x[n];
	int u[n];
	char temp[4];
	double ans=0;
	for(int i = 0;i<n;i++){
		cin >> x[i] >> temp;
		if(temp[0]=='J'){
			u[i]=1;
		}else{
			u[i]= 380000;
		}
		ans += (x[i]*u[i]);
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
const ll mod = 1e9 + 7, MAX = 1e5 + 5, INF = 1 << 60;

vector<ll>fac(MAX), finv(MAX), inv(MAX), a(100005);

ll combination(ll n, ll k) {
	if (n < k || n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
	ll n, v; cin >> n;
	map<ll, ll>mp;
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i]; mp[a[i]]++;
		if (mp[a[i]] == 2)v = a[i];
	}

	ll L = -1, R;
	for (int i = 0; i < n + 1; i++) {
		if (a[i] == v && L == -1)L = i;
		else if (a[i] == v)R = i;
	}
	fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
	for (ll i = 0; i < n + 1; i++) {
		ll k = combination(L + (n - R), i); ll p = (combination(n + 1, i + 1) - k + mod) % mod;
		cout << p << endl;
	}

	return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int ans = 0;
  if(a < b){
    int temp = b;
    b = a;
    a = temp;
  }
  ans += a;
  ans += max(a-1,b);
  cout << ans << endl;
}
    

Measured memory_bytes: 256
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################


a,b,c,d = map(int , input().split())
print(max([a*c,b*c,a*d,b*d]))







'''
# Wrap solution for more recursion depth
#submit as python3
import collections,sys,threading
sys.setrecursionlimit(10**9)
threading.stack_size(10**8)



threading.Thread(target=solve).start()
'''


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

int main()
{
    int n;

    while( cin >> n )
    {
        if( n == 0 )
            break;
        
        int p, sum = 0;
        for( int i = 0; i < 9; i++ )
        {
            cin >> p;
            sum += p;
        }
        cout << n - sum << endl;
    }
    return 0;
}


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

#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF=1e15;
const int MOD=1e9+7;
const int N=2e5+10;

signed main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    int t = 1;
//    cin >> t;
    while (t--) {
        int n,k;
        cin>>n>>k;
        int ans=0;
        for(int i=k;i<=n+1;i++) {
            int l=(i*(i-1))/2;
            int r=(i*(2*n-i+1))/2;
            ans=(ans%MOD+(r-l+1+MOD)%MOD)%MOD;
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC137B
{
    class Program
    {
        static void Main(string[] args)
        {
            var items = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToArray();
            var blackStoneNum = items[0];
            var blackStonePos = items[1];

            var min = blackStonePos - blackStoneNum + 1;
            var max = blackStonePos + blackStoneNum - 1;
            Console.WriteLine(string.Join(" ", Enumerable.Range(min, max - min + 1)));
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl
#define P pair<lint,lint>

int main() {
	lint N;
	string S;
	cin >> N >> S;
	lint cnt = 0;
	lint ans = 0;
	rep(i, N) {
		if (S[i] == 'I') {
			cnt++;
		}
		else {
			cnt--;
		}
		ans = max(ans, cnt);
	}
	cout << ans << enld;
}


Measured memory_bytes: 3588
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String,Integer> countMap = new HashMap<>();
        for (int i = 0; i < N ; i++) {
            char[] chars=sc.next().toCharArray();
            Arrays.sort(chars);
            String str = new String(chars);
            if(!countMap.containsKey(str)){
                countMap.put(str,1);
            }else{
                countMap.put(str,countMap.get(str)+1);
            }
        }

        long ans = 0 ;
        for (int count: countMap.values()) {
            ans += (long) count * (count -1) /2;
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 53852
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int main(){
	int N;
	cin >> N;
	int W[100];
	for(int i=0; i<N; i++) cin >> W[i];
	int ans = INT_MAX;
	for(int i=0; i<N-1; i++){
		int sum = 0;
		for(int j=0; j<=i; j++) sum += W[j];
		for(int j=i+1; j<N; j++) sum -= W[j];
		ans = min(ans, abs(sum));
	}
	cout << ans << endl;
}

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

int main(void) {
    int m; cin >> m;
    while (m--) {
        string str; cin >> str;

        set<string> trains;
        int n = str.size();
        for (int i = 1; i <= n; i++) {
            string sp = str.substr(0, i), sn = str.substr(i, n-i);

            trains.insert(sn+sp);
            reverse(sn.begin(), sn.end());
            trains.insert(sp+sn);
            trains.insert(sn+sp);
            reverse(sp.begin(), sp.end());
            trains.insert(sp+sn);
            trains.insert(sn+sp);
            reverse(sn.begin(), sn.end());
            trains.insert(sp+sn);
            trains.insert(sn+sp);
        }

        cout << trains.size() << endl;
    }

    return 0;
}

Measured memory_bytes: 1292
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pb push_back
#define pi acos(-1)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin >> n;
    int arr[n+5] = {0};
    for(int i = 0; i < n-1; i++)
    {
        int x;
        cin >> x;
        arr[x]++;
    }
    for(int i = 1; i <= n; i++)
    {
        cout << arr[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4424
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int getGCD(int a, int b)
{
	if (a > b)
	{
		swap(a, b);
	}
	return (a == 0) ? b : getGCD(a, b % a);
}

int main()
{
	int a, b;
	for (; cin >> a >> b;)
	{
		int gcd = getGCD(a, b);
		cout << gcd << " " << (a / gcd) * b << endl;
	}
}


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

int main(){
    long int n;
    scanf("%ld",&n);
    long long int A[n],sum=0;
    for (int i = 0; i<n;i++){
        scanf("%lld",&A[i]);
        sum += A[i];
    }
    sort(A,A+n);
    printf("%lld %lld %lld\n",A[0],A[n-1],sum);
}


Measured memory_bytes: 3332
n = int(input())
h = list(map(int, input().split()))

ans = 0
while sum(h) != 0:
  m = max(h)
  f = False
  for i in range(len(h)):
    if h[i] == m:
      h[i] -= 1
      if not f:
        f = True
        ans += 1
    else:
      f = False
print(ans)

Measured memory_bytes: 3060
using System;

namespace ConsoleApp1
{
    class Class1
    {
        static void Main( string[] args )
        {
            string N = Console.ReadLine();
            int numN = int.Parse( N );
            string W = Console.ReadLine();
            string[] WList = W.Split( ' ' );
            int min = 0, S1, S2, j, k;

            for ( int i = 1 ; i < numN ; i++ )
            {
                S1 = 0;
                S2 = 0;
                for ( j = 0 ; j < i ; j++ )
                {
                    S1 += int.Parse( WList[ j ] );
                }

                for ( k = j ; k < numN ; k++ )
                {
                    S2 += int.Parse( WList[ k ] );
                }

                if ( i == 1 )
                {
                    min = Math.Abs( S1 - S2 );
                }
                else if ( Math.Abs( S1 - S2 ) < min )
                {
                    min = Math.Abs( S1 - S2 );
                }

                if ( min == 0 )
                {
                    break;
                }
            }

            Console.WriteLine( min );
        }
    }
}


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

int main() {
	long long X;
	cin >> X;

	long long res = 100;
	long long ans = 0;
	while(X > res) {
		res += res / 100;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define int long long

using ll = long long;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)

#define rep(i,n) for_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

int N;
int A[11];

int r;

int k(int n) {
	if(n<1)return 1;
	else return 3*k(n-1);
}

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

	cin>>N;
	rep(i, N)cin>>A[i];

	r = 1;
	rep(i, N)r *= A[i]%2 ? 1 : 2;

	r = k(N) - r;

	cout<<r<<endl;

	return 0;
}


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

int main() {
  int N, T;
  cin >> N >> T;
  int minCost = 1001;
  for(int i=0;i<N;i++){
    int c, t;
    cin >> c >> t;
    if(t > T) {
      continue;
    } else {
      if(c < minCost) {
        minCost = c;
      }
    }
  }

  if(minCost == 1001) {
    cout << "TLE" << endl;
  } else {
    cout << minCost << endl;
  }
}

Measured memory_bytes: 256
[n, m] = [int(i) for i in input().split()]
s = [[int(i) for i in (input().split())[1:]] for j in range(m)]
p = [int(i) for i in input().split()]

cnt = 0
for i in range(1, 2 ** n + 1):
    for j, l in enumerate(s):
        c = 0
        for k in l:
            c += (i >> (k - 1)) % 2
        if (c % 2 != p[j]):
            break
        if (j == m - 1):
            cnt += 1

print(cnt)


Measured memory_bytes: 3064
import java.util.*;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int c = sc.nextInt();
        int w[] = new int[c];
        IntStream.range(0, c).forEach(i -> w[i] = sc.nextInt());

        OptionalInt r = IntStream.range(1, c).map(i -> {
            int s1 = Arrays.stream(w).limit(i).sum();
            int s2 = Arrays.stream(w).skip(i).sum();
            return Math.abs(s1 - s2);
        }).min();

        System.out.println(r.getAsInt());
    }
}


Measured memory_bytes: 28236
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int count=0;
  string s;
  string t;
  cin>>s>>t;
  
  for(int i=0;i<3;i++)
  {
    if(s[i]==t[i])
    {
      count++;
    }
  }
  
  cout<<count;
  return 0;
}
    
   

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
int parent[MAX],left[MAX],right[MAX],n, D[MAX],H[MAX];

int getDepth(int u);
int setHeight(int u);
int setSibling(int u);
void setDepth(int u,int p);
void printChildren(int u);

int main(){
  int i,j,d,v,c,l,r,w,t;
   scanf("%d",&n);
  for(i=0;i<n; i++){
    parent[i] = -1;
    left[i] = -1;
    right[i] = -1;   
  }
  
  for(i = 0; i < n; i++){
    scanf("%d",&v);
    scanf("%d",&l);
    scanf("%d",&d);
    left[v] = l;
    right[v] =d;
    if(l != NIL)parent[l] =v;
    if(d != NIL) parent[d] =v;
  }
  for(i = 0; i<n ; i++){
    if(parent[i] == NIL ) r = i;
  }
  setDepth(r,0);
  setHeight(r);
  for(i = 0; i< n; i++) printChildren(i);

  return 0;
}

int getDepth(int u){
  int d = 0;
  while(parent[u] != NIL){
    u = parent[u];
    d++;
  }
  return d;
}


void setDepth(int u, int p){
  D[u] = p;
  if(right[u] !=NIL){
    setDepth(right[u],p+1);
  }
  if(left[u] != NIL){
    setDepth(left[u],p+1);
  }
}
int setHeight(int u){
  int h1 = 0;
  int h2 = 0;
  if(right[u] != NIL){
    h1 = setHeight(right[u]) +1;
  }
  if(left[u] != NIL){
    h2 = setHeight(left[u]) + 1;
  }
  return H[u] = (h1 > h2 ? h1 : h2);
}

int setSibling(int u){
  if(parent[u] == NIL) return NIL;

  if(left[parent[u]] != u && left[parent[u]] != NIL) return left[parent[u]];
  
  if(right[parent[u]] != u && right[parent[u]] != NIL) return right[parent[u]];
  return NIL;
}
  


void printChildren(int u){
  int i,c;
  int deg = 0;

  printf("node %d: ", u);
  printf("parent = %d, ", parent[u]);
  printf("sibling = %d, ",setSibling(u));
  if(left[u] != NIL) deg++;
  if(right[u] != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);
  
  if(parent[u] == NIL){
    printf("root\n");
  }
  else if (left[u] == NIL && right[u] == NIL){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}






Measured memory_bytes: 2104
#include <iostream>
#include<string>
using namespace std;
int main(int argc, const char * argv[]) {
    char c[3],d[3];
    for(int i=0;i<3;i++){
        cin >>c[i];
    }
    for(int i=0;i<3;i++){
        cin >>d[i];
    }
    for(int i=0;i<3;i++){
        if(i==0&&c[i]==d[2]){
            continue;
        }
        else if(i==0){
            cout<<"NO"<<endl;
            break;
        }
        if(i==1&&c[i]==d[1]){
            continue;
        }
        else if(i==1){
            cout<<"NO"<<endl;
            break;
        }
        if(i==2&&c[i]==d[0]){
            cout<<"YES"<<endl;
            break;
        }
        else{
            cout<<"NO"<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
identification division.
       program-id.a.
       data division.
       working-storage section.
       1 inp pic x(9).
       1 a pic 99.
       1 b pic 99.
       1 d pic 9.
       1 i pic 9.
       procedure division.
       main.
       accept inp.
       perform varying i from 1 by 1 until inp(i:1)=SPACE
       end-perform.
       add -1 to i.
       move inp(1:i) to a.
       add 2 to i.
       move inp(i:2) to b.
       if a > b then
        add -1 to a
       end-if
       if a < 10 then
        move a to d
        display d
       else
        display a
       end-if.
       stop run.

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main(void){
	char a[7],b[4];
	scanf("%s %s",a,b);
	strcat(a,b);
	int num=atoi(a);
	if(sqrt(num)==(int)sqrt(num)){printf("Yes");return 0;}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    ll a,b;
    cin>>a>>b;
    ll c=__gcd(a,b);
    cout<<a*b/c<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<priority_queue<int>> Q(n);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    int s;
    cin >> s;
    if (s == 0){
      int t, x;
      cin >> t >> x;
      Q[t].push(x);
    }
    if (s == 1){
      int t;
      cin >> t;
      if (!Q[t].empty()){
        cout << Q[t].top() << endl;
      }
    }
    if (s == 2){
      int t;
      cin >> t;
      if (!Q[t].empty()){
        Q[t].pop();
      }
    }
  }
}


Measured memory_bytes: 4104
#include <stdio.h>

int A[50],n;

int solve(int i,int m)
{
	if(m == 0) return 1;
	if(i >= n) return 0;
	int res = solve(i + 1,m) || solve(i + 1,m - A[i]);
	return res;
}


int main(void)
{
	int q,M,i;
	
	scanf("%d",&n);
	for(i = 0; i < n; i++) scanf("%d",A + i);
	
	scanf("%d",&q);
	for(i = 0; i < q; i++){
		scanf("%d",&M);
		if(solve(0,M)) printf("yes\n");
		else printf("no\n");
	}
	
	return 0;
}

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


using namespace std;

int main () {
  int N,Y;
  cin>>N>>Y;
  
  int a=-1,b=-1,c=-1;
  for (int x=0;x<=N;x++) {
    for (int y=0;y<=N-x;y++) {
      int sum = 10000*x + 5000*y +1000*(N-x-y);
      if (sum == Y) {
        a = x;
        b = y;
        c = N-x-y;
      } 
    }
  }
  cout<<a<<" "<<b<<" "<<c<<endl;
}

Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    T = input().rstrip()

    N = len(T)
    res = ''

    for i in range(N):
        now = T[i]
        if now == '?':
            res += 'D'
        else:
            res += now

    print(res)



main()


Measured memory_bytes: 9448
while True:
    try:
        f = float(input())
    except:
        break

    L = [None]*10
    L[0] = f
    for i in range(1,10):
        if i % 2 > 0:
            L[i] = L[i-1] *2
        else:
            L[i] = L[i-1] /3
    print("{:.8f}".format(sum(L)))



Measured memory_bytes: 5588
#include<iostream>
using namespace std;
int change(char tmp);
int main(){
    char x,y;
    cin>>x>>y;
    if(change(x)<change(y))cout<<"<"<<endl;
    else if(change(x)>change(y))cout<<">"<<endl;
    else cout<<"="<<endl;
    return 0;
}
int change(char tmp){
    if(tmp=='A')return 10;
    if(tmp=='B')return 11;
    if(tmp=='C')return 12;
    if(tmp=='D')return 13;
    if(tmp=='E')return 14;
    if(tmp=='F')return 15; 
}

Measured memory_bytes: 256
fun main() {
    val n = readLine()?.toInt() ?: return
    val c = CharArray(n)

    fun query(i: Int): Boolean {
        println(i)
        val s = readLine()!!
        return (s == "Vacant").also {
            c[i] = s[0]
        }
    }

    var l = 0
    if (query(l)) return

    var r = n - 1
    if (query(r)) return

    repeat(20) {
        val m = (l + r) / 2
        if (query(m)) return
        
        if ((m - l) % 2 == 1 && c[l] == c[m]
            || (m - l) % 2 == 0 && c[l] != c[m]
        ) {
            r = m
        } else {
            l = m
        }
    }
    return
}

Measured memory_bytes: 34660
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>


#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  priority_queue<ll,vll,greater<ll>> pq1, pq2;
  vll a;
  SET st;
  ll k, q, ri, le;
  cin >> n >> k >> q;
  FOR(i, 0, n) {
	cin >> tmp;
	a.pb(tmp);
  }

  ans = inf;

  FOR(j, 0, n) {
	while (!pq2.empty()) pq2.pop();
	le = ri = 0;
	while (le + k <= n) {
	  while (!pq1.empty()) pq1.pop();
	  ri = le;
	  while (a[ri] >= a[j]) {
		pq1.push(a[ri]);
		ri++;
		if (ri >= n) break;
	  }
	  le = ri + 1;
	  if (pq1.empty()) continue;
	  cnt = pq1.size() + 1 - k;
	  FOR(i, 0, cnt) {
		pq2.push(pq1.top());
		pq1.pop();
	  }
	}
	if (pq2.empty()) continue;
	if (pq2.size() < q) continue;
	FOR(i, 0, q - 1) pq2.pop();
	ans = min(ans, pq2.top() - a[j]);
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

long long inf=1000000007;

long long modpow(long long n,long long p,long long mod);

int main(){
	long long q;
	cin>>q;
	vector<bool> sosu(inf/1000,true);
	sosu.at(0)=false;
	sosu.at(1)=false;
	vector<long long> ruiseki(inf/1000,0);

	for(long long i=0;i<inf/1000;i++){
		if(sosu.at(i)){
			for(long long j=i*2;j<inf/1000;j+=i){
				sosu.at(j)=false;
			}
		}

		if(i==0) continue;
		ruiseki.at(i)=ruiseki.at(i-1);
		if(sosu.at(i) && sosu.at((i+1)/2)){
			ruiseki.at(i)++;
		}
	}

	for(long long i=0;i<q;i++){
		long long l,r;
		cin>>l>>r;
		cout<<ruiseki.at(r)-ruiseki.at(l-1)<<endl;
	}

	return 0;
}

long long modpow(long long n,long long p,long long mod){
	if(p==0) return 1;
	if(p%2==0) return (modpow(n,p/2,mod)*modpow(n,p/2,mod))%mod;
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}


Measured memory_bytes: 11172
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	string s;
	cin >> s;
	if(s.size() % 2 == 0 ^ s[0] == s.back())
		puts("Second");
	else
		puts("First");

	return 0;
}

Measured memory_bytes: 3764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);

          if (A == B)
            {
                Console.WriteLine("Draw");
            }

            else if ((A>B&& B!=1)||A==1)
            {
                Console.WriteLine("Alice");
            }
            else if((B>A && A!=1)||B==1)
            {
                Console.WriteLine("Bob");
            }





        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<iomanip>
using namespace std;
int k,len[5],x[5];
string st[5];
int main()
{
	cin>>st[1];
	len[1]=st[1].size();
	cin>>st[2];
	len[2]=st[2].size();
	cin>>st[3];
	len[3]=st[3].size();
	k=1;
	while(x[k]<len[k])
	{
		k=st[k][x[k]++]-96;
	}
	cout<<char(k+64)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll X, Y;
  cin >> X >> Y;

  if(abs(X-Y)<=1) cout << "Brown\n";
  else cout << "Alice\n";

  return 0;
}

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

int main() {
	int n;
	int a[5][4][11] = {{{0}}};
	cin >> n;
	int b, f, r, v;

	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		a[b][f][r] += v;
	}

	for (int i = 1; i <= 4; i++) {
		for(int j = 1; j <= 3; j++) {
			for (int k = 1; k <= 10; k++){
				cout << " " << a[i][j][k];
			}
			cout << endl;
		}
		if (i < 4) {
			for(int l = 0; l < 20; l++) {
				cout << "#";
			}
			cout << endl;
	  }
	}
	return 0;
}


Measured memory_bytes: 3100
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
N, M = lr()
S = ['?'] + lr()
T = ['.'] +lr()
# dp[i][j] はSがi文字目までTがj文字目までの部分列で等しい組の総和
dp = [[1] * (M+1) for _ in range(N+1)]

for j in range(1, M+1):
    for i in range(1, N+1):
        dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]
        if S[i] == T[j]:
            dp[i][j] += (dp[i-1][j-1])
        dp[i][j] %= MOD

answer = dp[N][M]
print(answer%MOD)
# 21 pypy

Measured memory_bytes: 73052
#include <stdio.h>

int main(){
    int first,last,check,seed=0,i,n;
    for (n=0;;n=1){
        
        scanf("%d %d",&first,&last);
        if (first == 0 && last == 0) return 0;
        if (n != 0) printf("\n");
        check = first % 4;
        if (check == 0) i = first;
        else i = first + 4 - check;
        check = 0;
        for ( ;i <= last;i += 4){
            if (i % 100 == 0 && i % 400 != 0) ;
            else {
                printf("%d\n",i);
                check ++;
            }
        }
        if (check == 0){
            printf("NA\n");
        }
    }
}

Measured memory_bytes: 616
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
double get_value(int p, int a, int b, int c, int d, int e, int f, int s, int m){
  int total_value = s * m * f - p;
  int total_cost = a + b + c;
  total_cost += (d + e) * m;
  return (double)total_value / (double)total_cost;
}
struct food{
  double value;
  string name;
  food(double v, string n): value(v), name(n){}
  bool operator<(const food other) const{
    if(value == other.value){      
      return name < other.name;
    }
    return value > other.value;
  } 
};
int main(){
  int N;
  while(true){
    cin >> N;
    if(N == 0){
      break;
    }
    vector<food> arr;
    for(int i = 0; i < N; ++i){
      string l;
      int p, a, b, c, d, e, f, s, m;
      cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
      arr.push_back(food(get_value(p, a, b, c, d, e, f, s, m), l));
    }
    sort(arr.begin(), arr.end());
    for(int i = 0; i < N; ++i){
      cout << arr[i].name << endl;
    }
    cout << "#" << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>

int main(){
int n,i,j;
int a,b,c,f;

scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a);
b=0;
f=0;
for(j=1;j<10;j++){
scanf("%d",&c);
if(a>c&&b>c)f=1;
else if(a<c&&b<c){
if(a>b)a=c;
else b=c;
}
else{
if(a>b)b=c;
else a=c;
}
}
if(f==0){
printf("YES\n");
}
else if(f==1){
printf("NO\n");
}
}
return 0;
}

Measured memory_bytes: 1008
N=input()
n=int(N)%10

if n==2:
  print('hon')
elif n==4:
  print('hon')
elif n==5:
  print('hon')
elif n==7:
  print('hon')
elif n==9:
  print('hon')
elif n==0:
  print('pon')
elif n==1:
  print('pon')
elif n==6:
  print('pon')
elif n==8:
  print('pon')
elif n==3:
  print('bon')

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

int main() {
  int a,b,c,k,sum=0;
  cin >> a >> b >> c >> k;
  
  sum += min(a,k);
  
  int rest = k-a-b;
  if(rest>0){
	sum -= min(c,rest);
  }
  cout << sum << endl;
}

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


Measured memory_bytes: 2724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  ll res = 0;
  res = (n / 11) * 2;
  //cout << res << " "  << n % 11 << endl;
  if(n - 6 > res / 2 * 11)res++;
  if(n > res / 2 * 11)res++;
  cout << res << endl;
  return 0;
}

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

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

    string f = "", b = "";
    int rev = 0;
    for (int i = 0; i < Q; i++) {
        int T;
        cin >> T;
        if (T == 1) {
            rev = (rev + 1) % 2;
        } else {
            int F;
            char C;
            cin >> F >> C;
            if ((F + rev) % 2) f = C + f;
            else b += C;
        }
    }

    string ans = f + S + b;
    if (rev) reverse(ans.begin(), ans.end());

    cout << ans << endl;
}

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

using ll = long long;
using pii = pair<int, int>;

template <typename T> constexpr T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;
template <> constexpr double inf<double> = 1e18;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    for(int i = 0; i < N; ++i) {
        for(int j = i + 1; j < N; ++j) {
            if(abs(a[i] - a[j]) % (N - 1) == 0) {
                cout << a[i] << ' ' << a[j] << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3104
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
	string S;
	cin >> S;
	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) cout << "Bad";
	else cout << "Good";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

void yes(){
   cout<<"Yes"<<endl;
   //exit (0);
}
void no(){
   cout<<"No"<<endl;
   //exit (0);   
}

int n, m;
string s, t;

int32_t main(){_

   cin >> s >> t;

   bool good = 1;
   for (int i = 0; i+1 < (int)(t.size()); ++i)
   {
      good &= s[i] == t[i];
   }

   good &= (int)(s.size()) + 1 == (int)(t.size());

   if (good){
      yes();
   }
   else{
      no();
   }
     

   return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=100005;
int a[N];
bool cmp(int a,int b){return a>b;}
int main (){
	int n;scanf ("%d",&n);
	for (int i=1;i<=n;i++) scanf ("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;i++)
		if (i+1>a[i+1]){
			int j=i+1;while(a[j]==i) j++;
			if (((j-i-1)&1)|((a[i]-i)&1)) puts("First");
			else puts("Second");
			return 0;
		}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10;
int a[M];
pair<int,pii>cur[M];
int id[M];
int c[2];
vector<int>rem[M];
int x[M],y[M];
int cnt[1000+10][1000+10][2],cnt2[1000+10][1000+10][2];
int dp[1000+10][1000+10][2];
main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		char tmp;
		int a,b;
		cin>>a>>b>>tmp;
		bool flag=0;
		if(tmp=='B')flag=1;
		int col=a/k;
		if(col%2==1)flag=1-flag;
		col=b/k;
		if(col%2==1)flag=1-flag;
		c[flag]++;
		x[i]=a%k,y[i]=b%k;
		cnt[x[i]][y[i]][flag]++;
	}
	int ans=0;
	for(int i=0;i<=k-1;i++)
	{
		for(int j=0;j<=k-1;j++)
		{
			for(int l=0;l<=1;l++){
				if(i!=0)
					cnt2[i][j][l]+=cnt2[i-1][j][l];
				if(j!=0)cnt2[i][j][l]+=cnt2[i][j-1][l];
				if(i!=0 && j!=0)cnt2[i][j][l]-=cnt2[i-1][j-1][l];
				cnt2[i][j][l]+=cnt[i][j][l];
			}
		}
	}
	for(int i=k-1;i>=0;i--)
	{
		for(int j=k-1;j>=0;j--)
		{
			dp[i][j][1]=dp[i+1][j][1]+dp[i][j+1][1]-dp[i+1][j+1][1];
			dp[i][j][1]+=cnt[i][j][1];
			dp[i][j][0]=dp[i+1][j][0]+dp[i][j+1][0]-dp[i+1][j+1][0];
			dp[i][j][0]+=cnt[i][j][0];
			if(i!=0 && j!=0){
				ans=max(ans,dp[i][j][0]+cnt2[i-1][j-1][0]+c[1]-dp[i][j][1]-cnt2[i-1][j-1][1]),ans=max(ans,dp[i][j][1]+cnt2[i-1][j-1][1]+c[0]-dp[i][j][0]-cnt2[i-1][j-1][0]);
			}
			else
				ans=max(ans,dp[i][j][0]+c[1]-dp[i][j][1]),ans=max(ans,dp[i][j][1]+c[0]-dp[i][j][0]);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 57600
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 404;
bool ok[N];int n,m,t[N][N],x[102000],y[102000];
Vi pos[N];
inline bool solve(int S, int *t){
	static int q[N];int f=0,r=0;t[S]=-1;//WA
	rep(j,0,SZ(pos[S])-1){
		int i=pos[S][j],u=x[i]==S?y[i]:x[i];
		q[r++]=u;if(t[u])return 0;t[u]=i;
	}
	while(f!=r){
		int S=q[f++];
		rep(j,0,SZ(pos[S])-1){
			int i=pos[S][j],u=x[i]==S?y[i]:x[i];if(i>=t[S])break;
			if(!t[u])q[r++]=u,t[u]=i;else if(t[u]!=i)return 0;
		}
	}
	return 1;
}
int main() {
	read(n);read(m);rep(i,1,m)read(x[i]),read(y[i]);
	rep(i,1,m)pos[x[i]].pb(i),pos[y[i]].pb(i);//WA
	rep(i,1,n)ok[i]=solve(i,t[i]);
//	rep(i,1,n){printf("%d:",ok[i]);rep(j,1,n)printf("%d ",t[i][j]);puts("");}
	int res=0;
	rep(i,1,n)rep(j,i+1,n)if(ok[i]&&ok[j]){
		bool bo=1;rep(k,1,n)if(t[i][k]&&t[j][k])bo&=t[i][k]==t[j][k];res+=bo;
	}
	cout<<res;return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a;
        cin >> a;
        n -= a;
    }
    if (n < 0) n = -1;
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(void){
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if(x+r>W || x-r<0 || y+r>H || y-r<0){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 2104
A, B, C = map(int, input().split())
K = int(input())
flag = 0

for i in range(K):
  if A >= B:
    B = B*2
  elif B >= C:
    C = C*2
    if B < C:
      print("Yes")
      break      
  else:
    print("Yes")
    break
  flag += 1

if K == flag:
  print("No")

Measured memory_bytes: 9212