akhauriyash/Code-Regression huggingface dataset:
N = int(input())

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

Measured memory_bytes: 9120
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int main() {
    int N; cin >> N;
    int a[N]; for (int i = 0; i < N; ++i) cin >> a[i];
    long long res = 0;
    for (int i = 0; i < N; ++i) res += a[i] - 1;
    cout << res << endl;
}

Measured memory_bytes: 256
def solve(v, g, ans, time):
    if ans[v]["found"] != 10**9:
        return time
    time += 1
    # print(v + 1, time, file=sys.stderr)
    ans[v]["found"] = time
    for a in g[v]:
        time = solve(a, g, ans, time)
    time += 1
    # print(v + 1, time, file=sys.stderr)
    ans[v]["complete"] = time
    return time


def resolve():
    n = int(input())
    V = [list(map(int, input().split())) for _ in range(n)]
    g = [[] for _ in range(n)]
    for v, k, *a in V:
        v -= 1
        for ai in a:
            ai -= 1
            g[v].append(ai)
    ans = [{"found": 10**9, "complete": -1} for _ in range(n)]
    time = solve(0, g, ans, 0)
    for i in range(n):
        if ans[i]["found"] == 10**9:
            solve(i, g, ans, time)
        print(i + 1, ans[i]["found"], ans[i]["complete"])


resolve()



Measured memory_bytes: 5660
#include<bits/stdc++.h>
using namespace std;
int a[101][101],f[101],e[101],nt[101],cur,i,j,n,t=0;
int color[101];
void dfs(int u){
    f[u]=++t;
    color[u]=1;
    for(int v=0;v<n;++v){
        if(color[v]==0&&a[u][v]){
            dfs(v);
        }
    }
    e[u]=++t;
}
int main(){
    int u,v;
    scanf("%d",&n);
    for(i=0;i<n;++i){
        scanf("%d %d",&u,&cur);
        for(j=0;j<cur;++j){
            scanf("%d",&v);
            a[u-1][v-1]=1;
        }
    }
    for(i=0;i<n;++i){
        if(!color[i]){
            dfs(i);
        }
    }
    for(i=0;i<n;++i)    printf("%d %d %d\n",i+1,f[i],e[i]);
    return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll n,k;
ll fac[maxn];
ll poww(ll x,ll y,ll p){
	ll res = 1;
	while(y){
		if(y & 1) res = res * x % p;
		x = x * x % p;
		y >>= 1;
	}
	return res;
}
void init(){
	fac[0] = 1;
	for(int i = 1;i < maxn;i++) fac[i] = fac[i-1] * i % mod;
}
ll C(int a,int b,ll p){ //费马小定理 
	if(b > a) return 0;
	return fac[a] * poww(fac[b],p-2,p) % p * poww(fac[a-b],p-2,p) % p;
}
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
	cin >> n >> k;
	init();
	ll ans  = 0;
	for(int i = 0;i <= min(k,n);i++){
		ans = (ans + C(n,i,mod) * C(n-1,n-i-1,mod) % mod) % mod;
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    char a[3];
    
    for (int i = 0; i < 3; i++){
        cin >> a[i];
        if (a[i] == '1'){
            a[i] = '9';
        } else if (a[i] == '9'){
            a[i] = '1';
        }
        cout << a[i];
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
// ---------- begin multiset ----------
struct MultiSet<T> {
    size: usize,
    map: std::collections::BTreeMap<T, u32>,
}

impl<T> MultiSet<T>
where
    T: Ord,
{
    fn new() -> Self {
        MultiSet {
            size: 0,
            map: std::collections::BTreeMap::new(),
        }
    }
    fn len(&self) -> usize {
        self.map.len()
    }
    fn insert(&mut self, val: T) {
        self.size += 1;
        *self.map.entry(val).or_insert(0) += 1;
    }
    fn remove(&mut self, val: &T) {
        assert!(self.map.contains_key(val));
        let cnt = self.map.get_mut(val).unwrap();
        *cnt -= 1;
        if *cnt == 0 {
            self.map.remove(val);
        }
    }
}
// ---------- end multiset ----------

use proconio::marker::*;
use proconio::*;
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;

#[fastout]
fn run() {
    input! {
        h: usize,
        w: usize,
        p: [(Usize1, usize); h],
    }
    let mut map = BTreeMap::new();
    let mut set = MultiSet::new();
    for i in 0..w {
        map.insert(i, 0);
        set.insert(0usize);
    }
    for (i, &(l, r)) in p.iter().enumerate() {
        let mut del = vec![];
        for (&k, &v) in map.range((Included(&l), Included(&r))) {
            set.remove(&v);
            del.push((k, v + r - k));
        }
        for &(k, _) in del.iter() {
            map.remove(&k);
        }
        if r < w {
            if let Some(v) = del.iter().map(|p| p.1).min() {
                map.insert(r, v);
                set.insert(v);
            }
        }
        if let Some(&v) = set.map.keys().next() {
            println!("{}", v + i + 1);
        } else {
            println!("-1");
        }
    }
}

fn main() {
    run();
}


Measured memory_bytes: 14996
import java.util.Scanner;

public class Main {

	private static Scanner in;

	public static void main(String[] args) {
		in = new Scanner(System.in);
		
		String s = in.next();
		String t = in.next();
		
		int n = s.length();
		int m = t.length();
		
		int ans = Integer.MAX_VALUE;
		
		for(int i=0; i<n; i++) {
			if (i+m-1>=n) break;
			int diff = 0;
			for(int j=0; j<m; j++) {
				if (t.charAt(j)!=s.charAt(i+j)) diff++;
			}
			ans = Math.min(ans, diff);
		}
		
		System.out.println(ans);
		
		

	}

}


Measured memory_bytes: 35568
#include <stdio.h>
int main(void){
    int i,j,k,n;
    int sum,count;
    for(;;){
        scanf("%d",&n);
        if(n==0) break;
        count=0;
        if(n>2){
            for(i=n-1;i>0;i--){
                j=1;
                sum=i;
                while(j<=n-2){
                    sum+=(i-j);
                    if(sum>n) break;
                    else if(sum==n){
                        count++;
                        break;
                    }
                    j++;
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}



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

int main(){
    int n, x;
    cin >> n;
    
    for (int i = 1; i <= n; i++){
        if(i % 3 == 0){
            cout << " " << i;
            continue;
        }
        x = i;
        while(1){
            if (x % 10 == 3){
                cout << " " << i;
                break;
            }
            x /= 10;
            if(x == 0) break;
        }
    }
    cout << endl;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
pair<int,int> pii;
vector<int> vec;
int main()
{
  int n,cnt=1,p[200005],min;
  cin>>n;

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

  cout<<cnt<<'\n';
  return 0;
}


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

void trace(int a[],int n){
  int i;
  for(i=0;i<n;i++){
    if(i>0) cout<<' ';
    cout<<a[i];
  }
  cout<<endl;
}

int selectionsort(int a[],int n){
  int res=0;
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(a[j]<a[minj]) minj=j;
    }
    swap(a[i],a[minj]);
    if(i!=minj) res++;
  }
  return res;
}

int main() {
  int n,res;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  res=selectionsort(a,n);
  trace(a,n);
  cout<<res<<endl;
  return 0;
}



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

int main(void){
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;

    int passed = 0;
    int bpass = 0;
    for(int i=0; i<n; ++i){
        if(s[i]=='c'){
            cout << "No" << endl;
        }

        else if (s[i]=='a'){
            if(passed < a+b){
                cout << "Yes" << endl;
                passed++;
            }
            else
                cout << "No" << endl;
        }

        else{
            if(passed < a+b && bpass < b){
                cout << "Yes" << endl;
                passed++;
                bpass++;
            }
            else
                cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3736
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		int ans = 6 - A - B;
		System.out.println(ans);
		
		
	}
}

Measured memory_bytes: 21204
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int a=1,b=0,c=0;
	char x,y;
	while(scanf("%c,%c",&x,&y)!=EOF){
		if(x=='B'&&y=='A')swap(x,y);
		if(x=='C'&&y=='A')swap(x,y);
		if(x=='C'&&y=='B')swap(x,y);
		if(x=='A'&&y=='B'){
			swap(a,b);
		}else if(x=='A'&&y=='C'){
			swap(a,c);
		}else{
			swap(b,c);
		}
	}
	if(a==1)cout<<"A"<<endl;
	else if(b==1)cout<<"B"<<endl;
	else cout<<"C"<<endl;
	return 0;
}

Measured memory_bytes: 3140
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }
    val p = readLine()!!.split(" ").map { it.toLong() }.sorted()
    val f = readLine()!!.split(" ").map { it.toLong() }.sortedDescending()

    val sum = p.sum()
    if (sum < n) {
        println(0)
        return
    }

    // binary search
    var from = 0L
    var to = 1000000000001L

    while (from < to) {
        val mid = (from + to) / 2
        if (ok(p, f, k, mid)) to = mid
        else from = mid + 1
    }
    println(from)
}

fun ok(p: List<Long>, f: List<Long>, k: Long, target: Long) : Boolean {
    val limit = p.size
    var remain = k
    (0 until limit).forEach {
        var a = p[it]
        var b = f[it]

        if (a * b > target) {
            val m = target / b
            remain -= (a - m)
        }

        if (remain < 0L) return false
    }
    return true
}


Measured memory_bytes: 122224
N = int(input())
Mylist = list(map(int, input().split()))
ANSlist = [0 for i in range(N)]
for j in range(N):
    ANSlist[Mylist[j]-1] = j + 1
ANSlist=[str(a) for a in ANSlist]
ANS = ' '.join(ANSlist)
print(ANS)

Measured memory_bytes: 17892
#include<stdio.h>
int main(void)
{
	int r, d, x[100], n;
	scanf("%d %d %d", &r, &d, &x[0]);
	for (n = 0; n < 10; n++)
	{
		x[n + 1] = r * x[n] - d;
		printf("%d\n", x[n+1]);
	}
	return 0;
}

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

int arr[100001];
std::map<int, int> mx1, mx2;
std::set<int> od, ev;

int main(void)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	int n;
	std::cin>>n;
	for(int i=0;i<n;i++)
	std::cin>>arr[i];
	for(int i=0;i<n;i+=2)
	mx1[arr[i]]++;
	for(int i=1;i<n;i+=2)
	mx2[arr[i]]++;	
	int mval1 = 0, mval2 = 0, tc = 0;
	for(std::map<int, int>::iterator it = mx1.begin();it != mx1.end();it++)
	{
		if(mval1 < it->second)
		{
			ev.clear();
			ev.insert(it->first);
			mval1 = it->second;
		}	
		else if(mval1 == it->second)
		ev.insert(it->first);
		tc += (it->second);	
	}
	for(std::map<int, int>::iterator it = mx2.begin();it != mx2.end();it++)
	{
		if(mval2 < it->second)
		{
			od.clear();
			od.insert(it->first);
			mval2 = it->second;
		}
		else if(mval2 == it->second)
		od.insert(it->first);
		tc += (it->second);	
	}	
	if((int)od.size() > (int)ev.size())
	{	
		int x = *ev.begin();
		int y = 0;
		for(std::set<int>::iterator it = od.begin();it != od.end();it++)
		{
			if(x != *it)
			{
				y = *it;
				break;
			}
		}
	}	
	else
	{
		int x = *od.begin();
		int y = 0;
		for(std::set<int>::iterator it = ev.begin();it != ev.end();it++)
		{
			if(x != *it)
			{
				y = *it;
				break;
			}	
		}	
		if(!y)
		{
			int smval1 = 0, smval2 = 0;
			for(std::map<int, int>::iterator it = mx1.begin();it != mx1.end();it++)
			{
				if((it->second < mval1) && (it->second > smval1))
				smval1 = it->second;	
			}
			for(std::map<int, int>::iterator it = mx2.begin();it != mx2.end();it++)
			{
				if((it->second < mval2) && (it->second > smval2))
				smval2 = it->second;	
			}		
			if(smval1 > smval2)
			mval1 = smval1;
			else 	mval2 = smval2;
		}	
	}
	std::cout<<(tc - mval1 - mval2)<<"\n";
	return 0;
}

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

long long a, b,c;

int main() {
    cin>>a>>b>>c;
    long long x=0;
    if(b>c){
        x=c;
    }
    if(b<=c){
        x=b-1;
    }
    int one=a*x/b;
    cout<<one;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[1000],b,c,d,m,n,i,j,k;
	scanf("%d%d%d",&n,&c,&d);
	k=d;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		for(j=0;;j++)
		{
			m=a[i]*j+1;
			if(m>c)
			{
				break;
			}
			else
			{
				k++;
			}
		}
	}
	printf("%d",k);
	return 0;
}

Measured memory_bytes: 256
import Foundation
var s = readLine()!
let t = readLine()!
for _ in 0..<t.count {
  if s == t {
    print("Yes")
    exit(0)
  }
  let c = s[s.index(s.endIndex, offsetBy: -1)]
  s = "\(c)\(String(s.dropLast()))"
}
print("No")

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

long long n;
string s,sw = "SW";

string solve();
string check(string now);

int main() {
    cin >> n >> s;
    cout << solve() << endl;
    return 0;
}

string solve(){
    string ans;
    for(int i = 0;i < 4;++i){
        string now;
        now += sw[i % 2];
        now += sw[i / 2];
        ans = check(now);
        if(ans.size() == n)return ans;
    }
    return "-1";
}

string check(string now){
    for(int i = 2;i < n;++i){
        if(now[i-1] == 'S'){
            if(s[i-1] == 'o')now += now[i-2];
            else now += now[i-2] == 'S'? 'W':'S';
        }
        else {
            if(s[i-1] != 'o')now += now[i-2];
            else now += now[i-2] == 'S'? 'W':'S';
        }
    }
    bool ch = 1;
    if(now[0] == 'S'){
        if(now[1] == now[n-1] && s[0] != 'o')ch = 0;
        if(now[1] != now[n-1] && s[0] == 'o')ch = 0;
    }
    else {
       if(now[1] == now[n-1] && s[0] == 'o')ch = 0;
       if(now[1] != now[n-1] && s[0] != 'o')ch = 0;
    }
    if(now[n-1] == 'S'){
        if(now[n-2] == now[0] && s[n-1] != 'o')ch = 0;
        if(now[n-2] != now[0] && s[n-1] == 'o')ch = 0;
    }
    else {
        if(now[n-2] == now[0] && s[n-1] == 'o')ch = 0;
        if(now[n-2] != now[0] && s[n-1] != 'o')ch = 0;
    }
    if(ch)return now;
    return "";
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
bool check(int a,int b,int c)
{
	if((b>a and b<c) or (b<a and b>c))
		return true;
	else 
		return false;
}
int main()
{
	int n;
	cin>>n;
	vector<int> v;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		v.push_back(x);
	}
	int count=0;
	for(int i=0;i<n-2;i++)
	{
		if(check(v[i],v[i+1],v[i+2]))
			count++;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 256
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for modular inverse
ll inv(ll a,ll m){
	return mpow(a,m-2,m);
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

// Utility for binomial coefficient
ll ncr(ll n,ll k)
{
    if(n<k)
        return 0;
    ll C[n + 1][k + 1];
    ll i,j;
    for(i=0;i<=n;i++){
        for(j=0;j<=min(i,k);j++){
            if (j==0 || j==i)
                C[i][j]=1;
            else
                C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    return C[n][k];
}

void solve(){
	//code
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(max(a*c,b*d),max(a*d,b*c));
}

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


Measured memory_bytes: 3684
# -*- coding: utf-8 -*-
import math



MOD = 1000000007
def solve_odd(an):
  l = len(an)
  dif = (l+1)%2
  # False pattern
  for i in range(l):
    if math.ceil((i+dif)/2)*2 != an[i]+dif:
      return 0
  ans = 1  
  # True pattern
  for _ in range(l//2):
    ans = (ans*2) % MOD
  return ans


N = int(input())
An = list(map(int, input().split()))
An = sorted(An)
print(solve_odd(An))

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	vector<ll> a(N);
	REP(i, N) cin >> a[i];

	bool flag = true;
	REP(i, N){
		if(a[i]%2==1) flag = false;
	}
	cout << (flag?"second":"first") << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n;
int Min[26], cnt[26], pos[26];
char s[maxn];
int main()
{
	scanf("%s", s + 1);
	for(int i = 1; s[i]; ++i)
	{
		++cnt[s[i] - 'a'];
		int cur = cnt[s[i] - 'a'] * 2 - i;
		if(Min[s[i] - 'a'] < cur && i - pos[s[i] - 'a'] >= 2)
		{
			printf("%d %d\n", pos[s[i] - 'a'] + 1, i);
			return 0;
		}
		if((cnt[s[i] - 'a'] - 1) * 2 - (i - 1) < Min[s[i] - 'a'])
		{
			Min[s[i] - 'a'] = (cnt[s[i] - 'a'] - 1) * 2 - (i - 1);
			pos[s[i] - 'a'] = i - 1;
		}
	}
	puts("-1 -1");
	return 0;
}

Measured memory_bytes: 3816
#include <iostream>
#include <queue>

using namespace std;
static const int N = 100;
static const int INFTY = -1;

int n, M[N][N];
int d[N];

void bfs(int s)
{
	queue<int> q;
	q.push(s);
	for(int i=0; i<n; i++)
	{
		d[i]=INFTY;
	}
	d[s]=0;
	int u;
	while(!q.empty())
	{
		u=q.front();
		q.pop();
		for(int v=0; v<n; v++)
		{
			if(M[u][v]==0)
				continue;
			if(d[v]!=INFTY)//已经在前面遍历过 
				continue;
			d[v]=d[u]+1;
			q.push(v);
		}		 
	}
	for(int i=0; i<n; i++)
	{
		cout<<i+1<<" "<<((d[i]==INFTY) ? (-1) : (d[i]))<<endl;
	}
}

int main()
{
	int u, k, v;
	cin>>n;
	for(int i=0; i<n; i++)
	{
		for(int j=0; j<n; j++)
		{
			M[i][j]=0;
		}
	}
	for(int i=0; i<n; i++)
	{
		cin>>u>>k;
		u--;
		for(int j=0; j<k; j++)
		{
			cin>>v;
			v--;
			M[u][v]=1;
		}
	}
	bfs(0);
	return 0;
}


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

int main() {
    
    int N;
    cin >> N;
    vector<int> A;
    rep(i,N){
        int num;
        cin >> num;
        A.push_back(num);
    }

    int Q;
    cin >> Q;
    int B[Q], C[Q];
    rep(i,Q){
        cin >> B[i] >> C[i];
    }

    map<int , int> M;
    for(auto v:A) {
        M[v]++;
    }
    long long ans = accumulate(A.begin(), A.end(), 0LL);

    rep(i,Q){
        M[C[i]] += M[B[i]];
        ans = ans + (C[i] - B[i]) * M[B[i]];
        M[B[i]] = 0;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 8836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

Graph G;
vector<int> color;
int total = 0;

void dfs(int v, int p, int pcolor) {
    total = max(total, (int)G[v].size());
    int c = 1;
    for(auto np : G[v]) {
        int nv = np.first, nnum = np.second;
        if(nv == p)
            continue;
        if(c == pcolor)
            c++;
        color[nnum] = c;
        dfs(nv, v, color[nnum]);
        c++;
    }
}

int main() {
    int N;
    cin >> N;
    G.resize(N);
    color.resize(N - 1);
    for(int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(make_pair(b, i));
        G[b].push_back(make_pair(a, i));
    }
    dfs(0, -1, 0);
    cout << total << endl;
    for(auto i : color)
        cout << i << endl;
    return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <stack>
#include <tuple>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i ++)
using ll = long long;
int H, W;
int CH, CW, DH, DW;
char S[1001][1001];
typedef tuple<int, int, int> P;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> H >> W;
    cin >> CH >> CW >> DH >> DW;
    CH --; CW --; DH --; DW --;
    rep(y, H) rep (x, W) {
        cin >> S[y][x];
    }
    priority_queue<P, vector<P>, greater<P> > q;
    q.push(make_tuple(0, CW, CH));
    while (!q.empty()) {
        P p = q.top(); q.pop();
        int d = get<0>(p);
        int x = get<1>(p);
        int y = get<2>(p);
        //cout << "(" << d << "," << x << "," << y << ")" << endl;
        if (x == DW && y == DH) {
            cout << d << endl;
            return 0;
        }
        if (S[y][x] != '.') continue;
        S[y][x] = 'v';
        if (y >= 1 && S[y-1][x] == '.') q.push(make_tuple(d, x, y - 1));
        if (y <= H - 2 && S[y+1][x] == '.') q.push(make_tuple(d, x, y + 1));
        if (x >= 1 && S[y][x-1] == '.') q.push(make_tuple(d, x - 1, y));
        if (x <= W - 2 && S[y][x+1] == '.') q.push(make_tuple(d, x + 1, y));
        for (int i = -2; i <= 2; i ++) for (int j = -2; j <= 2; j ++) {
            int x2 = x + i, y2 = y + j;
            if (0 <= x2 && x2 < W && 0 <= y2 && y2 < H && S[y2][x2] == '.') {
                q.push(make_tuple(d + 1, x2, y2));
            }
        }
    }
    cout << "-1" << endl;
}

Measured memory_bytes: 5884
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmax(a,b) (a)=max((a),(b))
#define upmin(a,b) (a)=min((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
void myassert(const bool chk) { if(!chk) { while(1) puts("ERR!"); exit(-1); } }

char A[55];

int N;
ll Ans;

int main() {
	scanf(" %s", A);
	N = int(strlen(A));
	
	{
		ll sum = 0;
		for(int i = 0; i < N; i++) {
			sum = sum + (A[i]-'0');
		}
		Ans = sum;
	}
	
	ll sum = 0;
	for(int i = 0; i < N; i++) {
		A[i]--;
		sum = sum + (A[i]-'0');
		
		ll ret = sum;
		for(int j = i+1; j < N; j++)
			ret = ret + 9;
		upmax(Ans, ret);
	}
	
	cout << Ans << endl;
	return 0;
}

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

int main() {
	int n,m;cin>>n>>m;
	int a[m];
	for(int i=0;i<m;i++)
	{
	    cin>>a[i];
	}
	int sum=0;
	for(int i=0;i<m;i++)
	{
	    sum+=a[i];
	}
	if(sum>n)   cout<<"-1"<<endl;
	else if(sum==n)   cout<<"0"<<endl;
	else cout<<(n-sum)<<endl;
	return 0;
}

Measured memory_bytes: 3680
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a,b,c,d = map(int,input().split())
z = lcm(c,d)
ac = a // c *c
if a % c > 0:
    ac += c
ad = a // d * d
if a % d > 0:
    ad += d
az = a // z * z
if a % z > 0:
    az += z
bc = b // c * c
bd = b // d * d
bz = b // z * z
uc = (bc - ac) // c
ud = (bd - ad) // d
uz = (bz - az) // z
print((b-a)-(uc+ud)+uz)


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

int main() {
    int a,b;
    int ave;

    cin >> a >> b;
    ave = (a + b) / 2;

    if ((a+b)%2 != 0) {
        cout << ave+1 << endl;
    }
    else {
        cout << ave << endl;
    }

    return 0;
}

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

int main(void) {
    int N, W;
    cin >> N >> W;
    vector<int> w(N);
    vector<long long> v(N);
    vector<vector<long long>> dp(N + 1, vector<long long>(W + 1, 0));
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j - w[i - 1] >= 0) {
                dp[i][j] =
                    max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 80256
#include<iostream>
#include <algorithm>
#include <vector>
#include<functional>
int main() {
	int a[3];
	std::cin >> a[0] >> a[1] >> a[2];
	std::sort(a, a + 3);
	int y = (a[2] - a[1])+(a[2]-a[0]);
	if (y % 2 == 0) {
		std::cout << y / 2;	
	}
	else {
		std::cout << (y + 3) / 2;
	}
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val D = sc.nextInt

    val result = Range(D - 22, 3).foldLeft("Christmas"){(str, acc) =>
      str + " Eve"
    }
    println(result)
  }

}


Measured memory_bytes: 25384
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = list(map(int,S()))
    l = len(n)
    dp = [[[0 for k in range(16)] for j in range(2)] for i in range(l+1)]
    dp[0][0][0] = 1
    for i in range(l):
        for j in range(2):
            for k in range(9):
                x = 9 if j else n[i]
                for d in range(x+1):
                    if d == 3:
                        f = 1
                    elif d == 5:
                        f = 2
                    elif d == 7:
                        f = 4
                    else:
                        if k == 0 and d == 0:
                            f = 0
                        else:
                            f = 8
                    dp[i+1][j or d < n[i]][k|f] += dp[i][j][k]
    ans = 0
    for i in range(2):
        ans += dp[l][i][7]
    print(ans)
#D
def D():
    def factorial(n):
        if n <= 3:
            return [n]
        l = []
        i = 2
        m = n
        while i**2 <= n:
            while m%i == 0:
                l.append(i)
                m //= i
            i += 1
        if m != 1:
            l.append(m)
        return l

    n = I()
    d = defaultdict(int)
    for i in range(2,n+1):
        l = factorial(i)
        for j in l:
            d[j] += 1
    a3 = 0
    a5 = 0
    a15 = 0
    a25 = 0
    a75 = 0
    for i in d.keys():
        if d[i] >= 74:
            a75 += 1
        if d[i] >= 24:
            a25 += 1
        if d[i] >= 14:
            a15 += 1
        if d[i] >= 4:
            a5 += 1
        if d[i] >= 2:
            a3 += 1
    ans = a75+(a3-1)*a25+(a5-1)*a15+(a3-2)*a5*(a5-1)//2
    print(ans)
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 39920
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		
		if(n%1000 == 0) {
			System.out.println(0);
		}else {
			System.out.println(1000-(n%1000));
		}
		
	}
	
	
	public static int gcd(int x,int y) {
		if(x%y == 0) {
			return y;
		}else {
			return gcd(y,x%y);
		}
	}
}
 


Measured memory_bytes: 35868
#include <cstdio>
static const int MAXN = 52;

int n, m;
bool a[MAXN][MAXN], b[MAXN][MAXN];

inline bool check(int offset_r, int offset_c)
{
    for (int i = 0; i < m; ++i)
        for (int j = 0; j < m; ++j)
            if (a[i + offset_r][j + offset_c] ^ b[i][j]) return false;
    return true;
}

int main()
{
    scanf("%d%d", &n, &m); getchar();
    for (int i = 0; i < n; ++i)
        for (int j = 0; j <= n; ++j) a[i][j] = (getchar() == '#');
    for (int i = 0; i < m; ++i)
        for (int j = 0; j <= m; ++j) b[i][j] = (getchar() == '#');

    for (int i = 0; i <= n - m; ++i)
        for (int j = 0; j <= n - m; ++j)
            if (check(i, j)) { puts("Yes"); return 0; }

    puts("No"); return 0;
}


Measured memory_bytes: 128
n,d = map(int,input().split())
def dist(x,y):
  ans = 0
  for i in range(d):
    ans += abs(x[i]-y[i])**2
  ans **= 0.5
  return ans

ans = 0
l = [list(map(int, input().split())) for _ in range(n)]
for i in range(n-1):
  for j in range(i+1,n):
    if dist(l[i],l[j]).is_integer():
        ans += 1
print(ans)

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

void solve(){

	int n ;
	cin>>n ;

	ll ans=0 ;

	for(int a=1;a<=n;a++){
		ans+=(n-1)/a ;
	}

	cout<<ans ;

}


int main(){

		int y ;

		y=1 ;
		//cin>>y ;

		while(y--){
 
			solve() ;

		}

}

Measured memory_bytes: 3620
#include <stdio.h>

int main()
{
    int a;
    scanf("%d", &a);
    while(a > 3) {
        if (a % 4 == 0) {
            puts("Yes");
            return 0;
        } else if (a % 7 == 0) {
            puts("Yes");
            return 0;
        } else if (a % 11 == 0) {
            puts("Yes");
            return 0;
        }
        a -= 11;
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
template<typename T> void print(T t) {cout << t << endl;}


struct distanceData {
	int distance, id;
};

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> a(N), b(N), c(M), d(M);
	vector<distanceData> dist(M);
	for (int i = 0; i < N; i++) cin >> a[i] >> b[i];
	for (int i = 0; i < M; i++) cin >> c[i] >> d[i];

	for (int i = 0; i < N; i++) {
		
		for (int j = 0; j < M; j++) {
			dist[j] = distanceData{ abs(a[i] - c[j]) + abs(b[i] - d[j]), j+1 };
		}
		auto result = *min_element(dist.begin(), dist.end(),
			[](const distanceData& l, const distanceData& r)->int {
				if (l.distance == r.distance) return l.id < r.id;
				else return l.distance < r.distance;
			});
		print(result.id);
	}
}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int INF = 1e9 + 7;
const int maxn = 13;
const int maxp = 2e6 + 5;
const int maxm = 2e5 + 5;

int n, m;
int pw[maxn], ans[maxp];
char t[maxm];

class Trie{
public:
	int tot;
	int p[maxp], ch[maxp][3], tag[maxp];
	Trie(){
		tot = 1;
		memset(ch, -1, sizeof(ch));
		memset(p, -1, sizeof(p));
		return;
	}
	inline void insert(int x){
		int u = 0, y = x;
		for(int i = 0; i < n; ++i, x /= 3){
			if(!~ch[u][x % 3])
				ch[u][x % 3] = tot++;
			u = ch[u][x % 3];
		}
//		printf("u = %d y = %d\n", u, y);
		p[u] = y;
		return;
	}
	inline void inv(int u){
		tag[u] ^= 1;
		swap(ch[u][1], ch[u][2]);
		return;
	}
	inline void pushDown(int u){
		if(tag[u]){
			FOR(i, 0, 3)
				inv(ch[u][i]);
			tag[u] = false;
		}
		return;
	}
	inline void update(int dep, int u){
//		printf("dep = %d u = %d\n", dep, u);
		if(dep > n || !~u)
			return;
		pushDown(u);
		int tmp = ch[u][2];
		ch[u][2] = ch[u][1];
		ch[u][1] = ch[u][0];
		ch[u][0] = tmp;
		update(dep + 1, ch[u][0]);
		return;
	}
	inline void dfs(int dep, int u, int x){
		if(dep > n || !~u)
			return;
//		printf("dep = %d u = %d x = %d\n", dep, u, x);
		pushDown(u);
		FOR(i, 0, 3)
			dfs(dep + 1, ch[u][i], x + i * pw[dep]);
		if(~p[u])
			ans[p[u]] = x;
		return;
	}
}trie;

inline void precalc(){
	pw[0] = 1;
	FOR(i, 1, maxn)
		pw[i] = pw[i - 1] * 3;
	return;
}

int main(){
	scanf("%d", &n);
	precalc();
	scanf("%s", t);
	m = strlen(t);
	FOR(i, 0, pw[n])
		trie.insert(i);
	FOR(i, 0, m){
		if(t[i] == 'S')
			trie.inv(0);
		else
			trie.update(0, 0);
	}
	trie.dfs(0, 0, 0);
	FOR(i, 0, pw[n])
		printf("%d ", ans[i]);
	puts("");
	return 0;
}


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

int min(int a, int b) {
    if (a > b)return b;
    else return a;
}

int main()
{
    while (1) {
        int ans, E, x;
        cin >> E;
        if (E == 0)break;
        ans = 1000000;
        for (int i = 0; i*i*i <= E; i++) {
            int z = i;
            int y = sqrt(E - z*z*z);
            x = E - z*z*z - y*y;
            ans = min(ans, x + y + z);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

double a, b, h, m, s, t, d;
const double p = acos(-1);

int main()
{
	cin >> a >> b >> h >> m;

	s = (h * 30 + m * 0.5) / 180 * p;
	t = m / 30 * p;
	d = sqrt(a * a + b * b - 2 * a * b * cos(s - t));

	cout << setiosflags(ios::fixed|ios::showpoint) << setprecision(14)
	     << d << endl;
}


Measured memory_bytes: 4216
#include <stdio.h>
int main(){
int n,m;
int a[10010];
scanf("%d%d",&n,&m);
for(int i=0;i<m;i++)scanf("%d",&a[i]);
int s=0;
for(int i=0;i<m;i++)s+=a[i];
if(s>n){
printf("-1\n");
}else{
printf("%d\n",n-s);
}
}

Measured memory_bytes: 1744
#include<cstdio>
#pragma warning(disable:4996);
using namespace std;

int main(void)
{
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	int t1;
	int t2;
	t1 = c / b;
	if (c % b)
		t1++;
	t2 = a / d;
	if (a % d)
		t2++;
	if (t1 <= t2)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 1736
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=1;i<n;i++)
#define out(s) cout << s << endl

int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    ll cnt=0;
    bool flag=false;
    for(ll i=0;i<n;i++){
        cin >> a[i];
        if(a[i]==0)flag=true;
        if(a[i]<0)cnt++;
    }
    ll ans=0;
    for(ll x:a){
        ans+=abs(x);
    }
    
    if(!flag && cnt%2==1){
        ll m=100000000;
        for(ll i=0;i<n;i++){
            if(m>abs(a[i]))
                m=abs(a[i]);
        }
        ans=ans-2*m;
    }
    out(ans);
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    string s;
    cin >> n >> s;
    int dl = s.size();
    for (int i = 0; i < dl; ++i)
        cout << (char) ((s[i] - 'A' + n) % 26 + 'A');
    return 0;
}


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


int main()
{	
	int W,H,x,y,r;

	cin >> W >> H >> x >>y >>r;

	if (r <= x && x <= W - r)
	{
		if (r <= y && y <= H - r)
		{
			cout << "Yes" << endl;
		}

		else
		{
			cout << "No" << endl;
		}
	}

	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
int INF = 10000;
vector<int> dy = {1, 1, 0, 0, -1, -1};
vector<int> dx = {0, 1, 1, -1, -1, 0};
int score(vector<vector<int>> &T, int C){
  int N = T.size();
  vector<vector<bool>> used(N, vector<bool>(N, false));
  int ans = 0;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      if (!used[i][j]){
        if (T[i][j] != -1 && T[i][j] != 0){
          used[i][j] = true;
          int p = T[i][j];
          bool erase = true;
          int cnt = 0;
          queue<pair<int, int>> Q;
          Q.push(make_pair(i, j));
          while (!Q.empty()){
            int y = Q.front().first;
            int x = Q.front().second;
            cnt++;
            Q.pop();
            for (int k = 0; k < 6; k++){
              int y2 = y + dy[k];
              int x2 = x + dx[k];
              if (!used[y2][x2]){
                if (T[y2][x2] == p){
                  used[y2][x2] = true;
                  Q.push(make_pair(y2, x2));
                }
                if (T[y2][x2] == 0){
                  erase = false;
                }
              }
            }
          }
          if (erase){
            if (p == C){
              ans -= cnt;
            } else {
              ans += cnt;
            }
          } else {
          }
        }
      }
    }
  }
  return ans;
}
int main(){
  while (1){
    int N, C;
    cin >> N >> C;
    if (N == 0 && C == 0){
      break;
    }
    vector<vector<int>> S(N + 2, vector<int>(N + 2, -1));
    for (int i = 1; i <= N; i++){
      for (int j = 1; j <= i; j++){
        cin >> S[i][j];
      }
    }
    int ans = -INF;
    for (int i = 1; i <= N; i++){
      for (int j = 1; j <= i; j++){
        if (S[i][j] == 0){
          vector<vector<int>> T = S;
          T[i][j] = C;
          ans = max(ans, score(T, C));
        }
      }
    }
    cout << ans << endl;
  }
}


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

using namespace std;

#define int long long
#define uint unsigned int
#define dotimes(i, n) for (int i = 0, i##max__ = (n); i < i##max__; i++)
#define whole(x, f, ...) ([&](decltype((x)) c__) { return (f)(begin(c__), end(c__), ## __VA_ARGS__); })(x)

int rint() { int x; scanf("%lld", &x); return x; }
void wint(int x) { printf("%lld\n", x); }

template<typename T> int size(T const& c) { return static_cast<int>(c.size()); }
template<typename T> bool maxs(T& a, T const& b) { return a < b ? a = b, true : false; }
template<typename T> bool mins(T& a, T const& b) { return a > b ? a = b, true : false; }
inline int lg(int x) { return 63 - __builtin_clzll(static_cast<unsigned int>(x)); }

#ifdef EBUG
#define INT_WIDTH ""
#include "debug.h"
#else
#define inspect(...) do {} while (0)
#define debugf(...) do {} while (0)
#define debugv(...) do {} while (0)
#endif

signed main() {
  const int N = rint();
  const int M = rint();
  vector<vector<int>> edges(N);
  dotimes(i, M) {
    int A = rint() - 1;
    int B = rint() - 1;
    edges[A].emplace_back(B);
    edges[B].emplace_back(A);
  }
  int cs[2] = {};
  bool is_bipartite = [&]() {
    vector<int> colors(N, -1);
    stack<int> s;
    cs[colors[0] = 0]++;
    s.emplace(0);
    while (!s.empty()) {
      int u = s.top(); s.pop();
      for (int v : edges[u]) {
        if (colors[v] == colors[u])
          return false;
        if (colors[v] == -1) {
          cs[colors[v] = 1 - colors[u]]++;
          s.emplace(v);
        }
      }
    }
    return true;
  }();
  wint((is_bipartite ? cs[0] * cs[1] : N * (N - 1) / 2) - M);
  return 0;
}


Measured memory_bytes: 10092
import sys
input = sys.stdin.buffer.readline

s = int(input())
mod = 10**9 + 7

MAX_N = 3000

fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%mod)

fact_inv[-1] = pow(fact[-1],mod-2,mod)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%mod


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod

res = 0
for i in range(1,2000):
    if i*3 > s:
        break
    res = (res + mod_comb_k(s-3*i+i-1,i-1,mod))%mod
print(res)

Measured memory_bytes: 64992
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int a[N];
typedef long long ll;

int main()
{
    ll n;
    cin>>n;
    ll cnt=1,ans=0;
    while(n){
        ans+=cnt;;
        cnt*=2;
        n/=2;
    }
    cout<<ans;
    return 0;
}
/*

*/

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

using namespace std;

#define fast_io ios::sync_with_stdio(false); cin.tie(NULL);

int main()
{
	fast_io;
	
	int d,n;
	cin >> d >> n;

	if (d == 0)
	{
		if (n != 100)
			cout << n << endl;
		else
			cout << 101 << endl;
	}
	else if (d == 1)
	{
		if (n != 100)
			cout << n*100;
		else
			cout << n*100 + 100;
	}
	else
	{
		if (n != 100)
			cout << n*100*100;
		else
			cout << n*100*100 + 10000;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

int main(){
  ll N;
  cin >> N;

  ll dp[N][5][5][5] = {};
  repi(i, 1, 5) dp[0][0][0][i] = 1;
  repi(n, 1, N){
    rep(a, 5) rep(b, 5) rep(c, 5) repi(d, 1, 5){
      if(b == 1 && c == 3 && d == 2) continue;
      if(b == 3 && c == 1 && d == 2) continue;
      if(b == 1 && c == 2 && d == 3) continue;
      if(a == 1 && b == 3 && d == 2) continue;
      if(a == 1 && c == 3 && d == 2) continue;
      dp[n][b][c][d] = (dp[n][b][c][d] + dp[n-1][a][b][c]) % MOD;
    }
  }
  ll ans = 0;
  rep(a, 5) rep(b, 5) rep(c, 5) ans = (ans + dp[N-1][a][b][c]) % MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template<typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;      // モノイドに対して二項演算を行う関数オブジェクト
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
        sz = 1;
        while(sz < n)   sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x){
        seg[k + sz] = x;
    }

    void build(){
        for(int k = sz - 1; k > 0; --k){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    void update(int k, const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    Monoid query(int a, int b){
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
            if(a & 1)   L = f(L, seg[a++]);
            if(b & 1)   R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const{
        return seg[k + sz];
    }
};

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

    int H, W, M;
    cin >> H >> W >> M;
    vector<vector<int>> table(H);
    vector<int> column_sum(H, 0), row_sum(W, 0);
    SegmentTree<int> seg(W, [](int a, int b){return max(a, b);}, 0);
    for(int i = 0; i < M; ++i){
        int X, Y;
        cin >> X >> Y;
        --X, --Y;
        table[X].emplace_back(Y);
        column_sum[X]++;
        row_sum[Y]++;
    }
    for(int i = 0; i < W; ++i)  seg.set(i, row_sum[i]);
    seg.build();
    int ans = 0;
    for(int x = 0; x < H; ++x){
        for(int& y : table[x]){
            seg.update(y, seg[y] - 1);
        }
        chmax(ans, column_sum[x] + seg.query(0, W));
        for(int& y : table[x]){
            seg.update(y, seg[y] + 1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 26160
x,n=map(int,input().split())
p=sorted(list(map(int,input().split())))
q=[0]*(102)
for i in range(n):
    q[p[i]]=1
ans=(1000000,-1)
for i in range(102):
    if q[i]==0:
        if ans[0]>abs(i-x):
            ans=(abs(i-x),i)
print(ans[1])

Measured memory_bytes: 61984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair



int main() {
    int x[5];
    REP(i, 5) cin >> x[i];
    int ans;
    REP(i, 5) {
        if (x[i] == 0) ans = i + 1;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

int T[50];

int fibonacci(int n){
   int i;
   T[0] = 1;
   T[1] = 1;

   for (i=2; i<=n; i++)
      T[i] = T[i-2] + T[i-1];

   return T[i-1];
}


int main()
{
   int n;

   scanf("%d", &n);

   printf("%d\n", fibonacci(n));

   return 0;
}

Measured memory_bytes: 1820
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 30000;

int main() {
  int n;
  std::cin >> n;
  if(n == 3) {
    std::cout << 2 << " " << 5 << " " << 63;
    return 0;
  }
  std::cout << 3 << " " << 9 << " ";
  n -= 2;
  for(int i = 0; i < nmax; i += 6) {
    if(1 < n) {
      n -= 2;
      std::cout << i + 2 << " " << i + 4 << " ";
    }
  }
  for(int i = 12; i < nmax; i += 12) {
    if(1 < n) {
      n -= 2;
      std::cout << i + 3 << " " << i + 9 << " ";
    }
  }
  for(int i = 6; i <= nmax; i += 6) {
    if(1 <= n) {
      n -= 1;
      std::cout << i << " "; 
    }
  }
  return 0;
}


Measured memory_bytes: 3604
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		PriorityQueue<Integer> queue = new PriorityQueue<Integer>(new Comparator<Integer>() {
		    public int compare(Integer i1, Integer i2) {
		        return i2.intValue() - i1.intValue();
		    }
		});
		for (int i = 0; i < n; i++) {
		    queue.add(sc.nextInt());
		}
		for (int i = 0; i < m; i++) {
		    queue.add(queue.poll() / 2);
		}
		long total = 0;
		while (queue.size() > 0) {
		    total += queue.poll();
		}
		System.out.println(total);
   }
}




Measured memory_bytes: 57960
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

N = int(input())
adj = [ [] for _ in range(N) ]
for i in range(N-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  adj[a].append((b,i))

res = [None] * (N-1)
def dfs(n, c=-1, p=-1):
  if c==-1 or c>1: 
    nc = 1
  else:
    nc = c+1
  for nei,i in adj[n]:
    if nei == p: continue
    res[i] = nc
    dfs(nei, nc, n)
    nc += 1
    if nc==c: nc += 1

dfs(0)
print(max(res))
for r in res: print(r)

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

int main() {
  int n, p;
  cin >> n >> p;
  int odd = 0, evn = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a & 1) {
      odd++;
    } else {
      evn++;
    }
  }

  ll ans;
  if (p) {
    if (!odd) {
      ans = 0;
    } else {
      ans = 1LL << (n - 1);
    };
  } else {
    if (!odd) {
      ans = 1LL << n;
    } else {
      ans = 1LL << (n - 1);
    }
  }

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


Measured memory_bytes: 3620