akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
	char S[3][128];
	int idx[3] = {0, 0, 0};
	int turn = 0;
	if (scanf("%127s", S[0]) != 1) return 1;
	if (scanf("%127s", S[1]) != 1) return 1;
	if (scanf("%127s", S[2]) != 1) return 1;
	for (;;) {
		switch (S[turn][idx[turn]]) {
			case 'a':
				idx[turn]++;
				turn = 0;
				break;
			case 'b':
				idx[turn]++;
				turn = 1;
				break;
			case 'c':
				idx[turn]++;
				turn = 2;
				break;
			case '\0':
				putchar('A' + turn);
				putchar('\n');
				return 0;
			default:
				idx[turn]++;
				break;
		}
	}
	return 0;
}


Measured memory_bytes: 128
n = input()
a, b = map(int, raw_input().split())
ca = input()
max = ca / a
cb = [input() for i in range(n)]
sum_b = a
sum_cb = ca
for t in reversed(sorted(cb)):
    sum_b += b
    sum_cb += t
    if max <= sum_cb / sum_b: max = sum_cb / sum_b
    else: break
print max

Measured memory_bytes: 6448
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    P = [int(i)-1 for i in input().split()]
    XY = [[int(i)-1 for i in input().split()] for j in range(M)]

    par = [i for i in range(N)]
    rank = [1 for i in range(N)]

    def find_root(x):
        if par[x] == x:
            return x
        else:
            par[x] = find_root(par[x])
            return par[x]

    def is_same_group(x, y):
        return find_root(x) == find_root(y)

    def unite(x, y):
        x = find_root(x)
        y = find_root(y)
        if x == y:
            return
        if rank[x] < rank[y]:
            x, y = y, x
        rank[x] += rank[y]
        par[y] = x

    def size(x):
        # 連結成分のサイズを返す
        return rank[find_root(x)]

    for x, y in XY:
        unite(x, y)

    ans = 0
    for i, p in enumerate(P):
        if is_same_group(i, p):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
int main(){
   
    string s;
    cin>>s;
  long long int count=0,ans=0,i;
   
    for(long long int i = 0;i<s.length();i++){
        if(s[i] == 'R'){
            count++;
        }
        else{
            ans = max(ans,count);
            count = 0;
        }
    }
    ans=max(ans,count);
    cout<<ans<<"\n";
   return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    ll dp[105][4][4][4];
    rep(i,105){
        rep(j,4){
            rep(k,4){
                rep(l,4){
                    dp[i][j][k][l] = 0;
                }
            }
        }
    }
    dp[0][3][3][3] = 1;
    for (ll i = 0; i <= N + 3; i++){
        for (ll j1 = 0; j1 < 4; j1++){
            for (ll j2 = 0; j2 < 4; j2++){
                for (ll j3 = 0; j3 < 4; j3++){
                    for (ll j4 = 0; j4 < 4; j4++){
                        if (j1 == 0 && j3 == 2 && j4 == 1) continue;
                        if (j1 == 0 && j2 == 2 && j4 == 1) continue;
                        if (j2 == 0 && j3 == 2 && j4 == 1) continue;
                        if (j2 == 0 && j3 == 1 && j4 == 2) continue;
                        if (j2 == 2 && j3 == 0 && j4 == 1) continue;
                        
                        dp[i + 1][j2][j3][j4] = (dp[i][j1][j2][j3] + dp[i + 1][j2][j3][j4]) % 1000000007;
                    }
                }
            }
        }
    }
    ll ans = 0;
    rep(i,4){
        rep(j,4){
            rep(k,4){
                ans = (ans + dp[N][i][j][k]) % 1000000007;
            }
        }
    }
    cout << ans << endl;
}



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

int main() {
  int n, v, j;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    cout << a[i] << ((i == n - 1) ? "\n" : " ");
  }
  for (int i = 1; i < n; ++i) {
    v = a[i];
    j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = v;
    for (int k = 0; k < n; ++k) {
      cout << a[k] << ((k == n - 1) ? "\n" : " ");
    }
  }
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
int n, k, x, len[N], ans = 0;
vector<int> v[N];
void dfs(int x, int fx) {
    for (auto y : v[x]) {
        dfs(y, x);
        len[x] = max(len[x], len[y]);
    }
    len[x]++;
    if (fx != 1 && x != 1 && len[x] == k) ans++, len[x] = 0;
}
int main() {
    scanf("%d%d%d", &n, &k, &x);
    if (x != 1) ans++;
    for (int i = 2; i <= n; i++) {
        scanf("%d", &x);
        v[x].push_back(i);
    }
    dfs(1, 0);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 12288
#include<stdio.h>
 int main() {
     int n,i,p,q,r,P,Q,R,C,x,y=0;
     int a[1000][5]={0};
     while(scanf("%d",&n) && n!=0){ 
        for(x=0; x<n; x++){ 
            scanf("%d %d %d %d",&i,&p,&q,&r);
a[x][0]=i;
a[x][1]=p;
a[x][2]=q;
a[x][3]=r;
                    a[x][4]=p*4+q*9+r*4;
          }
         scanf("%d %d %d %d",&P,&Q,&R,&C);
         for(x=0; x<n; x++){
             if(a[x][1]<=P && a[x][2]<=Q && a[x][3]<=R && a[x][4]<=C){y=1;
                                printf("%d\n",a[x][0]);
             }         }
         if(y==0) 
            printf("NA\n");
         y=0; 
    }
     return 0;
 } 

Measured memory_bytes: 1068
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 998244353

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

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

def use_divisors(n):
    l_divisors, r_divisors = [], []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            if (n//i)%2:
                l_divisors.append(i)
            if i != n//i:
                if (n//(n//i))%2:
                    r_divisors.append(n//i)
    return l_divisors + r_divisors[::-1]
 
N = I()
X = str(input())
Xr = ''.join('1' if c=='0' else '0' for c in X)

divisors = use_divisors(2*N)
C = dict.fromkeys(divisors,0)

for d in divisors:
    T = X[:d//2]
    Tr = Xr[:d//2]
    Tc = T+Tr
    count = int(T,2)
    if int(Tc*(N//d)+Tc[:N-d*(N//d)],2) <= int(X,2):
        count += 1
    C[d] = count
    for d1 in divisors:
        if d%d1==0 and d!=d1:
            C[d] -= C[d1]

ans = 0
for d in divisors:
    ans += d*C[d]
    ans %= mod

print(ans)

Measured memory_bytes: 5476
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] h = new int[n];
    for(int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }
    Arrays.sort(h);
    int ans = h[n - 1] - h[0];
    for(int i = 0; i < (n - k + 1); i++) { 
      ans = Math.min(ans, h[i + k - 1] - h[i]);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 58480
#include <iostream>

int main(int argc, char const *argv[]) {
  int n=0;
  std::cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    int x;
    std::cin >> x;
    a[i] = x;
  }

  for(int i=n-1;i>=0;i--){
    if(i!=0){
      std::cout << a[i] << " ";
    }else std::cout << a[i];
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main()
{
	int i,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	printf("%d",a[n/2+1]-a[n/2]);
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=2e5+10;
int n,ans[N];bool vis[N];
vector<int>e[N],R,B;
void dfs(int x,int ff,int op){
    op?R.pb(x):B.pb(x);
    if(ff)e[x].erase(find(e[x].begin(),e[x].end(),ff));
    for(int i=0;i<e[x].size();i++)dfs(e[x][i],x,op^1);
}
int main(){
    scanf("%d",&n);
    for(int i=1,x,y;i<n;i++){
        scanf("%d%d",&x,&y);
        e[x].pb(y);e[y].pb(x);
    }
    dfs(1,0,0);
    if(R.size()>B.size())swap(R,B);
    if(R.size()<=n/3){
        for(int i=0,j=3;i<R.size();i++,j+=3)vis[ans[R[i]]=j]=1;
        for(int i=0,j=1;i<B.size();i++,j++){
            while(vis[j])j++;ans[B[i]]=j;
        }
    }
    else{
        int p=0,q=0;
        for(int i=1;i<=n;i+=3,p++)vis[ans[R[p]]=i]=1;
        for(int i=2;i<=n;i+=3,q++)vis[ans[B[q]]=i]=1;
        for(int i=1;p<R.size();p++,i++){
            while(vis[i])i++;vis[ans[R[p]]=i]=1;
        }
        for(int i=1;q<B.size();q++,i++){
            while(vis[i])i++;ans[B[q]]=i;
        }
    }
    for(int i=1;i<=n;i++)printf("%d ",ans[i]);puts("");
    return 0;
}

Measured memory_bytes: 19444
n = int(input())
x = list(map(int, input().split()))

#print(n,x)

def party(person_place,party_place):
    energy=pow(abs(party_place-person_place),2)
    return(energy)

if abs(sum(x)//len(x)-sum(x)/len(x))<0.5:
    party_place=sum(x)//len(x)
else:
    party_place=sum(x)//len(x)+1

#print(party_place)


answer=0    
for i in range(0,len(x)):
    answer+=party(x[i],party_place)
    #print(answer,party(x[i],n))
print(answer)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main() {
	int H, R;
	cin >> H >> R;
	int n = H + R;
	if (n > 0) {
		cout << "1" << endl;
	}
	else if (n < 0) {
		cout << "-1" << endl;
	}
	else {
		cout << "0" << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
N = int(input())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))

sumT = sum(ts)
va = [min(i / 2, sumT - i / 2) for i in range(2 * sumT + 1)]

accT = 0
for t, v in zip(ts, vs):
    for i in range(accT, accT + 2 * t + 1):
        va[i] = min(va[i], v)
    accT += t * 2

for i in range(len(va) - 1):
    if va[i + 1] - va[i] > 0.5:
        va[i + 1] = va[i] + 0.5

for i in range(len(va) - 1)[::-1]:
    if va[i] - va[i + 1] > 0.5:
        va[i] = va[i + 1] + 0.5

print(sum(va) / 2)


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector < int >A(N), B(N), C(N - 1);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N - 1; i++) {
		cin >> C[i];
	}

	int ans = accumulate(B.begin(), B.end(), 0);

	for (int i = 0; i < N - 1; i++) {
		if (A[i] + 1 == A[i + 1]) {
			ans += C[A[i] - 1];
		}
	}

	cout << ans << endl;

	return 0;
}


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

const int MOD =1000000007;
//

signed main() {
 int n,m,v,p,ans=0;
 cin>>n>>m>>v>>p;
 int a[n];
 for(int i=0;i<n;i++)cin>>a[i];
 sort(a,a+n);
 int z=m*(n-v),j=1,sh=0;
 while(j<n&&z>=sh+(a[j]-a[0])&&m-(a[j]-a[0])>=0){
     sh+=(a[j]-a[0]);
     j++;
 }
 if(n-j+1<=p){ans++;}
 //cerr<< 0 << j<<' '<<sh<<endl;
 for(int i=1;i<n;i++){
     sh-=(j-i)*(a[i]-a[i-1]);
     //sh-=m;
     while(j<n&&z>=sh+(a[j]-a[i])&&m-(a[j]-a[i])>=0){
         sh+=(a[j]-a[i]);
         j++;
     }
     if(n-j+1<=p){ans++;}
    // cerr<< i<<' '<<j<<' '<<sh<<endl;
 }
 cout<<ans;
 return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <cstring>
using namespace std;
const int maxn=2000;
int main()
{ stack<int>q;
string cc;
int sum=0;
//int i=0;
  while(cin>>cc)
  {   //int sum=0;

      if(cc[0]=='+')
    {  int c=q.top(); q.pop();
       int l=q.top(); q.pop();
       sum=c+l;
       //q.pop();q.pop();
        q.push(sum);
    }
      else if(cc[0]=='-')
      {  int c=q.top();
         q.pop();
         int l=q.top();
         q.pop();//q.pop();
         sum=l-c;
        q.push(sum);
      }
      else if(cc[0]=='*')
      {  int  c=q.top();
         q.pop();
         int l=q.top();
         q.pop();
          sum=l*c;
          q.push(sum);
      }
     else
        {//int l=atoi(cc);
             //int l=atoi(cc);
             //printf("%d ** \n",l);
         q.push(atoi(cc.c_str()));

        }

  }
   printf("%d\n",q.top());


    return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;

// WarshallFloyd
template <typename T>
void WarshallFloyd(vector<vector<T>> &link) {
    int N = link.size();
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                link[i][j] = min(link[i][j], link[i][k] + link[k][j]);
            }
        }
    }
}

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<i64>> c(10, vector<i64>(10));
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }
    WarshallFloyd(c);
    i64 ans = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            int A;
            cin >> A;
            if(A >= 0) ans += c[A][1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main
{
	public static void main(String args[]) throws java.lang.Exception
	{
		BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
			// String h[]=inp.readLine().split(" ");
			// String h[]=inp.readLine().split(" ");
			int n=Integer.parseInt(inp.readLine());
			// int k=Integer.parseInt(h[1]);
			String hh[]=inp.readLine().split(" ");
			long a[]=new long[n];
			for(int i=0;i<n;i++){a[i]=Long.parseLong(hh[i]);}
			long dp[][]=new long[n][n];
		// int c[][]=new int[n][n];
		long pre[][]=new long[n][n];
			for(int i=0;i<n;i++)
			{
				long u=0;
				for(int j=i;j<n;j++)
				{
					u+=a[j];
					pre[i][j]=u;
				}
			}
			for(int len=2;len<=n;len++)
			{
				for(int j=0;j<n-len+1;j++)
				{
					int l=j;
					int r=j+len-1;
					int pp=0;
					long min=Long.MAX_VALUE;
					for(int p=l;p<r;p++)
					{

						if(dp[l][p]+dp[p+1][r]+pre[l][p]+pre[p+1][r]<min)
						{
							pp=p;
							min=dp[l][p]+dp[p+1][r]+pre[l][p]+pre[p+1][r];
						}
					}
					// if(l==0 && r==n-1){System.out.println(pp);}
					dp[l][r]=min;
					// c[l][r]=pp;

				}
				
			}
			System.out.println(dp[0][n-1]);
			// System.out.println(get(dp,c,0,n-1));
					
		
	}
	static long get(long dp[][], int c[][], int l, int r)
	{
		if(l==r){return 0;}
		System.out.println(l+" "+r+" "+dp[l][r]);
		return dp[l][r]+get(dp,c,l,c[l][r])+get(dp,c,c[l][r]+1,r);
	}
	
}
class Pair
{
	int a;
	long b;
	
	Pair(int e, long f)
	{
		a=e;
		b=f;
		
	}
}

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

using namespace std;


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

    string s, t;
    int cnt = 0;
    cin >> s >> t;
    for (int i = 0; i < s.size(); ++i)
        if (s[i] != t[i])
            cnt++;
        
    cout << cnt << endl;

}

Measured memory_bytes: 3896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define scn(n) scanf("%d", &n)
#define scns(s) scanf("%s", &s)
#define pri(n) printf("%d", n)
#define priln(n) printf("%d\n", n)
#define pris(s) printf("%s", s)
#define prisln(s) printf("%s\n", s)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  char tmp;
  string ans = "No";
  for(int i = 0; i < 3; ++i) {
    if (i > 0 && tmp != str[i]) {
      ans = "Yes";
    }
    tmp = str[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main(){
	int n,m,k,i;
	scanf("%d%d%d",&n,&m,&k);
	for (i=1;i<=k;i++){
		int x1;
		scanf("%d",&x1);
		a[x1]++;
		m--;
	}
	for (i=1;i<=n;i++)
		if(a[i]+m<=0)puts("No");
		else puts("Yes");
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

// -------------------------------------------------------------------------------------



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

  cout << ceil(N / (double)(2*D+1)) << endl;

  return 0;
}

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


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 REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll h[114514], ans = 0, n, c;
bool used[114514][40];
int main() {
	cin >> n >> c;
	REP(i, n) {
		ll a, b, c;
		cin >> a >> b >> c;
		
		if (used[a][c]) h[a + 1]++;
		else h[a]++;
		if (used[b][c]) h[b]--;
		else h[b + 1]--;
		used[a][c] = true;
		used[b][c] = true;
	}
	REP(i, 101010)h[i + 1] += h[i];
	REP(i, 101010)ans = max(ans, h[i]);
	cout << ans << endl;
}



Measured memory_bytes: 5120
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


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<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

vector<int> S[1000];
int main()
{

	int n; cin >> n;
	int k = -1;
	for (int i = 1; i <=n+1; i++) {
		if (i*(i - 1)  == 2*n) {
			k = i;
		}
	}

	if (k == -1) {
		cout << "No" << endl;
		return 0;
	}
	
	

	int idx = 1;

	for (int i = 0; i < k; i++) {
		for (int j = i + 1; j < k; j++) {
			S[i].push_back(idx);
			S[j].push_back(idx++);

			
		}
	}

	cout << "Yes" << endl;
	cout << k << endl;

	for (int i = 0; i < k; i++) {
		cout << S[i].size();

		for (int j : S[i]) {
			cout << " " << j;
		}

		cout << endl;
	}
	

	return 0;
}



Measured memory_bytes: 2304
parseInt(x) = parse(Int, x)

function main()
	n = parseInt(readline())
	a = map(parseInt, split(readline()))
	d = Dict{Int, Int}()
	for i in 1:n
		if haskey(d,a[i])
			d[a[i]] += 1
		else
			d[a[i]]=1
		end
	end
	count = 0
	for i in keys(d)
		if i < d[i]
			count += d[i]-i
		elseif i > d[i]
			count += d[i]
		end
	end
	print(count)
end

main()

Measured memory_bytes: 131608
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL inf = 1e18;
int main() {
	int n;
	LL p=1,a;
	cin>>n;
	vector<LL> v(n);
	for(auto &i:v) cin>>i;
	sort(v.begin(), v.end());
	for(auto a:v) {
		if(!a) {
			p=0;
			break;
		}
		if(a > inf/p) {
			p=-1;
			break;
		} else
			p *= a;
	}
	cout<<p<<endl;
	return 0;
}


Measured memory_bytes: 4052
// Problem: A - Frog 1
// Contest: AtCoder - Educational DP Contest
// URL: https://atcoder.jp/contests/dp/tasks/dp_a
// Parsed on: 2020-09-06 12:44:28
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

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

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> dp(n, numeric_limits<int>::max()), arr(n);
    for (auto& e : arr) cin >> e;
    dp[0] = 0;
    dp[1] = abs(arr[0] - arr[1]);
    for (int a = 2; a < n; a++) {
        for (int b = 1; b <= k; b++) {
            if (b <= a) {
                int smt = dp[a - b] + abs(arr[a - b] - arr[a]);
                dp[a] = min(dp[a], smt);
            }
        }
    }

    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 3640
def check(s):
    if s == '':
        return True
    while(s != ''):
        if s.startswith('eraser'):
            s = s[6:]
        elif s.startswith('erase'):
            s = s[5:]
        elif s.startswith('dreamera'):
            #dream,erase(r)
            s = s[5:]
        elif s.startswith('dreamer'):
            s = s[7:]
        elif s.startswith('dream'):
            s = s[5:]
        else:
            return False
    return True

s=input()
if check(s):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3316
import java.util.*;

class Main {
	static int SIZE = 3;

	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		Puzzle p = new Puzzle();

		for (int i = 0; i < SIZE*SIZE; i++) {
			p.board[i] = scanner.nextInt();
			if(p.board[i] == 0)
				p.space = i;
		}

		int steps = solve(p);
		System.out.println(steps);
	}

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

	private int solve(Puzzle p) {
		Puzzle u = new Puzzle();
		Puzzle v = new Puzzle();

		Deque<Puzzle> queue = new ArrayDeque<>();
		queue.offer(p);

		Set<Puzzle> set = new HashSet<Main.Puzzle>();
		set.add(p);

		while(!queue.isEmpty()) {
			u = queue.poll();
			
			if(isSolution(u)) 
				return u.countStep;

			int y = u.space/SIZE;
			int x = u.space%SIZE;

			for(int[] d : dxy) {
				int dy = y + d[0];
				int dx = x + d[1];

				if(dy < 0 || dx < 0 || SIZE <= dy || SIZE <= dx) 
					continue;

				v = u.clone();
				move(v, u.space, dy*SIZE+dx);
				v.space = dy*SIZE+dx;

				if(!set.contains(v)) {
					set.add(v);
					v.countStep++;
					queue.offer(v);
				}
			}
		}

		return -1;
	}

	private boolean isSolution(Puzzle p) {
		for (int i = 0; i < SIZE*SIZE-1; i++) {
			if(p.board[i] != i+1)
				return false;
		}

		return true;
	}

	private void move(Puzzle p, int space, int i) {
		int tmp = p.board[i];
		p.board[i] = p.board[space];
		p.board[space] = tmp;
	}


	class Puzzle implements Cloneable {
		int[] board = new int[SIZE*SIZE];
		int space;
		int countStep = 0;

		@Override
		public Puzzle clone(){
			try {
				Puzzle newPuzzle = (Puzzle)super.clone();
				newPuzzle.board = Arrays.copyOf(board, SIZE*SIZE);
				return newPuzzle;
			} catch (CloneNotSupportedException e) {
				throw new InternalError();
			}
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime*result + getOuterType().hashCode();
			result = prime*result + Arrays.hashCode(board);
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if(this == obj)
				return true;

			if(obj == null)
				return false;

			if(getClass() != obj.getClass())
				return false;

			Puzzle p = (Puzzle)obj;
			
			if(!getOuterType().equals(p.getOuterType()))
				return false;

			if(!Arrays.equals(board, p.board))
				return false;

			return true;
		}

		private Main getOuterType() {
			return Main.this;
		}
	}
}


Measured memory_bytes: 80112
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

constexpr long long INF = LLONG_MAX;
constexpr long long MOD = 1000000007;
constexpr long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k;
ll ans = 0, sum = 0, cnt = 0;
//ld d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/

int main() {
    cin >> s;

    Yes((find(CALL(s),'7'))!=s.end());
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<sstream>
#include<cmath>

int main(){
	int a,b;
	int m[4]={0};

	for(int i=0;i<3;i++){
		std::cin >> a >> b;
		m[a-1]++;
		m[b-1]++;
	}

	for(int i=0;i<4;i++){
		if(m[i]>2){
			std::cout << "NO" << std::endl;
			return 0;
		}
	}

	std::cout << "YES" << std::endl;
	return 0;
}


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

#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;

int main()
{
	int n;
	cin >> n;
	vector<int> h(n);
	for(int i = 0; i < n; i++) cin >> h[i];
	int ans = 0;
	while(1){
		int flag = 0;
		for(int i = 0; i < n; i++){
			if(h[i] == 0) continue;
			while(i < n && h[i]){
				h[i]--;
				i++;
				flag = 1;
			}
			i--;
			ans++;
		}
		if(flag == 0) break;
	}
	cout << ans << endl;
	
	return 0;	
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    string S;
    cin >> S;
    int p1 = 0;
    for (int i = 0; i < S.length(); ++i) {
        if (i % 2 == 0 && S[i] != '0') ++p1;
        if (i % 2 == 1 && S[i] != '1') ++p1;
    }
    int p2 = 0;
    for (int i = 0; i < S.length(); ++i) {
        if (i % 2 == 0 && S[i] == '0') ++p2;
        if (i % 2 == 1 && S[i] == '1') ++p2;
    } 
    cout << min(p1, p2) << endl;
    return 0;
}

Measured memory_bytes: 3748
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll a, b, c;
  cin >> a >> b >> c;

  ll g = __gcd(a, b);
  if (c % g == 0)
    puts("YES");
  else
    puts("NO");

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i;
    vector<long long>v;
    cin>>n;
    while(n>0)
    {
        n--;
        v.push_back(n%26);
        n/=26;
    }
    for(i=v.size()-1;i>=0;i--)
        cout<<string(1,'a'+v.at(i));
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; cin >> n;
    vector<int> v(n);
    rep(i, n){
        cin >> v[i];
    }
    sort(ALL(v));

    ll ans = 0;
    rep(i, v.size()) FOR(j, i+1, v.size()){
        int l = upper_bound(ALL(v), v[j] - v[i]) - v.begin();
        int r = lower_bound(ALL(v), v[j] + v[i]) - v.begin();

        // FOR(k, l, r){
        //     printf("%d ", v[k]);
        // }
        // pr("");

        if(v[i] > v[j] - v[i] && v[i] < v[j] + v[i]) r--;
        if(v[j] > v[j] - v[i] && v[j] < v[j] + v[i]) r--;

        // printf("%d %d %d\n", v[i], v[j], r-l);
        // pr("");


        ans += max(r - l, 0);
        
    }
    pr(ans/3);
    return 0;}

Measured memory_bytes: 3632
#include <iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{   
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int s = a1 + a2 + a3;
    if (s > 21) {
        cout << "bust" << endl;
    }
    else
        cout << "win" << endl;
    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(h, w);

    vector<string> table(h);
    rep(i, h) {
        cin >> table[i];
    }

    vvi yoko(h, vi(w, 1));
    rep(i, h) {
        rep(j, w) {
            if (table[i][j] == '#') {
                yoko[i][j] = 0;
            }
        }
    }

    rep(i, h) {
        Rep(j, w) {
            if (yoko[i][j]) yoko[i][j] = yoko[i][j-1] + 1;
        }
    }

    rep(i, h) {
        for (int j = w-2; j >= 0; j--) {
            if (yoko[i][j+1] && yoko[i][j]) yoko[i][j] = yoko[i][j+1];
        }
    }

    vvi tate(h, vi(w, 1));
    rep(i, w) {
        rep(j, h) {
            if (table[j][i] == '#') {
                tate[j][i] = 0;
            }
        }
    }

    rep(i, w) {
        Rep(j, h) {
            if (tate[j][i]) tate[j][i] = tate[j-1][i] + 1;
        }
    }

    rep(i, w) {
        for (int j = h-2; j >= 0; j--) {
            if (tate[j][i] && tate[j+1][i]) tate[j][i] = tate[j+1][i];
        }
    }

    int ans = 0;
    rep(i, h) {
        rep(j, w) {
            ans = max(ans, tate[i][j] + yoko[i][j]);
        }
    }
   std::cout << ans -1<< std::endl;

    return 0;
}


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

#define ll long long
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define F(i, n) for (i = 0; i < (1LL*n); i++)
#define Fr(i, n) for (i = n - 1; i >= 0; i--)

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, int, custom_hash>
void prv(vct v)
{
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}
ll poww(ll x, ll y, ll m)
{
    ll res = 1;
    while (y)
    {
        if (y % 2 == 0)
        {
            x = (x * x) % m;
            y = y / 2;
        }
        else
        {
            res = (res * x) % m;
            y--;
        }
    }
    return res;
}
void deb(string s, ll n)
{
    cout << s << " : " << n << "\n";
}
void prn(ll n) { cout << n << "\n"; }
void prs(string n) { cout << n << "\n"; }

mat mt;
void setmtsize(ll m,ll n, ll ini=0){
    mt.resize(m,vector<ll>(n,ini));
}
void prmt(mat m){
    for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);
}
vct divsors(ll n)
{
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++)
    {if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
ll q;
ll i, j;
ll a, b, c;
ll mod = 1000000007;



void solve()
{
    cin>>n>>k;
    vct v(n);
    F(i,n)cin>>v[i];
    vct dp(n+1,LLONG_MAX);
    ll cr=v[0];
    dp[0]=0;
    for(i=1;i<n;i++){
        for(j=1;j<=k;j++){
            if((i-j)>=0){
                dp[i]=min(dp[i-j]+abs(v[i]-v[i-j]),dp[i]);   
            }
        }
    }
    prn(dp[n-1]);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    // cin >> t;
    // stress();
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 4728
#include <stdio.h>
int main(void){
    int N,i,j=0;
    scanf("%d",&N);
    for(i=1;i<10;i++){
        if(N%i==0){
            if(N/i<10){
                printf("Yes\n");
                j=j+1;
                break;
            }
        }
    }
    if(j==0){
        printf("No\n");
    }
    return 0;
}

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

constexpr int MAX_NUM = 100000;

struct Node{int p, l, r;};
int D[MAX_NUM];

Node T[MAX_NUM];

void setDepth(int tgt_id, int cur_depth) {
    D[tgt_id] = cur_depth;
    if (T[tgt_id].l != -1) setDepth(T[tgt_id].l, cur_depth + 1);
    if (T[tgt_id].r != -1) setDepth(T[tgt_id].r, cur_depth);
}

void printNode(int tgt_id) {
    int pid = -1;
    if (T[tgt_id].p != -1) {
        pid = T[tgt_id].p;
    }
    std::printf("node %d: parent = %d, depth = %d, ", tgt_id, pid, D[tgt_id]);
    std::string node_name = "root";
    if ((T[tgt_id].l != -1)) {
        if (pid > -1) node_name = "internal node";
        printf("%s, [", node_name.c_str());
        printf("%d", T[tgt_id].l);
        int c_id = T[tgt_id].l;
        while (T[c_id].r > -1) {
            printf(", %d", T[c_id].r);
            c_id = T[c_id].r;
        }
        printf("]\n");
    }else {
        if (pid > -1) node_name = "leaf";
        printf("%s, [", node_name.c_str());
        printf("]\n");
    }
}

int main(int argc, char** argv) {
    int n, k;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        T[i].p = -1;
        T[i].l = -1;
        T[i].r = -1;
    }
    for (int i = 0; i < n; ++i) {
        int id, k, r, l;
        std::cin >> id >> k;
        for (int j = 0; j < k; j++) {
            std::cin >> r;
            if (j == 0) T[id].l = r;
            else {
                T[l].r = r;
            }
            l = r;
            T[r].p = id;
        }
    }

    int r = -1;
    for (int i = 0; i < n; i++) {
        if (T[i].p == -1) {
            r = i;
        }
    }
    setDepth(r, 0);
    for (int i = 0; i < n; i++) {
        printNode(i);
    }

}


Measured memory_bytes: 4628
#include <bits/stdc++.h>
using namespace std;
int main() {
  string A,B;
  cin>>A>>B;
  if(A.size()>B.size()) cout<<"GREATER"<<endl;
  else if(A.size()<B.size()) cout<<"LESS"<<endl;
  else{
  	for(int i=0;i<A.size();i++){
    	if(A[i]>B[i]){
          cout<<"GREATER"<<endl;
          break;
        }else if(A[i]<B[i]){
          cout<<"LESS"<<endl;
          break;
        }
      if(i=A.size()) cout<<"EQUAL"<<endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	int a[n];
	for( int i = 0; i < n; ++i ){
		cin >> a[i];
	}
	vector<int> cntx(100000);
	vector<int> cnty(100000);
	for( int i = 0; i < 100000; ++i ){
		cntx[i] = 0;
		cnty[i] = 0;
	}
	for( int i = 0; i < n; i+=2 ){
		++cntx[a[i]-1];
		++cnty[a[i+1]-1];
	}
	int max_x = -1;
	int max_index = -1;
	int max_y = -1;
	int max_indey = -1;
	for( int i = 0; i < 100000; ++i ){
		if( max_x < cntx[i] ){
			max_x = cntx[i];
			max_index = i;
		}
		if( max_y < cnty[i] ){
			max_y = cnty[i];
			max_indey = i;
		}
	}
	if( max_index != max_indey ){
		cout << n - max_x - max_y << endl;
	} else {
		sort(cntx.rbegin(), cntx.rend());
		sort(cnty.rbegin(), cnty.rend());
		// cout << cntx[0] << " " << cntx[1] << " " << cnty[0] << " " << cnty[1] << endl;
		cout << n - max( cntx[0] + cnty[1], cntx[1] + cnty[0] ) << endl;
	}
	return 0;
}


Measured memory_bytes: 1408
dif = []
for i in range(3):
    c_i = list(map(int, input().split()))
    dif.append([c_i[0] - c_i[1], c_i[1] - c_i[2]])
if dif[0] == dif[1] == dif[2]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	d := make(map[int]struct{})
	for i := 0; i < n; i++ {
		a := iScan()
		if _, ok := d[a]; ok {
			delete(d, a)
		} else {
			d[a] = struct{}{}
		}
	}
	fmt.Println(len(d))
}


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

int main(void){
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    a.insert(a.begin(), 0); b.insert(b.begin(), 0);
    rep(i, n) a[i + 1] += a[i];
    rep(i, m) b[i + 1] += b[i];
    ll ans = 0;
    ll bp = m;
    rep(i, n + 1){
        if(a[i] > k) continue;
        while(a[i] + b[bp] > k) bp--;
        ans = max(ans, i + bp);
    }
    cout << ans << endl;
}

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

int cal(int a1, int a2, int a3) {
    return abs(a1 - a2) + abs(a2 - a3);
}

int main() {
    vector<int> A(3);
    for (int i = 0; i < 3; i++) cin >> A[i];

    int ans = 1000000000;
    ans = min(ans, cal(A[0], A[1], A[2]));
    ans = min(ans, cal(A[0], A[2], A[1]));
    ans = min(ans, cal(A[1], A[0], A[2]));
    ans = min(ans, cal(A[1], A[2], A[0]));
    ans = min(ans, cal(A[2], A[0], A[1]));
    ans = min(ans, cal(A[2], A[1], A[0]));
    
    cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
	else cout << "No";
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a_L=list(input().split())
ans1=[]
ans2=[]

if n==1:
	print(a_L[0])
else:
	for i in range(0,n,2):
		ans2.append(a_L[i])
	for i in range(1,n,2):
		ans1.append(a_L[i])


if n%2==0:
	ans1.reverse()
	print(*(ans1+ans2))
else:
	ans2.reverse()
	print(*(ans2+ans1))

Measured memory_bytes: 26436
//LOL
//LOL
//LOL
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans=0,k;
ll a[1003];
ll si[1003];
ll t[1003][1003];
bool ki[1003][1003][59];
int main(){
	memset (ki,0,sizeof(ki));
	cin>>n>>k;
	ll x=0;
	si[0]=0;
	for (ll i=1;i<=n;i++){
		cin>>a[i];
		si[i]+=si[i-1]+a[i];
	}
	for (ll i=1;i<=n;i++)
		for (ll j=i;j<=n;j++){
			t[i][j]=si[j]-si[i-1];
			for (int l=0;l<59;l++)
				if ((1ll*1<<l)&t[i][j]){
					ki[i][j][l]=1;
				}
		}
	vector <ll> q,v;
	for (ll i=1;i<=n;i++)
		for (ll j=i;j<=n;j++)
			q.push_back(i),v.push_back(j);
	for (ll i=58;i>=0;i--){
		ll zom=0;
		vector <ll> a,b;
		for (ll l=0;l<q.size();l++)
			if (ki[q[l]][v[l]][i])
				zom++;
		if (zom<k) continue;
		else{
			ans+=(1ll*1<<i);
			for (ll l=0;l<q.size();l++)
				if (ki[q[l]][v[l]][i])
					a.push_back(q[l]),b.push_back(v[l]);  
		}
		q=a,v=b;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 77020
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,m; cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;
	return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int H, W, N; cin >> H >> W >> N;
  int M = max(H, W);
  cout << (N + M - 1) / M << endl;
}


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 a[] = new int[6];
        int count = 0 ; 
        for(int i=0 ; i<6 ; i++){
            a[i]= sc.nextInt();
        }
        for(int i= 0 ; i <6-1 ; i++){
            for(int j =i+1; j<6 ; j++ ){
                
                if((a[j]-a[i])>a[6-1])
                    
                        count++;
                if(count>0)break;
            }
            if(count>0)break;
            
        }
        if(count>0)System.out.println(":(");
        else System.out.println("Yay!");
    }
 
}


Measured memory_bytes: 22740