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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true; }
    return false;
}
template<class T>
void DEBUG_DP(T* viewdp, int ilen, int jlen){
    REP(i,ilen){
        REP(j,jlen){
            if(viewdp[i][j] != -1)
                printf("[% 4d]", viewdp[i][j]);
            else
                printf("[    ]");
        }
        puts("");
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int h,n;
    const int H = 20005;
    int dp[H];
    cin>>h>>n;
    vi a(n), b(n);
    REP(i,n){
        cin>>a[i]>>b[i];
    }

    fill(dp,dp+H,INT_MAX);
    dp[0] = 0;

    REP(i,n){
        REP(j,h){
            if(dp[j] != INT_MAX)
                chmin(dp[j+a[i]],dp[j] + b[i]);
        }
    }

    //DEBUG_ARR(dp,h+10);
    int ans = INT_MAX;
    FOR(i,h,H){
        if(dp[i] != INT_MAX){
            chmin(ans, dp[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
typedef struct node{
	int key;
	int pri;
	struct node *right , *left;
}Node;

Node * Delete(Node **,int);
Node * del(Node **,int);

int find(Node *p,int x)
{
	while(p!=NIL)
	{
		if(p->key==x)return 1;
		else if(p->key > x)p = p->left;
		else p = p->right;
	}
	return 0;
}

void inorder(Node *a)
{
	if(a->left!=NIL) inorder(a->left);
	printf(" %d",a->key);
	if(a->right!=NIL) inorder(a->right);
	return;
}

void preorder(Node *p)
{
	printf(" %d",p->key);
	if(p->left!=NIL) preorder(p->left);
	if(p->right!=NIL) preorder(p->right);
	return;
}

void print(Node *p)
{
	inorder(p);
	printf("\n");
	preorder(p);
	printf("\n");
	return;
}

Node * makenode(int x , int y)
{
	Node *new = malloc(sizeof(Node));
	new->key = x;
	new->pri = y;
	new->left = NIL;
	new->right = NIL;
	return new;
}

Node *rightRotate(Node *p)
{
	Node *q = p->left;
	p->left = q->right;
	q->right = p;
	return q;
}

Node *leftRotate(Node *p)
{
	Node *q = p->right;
	p->right = q->left;
	q->left = p;
	return q;
}

Node* insert(Node **t , int key, int pri)
{
	Node *new;
	if((*t)==NIL)
	return new = makenode(key,pri);
	if((*t)->key == key)
	return *t;
	
	if(key < (*t)->key)
	{
		(*t)->left = insert(&(*t)->left,key,pri);
		if((*t)->pri < (*t)->left->pri)
		(*t) = rightRotate(*t);
	}
	else
	{
		(*t)->right = insert(&(*t)->right,key,pri);
		if((*t)->pri < (*t)->right->pri)
		(*t) = leftRotate((*t));
	}
	return *t;
}

Node * Delete(Node **t , int key)
{
	if((*t)==NIL)
	return NIL;
	
	if(key < (*t)->key)
	(*t)->left = Delete(&((*t)->left),key);
	
	else if(key > (*t)->key)
	(*t)->right = Delete(&((*t)->right),key);

	else return del(t,key);
	return *t;
}

Node * del(Node **t , int key)
{
	if((*t)->left == NIL && (*t)->right == NIL)
	{
		return NIL;
	}
	else if((*t)->left == NIL)
	{
		(*t) = leftRotate(*t);
	}
	else if((*t)->right ==NIL)
	{
		(*t) = rightRotate(*t);
	}
	else
	{
		if((*t)->left->pri > (*t)->right->pri)
		(*t) = rightRotate(*t);
		else
		(*t) = leftRotate(*t);
	}
	return Delete(t,key);
}

int main(void)
{
	int num ,  x, y;
	char com[8];
	Node *root = NIL;
	scanf("%d",&num);
	
	for(int i = 0; i < num; i++)
	{
		scanf("%s",com);
		switch(com[0])
		{
			case 'i':scanf("%d %d",&x,&y);
			root = insert(&root,x,y);
			break;
			case 'd':scanf("%d",&x);
			root = Delete(&root,x);
			break;
			case 'f':scanf("%d",&x);
			if(find(root,x))printf("yes\n");
			else printf("no\n");
			break;
			case 'p':print(root);
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 8036
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

// 素因数分解：nの素因数分解を{素数, 指数}の形で昇順に返す
vector<pair<long long, long long>> primeFactorize(long long n){
    vector<pair<long long, long long>> ret;
    for(long long i=2; i*i<=n; i++){
        if(n%i != 0) continue;
        long long ex = 0;
        while(n%i == 0){ ex++; n /= i; }
        ret.push_back({i, ex});
    }
    if(n != 1) ret.push_back({n, 1});
    return ret;
}

int main(){
    Init();
    ll n; cin >> n;
    vi cnt(1001);
    for(ll i=1; i<=n; i++){
        auto p = primeFactorize(i);
        for(auto c: p) cnt[c.first] += c.second;
    }
    ll ans = 1;
    for(auto c: cnt) if(c != 0) ans = (ans*(c+1))%MODV;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;

#define MAX (200000 + 1)

int main()
{
    char S[MAX], T[MAX];
    cin >> S >> T; 
    long len = strlen(S);
    long i;
    long count = 0;
    for (i = 0; i < len; i++) {
        if (S[i] != T[i]) count++;
    }

    cout << count;
    return 0;
}

Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
// #define int long long  

//////////

signed main()
{
	fastio;
	int a,b;
	cin>>a>>b;
	cout<<max(a+a-1,max(a+b,b+b-1));
}

Measured memory_bytes: 256
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int maxn=100000+10;
const int maxm=200000+10;

struct Edge{int u,v;Edge(int u=0,int v=0):u(u),v(v){}}e[maxm];

int first[maxn],Next[maxm],ecnt;
inline void add_edge(int u,int v){
	Next[ecnt]=first[u];first[u]=ecnt;e[ecnt++]=Edge(u,v);	
	Next[ecnt]=first[v];first[v]=ecnt;e[ecnt++]=Edge(v,u);	
}

int sz[maxn],fa[maxn],opp,cur;

int n;
int dfs(int u,int pre,int dep)
{
	fa[u]=pre;
	if(u==n){
		opp=(dep+1)/2;
		
		cur=u;
		for(int j=dep;j>opp+1;--j) cur=fa[cur];
	}
	
	sz[u]=1;
	for(int i=first[u];i!=-1;i=Next[i])
	{
		int v=e[i].v;
		if(v!=pre) sz[u]+=dfs(v,u,dep+1);
	}
	return sz[u];
}

int main()
{
	
	cin>>n;memset(first,-1,sizeof first);
	
	for(int i=1,u,v;i<n;++i)
	{
		cin>>u>>v;
		add_edge(u,v);
	}
	
	dfs(1,1,1);
	
	puts(sz[cur] >= n - sz[cur] ? "Snuke":"Fennec");
	return 0;
}


Measured memory_bytes: 8448
// package agc.agc019;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        char[] a = in.nextToken().toCharArray();
        long[] deg = new long[255];

        for (int i = 0; i < a.length ; i++) {
            deg[a[i]]++;
        }
        long pairs = 0;
        for (int c = 'a' ; c <= 'z' ; c++) {
            long pa = deg[c];
            pairs += pa * (pa - 1) / 2;
        }

        long n = a.length;
        long all = n * (n - 1) / 2;
        out.println(all - pairs + 1);
        out.flush();
    }

    public static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static class InputReader {
        private static final int BUFFER_LENGTH = 1 << 12;
        private InputStream stream;
        private byte[] buf = new byte[BUFFER_LENGTH];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            return (char) skipWhileSpace();
        }

        public String nextToken() {
            int c = skipWhileSpace();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            int c = skipWhileSpace();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        int skipWhileSpace() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            return c;
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
    int k,n,a[200005];
    cin>>k>>n;
    for(int i=0;i<n;i++)
        a[i]=read();
    int l=n-1,r=1,pl=0,pr=0;
    int cnt=0,L,R;
    ll ans=0;
    int flag=1;
    L=abs(a[l]-a[pl]);
	L=k-L;
	R=abs(a[r]-a[pr]);
    while(1)
    {
        if(cnt==n-1)
            break;
        if(L<R)
        {
            ans+=L;
            pl=l;
            l--;
            cnt++;
            L=abs(a[l]-a[pl]);
        }
        else
        {
            ans+=R;
            pr=r;
            r++;cnt++;
            R=abs(a[r]-a[pr]);
        }
    }
    cout<<ans<<endl;
	return 0;
}
/*
20 5
0 5 10 17 19
*/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k,ans = 300000000;
    ll pm;
    cin >> n >> k;
    vector<ll> x(n);
    for(int i = 0;i < n;i ++){
        cin >> x[i];
    }
    for(int i = 0;i < n-k+1;i ++){
        int d;
        pm = x[i]*x[i+k-1];
        if(pm>0) {
            d = max(abs(x[i]),abs(x[i+k-1]));
        }else{
            d = 2*(abs(x[i])+abs(x[i+k-1]))-max(abs(x[i]),abs(x[i+k-1]));
        }
        if(d<ans) ans = d;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n, res, cnt, ans;
string s, s1, s2;
int main()
{
    cin >> s >> s1 >> s2;
    cout << (char) toupper(s[0]) << (char) toupper(s1[0]) << (char) toupper(s2[0]) << endl;
}


Measured memory_bytes: 256
#■標準入力ショートカット

def get_next_int():
    return int(float(input()))
def get_next_str():
    return input()

def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])
def get_next_strs(delim=" "):
    return tuple(input().split(delim))

def get_next_by_types(*value_types,delim=" "):
    return tuple([t(x) for t, x in zip(value_types,input().split(delim))])

def main():
    n = get_next_int()
    from collections import defaultdict
    data = defaultdict(int)
    
    for i in range(2):
        for j, value in enumerate(get_next_ints()):
            data[(i,j)] = value
    
    max_get = defaultdict(int)
    
    for i in range(2):
        for j in range(n):
            max_get[(i,j)] = data[(i,j)] + max(max_get[(i-1,j)],max_get[(i,j-1)])
    
    return max_get[(1,n-1)]


if __name__ == '__main__':
    print(main())
    

Measured memory_bytes: 3444
n, m = gets.chomp.split(" ").map(&:to_i)
h = Hash.new(0)
n.times do
  row = gets.chomp.split("")
  row.each do |c|
    h[c] += 1
  end
end
if n.even? && m.even? then
  g1 = 0
  g2 = 0
elsif n.odd? && m.odd? then
  g1 = 1
  g2 = (n / 2) + (m / 2)
else
  g1 = 0
  g2 = 0
  g2 += (n / 2) if n.even?
  g2 += (m / 2) if m.even?
  g4 = (n / 2) * (m / 2)
end

flag = true
h.each do |k, v|
  if g1 < 0 || g2 < 0 then
    flag = false
    break
  end
  if v % 4 == 0 then
    next
  elsif v % 4 == 2 then
    g2 -= 1
  elsif v % 4 == 3 then
    g2 -= 1
    g1 -= 1
  else
    g1 -= 1
  end
end

if flag then
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 2044
let solve n m = (n - 1) * (m - 1)

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ =
  match read_ints () with
  | [n; m] -> solve n m |> string_of_int |> print_endline
  | _ -> ()

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}

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

const int M=500,L=10000;
ll a[M+2][M+2],n;
bool b[L];
vl p;
set<ll> st;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	fill(b,b+L,1);
	for(int i=0;i<M+2;i++) fill(a[i],a[i]+M+2,1);
	for(int i=2;i<L;i++) if(b[i]){
		p.push_back(i);
		for(int j=i;j<L;j+=i) b[j]=0;
	}
	for(int i=1;i<=M;i++) for(int j=1;j<=M;j++) if((i+j)%2==0){
		ll t=p[(j-i)/2+249]*p[(i+j)/2+498];
		a[i][j]=t;st.insert(t);
	}
	for(int i=1;i<=M;i++) for(int j=1;j<=M;j++) if((i+j)%2==1){
		ll x=1;
		for(int k=0;k<4;k++) x=lcm(x,a[i+dx[k]][j+dy[k]]);
		a[i][j]=x+1;st.insert(x+1);
	}
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) cout<<a[i][j]<<" \n"[j==n];
}

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

int main() {
  
  int N;
  cin >> N;
  int m = 0;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++){
    
    int x;
    cin >> x;
    vec.at(i) = x;
  }
  
  sort(vec.begin(), vec.end());
  
  for (int i = 0; i < N; i++){
    
    int y;
    y = i + 1;
    
    if (y < N){
      if (vec.at(i) < vec.at(y)){
        m = m + 1;
      }
    }
  }
  
  cout << m + 1 << endl;
  
  
}

Measured memory_bytes: 3572
import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
 
N=II()
A=[II() for i in range(N)]

b=sorted(A)
b.reverse()
for i in range(N):
    if A[i] == b[0]:
        print(b[1])
    else:
        print(b[0])

Measured memory_bytes: 16116
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<cfloat>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

#define PI (3.1415926535)
#define EPS (1e-10)

int main(){
  string str;
  while(getline(cin,str)){
    FOR(it,str) if(islower(*it)) *it=toupper(*it);
    cout << str << endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  int i,j,sum1=0,sum2=0;
  //dainyu-
  for(i=0;i<N;i++){cin >> a.at(i);}
  
  //sort
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  for(i=0;i<N;i++){
    if(i%2==0){sum1+=a.at(i);}
    else{sum2+=a.at(i);}
  }
	cout<<sum1-sum2<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

bool isPrime[100004];
vector<int> prime;
int main(){
   memset(isPrime, true, sizeof(isPrime));
   for(int i=2; i<100004; i++){
      if(isPrime[i]){
         prime.emplace_back(i);
         for(int j=i+i; j<100004; j+=i){
            isPrime[j]=false;
         }
      }
   }
   int N;
   cin >> N;
   auto it=lower_bound(prime.begin(),prime.end(),N);
   cout << *it << endl;

   return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a<=0&&b>=0)
		printf("Zero");
	else	if(a<0)
			{
				if((b-a)%2==0)printf("Negative");
				else printf("Positive");
			}
			else	printf("Positive");
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    A = Scanner.map_int()
    d = defaultdict(int)
    for a in A:
        d[a] += 1
    print('YNEOS'[not (d[5] == 2 and d[7] == 1)::2])


if __name__ == "__main__":
    main()


Measured memory_bytes: 60908
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int H;
int heap[500000];

inline void max_heapify(int node) {
    int left = node * 2 + 1, right = node * 2 + 2, largest = node;
    if (left < H && heap[left] > heap[node]) {
        largest = left;
    }
    else {
        largest = node;
    }
    if (right < H && heap[right] > heap[largest]) {
        largest = right;
    }
    if (largest != node) {
        int tmp = heap[node];
        heap[node] = heap[largest];
        heap[largest] = tmp;
        max_heapify(largest);
    }
}

inline void build_max_heap() {
    for (int i = (H) / 2; i >= 0; --i) {
        max_heapify(i);
    }
}

int main(void) {

    cin >> H;

    for (int i = 0; i < H; ++i) {
        scanf("%d", heap + i);
    }

    build_max_heap();

    for (int i = 0; i < H; ++i) {
        printf(" %d", heap[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 3184
n,k = map(int,input().split())
p = list(map(int,input().split()))
u = sum(p[0:k])
maxsum = u
for i in range(1, n-k+1):
	u = u + p[i+k-1] - p[i-1]
	if u >= maxsum:
		maxsum = u
print((maxsum+k)/2)

Measured memory_bytes: 71792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	if (N%K == 0) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
}

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

#define fast                     ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int                      long long 
#define pb                       push_back
#define pii                      pair<int,int>
#define vi                       vector<int>
#define vii                      vector<pii>
#define mi                       map<int,int>
#define mii                      map<pii,int>
#define all(a)                   (a).begin(),(a).end()
#define F                        first
#define S                        second
#define sz(x)                    (int)x.size()
#define endl                     '\n'
#define MOD                      1000000007
#define loop(i,a,b)              for(int (i)=(a);(i)<(b);(i)++)
#define rloop(i,a,b)             for(int (i)=(a);(i)>=(b);(i)--)
#define Unique(A)                (A).resize(distance((A).begin(),unique(all((A)))))
#define MXe(A)                   *max_element(all(A))
#define MNe(A)                   *min_element(all(A))
#define SP(val,precision)        fixed << setprecision((precision)) << (val)
#define setBits(x)               __builtin_popcountll(x)
#define zroBits(x)               __builtin_ctzll(x)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define mem(name,val)            memset(name,val,sizeof(name))
#define traceA(A,x)              cerr<<#A<<": ";loop(i,0,x)cerr<<A[i]<<' ';cerr<<endl
#define traceV(A)                cerr<<#A<<": ";for(auto i:A)cerr<<i<<' ';cerr<<endl
#define traceM(A,n,m)            cerr<<#A<<": "<<endl;loop(i,0,n){loop(j,0,m) cerr << A[i][j] << ' ';cerr << endl;}
#define maxheap                  priority_queue<int>
#define minheap                  priority_queue<int,vector<int>,greater<int>>

template<typename T> T pow(T a,T b, int m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

using namespace std;

const int N = 2e5+77;
int A[N];
string a,b;

void sol(){
    int n ; cin >> n ;
    loop(i,0,n) cin >> A[i];
    int ans =0 ;
    loop(i,0,n){
        loop(j,i+1,n){
            loop(k,j+1,n){
                if(A[i]==A[j] || A[j]==A[k] || A[k]==A[i]) continue;
                if(A[i]+A[j] > A[k] && A[i]+A[k] > A[j] && A[j]+A[k] > A[i]) ans++ ;
            }
        }
    }
    cout << ans << endl;
}

int32_t main(){
    int t = 1;  while(t--) sol();
    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 
  
  string s; cin >> s;

  int res = 700;
  for (int i = 0; i < 3; ++i) {
    if (s[i] == 'o') res += 100;
  }
  cout << res << "\n";
}


Measured memory_bytes: 3628
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(a, b) for(int unsafe_cnt=a; unsafe_cnt < b;unsafe_cnt++)
#define fn auto
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

void newline() {cout << endl;}
template <typename T> void display(T input){cout << input;}
template <typename T> void put(T input){display(input); newline();}
void iput(int input) {put(input);}

int gray   = 0;
int brown  = 0;
int green  = 0;
int aqua   = 0;
int blue   = 0;
int yellow = 0;
int orange = 0;
int red    = 0;
int other  = 0;

void select_color(int rate){
    rate <= 399  ? gray++
  : rate <= 799  ? brown++
  : rate <= 1199 ? green++
  : rate <= 1599 ? aqua++
  : rate <= 1999 ? blue++
  : rate <= 2399 ? yellow++
  : rate <= 2799 ? orange++
  : rate <= 3199 ? red++
  :                other++;
}

fn main() -> int {
  int n;
  vector<int> a;
  cin >> n;
  rep(0, n){
    int in;
    cin >> in;
    select_color(in);
  }
  int min = 0;
  int max = 0;
  vector<int> v = { gray  
                  , brown 
                  , green 
                  , aqua  
                  , blue  
                  , yellow
                  , orange
                  , red   
                  };
  for(auto iter=v.begin(); iter != v.end(); iter++){
    if(*iter != 0){
      min++;
    }
  }
  max = min;
  if(other != 0){
    max+=other;
    if(min == 0){ min++;}
  }
  cout << min << " " << max << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#define INF (1<<20)
using namespace std;

int main(){
    int n;
    cin>>n;
    int min=0;
    int minnum=0;
    for(int i=1;i<=n;i++){
        int x,y;
        cin>>x>>y;
        if(x>min) {
            min = x;
            minnum=y;
        }
    }
    int result=0;
    result=minnum+min;
    cout<<result;
    return 0;
}

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

int main() {
  double a, b, c, d;
  cin >> a >> b;
  c = (a+1)/0.08, d = (b+1)/0.1;
  a /= 0.08, b /= 0.1;
  if(a!=int(a)) a=int(a)+1;
  if(b!=int(b)) b=int(b)+1;
  if(c!=int(c)) c=int(c);
  else c=int(c)-1;
  if(d!=int(d)) d=int(d);
  else d=int(d)-1;
  
  if(a<=b && d<=c) cout << b << endl;
  else if(a<=d && d<=c) cout << a << endl;
  else if(a<=b && b<=c) cout << b << endl;
  else cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3696
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll a,b,t;
    cin>>a>>b>>t;
    ll ans=0;
    for(ll i=1;i<=t;i++){
        if(i%a==0){ans+=b;}
    }
    cout<<ans<<endl;
    
    
    return 0;
}


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

int main() {
  char c[10];
  for (int i = 0; i < 10; i++) {
    cin >> c[i];
  }
  
  c[3] = '8';
  
  for (int i = 0; i < 10; i++) {
    cout << c[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)

N, M = LI()
a = [0]*M; b = [0]*M; c = [0]*(M)
for i in range(M):
    a[i], b[i] = LI()
    C = LI()
    for j in range(b[i]):
        c[i] += 2**(C[j]-1)
cou = int(0)
#print(c)
dp = [[0]*(2**N) for _ in range(N)]
dp = [inf]*(2**N)
dp[0] = 0

for i in range(2**N):
    for k in range(M):
        if i^c[k]!=i-c[k]:
            dp[i|c[k]] = min(dp[i|c[k]],dp[i]+a[k])

ans = dp[2**N-1]
if ans==inf:
    ans = -1
print(ans)

Measured memory_bytes: 43608
l s=(take(n`div`2)s)==reverse(drop(n`div`2+n`mod`2)s)where n=length s
main=getLine>>=putStrLn.(\s->if(l s)&&(l$take(length s`div`2)s)&&(l$drop((1+length s)`div`2)s)then"Yes"else"No")

Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<62);

int main() {
    cin>>N;
    ll res = 1;
    vec a(N);
    rep(i,N){
        cin>>a[i];
        if(a[i] == 0){
            cout<<0<<endl;
            return 0;
        }
    }
    rep(i,N){
        if(res > INF / a[i]){
            cout<<-1<<endl;
            return 0;
        }else{
            res *= a[i];
        }
    }
    cout<<(res > ll(1e+18) ? -1 : res)<<endl;
}

Measured memory_bytes: 4052
#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
using namespace std;

int main() {
    int N;
    cin >> N;
    int A = 0;

    vector<int> b(N);
    for (int i = 0; i <= N - 1; i++) {
        cin >> b.at(i);
        
    }
    sort(b.begin(), b.end());
    for (int i = 0; i <= N-2; i++) {
       
        
        if (b.at(i) != b.at(i + 1))
            A++;
    }

    cout << A + 1 << endl;



    
}

Measured memory_bytes: 3620
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll inf =1LL << 62;
int main(void){
	int n;
	while(cin >> n,n){
		int m=1 << 29;
		for(int i=0;i<=100;i++)
			for(int j=0;j<=1000;j++){
				int x=n-i*i*i-j*j;
				if(x>=0)
					m=min(m,x+i+j);
			}
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<utility>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<cstring>
#define nax 305
#define mod 1000000007
#define ll long long int
using namespace std;
double p[nax][nax][nax]={0};
double ev[nax][nax][nax]={0};
int main(){
	int n=0;
	cin >> n;
	vector<int> v(n);
	vector<int> f(4,0);
	for(int i=0;i<n;i++){
		cin >> v[i];
		f[v[i]]++;
	}
	p[f[1]][f[2]][f[3]]=1;
	for(int c=n;c>=0;c--){
		for(int b=n;b>=0;b--){
			for(int a=n;a>=0;a--){
				if((a+b+c)>n){
					continue;
				}
				if(a==0 && b==0 && c==0){
					continue;
				}
				
				double p_w=(double)(1.0*(n-(a+b+c))/n);
				double e_w=(p_w/(1-p_w))+1;
				ev[a][b][c]+=e_w*p[a][b][c];
				if(a!=0){
				double p_1=(double)a/(a+b+c);
				p[a-1][b][c]+=p[a][b][c]*p_1;
				ev[a-1][b][c]+=ev[a][b][c]*p_1;
				}
				if(b!=0){
				double p_2=(double)b/(a+b+c);
				p[a+1][b-1][c]+=p[a][b][c]*p_2;
				ev[a+1][b-1][c]+=ev[a][b][c]*p_2;
				}
				if(c!=0){
				double p_3=(double)c/(a+b+c);
				p[a][b+1][c-1]+=p[a][b][c]*p_3;
				ev[a][b+1][c-1]+=ev[a][b][c]*p_3;
				}
			}
		}
	}
	printf("%.11f",ev[0][0][0]);
	return 0;
}

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

int x[55],y[55];
double distance(int I,int J){
    return sqrt((x[I]-x[J])*(x[I]-x[J])+(y[I]-y[J])*(y[I]-y[J]));
}

int main(){
    int n;
    cin >> n;
    double ans=1e9;
    double tmp;
    double a,b,c;
    double A,B,C;
    queue<pair<double,double>> q;
    for(int i=0;i<n;i++)cin >> x[i] >> y[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)continue;
            else{
                for(int k=0;k<n;k++){
                    if(i==k || j==k)q.push(make_pair((x[i]+x[j])/2.0,(y[i]+y[j])/2.0));
                    else{
                        a=distance(i,j);
                        b=distance(k,j);
                        c=distance(i,k);
                        if(a+b>c && a+c>b && b+c>a){
                            A=sin(2.0*acos((b*b+c*c-a*a)/(2.0*b*c)));
                            B=sin(2.0*acos((a*a+c*c-b*b)/(2.0*a*c)));
                            C=sin(2.0*acos((a*a+b*b-c*c)/(2.0*a*b)));
                            q.push(make_pair((A*x[k]+B*x[i]+C*x[j])/(A+B+C),(A*y[k]+B*y[i]+C*y[j])/(A+B+C)));
                        }
                    }
            }}
        }
    }
    while(!q.empty()){
        tmp=0;
        for(int i=0;i<n;i++)tmp=max(tmp,sqrt((x[i]-q.front().first)*(x[i]-q.front().first)+(y[i]-q.front().second)*(y[i]-q.front().second)));
        ans=min(tmp,ans);
        q.pop();
    }
    cout << fixed << setprecision(16);
    cout << ans << endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> p(2 * n);
    map<int, bool> isred;
    for (int i = 0; i < n; i++)
    {
        cin >> p[i].first >> p[i].second;
        isred[p[i].first] = 1;
    }
    for (int i = n; i < 2 * n; i++)
        cin >> p[i].first >> p[i].second;

    sort(p.begin(), p.end());
    set<int> t;
    int ans = 0;
    for (int i = 0; i < 2 * n; i++)
    {
        if (isred[p[i].first])
            t.insert(p[i].second);
        else
        {
            int a = -1;
            for (int x : t)
            {
                if (p[i].second > x)
                    a = x;
                else
                    break;
            }
            if (a != -1)
            {
                t.erase(a);
                ans += 1;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;




ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}
int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    ll X;
    cin >> X;
    vector<ll> table;
    ll i = 0;
    while(1){
        table.push_back(i*i*i*i*i);
        table.push_back(i*i*i*i*i* -1);
        if(i*i*i*i*i >pow(10,18)) break;
        i++;
    }
    rep(i, table.size()){
        for(int j = i + 1; j < table.size(); j++){
            if(table[i] - table[j] == X){
                if(i%2 == 1) i *= -1;
                if(j%2 == 1) j *= -1;
                cout << i / 2 << " " << j / 2 << endl; 
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3756
using System;
using System.Collections.Generic;

class MainClass
{

    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] cards = Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), int.Parse);
        var list = new List<int> {  };
        list.AddRange(cards);
        list.Sort();
        int sumA = 0;
        int sumB = 0;

        if(list.Count % 2 ==0)
        {
            for(var i = 0; i<list.Count; i += 2)
            {
                sumB += list[i];
            }
            for (var i = 1; i < list.Count; i += 2)
            {
                sumA += list[i];
            }
        }
        else
        {
            for (var i = 0; i < list.Count; i += 2)
            {
                sumA += list[i];
            }
            for (var i = 1; i < list.Count; i += 2)
            {
                sumB += list[i];
            }
        }
        Console.WriteLine(sumA - sumB);
    }

}

Measured memory_bytes: 11220
#include<stdio.h>
int main(){
  int n,m,a[1010][2],b[1010][2],c[2010],s[1010],i,j,ar=0,br=0,r;
  while(scanf("%d",&n),n){
    for(i=ar=0;i<n;i++)scanf("%d %d",&a[i][0],&a[i][1]);
    scanf("%d",&m);
    for(i=br=0;i<m;i++)scanf("%d %d",&b[i][0],&b[i][1]);
    a[n][0]=b[m][0]=10000;
    for(i=0;i<n+m;i++){
      if     (a[ar][0]<b[br][0])c[i]=a[ar++][1];
      else if(a[ar][0]>b[br][0])c[i]=b[br++][1];
      else{
	if   (a[ar][1]<b[br][1])c[i]=b[br++][1];
	else                    c[i]=a[ar++][1]; 
      }
    }
    //for(i=0;i<n+m;i++)printf("%d ",c[i]);printf("\n");
    r=1;
    for(s[i=0]=-1;i<n+m;i++){
      for(s[j=r]=10000;s[j-1]>=c[i];j--);
      if(s[j]>c[i])s[j]=c[i];
      if(j==r)r++;
      //for(j=0;j<r;j++)printf("%d ",s[j]);printf("\n");
    }
    printf("%d\n",r-1);
  }
  return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<cassert>
using namespace std;

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;

        vector<vector<int>> win(N);
        repeat(i, 1, N) {
            int a; cin >> a; a--;
            win[a].push_back(i);
        }

        function<int(int)> f = [&](int n) {
            int m = win[n].size();
            vector<int> depth;
            for(int nxt : win[n]) depth.push_back(f(nxt));
            sort(all(depth));
            int mx = 0;
            repeat(i, 1, m + 1) {
                set_max(mx, max({i, depth[i - 1] + 1, mx + 1}));
            }
            // cerr << n << " " << mx << endl;
            return mx;
        };
        int ans = f(0);
        assert(ans <= N);
        cout << f(0) << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


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

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

    int ans = 0;
    vector<int> a(N);

    for (int i = 0; i < M; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int s;
            cin >> s;
            s--;
            a[s] |= 1 << i;
        }
    }

    int p = 0;
    for (int i = 0; i < M; i++) {
        int x;
        cin >> x;
        p |= x << i;
    }

    for (int bit = 0; bit < (1 << N); bit++) {
        int t = 0;
        for (int i = 0; i < N; i++) {
            if (bit >> i & 1) {
                t ^= a[i];
            }
        }
        if (t == p) {
            ans++;
        }
    }

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


Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, M; cin >> N >> M;
    int L = N / __gcd(N, M) * M;

    string s, t; cin >> s >> t;
    bool ok = true;
    for(int i=0; i<N; i++) {
        int idx = i * L / N;
        // k * L / M = idx を満たす k が存在するか
        if(idx * M % L == 0) {
            int k = idx * M / L;
            ok &= (s[i] == t[k]);
        }
    }
    cout << (ok ? L : -1) << endl;
    return 0;
}

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

// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  for (int bit = 0; bit < (1 << 3); bit++) {
    ll t = s[0] - '0';
    string op = "";
    for (int i = 0; i < 3; i++) {
      if (bit & (1 << i)) {
        t += s[i + 1] - '0';
        op += "+";
      } else {
        t -= s[i + 1] - '0';
        op += "-";
      }
    }
    if (t == 7) {
      cout << s[0] << op[0] << s[1] << op[1] << s[2] << op[2] << s[3]
           << "=7\n";
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var A = ReadLongs().OrderByDescending(x => x).ToList();

            var confort = 0L;
            for (int i = 0; i < N - 1; i++)
            {
                if (i == 0)
                {
                    confort += A[i];
                    continue;
                }
                if (i % 2 == 0)
                {
                    confort += A[i / 2];
                }
                else
                {
                    confort += A[(i + 1) / 2];
                }
            }

            return confort;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 52900