akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    cout << fixed << setprecision(10);
    int n; cin >> n;
    V<long double> A(n);
    loop (n, i) cin >> A[i];
    long double ans = 0;
    loop (n, i) {
        ans += 1 / A[i];
    }
    cout << 1 / ans << endl;
    return 0;
}



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

int main()
{
	unordered_map<long long,long long> mp;
    long long n;
    cin>>n;
    
    long long arr[n];
    for(long long i=0;i<n;i++)
    {
        cin>>arr[i];
        mp[arr[i]]++;
    }
    
    long long cnt=0;
    for(auto i:mp)
    {
		cnt+=(((i.second)*(i.second-1))/2);
    }
    
    for(long long i=0;i<n;i++)
    {
		long long ans=cnt-(mp[arr[i]]-1);
        cout<<ans<<endl;
    }
	return 0;
}

Measured memory_bytes: 9160
package main

import "fmt"

func main() {
	var S string

	fmt.Scan(&S)

	ans := 0
	for i := 0; i < len(S); i++ {
		tmp := 0
		if S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T' {
			for ; i < len(S); i++ {
				if S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T' {
					tmp++
				} else {
					break
				}
			}
			ans = max(tmp, ans)
		}
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


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


#define int long long 


const int N = 2e5 + 7;

int nxt[N], vis[N];

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, x, m; cin >> n >> x >> m;
	int y = x;
	memset(nxt, -1, sizeof nxt);
	while(nxt[y] == -1) {
		//cout << y << endl;
		nxt[y] = y * y % m;
		y = y * y % m;
	}
	vector <int> a, b;
	int z = x;
	while(z != y) {
		a.push_back(z);
		z = z * z % m;
	}
	int csum = 0;
	while(!vis[y]) {
		csum += y;
		b.push_back(y);
		vis[y] = 1;
		y = y * y % m;
	}

	int ans = 0;

	for(int i = 1; i <= n && i <= a.size(); ++i) ans += a[i - 1];

	n -= (int)a.size();

	ans += (n / (int)b.size()) * csum;

	n %= (int)b.size();

	for(int i = 1; i <= n; i++) ans += b[i - 1];

	cout << ans << endl;


}


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



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
    
    
    
//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,n,m,k;
ll t=1;

void solve()
{
    cin>>n>>m>>k>>a;
    if(m<=n)
    {
        while(m<=n)
        {
            m*=2LL;a--;
            if(a==0)break;
        }
        if(m<=n)
        {
            cout<<"No";return;
        }
    }
    
    if(k<=m)
    {
        while(k<=m)
        {
            k*=2LL;
            a--;
            if(a<=0)break;
        }
        if(k<=m or a<0){cout<<"No";return;}
    }
   cout<<"Yes";
 if(t>0)cout<<"\n";
   
}



int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}
int H, W, K;
int mp[15][1010];
int ans = 1 << 30;
int main(){
    cin >> H >> W >> K;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            char a;
            cin >> a;
            mp[i][j] = a - '0';
        }
    }
    for(int i = 0; i < (1 << H); i++){
        int res = 0;
        vector<int> wh = {0};
        for(int j = 0; j < 10; j++){
            if((i >> j) & 1){
                res++;
                wh.push_back(0);
            }
        }
        for(int j = 0; j < W; j++){
            int idx = 0;
            for(int k = 0; k < H; k++){
                wh[idx] += mp[k][j];
                if((i >> k) & 1) idx++;
            }

            bool flag = false;
            for(auto u : wh){
                if(u > K) flag = true;
            }

            if(flag){
                res++;
                for(auto& u : wh) u = 0;
                idx = 0;
                for(int k = 0; k < H; k++){
                    wh[idx] += mp[k][j];
                    if((i >> k) & 1) idx++;
                }
                for(auto u : wh){
                    if(u > K) res += 1010;
                }
            }
        }
        chmin(ans, res);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int x, y;
	while (1){
		scanf("%d %d", &x, &y);
		if (!(x + y))break;
		if (x < y)
			printf("%d %d\n", x, y);
		else
			printf("%d %d\n", y, x);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>
#include <numeric>
#include <vector>

constexpr int INF = 1 << 30;

bool solve() {
    int n, m;
    std::cin >> n >> m;
    if (n == 0) return false;

    std::vector<int> xs(n), ys(m);
    for (auto& x : xs) std::cin >> x;
    for (auto& y : ys) std::cin >> y;

    std::vector<int> dp(1 << n, INF);
    dp[0] = 0;
    for (int b = 0; b < (1 << n); ++b) {
        int s = 0;
        for (int i = 0; i < n; ++i) {
            if ((b >> i) & 1) s += xs[i];
        }

        for (int i = 0; i < n; ++i) {
            if ((b >> i) & 1) continue;

            int nb = b | (1 << i);
            int t = s + xs[i];
            int score = 0;
            for (auto y : ys) {
                if (s <= y && y < t) {
                    score += std::min(std::abs(y - s),
                                      std::abs(t - y));
                }
            }

            dp[nb] = std::min(dp[nb], dp[b] + score);
        }
    }

    int ans = dp.back();
    int s = std::accumulate(xs.begin(), xs.end(), 0);
    for (auto y : ys) {
        if (s <= y) ans += y - s;
    }
    std::cout << ans << std::endl;

    return true;
}

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

    while (solve()) {}

    return 0;
}



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

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << char(s1[0] - 'a' + 1 + 'A' - 1)  << char(s2[0] - 'a' + 1 + 'A' - 1)  << char(s3[0] - 'a' + 1 + 'A' - 1);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define db long double
#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define lb lower_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<a.size();++i)
#define gc() getchar()
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
inline int rd()
{
	int x=0;char c=gc();while(!isdigit(c))c=gc();
	while(isdigit(c))x=x*10+c-48,c=gc();return x;
}
const int N=100005;
int n,a[4][N],f[2],g[2],ps[N],bit[N];
inline bool cmp(int a,int b,int c){return b==a+1&&c==b+1&&c%3==0;}
inline void init(){rep(i,0,n)bit[i]=0;}
inline void upd(int x,int v){for(;x;x-=x&-x)bit[x]+=v;}
inline int qry(int x){int s=0;for(;x<=n;x+=x&-x)s+=bit[x];return s;}
int main()
{
	n=rd();rep(i,0,2)rep(j,1,n)a[i][j]=rd();
	rep(i,1,n)
	{
		if(!cmp(a[0][i],a[1][i],a[2][i])&&!cmp(a[2][i],a[1][i],a[0][i])){puts("No");return 0;}
		int t=max(a[0][i],a[2][i])/3;
		if((i-t)&1){puts("No");return 0;}
		ps[t]=i;if(a[0][i]>a[2][i])f[i&1]^=1;
	}
	int s=0;for(int i=1;i<=n;i+=2){s+=qry(ps[i]);upd(ps[i],1);}g[1]=s&1;
	init();s=0;for(int i=2;i<=n;i+=2){s+=qry(ps[i]);upd(ps[i],1);}g[0]=s&1;
	puts(f[0]==g[1]&&f[1]==g[0]?"Yes":"No");
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int res = 0;
    int B[N-1];
    for(int i =0; i < N-1; i++){
        cin >> B[i];
    }
    res += B[0];
    for(int i = 0; i < N-2; i++){
        res += min(B[i],B[i+1]);
    }
    res += B[N-2];
    cout << res << endl;   
}

Measured memory_bytes: 256
n=input()
r=range
d=[(i,0)for i in r(1,n,2)]
for i in r(1,n,3):d+=[(i,j)for j in r(1+i%2,n,2)]
if n%3==1:d+=[(n-1,i)for i in r(2-n%2,n,2)]
print len(d)
print"\n".join(" ".join(map(str,e))for e in d)

Measured memory_bytes: 29492
use std::io; 

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let v :Vec<&str> = buf.trim().split(' ').collect();
    let a = v[0].parse::<i64>().unwrap();
    let b = v[1].parse::<i64>().unwrap();
    let cmp = match a - b {
        i if i > 0 => ">",
        i if i < 0 => "<",
        _ => "=="
    };
    println!("a {} b", cmp);
}


Measured memory_bytes: 5024
#include<bits/stdc++.h>
using namespace std;
int n,cnt,a[51],p[51];
int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
signed main(){
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),p[a[i]]=i;
	for(int i=1;i<=n;i++)
		if(p[i]!=i) swap(p[a[i]],p[i]),++cnt;
	puts(cnt>1?"NO":"YES");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
    FAST();
    ll n,i,j,k,t,a,b,c,d,p,q,x,y;
    cin>>i>>j;
    if(j>=i)
        cout<<"unsafe"<<endl;
    else
        cout<<"safe"<<endl;
    return 0;
}



Measured memory_bytes: 3692
#E https://atcoder.jp/contests/abc142/submissions/7853616
def main():
    n, m = map(int, input().split())
    inf = 10**9 #この10億は何に使う？->とにかくデカい数字。
    bit_dp = [inf for _ in range(2**(n))] #10億を2**n個並べる配列を作る。n=12 => 4096個
    bit_dp[0] = 0
    for i in range(m):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))#鍵1個につきa,b,c1~cbを決める
        bit_n = 0
        for i in c:
            bit_n |= 1 << i - 1 #ここで何番目をあけられるのかをbit_nで定義する。1と3ならbit_n=(5)101、2と3なら110(6)
        for i in range(2**n):
            if bit_dp[i|bit_n] > bit_dp[i] + a:
                bit_dp[i|bit_n] = bit_dp[i] + a
    if bit_dp[-1] >= inf:
        print(-1)
    else:
        print(bit_dp[-1])
                
if __name__ == "__main__":
    main()

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

int main() {
  int i, j;
  int n, m, k;

  scanf("%d %d %d", &n, &m, &k);
  // printf("%d %d %d", n, m, k);

  int flag = 0;
  int temp;

  for (i = 0; i <= n;i++){
    if (flag != 0){
      break;
    }
    for (j = 0; j <= m; j++){
      temp = i * m + j * n - 2* i * j;
      // printf("%d %d %d\n", i, j, temp);
      if (temp == k){
        flag = 1;
        break;
      }
    } }

  if (flag == 1){
    printf("Yes");
  }
  else {
    printf("No");
  }
  
  return 0;
}

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

namespace csharp
{
    class Program
    {
        private const float V = 1.0f;

        static void Main(string[] args)
        {
            string lineStr;
            lineStr = Console.ReadLine();
            int n = int.Parse(lineStr);
            float ret;

            if (n % 2 == 0)
                ret = 0.5f;
            else
            {
                ret = (n / 2 + 1) * V / n;
            }

            Console.WriteLine(ret);

            return;
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <stdlib.h>

using namespace std;

vector<long>a(100000, 9999999999), b(100000, 9999999999), c(100000, 9999999999);
int i, j, k;

bool amin(long t) {
	
	return (b[i] > t) ? true : false;
}

bool cmin(long t) {

	return (b[i] < t) ? true : false;
}

int main() {
	
	int n;
	

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (i = 0; i < n; i++) {
		cin >> c[i];
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	long long sum = 0;
	long acnt = 0, ccnt = 0;
	j = 0, k = 0;

	for (i = 0; i < n; i++) {
		//long acnt = count_if(a.begin(), a.end(), amin);
		//long ccnt = count_if(c.begin(), c.end(), cmin);
		//sum += (acnt*ccnt);

		for (j ; j < n; j++) {
			if (b[i] > a[j]) {
				acnt++;
			}
			else {
				break;
			}
		}

		for (k ; k < n; k++) {
			if (b[i] >= c[k]) {
				ccnt++;
			}
			else {
				break;
			}
		}

		sum += ( acnt * ((long)n - ccnt) );
	}

	cout << sum << endl;





	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 3200
// RとLが隣り合う場所に閉じ込められる 10^100は偶数
// 左端からみていったときに現れるLはそこより左側かつそこ以前の直近のLより右にいるRを巻き込む（巻き込むとは

package main

import (
	"fmt"
)

func main() {
	var S string
	fmt.Scan(&S)
	SS := make([]string, len(S))
	for i, c := range []rune(S) {
		SS[i] = string(c)
	}
	Ls := make([]int, len(S))
	Rs := make([]int, len(S))
	preLidx, preRidx := 0, len(S)-1
	for i := 0; i < len(S); i++ {
		if SS[i] == "L" {
			dist := i - preLidx
			if dist%2 == 0 {
				Ls[i] += dist / 2
				Ls[i-1] += dist / 2
			} else {
				// RRRLだと奇数番目のRは偶数回後はi-1にいる
				Ls[i] += dist / 2
				Ls[i-1] += dist/2 + 1
			}
			preLidx = i + 1
		}
	}
	for i := len(S) - 1; i >= 0; i-- {
		if SS[i] == "R" {
			dist := preRidx - i
			if dist%2 == 0 {
				Rs[i] += dist / 2
				Rs[i+1] += dist / 2
			} else {
				Rs[i] += dist / 2
				Rs[i+1] += dist/2 + 1
			}
			preRidx = i - 1
		}
	}
	for i := 0; i < len(S); i++ {
		if i < len(S)-1 {
			fmt.Printf("%d ", Ls[i]+Rs[i])
		} else {
			fmt.Println(Ls[i] + Rs[i])
		}
	}
}


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

bool secondaryLarge(int p_i, int a, int b) {
    if (a > p_i) {
        if (b > p_i) {
            return false;
        } else if (b <= p_i) {
            return true;
        }
    } else if (a == p_i) {
        if (b > p_i) {
            return true;
        } else {
            return false;
        }
    } else {
        if (b >= p_i) {
            return true; 
        } else {
            return false;
        }
    }

    return false;
}

int main(){
    int n; cin >> n;
    int p[n];

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

    int count = 0;

    for (int i=1; i<n-1; i++){
        if (secondaryLarge(p[i], p[i-1], p[i+1])){
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
X,Y= map(int,input().split())
b=(Y-2*X)%2
a=(4*X-Y)%2
B=(Y-2*X)/2
A=(4*X-Y)/2
if (b==0 and a==0 and A>=0 and B>=0):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9096
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
using namespace std;
#define ll long long 
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, 0, h) cin >> s[i];
    int x[4] = {-1, 0, 1, 0};
    int y[4] = {0, -1, 0, 1};
    rep(i, 0, h) {
        rep(j, 0, w) {
            int sum = 0;
            char c = s[i][j];
            if(c == '.') continue;
            rep(k, 0, 4) {
                if(i+y[k] >= 0 && i+y[k] < h && j+x[k] < w && j+x[k] >= 0) {
                    if(c == s[i+y[k]][j+x[k]]) {
                        sum++;
                    }
                }
            }
            if(sum == 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<string, string> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	int m = 2*n;
	string s1 = "", s2 = "";
	rep(i,n) s1 += s[i];
	rep(i,n) s2 += s[i+n];
	ll ans = 0;
	map<P, ll> mp;
	rep(i,1<<n){
		string sw = "", sv = "";
		rep(j,n){
			if(i>>j & 1) sw += s1[j];
			else sv += s1[j];
		}
		reverse(sv.begin(), sv.end());
		++mp[P(sw, sv)];
	}
	rep(i,1<<n){
		string su = "", st = "";
		rep(j,n){
			if(i>>j & 1) su += s2[j];
			else st += s2[j];
		}
		reverse(st.begin(), st.end());
		ans += mp[P(st, su)];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 60836
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <queue>

#define INF 2147483647

using namespace std;

struct edge { int to,cost;};	
typedef pair<int,int> P;

int main(){
	int V,E,r,
	    s,t,d,
	    score[100000];
	P p;
	edge e;
	vector<edge> G[100000];
	priority_queue<P,vector<P>,greater<P> > q;
	
	scanf("%d %d %d",&V,&E,&r);
	for(int i=0;i<E;i++){
		scanf("%d %d %d",&s,&t,&d);
		G[s].push_back( {t,d} );
	}
	
	fill(score , score + V , INF);
	score[r] = 0;
	q.push( P(0,r) );
	
	while(!q.empty()){
		p = q.top();
		q.pop();
		r = p.second;
		if(score[r] < p.first) continue;
		for(int j=0;j<G[r].size();j++){
			e = G[r][j];
			if(score[e.to] > score[r]+e.cost){
				score[e.to] = score[r]+e.cost;
				q.push( P(score[e.to],e.to) );
			}
		}
	}
	for(int i=0;i<V;i++){
		if(score[i]==2147483647) printf("INF\n");
		else printf("%d\n",score[i]);
	}
		
	return 0;
}


Measured memory_bytes: 13028
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
		String strR = bufferedReader.readLine();
		String strG = bufferedReader.readLine();
		int r = Integer.parseInt(strR);
		int g = Integer.parseInt(strG);

		int answer = g * 2 - r;
		System.out.println(answer);
	}

}


Measured memory_bytes: 20436
N = int(input())
h = list(map(int,input().split()))

costs = [0] * N
costs[0] = 0
costs[1] = abs(h[1] - h[0])
for i in range(2,N):
  tmp1 = costs[i-2] + abs(h[i] - h[i-2])
  tmp2 = costs[i-1] + abs(h[i] - h[i-1])
  costs[i] = min(tmp1,tmp2)
print(costs[N-1])

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;

int main()
{
   ll n;cin >>n;
   V a(n),b(n);rep(i,n)cin >>a[i]>>b[i];
   vector<P> s(n);
   rep(i,n){
    ll k=a[i]+b[i];
        s[i]=make_pair(k,i);
   }
   sort(s.rbegin(),s.rend());
   ll takahasi=0,aoki=0;
   rep(i,n){
    ll key=s[i].second;
    if(i%2==0){
        takahasi+=a[key];
    }
    else {
        aoki+=b[key];
    }
   }
   cout << takahasi-aoki<< endl;
    return 0;
}


Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		ArrayList<ArrayList<Pair>> edge = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			edge.add(new ArrayList<>());
		}

		for (int i = 0; i < n - 1; i++) {
			String str[] = br.readLine().split(" ");
			int a = Integer.parseInt(str[0]) - 1;
			int b = Integer.parseInt(str[1]) - 1;

			edge.get(a).add(new Pair(i, b));
			edge.get(b).add(new Pair(i, a));
		}
		int max = 0;
		for (int i = 0; i < n; i++) {
			max = Math.max(max, edge.get(i).size());
		}

		ArrayList<Integer> ans = new ArrayList<>();

		for (int i = 0; i < n - 1; i++) {
			ans.add(-1);
		}

		dfs(0, -1, -1, edge, ans);

		System.out.println(max);
		for (int i : ans) {
			System.out.println(i);
		}
	}

	static void dfs(int now, int p, int pcolor, ArrayList<ArrayList<Pair>> edge, ArrayList<Integer> ans) {
		int color = 1;
		if (color == pcolor)
			color++;

		for (int i = 0; i < edge.get(now).size(); i++) {
			int next = edge.get(now).get(i).to;
			if (next == p) {
				continue;
			}
			ans.set(edge.get(now).get(i).id, color);
			dfs(next, now, color, edge, ans);
			++color;
			if (color == pcolor)
				++color;
		}
	}
}

class Pair {
	int id;
	int to;

	public Pair(int id, int to) {
		this.id = id;
		this.to = to;
	}
}

Measured memory_bytes: 77544
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long LL;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	deque<int> a;
	int n; cin >> n;
	for(int i = 0; i < n; i++)
	{
		int x; cin >> x;
		if(i&1)
			a.push_front(x);
		else
			a.push_back(x);
	}
	if(n&1)
		reverse(a.begin(),a.end());
	for(int i = 0; i < n; i++)
		cout<<a[i]<<" ";
	cout<<endl;

	cout<<flush;
	return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  vector<int> c;
  rep(i,1005) c.push_back(i*i);
  string ans = "No";
  if(b==100 and find(c.begin(),c.end(),1000*a+b)!=c.end()) ans="Yes";
  else if(b>=10 and find(c.begin(),c.end(),100*a+b)!=c.end()) ans="Yes";
  else if(find(c.begin(),c.end(),10*a+b)!=c.end()) ans="Yes";
  cout << ans;
  return 0;
}

Measured memory_bytes: 3588
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;
static const ll MOD = (ll)1e9 + 7;
static const double EPS = 1e-9;

#define REP(i, n) for(ll i = 0; i < static_cast<ll>(n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll power(ll x, ll y) {
    ll ret = 1;
    while(y-- > 0) ret *= x;
    return ret;
}

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

ll extgcd(ll a, ll b, ll& x, ll& y) {
    x = 1; y = 0;
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    ll X, Y;
    auto d = extgcd(b, a % b, X, Y);
    x = Y;
    y = X - (a / b) * Y;
    return d;
}

int run(istream& in, ostream& out) {
    std::string S;
    in >> S;
    ll ans = 0;

    char prev = 0;
    ll max_len = 0;
    REP(i, S.size()) {
        if (S[i] == 'R') {
            if (prev == S[i]) {
                ++max_len;
            } else {
                max_len = 1;
            }
        } else {
            ans = max(max_len, ans);
            max_len=0;
        }
        prev = S[i];
    }
    ans = max(max_len, ans);
    out << ans << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 3560
def ascan; gets.split.map(&:to_i); end
def scan; gets.to_i; end

gets
aa = ascan.map{|e| e/400}.map{|e| [e,8].min}

m = {}
aa.each{|e| m[e]||=0;m[e] += 1}

c = m.keys.size

if !m[8]
    puts "#{c} #{c}"
else
    if c == 1
        puts "#{c} #{m[8]}"
    else
        puts "#{c-1} #{c+m[8]-1}"
    end
end

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<stdio.h>
#include<vector>
#include<map>
using namespace std;

int A, B, T;
int ans;

int main() {
	cin >> A >> B >> T;
	T /= A;
	T *= B;
	
	cout << T << endl;

	return 0;
}

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


int main(){
	ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	double l;cin>>l;
	double  m;
	m=(float)l/3;
	
	cout<<fixed<<setprecision(12)<<(m*m*m);
}

Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())

total = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            total += gcd(a, b, c)

print(total)

Measured memory_bytes: 69720
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  string S, T; cin >> S >> T;
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != T[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 3576
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string l; cin >> l;
  int n = l.length();
  vector<vector<long long> > dp(n + 1, vector<long long>(2, 0));
  dp[0][true] = 1;
  REP(i, n) {
    if (l[i] == '0') {
      dp[i + 1][true] = dp[i][true];
      dp[i + 1][false] = dp[i][false] * 3 % MOD;
    } else {
      dp[i + 1][true] = dp[i][true] * 2 % MOD;
      dp[i + 1][false] = (dp[i][true] + dp[i][false] * 3) % MOD;
    }
  }
  cout << (dp[n][true] + dp[n][false]) % MOD << '\n';
  return 0;
}


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

int main(){
    long long N;
    cin >> N;
    long long sq = sqrt(N);
    for(int i=sq;i>=0;i--){
        if(N%i == 0){
            cout << (i-1) + (N/i - 1);
            return 0;
        }
    }
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, x;
  while (cin >> n >> x) {
    vector<int> v(n);
    each (i, v) cin >> i;
    sort(v.begin(), v.end());

    vector<int> u;
    each (i, v) {
      u.push_back(min(x, i));
      x = max(0, x - i);
    }
    if (x) {
      u.back() += x;
      x = 0;
    }

    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      cnt += (v[i] == u[i]);
    }
    cout << cnt << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
N = int(input())
h = [i for i in map(int, input().split())]

dp = [0]*N
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(N-2):
    dp[i+2] = min(dp[i]+abs(h[i+2]-h[i]), dp[i+1]+abs(h[i+2]-h[i+1]))
print(dp[-1])

Measured memory_bytes: 13980
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
int A[999999], W[999999];
long long merge_and_count(int l, int r) { // range [l,r)
	if (l+1 >= r) return 0; // empty
	if (l+2 == r) { // [l,r) == [l,l+1] 要素2つだけ
		if (A[l] <= A[l+1]) return 0; // 逆転はなし
		std::swap(A[l], A[l+1]);
		return 1; // 逆転一つ
	}
	int m = (l+r)/2; // [l,r) == [l,m) + [m,r)
	long long cl = merge_and_count(l, m); // 左半分を再帰的に数える
	long long cr = merge_and_count(m, r); // 右半分を再帰的に数える
	long long c = 0; // 左と右を混ぜるときの逆転数
	int i=l, j=m; // iは[l,m)を動き, jは[m,r)を動いて、
	int k=l; // 小さいものから W[k] に書き込む
	while (i<m && j<r) { // A[i]とA[j]を比べながら進む
		if (A[i] <= A[j]) W[k++] = A[i++]; // 左半分の方が小さく逆転なし
		else {
			W[k++] = A[j++];
			c += m-i; // 左半分の方が大きい、左半分で未処理の要素だけ飛び越える
		}
	}
	while (i<m) W[k++] = A[i++]; // 左半分が余った場合
	while (j<r) W[k++] = A[j++]; // 右半分が余った場合
	//assert(k == r);
	std::copy(W+l, W+r, A+l);
	return cl + cr + c;
}

// cpp_binarysearch (C) @cielavenir under Boost Software License.
// returns the smallest value satisfying the predicate.

#include <functional>
template<typename T,typename F=std::function<bool(T)>>
T binarysearch(T lo,T hi,const T eps,const F &predicate){
	T r=hi+eps;
	for(;lo<hi+eps;){
		T mi=eps!=1||(lo<0)==(hi<0) ? lo+(hi-lo)/2 : (lo<-hi) ? -((-lo-hi-1)/2+1) : (lo+hi)/2;
		if(predicate(mi)){
			r=mi;
			hi=mi-eps;
		}else{
			lo=mi+eps;
		}
	}
	return r;
}

int main(){
	int T,i,N;
	scanf("%d",&N);std::vector<int>v(N);for(T=i=0;i<N;i++){scanf("%d",&v[i]);if(v[i]>T)T=v[i];}
	printf("%d\n",binarysearch(1,T,1,[&](int m){
		A[0]=0;
		for(i=1;i<=N;i++)A[i]=A[i-1]+(v[i-1]>m?1:-1);
		long long r=merge_and_count(0,N+1);
		return r>=(long long)(N+1)*N/4+1;
	}));
}

Measured memory_bytes: 5120
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ld r;
  cin >> r;
  print(2*PI*r);
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
int k,i= -1;
vector<long long> vec = {};
void dfs(long long x,int a){
    vec.push_back(x);
    if(x > 1000000000) return;
    if(x == 0){
        for (int j = 1; j < 10; j++)
        {
            dfs(j,j);
        }
    }
    else{
        if(a != 0 && a!= 9){
            dfs(10*x + a-1,a-1);
            dfs(10*x + a,a);
            dfs(10*x + a+1,a+1);
        }
        if(a == 0) {
            dfs(10*x + 0,0);
            dfs(10*x + 1,1);
        }
        if(a == 9) {
            dfs(10*x + 8,8);
            dfs(10*x + 9,9);
        }
    }
}

int main(){
    cin >> k;
    dfs(0,0);
    sort(vec.begin(),vec.end());
    cout << vec[k] << endl;
}

Measured memory_bytes: 5276
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  usize N;
  std::cin >> N;
  std::vector<i32> A(N), ans(N, 0);
  for (usize i = 0; i < N; i++) std::cin >> A[i];

  i32 ans_first = 0;
  for (usize i = 0; i < N; i++) {
    if (i % 2 == 0) {
      ans_first += A[i];
    } else {
      ans_first -= A[i];
    }
  }

  ans[0] = ans_first;

  for (usize i = 1; i < N; i++) {
    ans[i] = (A[i - 1] - ans[i - 1] / 2) * 2;
  }

  for (usize i = 0; i < N; i++) {
    if (i) std::cout << " ";
    std::cout << ans[i];
  }
  std::cout << std::endl;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>

int main(void){
  long long int s=0;
  int n,m;

  scanf("%d %d",&n,&m);

  s = 1900 * m + 100 * (n - m);

  while(m>0){
    s*=2;
    m--;
  }

  printf("%lld\n",s);

  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class B
{
    static void Main()
    {
        var line = Console.ReadLine().Trim();
        int N = int.Parse(line);
        int[] intRecord = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();

        int max = 0;
        int sum_Rejectmax = 0;
        for (int i = 0; i < N; i++)
        {
            if (intRecord[i] > max)
            {
                sum_Rejectmax += max;
                max = intRecord[i];
            }
            else
            {
                sum_Rejectmax += intRecord[i];
            }
        }

        Console.WriteLine(sum_Rejectmax > max ? "Yes" : "No");
    }

}

Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


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

    int N; cin >> N;

    int t1 = 0, x1 = 0, y1 = 0;
    int t2, x2, y2;
    int d = 0;
    rep(i, N) {
        cin >> t2 >> x2 >> y2;
        d = abs(x2-x1) + abs(y2-y1);
        int t = t2 - t1;
        if (t < d || d % 2 != t % 2) {
            cout << "No" << endl;
            return 0;
        }
        t1 = t2; x1 = x2; y1 = y2;
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
#define MIN 0
#define MAX 100
#define IS_ERR(x) (x < MIN || x > MAX)
 
 
int main(void)
{
    int a,b,c;
 
    scanf("%d %d %d", &a, &b, &c);
 
    if(IS_ERR(a) || IS_ERR(b) || IS_ERR(c))
    {
        return -1;
    }
 
    if(a < b && b < c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
 
    return 0;
 
}


Measured memory_bytes: 2140
#include<stdio.h>
int main(){
	int a,b,c,d,e,f;
	while (~scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)){
		double y=(double)(c*d-a*f)/(double)(b*d-a*e);
		if(a!=0)printf("%.3f %.3f\n",(c-b*y)/a,y);
		else printf("%.3f %.3f\n",(f-e*y)/d,y);
	}
}



Measured memory_bytes: 2672
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  vector<int> a(9);
  for (int i=0; i<3; i++){
    cin >> a[i*3] >> a[i*3+1] >> a[i*3+2];
  }
  int n;
  cin >> n;
  int b;
  for (int i=0; i<n; i++){
    cin >> b;
    for (int j=0; j<9; j++){
      if (a[j] == b) {
        a[j] = 0;
        break;
      }
    }
  }
  if (a[0]+a[1]+a[2]==0 || a[3]+a[4]+a[5]==0 || a[6]+a[7]+a[8]==0 || a[0]+a[3]+a[6]==0 || a[1]+a[4]+a[7]==0 || a[2]+a[5]+a[8]==0 || a[0]+a[4]+a[8]==0 || a[2]+a[4]+a[6]==0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    int n, d, x;
    cin >> n >> d >> x;
    int a[114514];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        x += 1+(d-1)/a[i];
    }
    cout << x << endl;
    return 0;
}


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

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}

int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 
int fact[1000005];int fact_inv[1000005];
int ncr(int n,int r){
    if(n<r){return 0;}
    if(n==r||r==0){return 1;}
    return (((fact[n]*fact_inv[n-r])%mod)*fact_inv[r])%mod;
    //return x; 
}
signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<": ";
    int n,m;
    cin>>n>>m;
    fact[0]=1;
    for(int i=1;i<1000005;i++){
        fact[i]=(fact[i-1]*i)%mod;
        fact_inv[i]=power(fact[i],mod-2);
    }


    VI re;int anss=1;
    for(int i=2;i<=sqrt(m);i++)
    {   int flag=0;int ans=0;
        while(m%i==0)
        { flag=1;
            m/=i;ans++;
        }
        if(flag==1)re.pb(ans);
    }
    if(m!=1)re.pb(1);
    
    for(auto it:re)
    {
    	anss*=ncr(n+it-1,n-1);
    	anss%=mod;
    }
    cout<<anss<<endl;
}


return 0;
}





Measured memory_bytes: 15872
#include <iostream>

int main() {
    int n, y; std::cin >> n >> y;
    int s = y / 1000;

    for (int i = 0; i <= y / 5000; i++) {
        for (int j = 0; j <= y / 10000; j++) {
            int ss = s - 5 * i - 10 * j;
            if (ss < 0) {
                break;
            }
            if (i + j + ss == n) {
                std::cout << j << " " << i << " " << ss << std::endl;
                return 0;
            }
        }
    }
    std::cout << "-1 -1 -1" << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define random_shuffle asdasdd

const int MAXN = 2 * 105000;
const int mod = (int) 1e9 + 7;

long long binpow(long long x, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) {
      res = (res * x) % mod;
      p--;
    } else {
      x = (x * x) % mod;
      p /= 2;
    }
  }
  return res % mod;
}

int n;
int c[MAXN];

int main() { 

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i]);
  }
  sort(c, c + n);
  reverse(c, c + n);

  long long ans = 0;

  for (int i = 0; i < n; i++) {
    long long mul = binpow(2, n) % mod;
    mul = mul * c[i] % mod;
    int bef = i, aft = n - i - 1;
    mul = mul * binpow(2, aft) % mod;
    if (bef > 0) {
      long long x = binpow(2, bef - 1) % mod;
      x = x * (bef + 2) % mod;
      mul = mul * x % mod;
    }
    ans = (ans + mul) % mod;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int sum = 0;
  
  if (A <= B) sum += A;

  else sum += B;
 
  if (C <= D) sum += C;

  else sum += D;
  
  cout << sum << endl;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for(int i = 0; i < (int)n; i++)

void solve() {
    int x, y;
    cin >> x >> y;
    vector<string> v;
    for (int i = 0; i < x; i++) {
        string a;
        cin >> a;
        v.push_back(a);
    }
    sort(bn(v));
    for (string a : v) {
        cout << a;
    }
}

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

    int t = 1, i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
#define all(v) (v).begin(),(v).end()
#define int long long
#define P pair<int,int>

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

    int n;
    cin >> n;

    set<int> st;
    map<int,int> mp;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        st.insert(a);
        mp[a]++;
    }
    int even = 0;
    for(auto i : mp){
        if(i.second % 2 == 0) even++;
    }
    if(even % 2 == 0) cout << st.size();
    else cout << st.size() - 1 << endl;

}

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

int main() {
  int m, f, b; cin >> m >> f >> b;
  int ans = b - m;
  if (m > b) cout << 0 << endl;
  else if (ans <= f) cout << ans << endl;
  else cout << "NA" << endl;
  return 0;
}


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

constexpr static int ___mod = 1000000007;

long long fastExp(long long base, int index = ___mod - 2)
{
    long long ret = 1;
    for (; index; index >>= 1, base = base * base % ___mod)
        if (index & 1)
            ret = ret * base % ___mod;
    return ret;
}

int n, m, k;
long long fact[1000010], invFact[1000010];

void pre()
{
    fact[0] = invFact[0] = 1;
    for (int i = 1; i <= n * m; ++i)
        fact[i] = fact[i - 1] * i % ___mod, invFact[i] = fastExp(fact[i]);
}

long long C(long long n, long long r)
{
    if (n < r || r < 0 || n < 0)
        return 0;
    return fact[n] * invFact[r] % ___mod * invFact[n - r] % ___mod;
}

int main()
{
    std::cin >> n >> m >> k;
    pre();
    long long ans = 0;
    for (int d = 1; d < n; ++d)
        ans = (ans + 1ll * d * (n - d) % ___mod * m % ___mod * m % ___mod * C(n * m - 2, k - 2) % ___mod) % ___mod;
    for (int d = 1; d < m; ++d)
        ans = (ans + 1ll * d * (m - d) % ___mod * n % ___mod * n % ___mod * C(n * m - 2, k - 2) % ___mod) % ___mod;
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 5888
// C - Next Prime

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

bool IsPrime(long long num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (long long i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main ()
{
    long long X;
    cin >> X;
    for (long long n = X; n < 100004; n++) {
        if (IsPrime(n)) {
            cout << n << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;

int main() {
	ll N; cin >> N;
	if (N % 2 == 0) {
		cout << N << endl;
	}
	else {
		cout << 2 * N << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void){

  int N;
  scanf("%d\n", &N);

  int *A;
  A = (int*)malloc(N*sizeof(int));
  for(int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }

  int ans=0;

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

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VB = vector<bool>;
using VS = vector<string>;
using graph = vector<vector<int>>;

int main()
{
string a,b;
cin>>a>>b;
int num=a.length(),aaaa=b.length();
num=num+aaaa;
int x=0,y=0;
for (int i = 1; i <= num; i++)
{
    if (i%2==1)
    {
        cout<<a.at(x);
        x++;
    }
    else
    {
        cout<<b.at(y);
        y++;
    }
    
}
cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,n,ans=0;
  cin>>N>>n;
  if(n){
    puts("-1");
    return 0;
  }
  for(int i=1;i<N;i++){
    int a;
    cin>>a;
    if(n>=a)ans+=a;
    else if(n+1==a)ans++;
    else{
      puts("-1");
      return 0;
    }
    n=a;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636