akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
 
int main() {
 
   int n;
   if(scanf("%d",&n)){};
   int a = pow(n,2);
   printf("%d",a);
 
  return 0;
}

Measured memory_bytes: 128
def Sol(n):
    
    cur= 100
    y = 0
    while cur < n:
        cur += int(cur/100)
        y +=1
    print(y)
    
    return

    
n = int(input())

#for t in range(int(input())):
#a,b = map(int,input().split())
#    arr = []
#    for i in range(c):
#        arr.append(list(map(int,input().split())))
#arr = list(map(int,input().split()))
#k = input()
#n = int(input())
Sol(n)

Measured memory_bytes: 64256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


a, b = Is()

def factorization(n):
    arr = []
    tmp = n
    for i in range(2, int(floor(sqrt(n)))+1):
        if tmp % i == 0:
            count = 0
            while tmp % i == 0:
                count += 1
                tmp //= i
            arr.append([i, count])

    if tmp != 1:
        arr.append([tmp, 1])

    return arr


g = gcd(a, b)
A = factorization(g)
print(len(A)+1)

Measured memory_bytes: 63468
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

static const int N = 100;

int main(){
    int n, p[N+1], m[N+1][N+1];
    cin >> n;
    for(int i =1 ; i<=n ; i++){
        cin >> p[i-1] >> p[i];
    }
    
    for(int i =1 ; i<=n ; i++){m[i][i] = 0;}
    for(int l =2 ; l<=n ; l++){
        for(int i =1 ; i<=n-l+1 ; i++){
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for(int k =i ; k<=j-1 ; k++){
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
            }
        }
    }
    
    cout << m[1][n] << endl;
  
    return 0;
}


Measured memory_bytes: 3136
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
 
static const double EPS = 1e-8;
 
int main(){
  int math,greedy,geometry,DP,graph,other;
  while(~scanf("%d %d %d %d %d %d",
               &math,&greedy,&geometry,&DP,&graph,&other)){
    if(math + greedy + geometry + DP + graph + other == 0) break;

    int A = math+DP;
    int B = greedy + graph;
    int C = geometry + other;
    
    int res = 0;

    int max_game = min(min(A,B),C);
    for(int balance_game = 0; balance_game <= min(2,max_game); balance_game++){
      int tmpA = A;
      int tmpB = B;
      int tmpC = C;
      tmpA -= balance_game;
      tmpB -= balance_game;
      tmpC -= balance_game;
      int math_game = tmpA / 3;
      int algorithm_game = tmpB / 3;
      int implement_game = tmpC / 3;

      res = max(balance_game + math_game + algorithm_game + implement_game,res);
    }
    printf("%d\n",res);
  }
}

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

int main(){
  int64_t N, K;
  cin >> N >> K;
  int64_t Ans=0;
  for(int64_t i=K; i<=N+1; i++){
    Ans+=(N-i+1)*i+1;
    Ans%=1000000007;
  }
  cout << Ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline void chmin(T &a, T b){if(a>=b)a=b;}
template<class T> inline void chmax(T &a, T b){if(a<=b)a=b;}
typedef long long ll;
const int INF = 1e9;
 
int N, M;
int P[110000], Y[110000];
map<int, vector<int> > m; // map[area] = vector[year]
int main(){
    cin >> N >> M;
    // 入力、各県ごとに年月を管理
    REP(i,M){
        cin >> P[i] >> Y[i];
        m[P[i]-1].push_back(Y[i]);
    }
    // 各県ごとにソート
    REP(i,N) sort(m[i].begin(),m[i].end());
    // 入力した順番にプリント
    REP(i,M){
        // num = i番目の都市の、P[i]の県で誕生した順番 (1-indexed)
        int num = lower_bound(m[P[i]-1].begin(),m[P[i]-1].end(),Y[i]) - m[P[i]-1].begin() + 1;
        cout << setfill('0') << setw(6) << right << P[i];
        cout << setfill('0') << setw(6) << right << num << endl;
    }

    return 0;
}

Measured memory_bytes: 13184
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    Q=[]
    for _ in range(N):
        a,b=MI()
        Q.append([b,a])
        
    Q.sort()
    now=0
    flag=1
    for i in range(N):
        b,a=Q[i]
        now+=a
        if now>b:
            flag=0
            break
            
    if flag:
        print("Yes")
    else:
        print("No")
        

main()


Measured memory_bytes: 100380
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]

happy = [abc[0]]

for i in range(1, N):
    a = max(happy[i - 1][1], happy[i - 1][2]) + abc[i][0]
    b = max(happy[i - 1][0], happy[i - 1][2]) + abc[i][1]
    c = max(happy[i - 1][0], happy[i - 1][1]) + abc[i][2]
    happy.append([a, b, c])

print(max(happy[N - 1]))




Measured memory_bytes: 47272
A,B,C,D,E,F = map(int,input().split())

water = set()
sugar = set()

s = 0
a = 0
b = 0

for i in range(30):
    for j in range(30-i):
        if 100*A*i+100*B*j <= F:
            water.add(100*A*i+100*B*j)

water.remove(0)

for i in range(3000):
    for j in range(3000-i):
        if C*i+D*j <= F:
            sugar.add(C*i+D*j)

sugar.remove(0)

WATER = list(water)
SUGAR = list(sugar)

for i in WATER:
    for j in SUGAR:
        if (j <= i*E/100) and (i+j <= F):
            if s == 0:
                s = 100*j /(i + j)
                a = i
                b = j
            else:
                if s < 100*j /(i + j):
                    s = 100*j /(i + j)
                    a = i
                    b = j

if a == 0 and b == 0:
    print(100*A,0)
else:
    print(a+b,b)


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

int main(){
    string s,t;
    cin>>s>>t;
    int ans = 10000;
    int ls  = (int)s.size();
    int lt  = (int)t.size();
    rep(i,ls-lt+1){
        string ss = s.substr(i,lt);
        int count = 0;
        rep(j,lt){
            if(ss[j]!=t[j])count++;
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

const int N = 1010;

int n,m,dp[N][N],mod=1e9+7;
char a[N][N],A[N][N];

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%s",&A[i]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            a[i][j] = A[i-1][j-1];

    dp[n][m] = 1;
    for(int i=n;i>=1;i--)
        for(int j=m;j>=1;j--)
        {
            if( a[i][j] == '#' || ( i == n && j == m ) )
                continue;

            if( i != n && a[i+1][j] == '.' )
                dp[i][j] += dp[i+1][j];
            if( j != m && a[i][j+1] == '.' )
                dp[i][j] += dp[i][j+1];

            dp[i][j] %= mod;
        }

    printf("%d\n",dp[1][1]);
}


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

double p[3030];
double dp[3030][3030];

int n;

signed main ( ) {

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

    dp[0][0] = 1;

    for ( int i = 0; i <= n; i++ ) {
        for ( int j = 0; j <= n; j++ ) {
            dp[i+1][j]   += (1-p[i]) * dp[i][j];
            dp[i+1][j+1] += p[i]     * dp[i][j];
        }
    }

    double rec = 0;
    for ( int i = n/2+1; i <= n; i++ ) {
        rec += dp[n][i];
    }

    printf("%.012lf\n", rec);

    return 0;
}

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

using namespace std;

/*helpfull*/
using vt  = vector<long long>;
using pr  = pair<long long, long long>;
using ll  = long long int;


struct hash_pair {
	template <class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const
	{
		auto hash1 = hash<T1> {}(p.first);
		auto hash2 = hash<T2> {}(p.second);
		return hash1 ^ hash2;
	}
};
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

// shortcut macros
#define mp              make_pair
#define fi              first
#define se              second
// #define mt              make_tuple
#define pb              push_back
#define all(x)          (x).begin(), (x).end()
#define ini(a, v)       memset(a, v, sizeof(a))
#define rep(i, a, n)    for(ll i=a ; i<n ; ++i)
#define For(i, n)       rep(i, 0, n)
#define sz(x)           (int((x).size()))
#define ump(x,y)        unordered_map<x,y>
#define umpr(x,y,z)     unordered_map<x,y,z>

ll min_edit_dist(string s1, string s2, ll n1, ll n2) {
	ll dp[n1 + 1][n2 + 1];
	for (int i = 0; i <= n1; i++)
		dp[i][0] = i;
	for (int j = 1; j < n2; j++)
		dp[0][j] = j;
	for (int i = 1; i <= n1; i++) {
		for (int j = 1; j <= n2; j++) {
			if (s1[i - 1] == s2[j - 1])
				dp[i][j] = dp[i - 1][j - 1];
			else
				dp[i][j] = 1 + min({dp[i][j - 1], dp[i - 1][j], dp[i - 1][j - 1]});

		}
	}
	return dp[n1][n2];
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll n;
	cin >> n;
	vt h(n), cost(n + 1);
	For(i, n)
	cin >> h[i];
	cost[0] = 0;
	cost[1] = cost[0] + abs(h[0] - h[1]);
	for (int i = 2; i < n; i++) {
		cost[i] = cost[i - 1] + abs(h[i] - h[i - 1]);
		cost[i] = min(cost[i], cost[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << cost[n - 1] << endl;
	return 0;
}



Measured memory_bytes: 4752
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int read() {
	int x = 0,f = 0;char ch = getchar();
	while(!isdigit(ch)) {if(ch == '-')f = 1;ch = getchar();}
	while(isdigit(ch)) {x = x * 10 + ch - '0';ch = getchar();}
	return f ? -x : x;
}
const int N = 3e5 + 100;
int a[N],f[N],t[N<<2],Max,ans,n,k;
void update(int u,int l,int r,int pos,int k) {
	if(l == r) {
		t[u] = max(t[u],k);return;
	}
	int mid = l + r >> 1;
	if(pos <= mid) update(u<<1,l,mid,pos,k);
	else update(u<<1|1,mid+1,r,pos,k);
	t[u] = max(t[u<<1],t[u<<1|1]);
}
int ask(int u,int l,int r,int L,int R) {
	if(R < l || r < L) return 0;
	if(L <= l && r <= R) return t[u];
	int mid = l + r >> 1;
	return max(ask(u<<1,l,mid,L,R),ask(u<<1|1,mid+1,r,L,R));
}
int main() {
	n = read();k = read();
	for(int i = 1;i <= n;i++) {
		a[i] = read() + 1;Max = max(a[i],Max);
	}
	for(int i = 1;i <= n;i++) {
		int L = a[i] - k;if(L <= 0) L = 1;
		int R = a[i] + k;if(R > Max) R = Max;
		// cout <<a[i]<<" ans:: "<< L << " " << R << endl;
		int res = ask(1,1,Max,L,R);
		f[i] = res + 1;ans = max(ans,f[i]);
		//cout << f[i] << endl;
		update(1,1,Max,a[i],f[i]);
	}
	cout << ans << endl;
}

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

int main(){
    char s[200001], * a, * z;
    scanf("%s", s);
    a = strchr(s, 'A');
    z = strrchr(s, 'Z');
    printf("%ld\n", (z-s+1) - (a-s));
    return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if((a+b) % 2 == 1){
    cout << 1 + (a+b)/2 << endl;
  }
  else{
    cout << (a+b)/2 << endl;
  }
}
  

Measured memory_bytes: 256
import java.io.*;
// import java.util.*;
import java.lang.Math.*;

public class Main{

 
    
    public static void main(String[] args)throws IOException{
	int[] sample = new int[101];
	BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
	String line;
	int x;
	while((line=br.readLine())!=null){
		x=Integer.parseInt(line);
		sample[x]++;
      	
	    }
	 int max=0;
    for(int i =1 ;i<101;i++)
	max=Math.max(max,sample[i]);
    for(int i =0;i<101;i++)
	if(max==sample[i])
	    System.out.println(i);
    }
}

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

int n, x;
vector<pair<int, int>> a;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> x;
        a.push_back({x, i});
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < (int)a.size(); i++) {
        cout << a[i].second << ' ';
    }
    return 0;
}

Measured memory_bytes: 4236
from sys import stdin
input = lambda: stdin.readline().rstrip()
n = int(input())
h = list(map(int, input().split()))
max_h = h[0]
ans = 1
for i in range(1, n):
    if h[i] >= max_h:
        ans += 1
        max_h = h[i]
print(ans)


Measured memory_bytes: 61688
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef long double LD;

const int MOD = 1e9 + 7;
const int MAXN = 1e5;

vector<int> G[MAXN];

int calc(int n) {
	if (G[n].size() == 0) return 0;
	priority_queue<int, vector<int>, greater<int>> q;
	int res = 0;
	for (int s : G[n]) {
		q.push(calc(s));
	}
	while(q.size()) {
		int d = q.top(); q.pop();
		res = max(d, res) + 1;
//		cout << "hoge" << d << ":" << res << endl;
	}
//	cout << n << ":" << res << endl;
	return res;
}

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

	int N, A;
	cin >> N;
	for (int i = 1; i < N; i++) {
		cin >> A;
		G[--A].push_back(i);
	}
	cout << calc(0) << endl;

	return 0;
}

Measured memory_bytes: 13568
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int wa,tuginoSaidai,hozon;
		wa = 0;
		final int KOSU = N;
		int[] kakaku = new int[KOSU];
		int[] narabi = new int[KOSU]; 
		for (int i=0;i<KOSU;i++) {
			kakaku[i] = sc.nextInt();
		}
		Arrays.sort(kakaku);
		for(int i=0;i<K;i++) {
			wa = wa +kakaku[i];
		}
		System.out.println(wa);
		sc.close();
	}

}

Measured memory_bytes: 38656
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

#include <iomanip>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const ll INF = 1e17;
ll dp[100005][13];

signed main(void) {
  ll N;
  string S;
  cin >> N;
  cin >> S;

  string ans = "No";
  if (N%2 == 0) {
    ans = "Yes";
    rep(i, N/2) {
      if (S[i] != S[i+N/2]) {
        ans = "No";
        break;
      }
    } 
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def resolve():
    k, s = map(int, input().split())
    cnt = 0
    for i in range(k+1):
        if i > s:
            break
        for j in range(k+1):
            if 0 <= s-i-j <= k:
                cnt += 1
            elif s-i-j < 0:
                break
    print(cnt)
resolve()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
int n,m;
vector<ll> x,y,z;

ll solve(int mask) {
    vector<ll> sum;
    REP(i,n) {
        ll tmp = 0;
        if (mask&(1<<0)) tmp += -x[i];
        else tmp += x[i];
        if (mask&(1<<1)) tmp += -y[i];
        else tmp += y[i];
        if (mask&(1<<2)) tmp += -z[i];
        else tmp += z[i];
        sum.push_back(tmp);
    }
    sort(sum.begin(), sum.end(), greater<>());
    ll ret = 0;
    REP(i,m) {
        ret += sum[i];
    }
    return ret;
}

int main(int argc, char const *argv[]) {
    cin >> n >> m;
    x.resize(n); y.resize(n); z.resize(n);
    REP(i,n) {
        cin >> x[i] >> y[i] >> z[i];
    }

    ll ans = 0;
    for (int bit = 0; bit < (1 << 3); ++bit) {
        ans = max(ans, solve(bit));
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
    string t;
    cin >> t;
    stack<char> s;
    int sum = 0;
    for(int i = 0;i < t.size();i++){
        if(s.empty() || s.top() == t[i])s.push(t[i]);
        else {
            sum += 2;
            s.pop();
        }
    }
    cout << sum << endl;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int k, x;
  cin >> k >> x;
  int bgn = x -k +1;
  int end = x +k -1;
  
  for(int i = bgn; i <= end; i++)
    cout << i << " " << "\n";
}


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

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

#define rep(i,n) for (ll i = 0; i < (n); i++)
#define ru(a,b) (((a)+((b)-1)) / (b))   //切り上げ(a/b)
#define dump(x)  cout << #x << " = " << (x) << endl;

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

	if ((s[2] == s[3]) && (s[4] == s[5]))

	cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
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();}
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 EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int sign(int a){
	return (a>0?1:-1);
}
int main() {
	int n;
	while(cin>>n,n){
		vi stones;
		REP(i,n){
			int c;
			cin>>c;
			if(stones.size()==0){
				stones.push_back(c>0?1:-1);
			}else{
				vi::iterator back=stones.end()-1;
				if(*back>0==c){
					(*back)+=sign(*back)*1;
				}else{
					if(i%2==0){
						stones.push_back(c>0?1:-1);
					}else{
						if(stones.size()==1){
							(*back)*=-1;
							(*back)+=sign(*back)*1;
						}else{
							int a=abs(*back);
							stones.erase(back);
							vi::iterator newback=stones.end()-1;
							*newback+=sign(*newback)*a;
							*newback+=sign(*newback)*1;
						}
					}
				}
			}
		}
		int ans=0;
		REP(i,stones.size()){
			ans+=stones[i]<0?-stones[i]:0;
		}
		cout<<ans<<endl;
	}
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()

int dfs(int now, vector<vector<int>>& graph)
{
    int i;
    vector<int> v;
    for(i = 0;i < graph.at(now).size();++i){
        v.push_back(dfs(graph.at(now).at(i), graph));
    }
    sort(all(v));
    int res = 0;
    for(i = 0;i < v.size();++i){
        res = max(res, v.at(i) + (int)v.size() - i);
    }
    return res;
}

int main()
{
    int i,j;
    int n;
    cin >> n;
    vector<vector<int>> graph(n);
    for(i = 1;i < n;++i){
        int a;
        cin >> a;
        --a;
        graph.at(a).push_back(i);
    }
    cout << dfs(0, graph) << endl;

    return 0;
}

Measured memory_bytes: 17880
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()] # 必要な準備

needs = []
need = 0
ans = 0
if sum(A) < sum(B):
    print(-1)
else:
    for i in range(N):
        diff = A[i] - B[i]
        if diff < 0:
            ans += 1
            need += (-diff)
        elif diff > 0:
            needs.append(diff)
    if need != 0:
        needs.sort(reverse=True)
        for item in needs:
            need -= item
            ans += 1
            if need <= 0:
                break
    print(ans)


Measured memory_bytes: 18356
#include<iostream>
#include<cstdio>
#include<functional>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<map>
#include<ctime>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxn = 7e4+7;
const int inf = 1e5;
const int modn = 1e9+7;
const ld eps = 1e-8;
const long double PI = acos(-1.0);
void qRead(ll &x){x = 0;char a;for(a = getchar();a <'0' || a > '9';a = getchar());for(;a >= '0' && a <= '9';a = getchar())x = x*10 + a-'0';}
void qRead(int &x){x = 0;char a;for(a = getchar();a <'0' || a > '9';a = getchar());for(;a >= '0' && a <= '9';a = getchar())x = x*10 + a-'0';}
ll qpow(ll a,ll b,ll mo = modn){
//    printf("%lld\n",mo);
    ll res = 1;
    while(b){
        if(b & 1)res = (res*a) % mo;
        a = (a*a) % mo;
        b >>= 1;
    }
    return res;
}
ld qpow(ld a,ll b){
    ld res = 1;
    while(b){
        if(b & 1)res *= a;
        a = a*a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b){
    if(!b)return a;
    return gcd(b,a%b);
}
//ll vis[maxn],prime[maxn],cnt,smallP[maxn];
//void getPrime(int n){
//    cnt = 0;
//    for(int i = 1;i <= n;i++)vis[i] = 0;
//    for(ll i = 2;i <= n;i++){
//        if(!vis[i]){
//            prime[++cnt] = i;
//            smallP[i] = i;
//        }
//        for(int j = 1;j <= cnt && i*prime[j] <= n;j++){
//            vis[prime[j]*i] = 1;
//            smallP[prime[j]*i] = prime[j];
//            if((i % prime[j]) == 0)break;
//        }
//    }
//}
//ll cnm[maxn][maxn];
//void getCnm(){
//    cnm[0][0] = 1;
//    for(int i = 1;i < maxn;i++){
//        for(int j = 0;j <= i;j++){
//            cnm[i][j] = cnm[i-1][j];
//            if(j)cnm[i][j] += cnm[i-1][j-1];
//            cnm[i][j] %= (modn-1);
//        }
//    }
//}
//ll f[maxn],invF[maxn];
//void getF(){
//    f[0] = invF[0] = 1;
//    for(int i = 1;i < maxn;i++)f[i] = f[i-1]*i % modn;
//    invF[maxn-1] = qpow(f[maxn-1],modn-2);
//    for(int i = maxn-2;i >= 1;i--)invF[i] = invF[i+1]*(i+1) % modn;
//}
int main(){
    int n;
    scanf("%d",&n);
    int ans = 0,wei = 1;
    while(n){
        int judge = n%10;
        if(judge == 9)ans += wei;
        else ans+= 9*wei;
        n /= 10;
        wei *= 10;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

A = A + [0]
for k in range(K):
    t = [0]*(N+1)
    for i in range(N):
        l = max(i-A[i], 0)
        r = min(i+A[i], N-1)
        t[l] += 1
        t[r+1] -= 1

    S = [0]*N
    S[0] = t[0]
    for i in range(1, N):
        S[i] = S[i-1] + t[i]

    A = S.copy()
    if all(a == N for a in A):
        print(*A)
        exit()
print(*S)


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

int main()
{
    int a,b,r;
    scanf("%d%d",&a,&b);
    if(a+b==15)
        printf("+\n");
    else if(a*b==15)
        printf("*\n");
    else
        printf("x\n");
    return 0;
}

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

using namespace std;
long long ans;
int n, k;
int main() {
    cin >> n >> k;
    if (k == 0) {
        cout << (1LL * n * n);
        return 0;
    }
    for (int b = 1; b <= n; b++) {
        if (b - 1 < k) continue;
        int nn = n;
        if (nn % b < k) nn = b * (nn / b);
        else ans += (nn % b - k + 1);
        nn = b * (nn / b);
        ans += (nn / b) * (b - 1 - k + 1);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<=n;i++)
typedef long long ll;
using namespace std;
int main()
{
   int N;
   cin >> N;
   string S;
   cin >> S;
   ll ans=-1;

   rep(i,1,N)
   {
      vector<bool>c(26,false);
      string s1=S.substr(0,i);
      string s2=S.substr(i);
      ll a=0;
      rep(j,0,s1.length())
      {
        c[s1[j]-'a']=true;
      }
      rep(j,0,s2.length())
      {
         if(c[s2[j]-'a']){
            ++a;
            c[s2[j]-'a']=false;
         }
      }
      ans=max(ans,a);
   }

   cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll m, n;
ll b[1000], r[1000];

struct edge { ll to, cap, rev; };

vector<edge> G[2000];
ll level[2000];	//sからの距離
ll iter[2000];	//どこまで調べ終わったか

void add_edge(ll from, ll to, ll cap) {
	G[from].push_back({ to,cap,(ll)G[to].size() });
	G[to].push_back({ from,0,(ll)G[from].size() - 1 });
}

void bfs(ll s) {
	fill(level, level + 2000, -1);
	queue<ll> que;
	level[s] = 0;
	que.push(s);
	while (!que.empty()) {
		ll v = que.front();
		que.pop();
		for (ll i = 0; i < G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

ll dfs(ll v, ll t, ll f) {
	if (v == t)return f;
	for (ll &i = iter[v]; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (e.cap > 0 && level[v] < level[e.to]) {
			ll d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

ll max_flow(ll s, ll t) {
	ll flow = 0;
	for (;;) {
		bfs(s);
		if (level[t] < 0)return flow;
		fill(iter, iter + 2000, 0);
		ll f;
		while ((f = dfs(s, t, INF)) > 0) {
			flow += f;
		}
	}
}

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

int main() {
	while (cin >> m >> n&&m + n) {
		rep(i, 2000)G[i].clear();
		rep(i, m) {
			add_edge(0, i + 1, 1);
			cin >> b[i];
		}
		rep(i, n) {
			add_edge(m + 1 + i, m + n + 1, 1);
			cin >> r[i];
		}
		rep(i, m) {
			rep(j, n) {
				if (gcd(b[i], r[j]) != 1) {
					add_edge(i + 1, m + j + 1, 1);
				}
			}
		}
		//rep(i, m + n + 2) {
		//	cout << "!" << i << endl;
		//	rep(j, G[i].size()) {
		//		cout << G[i][j].to << " " << G[i][j].cap << " " << G[i][j].rev << " " << endl;
		//	}
		//}
		cout << max_flow(0, m + n + 1) << endl;
	}
}



Measured memory_bytes: 15888
H, W = map(int,input().split())

L = [input() for i in range(H)]
count = [i*W for i in [[0]]*H]
for i in range(H):
    start = 0
    end = 1
    seq = 0
    for j in range(W):
        if L[i][j]=='.':
            seq+=1
            end+=1
            if j==W-1:
                count[i][start:W]=[seq for k in range(W-start)]
            
        else:
            end=j
            count[i][start:end]=[seq for k in range(end-start)]
            if not W-1==j:
                start=j+1
            seq=0
L = list(map(list, (zip(*L))))
count = list(map(list, (zip(*count))))
for i in range(W):
    start = 0
    end = 1
    seq = 0
    for j in range(H):
        if L[i][j]=='.':
            seq+=1
            end+=1
            if j==H-1:
                for n in range(H-start):
                    count[i][start+n]+=seq
        else:
            end=j
            for n in range(end-start):
                count[i][start+n]+=seq
            if not H-1==j:
                start=j+1
            seq=0
num_max=0
for i in range(W):
    for j in range(H):
        if num_max<count[i][j]:
            num_max=count[i][j]
print(num_max-1)



Measured memory_bytes: 270468
#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN = 1e5+10;
const int MAXQ = 1e5+10;

ll n, k, q;
ll a[MAXQ];
ll cnt[MAXN];

void solve() {
  for (int i=0;i<q;i++) {
    cnt[a[i] - 1]++;
  }
  for (int i=0;i<n;i++) {
    if (cnt[i] + k > q) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

int main() {
  cin >> n >> k >> q;
  for (int i=0;i<q;i++) {
    cin >> a[i];
  }
  solve();
}


Measured memory_bytes: 2176
n = int(input())

A, B = [], []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

s, t = 0, 0
if n % 2 == 0:
    s = (A[n//2-1] + A[n//2])
    t = (B[n//2-1] + B[n//2])
else:
    s = A[n//2]
    t = B[n//2]

print(t-s+1)

Measured memory_bytes: 25404
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 
ll mpow(ll a, ll b){
	if(a==0) return 0;
	if(b >= (MOD-1)) b %= (MOD-1);
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}
 
ll mpow(ll a, ll b, ll p){
	if(a==0) return 0;
	if(b==0) return 1;
	ll t1 = mpow(a,b/2,p);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
 
ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}

mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
 
ll range(ll l, ll r){
	return l + mt()%(r-l+1);
}
 
ll rev(ll v){
	return mpow(v,MOD-2);
}

void solve(){
	string s;
	cin >> s;
	vp64 vec;
	ll ones = 0;
	forn(i,sz(s)){
		if(s[i]=='1') ones++;
		else vec.pb(mp(ones%2,i));
	}
	ll ans = 0;
	ll csz=0;
	ll cans = 0;
	forn(i,ones){
		csz++;
		if(csz%2) cans++;
		ans += cans;
	}
	ll cur = 1;
	ll rem = sz(vec);
	v64 odd;
	for(auto it : vec){
		if(it.fi==cur){
			cur^=1;
			csz++;
			if(csz%2) cans++;
			ans += cans;
			rem--;
		}
		else{
			odd.pb(it.se);
		}
	}
	ll in=0;
	ll parity=1;
	forn(i,sz(s)) {
		if(in<sz(odd) && odd[in]==i){
			in++;
		}
		else{
			if(s[i]=='1') {
				ans += parity*(rem-in);
				ans += (in+1-parity)/2;
			}
			parity ^= 1;
		}
	}
	cout << ans << ln;
}
 
int main()
{
	fast_cin();
    ll t=1;
    // cin >> t;
    forn(i,t) {
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    }
    return 0;
}

Measured memory_bytes: 10148
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
const long long N=2005,L=11;
long long n,cnt,v[N];
long long f2(int a,int b)
{
    long long pas=1<<L;
    long long r=0;
    while(pas!=0){
        if(r+pas<=n && v[r+pas]<a+b)
            r+=pas;
        pas/=2;
    }
    return r;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    for(int i=1;i<n;i++)
    for(int j=i+1;j<=n;j++){
        int p=f2(v[i],v[j]);
        if(p>=j)
           cnt+=p-j;
    }
    cout<<cnt;
    return 0;
}

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

using namespace std;

#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define LL long long
#define ULL unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<LL,int>
#define PLL pair<LL,LL>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<LL,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();
    int n;
    cin >> n;
    if(n >= 1800)cout << '1';
    else if(n >= 1600)cout << '2';
    else if(n >= 1400)cout << '3';
    else if(n >= 1200)cout << '4';
    else if(n >= 1000)cout << '5';
    else if(n >= 800)cout << '6';
    else if(n >= 600)cout << '7';
    else cout << '8';
    return 0;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template<class A, class B>
inline bool chmax(A &a, const B &b) { return b > a ? a = b, 1 : 0; }

template<class A, class B>
inline bool chmin(A &a, const B &b) { return b < a ? a = b, 1 : 0; }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
// }}} End

template<typename T>
T extgcd(T a, T b, T &x, T &y) {
  T g = a;
  x = 1, y = 0;
  if (b != 0) {
    g = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  }
  return g;
}

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

  int a, b, x, y;
  cin >> a >> b;

  extgcd(a, b, x, y);
  cout << x << " " << y << "\n";

  return 0;
}



Measured memory_bytes: 3216
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>


using namespace std;


int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((b+c)==a)
    cout<<"0";
    if((b+c)!=a)
    cout<<(a-b)%c;
    system("pause");
    return 0;
}     

Measured memory_bytes: 504
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int main(){
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	int val=2000000000,tmp=0;
	for(int i=0;i<=max(x, y);i++){
		tmp = i*2*c + max(0, x-i)*a + max(0, y-i)*b;
		val = min(tmp, val);
	}

	cout<< val <<endl;

	return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
void colorEdges(int ptr, vector<vector<pair<int, int> > >& gra,vector<int>& edgeColors, bool isVisited[]) 
{ 
    queue<int> q; 
    int c = 0;
    set<int> colored; 
    if (isVisited[ptr]) 
        return; 
    isVisited[ptr] = 1; 
    for (int i = 0; i < gra[ptr].size(); i++)
    { 
        if (edgeColors[gra[ptr][i].second] != -1) 
            colored.insert(edgeColors[gra[ptr][i].second]); 
    } 
  
    for (int i = 0; i < gra[ptr].size(); i++) 
    { 
        if (!isVisited[gra[ptr][i].first]) 
            q.push(gra[ptr][i].first); 
        if (edgeColors[gra[ptr][i].second] == -1) 
        {
            while (colored.find(c) != colored.end()) 
                c++; 
            edgeColors[gra[ptr][i].second] = c; 
            colored.insert(c); 
            c++; 
        } 
    }  
    while (!q.empty()) 
    { 
        int temp = q.front(); 
        q.pop(); 
        colorEdges(temp, gra, edgeColors, isVisited); 
    } 
  
    return; 
} 
int main() 
{ 
    fastio();
    set<int> empty;
    ll N;
    cin>>N;
    vector<vector<pair<int, int> > > gra; 
    vector<int> edgeColors; 
    bool isVisited[N+5] = { 0 }; 
    int ver = N; 
    int edge = N-1; 
    gra.resize(ver); 
    edgeColors.resize(edge, -1); 
    for(ll i=0;i<N-1;i++)
    {
        int a,b;
        cin>>a>>b;
        gra[b-1].pb(mp(a-1,i));
        gra[a-1].pb(mp(b-1,i));
    }
    colorEdges(0, gra, edgeColors, isVisited); 
    set <int> se;
    for (int i = 0; i < edge; i++) 
        se.insert(edgeColors[i]);
    cout<<se.size()<<endl;
    for(ll i=0;i<edge;i++)
    {
        cout<<edgeColors[i]+1<<endl;
    }
  
    return 0; 
}

Measured memory_bytes: 65792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<ll,ll>
#define sc(x) scanf("%lld",&x)
 
int main(){
	io;
	ll n;
	cin>>n;
	ll ans=(n/500)*1000;
	n=n%500;
	ans+=(n/5)*5;
	cout<<ans;
	return 0;
}


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



int main() {
  ll n, d;
  cin >> n >> d;
  
  int ans=0;
  d = d*d;
  rep(i, n){
    ll x, y;
    cin >> x >> y;
    ll xy = x*x + y*y;
    if(xy <= d) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
typedef long long int ll;
int main(){
ll A, V;
cin >> A >> V;
ll B,W;
cin >> B >> W;
ll T;
cin >> T;
ll D=abs(A-B);
ll D2=(V-W)*T;
puts(D<=D2?"YES":"NO");
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        int a = in.nextInt();
        int ans = 0;
        int n = 1;
        while(n <= a) {
            n *= 2;
            ans++;
        }
        System.out.println(n / 2);
    }
}

Measured memory_bytes: 25684
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
int num[2][200][200][200];
char mat[200][200];
int main()
{
    int n,m;scanf("%d%d",&n,&m);
    rep(i,1,n+1)scanf("%s",mat[i]+1);
    for(int i=m;i;i--)
    rep(j,1,n+1)
    {
        int flag=1,bef=mat[j][i];
        for(int k=j;k;k--)
        {
            flag&=(bef==mat[k][i]);
            if(flag)num[0][i][j][k]=mat[k][i]==mat[k][i+1]?(i!=m?num[0][i+1][j][k]:m):i;
            else num[0][i][j][k]=i-1;
            bef=mat[k][i];
        }
    }
    int type=1,r=0;
    while(1)
    {
        if(num[!type][1][n][1]==m)break;
        r++;
        rep(i,1,m+1)rep(j,1,n+1)rep(k,1,j+1)
        num[type][i][j][k]=num[!type][i][j][k]==m?m:num[!type][num[!type][i][j][k]+1][j][k];
        rep(i,1,m+1)rep(j,1,n+1)
        {
            int pos=j;
            for(int k=j;k;k--)
            {
                while(pos>k+1&&min(num[!type][i][j][pos],num[!type][i][pos-1][k])<=
                                       min(num[!type][i][j][pos-1],num[!type][i][pos-2][k]))
                    pos--;
                if(pos!=k)
                    num[type][i][j][k]=max(num[type][i][j][k],min(num[!type][i][j][pos],num[!type][i][pos-1][k]));
            }
        }
        type=!type;
    }
    printf("%d\n",r);
}

Measured memory_bytes: 61440
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr = (input.trim()).split("\n");

const linearSearch = (key, arr, N) => {
  arr[N] = key
  let i = -1;
  while (arr[++i] !== key);
  return i !== N ? 1 : 0;
  // for (let i = 0; i < N1; i++) {
  //     if (arr[i] === key) return 1;
  // }
  // return 0;
}

(function() {
  var N1 = Number(Arr[0])
  var arr1 = Arr[1].split(" ").map(Number);
  var N2 = Number(Arr[2])
  var arr2 = Arr[3].split(" ").map(Number);
  console.log(arr2.map(e => linearSearch(e, arr1, N1)).reduce((a, b) => a + b, 0));
})();



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

// repetition
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

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

const ll MOD = 1e9 + 7;
ll dp[201][201][201];

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

  int n;
  cin >> n;
  char rank[n];
  rep(i, n) { cin >> rank[i]; }
  dp[0][0][0] = 1;

  // dp[i番目までみる]['U'を使わないといけない数][前回までに保留されている'U'の数]
  rep(i, n) {
    rep(j, i + 1) {
      rep(k, i + 1) {
        if (rank[i] == 'U') {
          // iの場所を保留して、以前の'U'を使う
          (dp[i + 1][j][k] += dp[i][j][k] * j) %= MOD;
          // iの場所は保留 & 以前の'U'を使わない
          (dp[i + 1][j + 1][k + 1] += dp[i][j][k]) %= MOD;
        } else if (rank[i] == 'D') {
          // iの場所を保留して、以前の'U'で空けた順位を使う
          if (k) {
            (dp[i + 1][j][k] += dp[i][j][k] * k) %= MOD;
            if (j) {
              // iの場所を保留して、以前の'U'で空けた順位を使う
              (dp[i + 1][j - 1][k - 1] += (dp[i][j][k] * j % MOD) * k) %= MOD;
            }
          }
        } else {
          (dp[i + 1][j][k] += dp[i][j][k]) %= MOD;
        }
      }
    }
  }
  cout << dp[n][0][0] << "\n";
  return 0;
}



Measured memory_bytes: 35468
#include <stdio.h>

int main(void)
{
	int a,b,c,d,n;

	while(scanf("%d",&n)!=EOF){
		int cnt=0;
		for(a=0; a<10; a++)
			for(b=0; b<10; b++)
				for(c=0; c<10; c++)
					for(d=0; d<10; d++)
						if(a+b+c+d==n)
							cnt++; 
		printf("%d\n",cnt);
	}

	return 0;
}

Measured memory_bytes: 596
import collections

n = int(input())
a = [input() for i in range(n)]
c = collections.Counter(a)

i = 0

common = c.most_common()
common.sort(key = lambda x: x[1], reverse=True)

ans = []

while common[i][1] >= common[0][1]:
	ans.append(common[i][0])

	if i < len(common)-1:
		i += 1
	else:
		break

ans.sort()

for i in range(len(ans)):
	print(ans[i])

Measured memory_bytes: 47640
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    long ans = 0;
    while(N > 0){
      ans += sc.nextLong() - 1;
      N--;
    }
    
    System.out.println(ans);
  }
}       

Measured memory_bytes: 40488
#include<stdio.h>
#define mod 1000000007
int n,a[2001];
main()
{
	scanf("%d",&n);
	if(n<3){puts("0");return 0;}
	a[0]=1;
	for(register int i=3;i<=n;++i)
		for(register int j=3;j<=i;++j)a[i]=(a[i]+a[i-j])%mod;
	printf("%d",a[n]);
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
int main(){
  cin >> s;
  ll b = 0;
  ll cnt = 0;
  ll ans = 0;
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == 'W') {
      cnt++;
    } else {
      b++;
      ans += cnt;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 644
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n, m;
    cin >> n >> m;
    vi c(m);
    rep(i,n){
        lli k;
        cin >> k;
        rep(j,k){
            lli a;
            cin >> a;
            a--;
            c[a]++;
        }
    }
    lli ans = 0;
    rep(i,m){
        if(c[i]==n){
            ans++;
        }
    }
    out(ans);
}

Measured memory_bytes: 3636