akhauriyash/Code-Regression huggingface dataset:
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let m: usize = scan(tokens);
    let s: String = scan(tokens);
    let s = s.into_bytes();
    let mut ans = Vec::new();
    let mut p = n;
    loop {
        if p <= m {
            print!("{}", p);
            for x in ans.into_iter().rev() {
                print!(" {}", x);
            }
            println!("");
            return;
        }
        let mut x = m;
        while x > 0 && s[p - x] == b'1' {
            x -= 1;
        }
        if x == 0 {
            println!("-1");
            return;
        }
        ans.push(x);
        p -= x;
    }
}


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

//|\\---------------//|\\
//|\\RISE FROM ASHES//|\\
//|\\---------------//|\\

int main() {
    int n;
    cin>>n;
    char a[n];
    int ans=0;
    int r=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]=='R'){
            r++;
        }
    }
    for(int i=r;i<n;i++){
        if(a[i]=='R'){
            ans++;
        }
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3820
import sys

#+++++
	



def main():
	a,b,c,x,y = map(int, input().split())
	
	get_price=lambda na,nb,nab:max(na,0) * a + max(nb,0) * b + max(nab,0) * c
	us=lambda x:max(0,x)
	
	r_min=get_price(x,y,0)
	#print(r_min)
	for i in range(max(x,y)+1):
		r=get_price(us(x - i), us(y - i), 2*i)
		r_min=r if r<r_min else r_min
		#print(r, '_',r_min)
	
	print(r_min)
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
		
	ret = main()
	if ret is not None:
		print(ret)
		
	if sys.platform =='ios':
		sys.stdin.close()

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A + B <= C || A + C <= B || C + B <= A || A != B || B != C || C != A){
        cout << "No" << endl;
    }
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    a = input()
    print('A' if a.isupper() else 'a')


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 65716
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int A, B, ans = 0;
	cin >> A >> B;
	for (int i = 0; i < 2; i++) {
		ans += max(A, B);
		if (A >= B) {
			A--;
		}
		else B--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 100005

char s[2*MAX], t[2*MAX];

int main() {

	int n, l, i, ans = 0;
	scanf("%s", s);
	scanf("%s", t);

	l = strlen(s);

	for(i = 0 ; i < l ; i++) {
		if(s[i] != t[i]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4144
#include<iostream>

using namespace std;

int n, a[11];

bool dfs(int idx, int mxa, int mxb){
  if(idx==10)return true;
  if(a[idx]<mxa && a[idx]<mxb)return false;
  bool ap=false, bp=false;
  if(a[idx]>mxa){
    ap = dfs(idx+1, a[idx], mxb);
  }
  if(a[idx]>mxb){
    bp = dfs(idx+1, mxa, a[idx]);
  }
  return ap || bp;
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++)cin >> a[j];
    cout << (dfs(0, -1, -1)?"YES":"NO") << endl;
  }
}


Measured memory_bytes: 3088
#キーエンス プログラミング コンテスト 2019 b
s=input()
ans=False
for x in range(len(s)):
    for y in range(x,len(s)):
        if (s[:x]+s[y:])=='keyence':
            ans=True
if ans:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9056
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
typedef long long LL;
typedef pair<int,int> pii;

int x[] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

void run_case() {
    int k;cin >> k;
    cout << x[k];

}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(10);
    run_case();
    cout.flush();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int N;
	char S[100000];
	int i = 0, ans = 0;
	
	scanf("%d", &N);
	scanf("%s", S);
	
	while(i < N - 1){
		if((S[i] == 'O' && S[i + 1] == 'X') || (S[i] == 'X' && S[i + 1] == 'O')){
			ans++;
			i += 2;
		}else{
			i++;
		}
	}
	
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 2108
#include<iomanip>
#include<iostream>
#include<cstring>
#include<cmath>
#include<time.h>
#include<stdlib.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		c-=b;
		if(c<=0)return puts("Yes"),0;
		a-=d;
		if(a<=0)return puts("No"),0;
	}
    return 0;
}

Measured memory_bytes: 3636
c = [ list(map(int, input().split())) for _ in range(3)]
if (c[0][1] - c[0][0] == c[1][1] - c[1][0]) and (c[1][1] - c[1][0] == c[2][1] - c[2][0]) and (c[2][1] - c[2][0] == c[0][1] - c[0][0]) and (c[0][2] - c[0][0] == c[1][2] - c[1][0]) and (c[1][2] - c[1][0] == c[2][2] - c[2][0]) and (c[2][2] - c[2][0] == c[0][2] - c[0][0]):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
//dont try to understand my code i really dont understand it 
#include<iostream>
#include<fstream>
#include<cmath>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<vector>
#include <queue>
#include <stack>
#include<algorithm>
#include<memory.h>
using namespace std;
typedef long long ll;
#define f( i , x , n ) for(int i = x; i < (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define mt make_tuple
typedef pair<int, int> ii;
const double PI = acos(-1.0);
//const ll oo = 1000000000000030200;
//const ll F = LLONG_MIN;	
//const int A = 1234567;
typedef long long ll;
// write what you need here : ... 
int arr[102002];
int main()
{
	int a;
	cin >> a;
	for (int i = 1; i <= a;i++)
	{
		int temp;
		scanf("%d", &arr[i]);
	}

	int ans = 0;

	for (int i = 1; i <= a;i++)
	{
		if (arr[i] == i)
		{
			ans++;
			arr[i + 1] = arr[i];
		}
	}


	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
using namespace std;
int main(){
 string a,b;
 cin >>a>>b;
 int n= a.length();

 for(int i=0;i<n;i++){
   int count =0;
   for(int j=0;j<n;j++){
     int k=i+j;
     if(k>n-1) k-=n;
     if(a[k]==b[j]) count++;
   }
   if(count ==n) {cout<<"Yes"<<endl; return 0;}
 }
 cout <<"No"<<endl;

}


Measured memory_bytes: 256
import numpy as np
N=int(input())
A=np.array(list(map(int,input().split())))
B=np.array(list(map(int,input().split())))

AB=np.array([(A[i],B[i]) for i in range(N)])
AB=AB[np.argsort(AB[:,1])]

AI=np.array([[i,AB[i,0]] for i in range(N)])
AI=AI[np.argsort(AI[:,1])]

sigma=AI[:,0]
ASort=AI[:,1]
BSort=AB[:,1]

g=0
f=0
for i in range(N):
    if ASort[i]>BSort[i]:
        g=1
        break

counter=1
start=0
now=sigma[start]
while start!=now:
    now=sigma[now]
    counter+=1
    
if N==counter:
    f=1
    for i in range(N-1):
        if BSort[i]>=ASort[i+1]:
            f=0
            break

if f==0 and g==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 34552
s = input()

while len(s) > 0:
    if s[-5:] == "dream":
        s = s[:-5]
    elif s[-7:] == "dreamer":
        s = s[:-7]
    elif s[-5:] == "erase":
        s = s[:-5]
    elif s[-6:] == "eraser":
        s = s[:-6]
    else:
        print("NO")
        exit()

if len(s) == 0:
    print("YES")



Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
int n,l;
int flavor[1000];
int sum=0;
int main()
{
	cin>>n>>l;
	for(int i=1;i<=n;i++)
	{
		flavor[i]=l+i-1;
		sum+=l+i-1;
	}
	int ans=INT_MAX,store=0;
	for(int i=1;i<=n;i++)
	{
		if(sum-(abs(sum)-abs(flavor[i]))<=ans)
		{
			ans=sum-(abs(sum)-abs(flavor[i]));
			store=flavor[i];
		}
	}
	cout<<sum-store;
	return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS

#pragma comment(linker, "/STACK:256000000")

#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <deque>
#include <queue>
#include <iomanip>
#include <fstream>
#include <string>
#include <climits>

typedef long long ll;
typedef long double ld;

#define fi(n) for(int i = 0; i < (n); i++)
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define RFOR(i, k, n) for(int i = (k); i >= (n); i--)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = INT_MAX;
const int mod = 1e9 + 7;
const long long LINF = LLONG_MAX;

using namespace std;
vector<vector<int>> g;
vector<bool> used;
void dfs(int v, int l)
{
	used[v] = true;
	if (l >= 2)
		return;
	for (auto e : g[v])
		if (!used[e])
			dfs(e, l + 1);
}

int main()
{
	int n, m;
	cin >> n >> m;
	g.resize(n);
	used.resize(n);
	fi(m)
	{
		int v, u;
		scanf("%d %d", &v, &u);
		v--, u--;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	dfs(0, 0);
	if (used.back())
		cout << "POSSIBLE" << endl;
	else
		cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
#define pll pair<ll,ll>
#define pii pair<int,int>
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
 
ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b) ;} 

template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}
 

 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 	ll x,y;
 	cin>>x>>y;
 	int fl = 0;
 	for(int i=0;i<=x;i++){
 		ll cr = x-i;
 		ll tt = i;
 		ll crl = cr*2;
 		ll ttl = i*4;

 		if(crl+ttl==y){
 			fl = 1;
 			break;
 		}
 	}   
 	if(fl==0){
 		cout<<"No"<<endl;
 	}
 	else{
 		cout<<"Yes"<<endl;
 	}
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;
typedef pair<double, int> P;

void solve()
{
	priority_queue<P, vector<P>, greater<P> > PQue;
	for(int i = 0; i < 3; ++i)
	{
		vector<P> Vec(8);
		for(int j = 0; j < 8; ++j)
		{
			cin >> Vec[j].second >> Vec[j].first;
		}
		sort(Vec.begin(), Vec.end());
		printf("%d %.2f\n", Vec[0].second, Vec[0].first);
		printf("%d %.2f\n", Vec[1].second, Vec[1].first);
		for(int j = 2; j < 8; ++j)
		{
			PQue.push(Vec[j]);
		}
	}
	printf("%d %.2f\n", PQue.top().second, PQue.top().first);
	PQue.pop();
	printf("%d %.2f\n", PQue.top().second, PQue.top().first);
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();
        
        int result = a - b;
        if (op.equals("+")) result = a + b;
        System.out.println(result);
    }
}


Measured memory_bytes: 21972
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))


k = int(input())
n = 7
flag = False
for i in range(k):
    if n % k == 0:
        print(i+1)
        flag = True
        break
    else:
        n = n*10+7
        n %= k
if not flag:
    print(-1)



Measured memory_bytes: 63244
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  ll n,ans=0;
  cin >> n;
  string str;
  cin >> str;
  rep(i,1000){
    vi c(3);
    c = {i/100,(i/10)%10,i%10};
    int f=0;
    rep(j,str.size()){
      if((str[j]-'0')==c[f]){f++;}
      if(f==3){break;}
    }
    if(f==3){ans++;}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<queue>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

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

int main(){
    int d, n;
    cin >> d >> n;
    vector<int> vec(n);
    int tmp = 1;
    for(int i = 0 ; i < n ; i++){
        if((i + 1) % 100 == 0){
            tmp++;
        }
        vec[i] = pow(100, d) * tmp;
        tmp++;
    }
    cout << vec[n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	
	private static int gcd(int a, int  b) {
		int  temp = 0;

		if(a == 0) {
			return b;
		}
		if(b == 0) {
			return a;
		}
		if(a != 0 && b != 0) {
		while (a % b != 0){
			temp = a;
			a = b;
			b = temp % b;
		}
		}
		return b;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int []a = new int [n];
		
		for(int i = 0; i < n ; i++) {
			a[i] = sc.nextInt();
		}
		int []l = new int [n+1];
		int []r = new int [n+1];
		l[0] = 0;
		r[n] = 0;
		
		for(int i = 0; i < n ; i++) {
			l[i+1] = gcd(l[i],a[i]);
		}
		for(int j = n-1; j>=0; j--) {
			r[j] = gcd(r[j+1],a[j]);
		}
		int max = 1;
		
		for(int i = 0 ; i < n ; i++) {
			int p = gcd(l[i],r[i+1]);
			if(max < p)
				max = Math.max(max, p);
		}
		System.out.println(max);
		
		}
	}



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

int SumOfDigits(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main() {
	int N;
	cin >> N;
	int sum = SumOfDigits(N);
	int res = 0;
	if (N % sum == 0) ++res;
	if (res) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
N = int(input())
count=0
for i in range(3,N+1):
  if i%2==1 and len(make_divisors(i))==8:
    count += 1
print(count)

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

static const int NIL = -1;

class Node {
public:
    int parent;
    int left;
    int right;
    int depth;
    Node() : parent(NIL), left(NIL), right(NIL), depth(0) {}
};


int main()
{
    int n;
    cin >> n;
    vector<Node> tree(n);
    for (int i = 0; i < n; i++) {
        int id, c;
        cin >> id >> c;
        int k = id;
        for (int j = 0; j < c; j++) {
            int cid;
            cin >> cid;
            if (j == 0) {
                tree[k].left = cid;
            } else {
                tree[k].right = cid;
            }
            k = cid;
            tree[k].parent = id;
        }
    }
    for (int i = 0; i < n; i++) {
        int k = i;
        while (tree[k].parent != NIL) {
            tree[i].depth++;
            k = tree[k].parent;
        }
    }

    for (int i = 0; i < n; i++) {
        cout << "node " << i << ": parent = " << tree[i].parent << ", depth = " << tree[i].depth << ", ";
        if (tree[i].parent == NIL) {
            cout << "root";
        } else if (tree[i].left == NIL) {
            cout << "leaf";
        } else {
            cout << "internal node";
        }
        cout << ", [";
        if (tree[i].left != NIL) {
            cout << tree[i].left;
            int j = tree[tree[i].left].right;
            while (j != NIL) {
                cout << ", " << j;
                j = tree[j].right;
            }
        }
        cout << "]" << endl;
    }
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; 

int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  if(c-a-b < 0){
    cout << "No" << endl;
    return 0;
  }
  else{
    ll i = (c-a-b)*(c-a-b)-4*a*b;
    if(i > 0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

  

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

#define fio() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;

const ll mod = 1e9 + 7;
const ll maxn = 1e5 + 6;
const ll N = 1e2 + 2;
const ll inf = 1e12;
const ld eps = 1e-6;

ll n, tn, ans;
map <pair<string, string>, ll> cnt;
string s, l, r;

int main() {
	fio();
	cin >> n;
	cin >> s;
	for (int i = 0; i < (1LL << n); i++) {
		l = "", r = "";
		for (int j = 0; j < n; j++) 
			if (i & (1LL << j)) 
				l += s[j];	
		for (int j = n - 1; j >= 0; j--)
			if ((i & (1LL << j)) == 0)
				r += s[j];
		cnt[{l, r}]++;
	}
	for (int i = 0; i < (1LL << n); i++) {
		l = "", r = "";
		for (int j = n - 1; j >= 0; j--)
			if ((i & (1LL << j)) == 0)
				r += s[j + n];
		for (int j = 0; j < n; j++)
			if (i & (1LL << j))
				l += s[j + n];
		ans += 	cnt[{r, l}];
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 91904
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  cin >> n;
  if (n == 0 || n == 2)
    cout << 1 << endl;
  else if (n == 1)
    cout << 2 << endl;
  else
    cout << 0 << endl;
  return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef complex<ld> Point;
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

void solve() {
	int a[5];
	rep(i, 5)cin >> a[i];
	sort(a, a + 5);
	int ans = mod;
	while (true) {
		int sum = 0;
		rep(i, 5) {
			sum += a[i];
			if (i < 4) {
				if (sum % 10) {
					sum += 10 - sum % 10;
				}
			}
		}
		ans = min(ans, sum);
		if (!next_permutation(a, a + 5))break;
	}
	cout << ans << endl;
}
int main() {
	solve();
	//stop
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i=0; i<N; ++i) cin >> A[i];
  
  sort(A, A+N);
  
  cout << A[N-1] - A[0] << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(void) {
  int n;cin>>n;
  vector<int> d(n);
  fr(i,n)cin>>d[i];
  int ans = 0;
  fr(i,n-1) {
    for(int j = i+1; j < n; j++) ans += d[i]*d[j];
  }
 
  cout << ans<< endl;

  return 0;
}

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

const double eps = 1e-10;

int dcmp(double x) {
        if(fabs(x) < eps) return 0;
        return x < 0 ? -1 : 1;
}

#define Vector P
struct P {
        double x, y;
        P(double x = 0, double y = 0): x(x), y(y) {}
        P operator + (P b) {return P(x + b.x, y + b.y);}
        P operator - (P b) {return P(x - b.x, y - b.y);}
        P operator * (double b) {return P(x * b, y * b);}
        P operator / (double b) {return P(x / b, y / b);}
        double operator * (P b) {return x * b.x + y * b.y;} // Dot
        double operator ^ (P b) {return x * b.y - y * b.x;} // Cross
        double abs() {return hypot(x, y);}
        P unit() {return *this / abs();}
        P spin(double o) {
                double c = cos(o), s = sin(o);
                return P(c * x - s * y, s * x + c * y);
        }
};

struct Line {
        //ax + by + c = 0
        double a, b, c, theta;
        P pa, pb;
        Line(): a(0), b(0), c(0), theta(0), pa(), pb() {}
        Line(P pa, P pb): a(pa.y - pb.y), b(pb.x - pa.x), c(pa ^ pb), theta(atan2(-a, b)), pa(pa), pb(pb) {}        P projection(P p) {return pa + (pb - pa).unit() * ((pb - pa) * (p - pa) / (pb - pa).abs());}                P reflection(P p) {return p + (projection(p) - p) * 2;}
        double get_ratio(P p) {return (p - pa) * (pb - pa) / ((pb - pa).abs() * (pb - pa).abs());}
        P dis(P p) {return ((pb - pa) ^ (p - pa)) / (pb - pa).abs();} // directed distance
};

struct Circle {
        P c;
        double r;
        Circle(P c, double r = 0): c(c), r(r) {}
};
bool onsegment(P p, P a, P b) {
        return dcmp((a - p) ^ (b - p)) == 0 && dcmp((a - p) * (b - p)) <= 0;
}
bool segment_intersection(P p1, P p2, P p3, P p4) { // end points are not allowed
        return dcmp((p2 - p1) ^ (p3 - p1)) * dcmp((p2 - p1) ^ (p4 - p1)) < 0
                && dcmp((p4 - p3) ^ (p1 - p3)) * dcmp((p4 - p3) ^ (p2 - p3)) < 0;

}

int main() {
        ios_base::sync_with_stdio(false); cin.tie(0);
        P p1, p2;
        cin >> p1.x >> p1.y >> p2.x >> p2.y;
        Line l = Line(p1, p2);
        int q; cin >> q;
        while(q--) {
                P p; cin >> p.x >> p.y;
                P ans = l.projection(p);
                cout << fixed << setprecision(12) << ans.x << ' ' << ans.y << '\n';
        }
        return 0;
}


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

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  int x=0, best=0;
  for (int i = 0; i < n; ++i) {
    x += (s[i]=='I' ? 1 : -1);
    best = max(x, best);
  }
  cout << best << endl;
  return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)

a = []
n.times do
  a << gets.chomp
end

b = []
m.times do
  b << gets.chomp
end

d = n - m + 1
d.times do |x|
  d.times do |y|
    c = 0
    b.each_with_index do |s, i|
      c += 1 if a[y + i][x, m] == s
    end
    if c == m
      puts 'Yes'
      exit
    end
  end
end

puts 'No'




Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define X first
#define Y second
const int N = 2e5 + 87;
struct line
{
    ll a, b;
    ll operator () (ll x)
    {
        return a * x + b;
    }
};
bool ok(const line & o, const line & f, const line & g)
{
    return (g.b - o.b) * (o.a - f.a) <= (f.b - o.b) * (o.a - g.a);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    ll C;
    cin >> n >> C;
    vector<ll> dp(n);
    deque<line> dk;
    for (int i = 0; i < n; ++i) {
        ll h;
        cin >> h;
        if (i > 0) {
            while (dk.size() > 1 && dk[0](h) >= dk[1](h))
                dk.pop_front();
            dp[i] = h * h + dk[0](h);
        } 
        line nf = {-2 * h, h * h + C + dp[i]};
        for (int sz = dk.size(); sz >= 2 && ok(dk[sz - 2], dk[sz - 1], nf); --sz)
            dk.pop_back();
        dk.push_back(nf);
    }
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
using namespace std;

long long N, M, S, T, U, V, A[1 << 18], B[1 << 18], C[1 << 18], dist[1 << 18], dp1[1 << 18], dp2[1 << 18];
long long dista[1 << 18], distb[1 << 18], distc[1 << 18], distd[1 << 18];
vector<pair<long long, long long>>X[1 << 18];
int Order[1 << 18];

vector<long long>getdist(int pos) {
	priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>>Q;
	for (int i = 1; i <= N; i++) dist[i] = (1LL << 60);
	Q.push(make_pair(0, pos)); dist[pos] = 0;

	while (!Q.empty()) {
		int pos = Q.top().second; long long cost = Q.top().first; Q.pop();
		for (int i = 0; i < X[pos].size(); i++) {
			int to = X[pos][i].first; long long tm = X[pos][i].second;
			if (dist[to] > cost + tm) {
				dist[to] = cost + tm;
				Q.push(make_pair(dist[to], to));
			}
		}
	}
	vector<long long>E;
	for (int i = 1; i <= N; i++) E.push_back(dist[i]);
	return E;
}

int main() {
	cin >> N >> M >> S >> T >> U >> V;
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i] >> C[i];
		X[A[i]].push_back(make_pair(B[i], C[i]));
		X[B[i]].push_back(make_pair(A[i], C[i]));
	}
	vector<long long>A1 = getdist(S); for (int i = 1; i <= N; i++) dista[i] = A1[i - 1];
	vector<long long>A2 = getdist(T); for (int i = 1; i <= N; i++) distb[i] = A2[i - 1];
	vector<long long>A3 = getdist(U); for (int i = 1; i <= N; i++) distc[i] = A3[i - 1];
	vector<long long>A4 = getdist(V); for (int i = 1; i <= N; i++) distd[i] = A4[i - 1];

	vector<pair<long long, long long>>vec1;
	for (int i = 1; i <= N; i++) { if (dista[i] + distb[i] == dista[T]) vec1.push_back(make_pair(dista[i], i)); }
	sort(vec1.begin(), vec1.end());

	for (int i = 1; i <= N; i++) { dp1[i] = (1LL << 60); dp2[i] = (1LL << 60); Order[i] = -1; }
	for (int i = 0; i < vec1.size(); i++) Order[vec1[i].second] = i;

	for (int i = 0; i < vec1.size(); i++) {
		int pos = vec1[i].second; dp1[pos] = min(dp1[pos], distc[pos]);
		for (int j = 0; j < X[pos].size(); j++) {
			if (Order[X[pos][j].first] != -1 && Order[X[pos][j].first] > i) {
				dp1[X[pos][j].first] = min(dp1[X[pos][j].first], dp1[pos]);
			}
		}
	}
	for (int i = vec1.size() - 1; i >= 0; i--) {
		int pos = vec1[i].second; dp2[pos] = min(dp2[pos], distc[pos]);
		for (int j = 0; j < X[pos].size(); j++) {
			if (Order[X[pos][j].first] != -1 && Order[X[pos][j].first] < i) {
				dp2[X[pos][j].first] = min(dp2[X[pos][j].first], dp2[pos]);
			}
		}
	}

	long long ans = distc[V];
	for (int i = 1; i <= N; i++) ans = min(ans, min(dp1[i], dp2[i]) + distd[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 36596
#include <iostream>

using namespace std;
int n,a[21],b[21],res=0;
int main()
{
    //freopen("B.INP","r",stdin);
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n;
    for (int i=1;i<=n;i++) cin >> a[i];
    for (int i=1;i<=n;i++) cin >> b[i];
    for (int i=1;i<=n;i++) if (a[i]-b[i]>0) res+=a[i]-b[i];
    cout << res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(m);
    rep(i, m) cin >> a[i];

    int sum0 = 0, sum1 = 0;

    rep(i, m) {
        if (a[i] < x) {
            sum0 += 1;
        }
        else {
            sum1 += 1;
        }
    }

    put(min(sum0, sum1))
    
    return 0;
}

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

using namespace std;

constexpr int dx[] = {-1, -1, -1, +0, +0, +1, +1, +1};
constexpr int dy[] = {-1, +0, +1, -1, +1, -1, +0, +1};

bool is_goal(const vector<string>& f)
{
    int N = f.size();
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (f[i][j] == '#') {
                return 0;
            }
        }
    }
    return 1;
}

bool in_field(int x, int y, int N)
{
    return (0 <= x && x < N && 0 <= y && y < N);
}

vector<string> next(int x, int y, const vector<string>& f)
{
    int N = f.size();
    vector<string> nf = f;
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {            
            int cnt = 0;
            for (int k = 0; k < 8; k++) {
                int nx = j + dx[k], ny = i + dy[k];
                if (!in_field(nx, ny, N)) continue;
                if (f[ny][nx] == '#' || (nx == x && ny == y)) {
                    cnt++;
                }
            }

            if (f[i][j] == '#') {
                nf[i][j] = ((cnt == 2 || cnt == 3) ? '#' : '.');
            } else {
                nf[i][j] = (j == x && i == y ? '@' : (cnt == 3 ? '#' : '.'));
            }
        }
    } 
    return nf;
}

int bfs(int sx, int sy, const vector<string>& sf)
{
    int N = sf.size();
    
    queue<tuple<int, int, vector<string>>> Q;
    queue<int> Qt;
    
    Q.push(make_tuple(sx, sy, sf));
    Qt.push(0);    

    set<vector<string>> closed;
    
    int x, y;
    vector<string> f;
    
    while (!Q.empty()) {
        tie(x, y, f) = Q.front(); Q.pop();
        int t = Qt.front(); Qt.pop();
        
        if (is_goal(f)) return t;

        for (int i = 0; i < 8; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if (!in_field(nx, ny, N)) continue;
            if (f[ny][nx] == '#') continue;            
            
            auto nf = next(nx, ny, f);
            if (closed.count(nf) == 0) {
                closed.insert(nf);
                Q.push(make_tuple(nx, ny, nf));
                Qt.push(t + 1);
            }
        }
    }        
    return -1;
}

int main()
{
    int N;
    while (1) {
        cin >> N;
        if (N == 0) break;
        vector<string> f(N);
        int sx, sy;
        for (int i = 0; i < N; i++) {
            cin >> f[i];
            for (int j = 0; j < N; j++) {
                if (f[i][j] == '@') {
                    sx = j; sy = i;
                }
            }
        }
        cout << bfs(sx, sy, f) << endl;
    }        
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector< pair<int,int> > a(n);
	for(auto &x:a)cin>>x.first>>x.second;
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++){
		cout << a[i].first << " " << a[i].second << endl;
	}
}


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

int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    vector<int> ht(n);
    int m=0,cnt=0;
    rep(i,n){
        cin>>h[i];
        m=max(m,h[i]);
    }
    rep(j,m){
        bool f=false;
        rep(i,n){
            if(ht[i]<h[i]){
                ht[i]++;
                if(f==false) cnt++;
                f=true;
            }else f=false;
        }
    }
    cout <<cnt<<endl;
}


Measured memory_bytes: 384
import java.util.Scanner;


public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    System.out.println(lcm(a,b));
  }
  
  static long gcd(long a, long b) 

    { 

        if (a == 0) 

            return b; 

              

        return gcd(b % a, a); 

    } 

      

    // function to calculate lcm of 

    // two numbers. 

    static long lcm(long a, long b) 

    { 

        return (a * b) / gcd(a, b); 

    } 

}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int N;
int factor[1001];

int main() {
	cin >> N;
	rep(i, N) factor[i] = 0;

	for(int i = 1; i <= N; i++){
		int n = i;
		int k = 2;
		while(k <= 1000){
		    if (n % k == 0){
				n /= k;
				factor[k]++;
			}
			else{
				k++;
			}
		}
	}

	ll ret = 1;
	for(int k = 2; k <= 1000; k++){
		ret *= (1 + factor[k]);
		ret %= 1000000007;
	}

	cout << ret << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char a[4002];
char b[4002];
int maxmatch(char *a,char *b)
{
  int i=0,m=0,l=0;
  while(a[i] != '\0' && b[i] != '\0'){
    if(a[i] == b[i]) {
      l++;
      if(m < l) m = l;
    }else{
      l = 0;
    }
    i++;
  }
  return m;
}
int main()
{
  int d,i,l,m;
  while((scanf("%s",a)) != EOF){
    scanf("%s",b);
    m = 0;
    d = strlen(b);
    for(i=0;i<d;i++){
      l = maxmatch(a,b+i);
      if(m < l) m = l;
      if(m > d-i) break;
    }
    d = strlen(a);
    for(i=0;i<d;i++){
      l = maxmatch(a+i,b);
      if(m < l) m = l;
      if(m > d-i) break;
    }
    printf("%d\n",m);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int a, b, c; cin >> a >> b >> c;
    int ans = b + min(a+b+1,c);
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
int n, a, b; long long v[55], dp[55][55];
long long ncr(long long p1, long long p2) {
	if (p2 < 0 || p1 < p2)return 0;
	return dp[p1 - p2][p2];
}
int main() {
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)cin >> v[i];
	sort(v, v + n);
	long long T = v[n - a];
	long long H = 0; for (int i = n - a; i < n; i++)H += v[i];
	for (int i = 0; i < 55; i++) {
		for (int j = 0; j < 55; j++) {
			if (i == 0 || j == 0)dp[i][j] = 1;
			else dp[i][j] += dp[i - 1][j] + dp[i][j - 1];
		}
	}
	int L = n, R = 0; long long ret = 0;
	for (int i = 0; i < n; i++) { if (v[i] == T) { L = min(L, i); R = max(R, i); } }
	for (int i = a; i <= b; i++) {
		if (i != a && R != n - 1)continue;
		ret += ncr(R - L + 1, i - (n - R - 1));
	}
	printf("%.25Lf\n", 1.0L*H / a);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean ch=false;
		int i=1;
		for(; (i*(i+1))<=n*2; i++){
			if((i*(i+1))==n*2){
				ch=true;
				break;
			}
		}
		int[][] tmp=new int[i][i];
		int count=1;
		for(int j=0; j<i; j++){
			for(int k=0; k<i; k++){
				if(j>=k){
					tmp[j][k]=count++;
				}
			}
		}
		int[][] ans=new int[i+1][i];
		int cc=0;
		int bb=0;
		boolean tk=false;
		for(int j=0; j<i; j++){
			cc=j;
			bb=0;
			tk=false;
			for(int k=0; k<i; k++){
				if(cc==bb || tk){
					ans[j][k]=tmp[cc][bb];
					tk=true;
					cc++;
				}else{
					ans[j][k]=tmp[cc][bb++];
				}
			}
		}
		for(int j=0; j<i; j++){
			ans[i][j]=tmp[j][j];
		}
		if(ch){
			System.out.println("Yes");
			System.out.println(i+1);
			for(int j=0; j<i+1; j++){
				System.out.print(i+" ");
				for(int k=0; k<i; k++){
					System.out.print(ans[j][k]+" ");
				}
				System.out.println();
			}
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 56004
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 200005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	int w,h;
	scanf("%d %d",&w,&h);
	vector <P> vx;
	for(int i=0;i<w;i++)
	{
		int c;
		scanf("%d",&c);
		vx.push_back(P(c,0));
	}
	for(int i=0;i<h;i++)
	{
		int c;
		scanf("%d",&c);
		vx.push_back(P(c,1));
	}
	sort(vx.begin(),vx.end());
	int L=h+1,R=w+1;
	ll ret=0;
	for(int i=0;i<vx.size();i++)
	{
		P p=vx[i];
		if(p.second==0)
		{
			ret+=(ll) L*(ll) p.first;
			R--;
		}
		else
		{
			ret+=(ll) R*(ll) p.first;
			L--;
		}
	}
	printf("%lld\n",ret);
	return 0;
}


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

template <typename T> inline void read (T &x) {bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x<<3) + (x<<1) + c - 48; if (b)x=-x;}
template <typename T> inline void wrip(T x) {if (x > 9) wrip(x / 10); putchar(x%10 + 48); }

template <typename T> inline void write(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
inline char readch() {char c; do c = getchar(); while (c == '\n' || c == ' '); return c;}
inline void reads(string &s) {char c; while((c=getchar())==' '||c =='\n'); s=c; while((c=getchar())!=' '&&c!='\n') s+=c;}
inline void getlines(string &s) {char c; while((c=getchar())=='\n'); s=c; while((c=getchar())!='\n') s+=c;}
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair <int, int> ii;
typedef vector <int> vi;

const ld pi = acos(-1);
const ll inf = 1e16;
const int mod = 1e9 + 7,
N = 5055;
int Ask(int a, int b) {
    cout << "? " << a << ' ' << b << '\n';
    fflush(stdout);
    string s;
    cin >> s;
    if (s == "Y")
        return 1;
    return 0;
}
int main() {
    #ifdef makacha
        //freopen("m.inp", "r", stdin);
        //freopen("m.out", "w", stdout);
    #endif // makacha
    int A, B;
    cin >> A >> B;
    if (A <= B)
        return cout << "Impossible", 0;
    int n = A + B;
    vi ds, ans(n, 0);
    ds.push_back(0);
    for (int i = 1; i < n; i++) {
        if (!ds.size()) {
            ds.push_back(i);
            continue;
        }
        int tmp = Ask(ds.back(), i);
        if (tmp)
            ds.push_back(i);
        else
            ds.pop_back();
    }
    ans[ds.back()] = 1;
    for (int i = 0; i < n; i++)
        if (i != ds.back() && Ask(ds.back(), i))
            ans[i] = 1;
    cout << "! ";
    for (int i = 0; i < n; i++)
        cout << ans[i];
}



Measured memory_bytes: 724
#include <iostream>
using namespace std;
int min(int a, int b){
    if(a<=b){
        return a;
    }else{
        return b;
    }
}

int main(void){
    int N;
    int A, B;
    cin >> N >> A >> B;
    int P[N];
    for(int i=0;i<N;i++){
        cin >> P[i];
    }
    int g1=0;
    int g2=0;
    int g3=0;
    for(int i=0;i<N;i++){
        if(P[i]<=A){
            g1++;
        }else if(A < P[i] && P[i] <= B){
            g2++;
        }else{
            g3++;
        }
    }
    int MIN = min(g1, min(g2, g3));
    cout << MIN << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    vector<string>v(n);
    map <string,int> m;
    set <string> s;
    map <string,int> :: iterator it;

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

    for(int i=0; i<n; i++)
    {
        if(m.count(v[i]))
            m[v[i]]++;
        else
            m[v[i]]=1;
    }

    int high=0;
    for(it=m.begin(); it!=m.end(); it++)
        high=max(it->second,high);

    for(it=m.begin(); it!=m.end(); it++)
    {
        if(it->second==high)
            s.insert(it->first);
    }

    set <string> :: iterator itr;
    for(itr=s.begin(); itr!=s.end(); itr++)
        cout<<*itr<<endl;

    return 0;
}

Measured memory_bytes: 40736
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 999;// 1e25;
static const ll MAX_N = 100001;

//ll a[100001];
ll p[100001];
int main() {
	ll n, k, q; cin >> n >> k >> q;
	//repe(i, 1, q)cin >> a[i];
	repe(i, 1, n) p[i] = k - q;

	repe(i, 1, q) {
		ll a; cin >> a;
		p[a]++;
	}

	repe(i, 1, n) {
		if (p[i] <= 0)cout << "No" << endl;
		else cout << "Yes" << endl;
	}

	return 0;
}


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

using namespace std;

int main()
{
    vector<int> vec;
    bool flag;
    // 素数表の生成
    for(int i=2;i<55556;++i){
        flag = true;
        for(int j=2;j*j<=i;++j){
            if(i % j == 0){
                flag = false;
                break;
            }
        }
        if(flag) vec.push_back(i);
    }

    int N;
    cin >> N;

    vector<int> ans(N);

    int j=0;
    for(int i=0;i<N;++i){
        for(;j < vec.size(); ++j){
            if(vec[j] % 5 == 1){
                ans[i] = vec[j++];
                break;
            }
        }
    }
    for(int i=0;i<N;++i){
        if(i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let _: usize = iter.next().unwrap().parse().unwrap();
    
    let mut hmap = std::collections::HashMap::new();

    for _ in 0..n {
        let k: usize = iter.next().unwrap().parse().unwrap();
        let a: Vec<usize> = (&mut iter).take(k).map(|x| x.parse().unwrap()).collect();
        for a_i in a {
            *hmap.entry(a_i).or_insert(0) += 1;
        }
    }

    let mut ret = 0;
    for &e in hmap.values() {
        if e == n {
            ret += 1;
        }
    }
    println!("{}", ret);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define bug cout<<"AIkahne aise"<<endl
ll A[5000001];
vector<ll>v;
vector<pair<ll,ll> >v2;
/*void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}*/
int main()
{
    ll n,k,white=0,black=0,ans=9999999999,nblack=0,nwhite=0;
 string s;
 cin>>n;
 cin>>s;
  for(int i=0;i<s.size();i++)
 {
     if(s[i]=='#')
        black++;
     else
        white++;

 }
 ans=white;
  for(int i=0;i<s.size();i++)
  {
      if(s[i]=='#')
        nblack++;
      else
        nwhite++;
      ans=min(ans,nblack+white-nwhite);
  }
  cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 640