akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')

N, M = MAP()
mod = M

tree = [[] for _ in range(N+1)]  # 1-indexed
for _ in range(N-1):
	a, b = MAP()
	tree[a].append(b)
	tree[b].append(a)

root = 1
parent = [0]*(N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in tree[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

dp_d = [0]*(N+1)

for v in order[::-1]:
    x = 1
    for node in tree[v]:
        x = (x * (dp_d[node]+1))%mod
    dp_d[v] = x

dp_u = [1]*(N+1)
modmul = lambda x, y: x*y%mod
for v in order:
    p = parent[v]
    val = [dp_d[node]+1 if node != p else dp_u[v] for node in tree[v]]
    left = [1] + list(accumulate(val, modmul))[:-1] # 左累積和
    right = list(accumulate(val[::-1], modmul))[-2::-1] + [1] # 右累積和
    contrib = [x*y%mod for x, y in zip(left, right)]
    for node, c in zip(tree[v], contrib):
        if node != p:
            dp_u[node] = 1+c

ans = []
for xd, xu in zip(dp_d[1:], dp_u[1:]):
    ans.append(xd*xu%mod)
print(*ans, sep="\n")


Measured memory_bytes: 44040
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

struct UnionFind {
	VI par, s;
	UnionFind(int N) :par(N), s(N) {
		REP(i, N)par[i] = i;
		REP(i, N)s[i] = 1;
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		if (!(same(x, y)))s[ry] += s[rx];
		par[rx] = ry;
	}
	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
	int size(int x) {
		return s[root(x)];
	}
};

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

	int N,M; cin >> N >> M;
	UnionFind uni(N);
	REP(i, M) {
		int a, b; cin >> a >> b;
		a--, b--;
		uni.unite(a, b);
	}
	vector<bool>F(N, false);
	int ans = 0;
	REP(i, N) {
		if (!F[uni.root(i)]) {
			ans++;
			F[uni.root(i)] = true;
		}	
	}
	cout << ans - 1 << endl;
	return 0;
}



Measured memory_bytes: 4784
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで

vector<vector<int>> G;

void dfs(int v, vector<bool> &seen, int &res) // 0、チェック済み配列、まずは0
{
    bool end = true; // 終了フラグ
    for (int i = 0; i < seen.size(); i++) { //チェック済み配列の長さ分最大N繰り返す
        if (!seen[i] && i != v) //もしチェック済みじゃなくて、かつ、iがvじゃなければ
            end = false; //終了しない
    }
    // 全部チェック済みだと上記のループをtrueで抜けることになり、カウンタが加算される
    if (end) //全部チェック済みなら
    {
        ++res; //終了する場合はカウンタを加算して返す
        return;
    }

    seen[v] = true; // v を訪問済にする
    for (auto next_v : G[v]) // v から行ける各頂点 next_v について
    {
        if (seen[next_v]) // next_v が探索済だったらスルー
            continue;
        dfs(next_v, seen, res); // 再帰的に探索
    }
    seen[v] = false; //v番目をfalseにする
}

int main()
{
    int N, M; //N頂点、M辺
    cin >> N >> M;
    G.assign(N, vector<int>()); //N個のint型の配列を入れる
    // 各辺と頂点の関係性の表の作成。下記のように各頂点と線でつながってる頂点の表ができる。
    // G[0] {1, 3}
    // G[1] {0, 3}
    // G[2] {0, 1}
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        --a, --b; //配列の0スタートに合わせてる
        G[a].push_back(b);
        G[b].push_back(a); //無向グラフのため
    }
    vector<bool> seen(N, false); //チェック済みの頂点を格納してる配列 初期値はN個のfalse
    int res = 0;
    dfs(0, seen, res); // 頂点 0 をスタートとした探索
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int n, k;
    cin >> n >> k;
    ll mi = 0, ma = 0;
    ll ans = 0;
    rep (i, n + 1) {
        mi += i;
        ma += n - i;
        if (i + 1 >= k) {
            ans += ma - mi + 1;
            ans %= MOD;
        }
    }
    cout << ans << endl;


    // int n;
    // cin >> n;
    // vi a(n - 1);
    // rep (i, n - 1) {
    //     cin >> a[i];
    //     a[i]--;
    // }

    // vi num(n);
    // rep (i, n - 1) {
    //     num[a[i]]++;
    // }
    // rep (i, n) {
    //     cout << num[i] << endl;
    // }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define N 100020
#define mod 1000000007
#define ll long long
using namespace std;
inline long long read(){
  long long x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}

long long s[N], f[N], g[N];

int main(int argc, char const *argv[]) {
  long long n = read(), a = read(), b = read();
  for (int i = 1; i <= n; ++ i) {
    s[i] = read();
  }
  if (a > b) swap(a, b);
  for (int i = 3; i <= n; ++ i) {
    if (s[i] - s[i-2] < a){
      puts("0");
      return 0;
    }
  }
  s[0]     = - 2e18;
  s[n + 1] =   2e18;
  f[0] = g[0] = 1;
  int l = 0, r = 0;
  for (int i = 1; i <= n + 1; ++ i) {
    while (r < i - 1 && s[i] - s[r + 1] >= b)
      ++ r;
    if (l <= r) {
      f[i] = (g[r] + mod - (l ? g[l - 1] : 0)) % mod;
    }
    g[i] = (g[i - 1] + f[i]) % mod;
    if (i > 1 && s[i] - s[i - 1] < a) {
      l = i - 1;
    }
  }
  printf("%d\n", f[n + 1]);
}


Measured memory_bytes: 2688
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  string s;
  cin >> s;
  int count = 0;
  size_t len = s.length();
  rep(i, s.length() / 2) {
    if (s.at(i) != s.at(len - i - 1)) {
      count++;
    }
  }
  cout << count;
  return 0;
}


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

if K > (N-1)*(N-2)/2:
    print(-1)
else:
    edge = []
    for i in range(1, N):
        for j in range(i+1, N+1):
            edge.append([i, j])
    M = int((N-1) + (N-1)*(N-2)/2 - K)
    print(M)
    for ind in range(M):
        print(" ".join(map(str, edge[ind])))

Measured memory_bytes: 3844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		for (Scanner in = new Scanner(System.in); in.hasNext();) {
			long t;
			System.out.println(new StringBuilder().append((t = (-in.nextInt() * 3600 - in.nextInt() * 60 - in.nextInt()) + (in.nextInt() * 3600 + in.nextInt() * 60 + in.nextInt())) / 3600).append(' ').append((t %= 3600) / 60).append(' ').append(t % 60)	.toString());

		}
	}
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;

int main()
{
    int n,m;
    cin >>n >>m;

    vvi a(n,vi(n));
    rep(i,n)rep(j,n) cin >>a[i][j];

    //query
    rep(M,m)
    {
        int op;
        scanf(" %d", &op);

        vvi b(a);
        if(op==0)
        {
            int r,c,size,angle;
            scanf(" %d %d %d %d",&r,&c,&size,&angle);
            --r;
            --c;

            rep(T,angle/90)
            {
                vvi t(b);

                for(int i=r; i<r+size; ++i)
                for(int j=c; j<c+size; ++j)
                t[r+(j-c)][c+size-1-(i-r)]=b[i][j];

                for(int i=r; i<r+size; ++i)
                for(int j=c; j<c+size; ++j)
                b[i][j]=t[i][j];
            }

        }
        else if(op==1)
        {
            int r,c,size;
            scanf(" %d %d %d",&r,&c,&size);
            --r;
            --c;

            for(int i=r; i<r+size; ++i)
            for(int j=c; j<c+size; ++j)
            b[i][j]=!b[i][j];
        }
        else if(op==2)
        {
            int r;
            scanf(" %d",&r);
            --r;

            int tmp=b[r][0];
            rep(i,n-1) b[r][i]=b[r][i+1];
            b[r][n-1]=tmp;
        }
        else if(op==3)
        {
            int r;
            scanf(" %d",&r);
            --r;

            int tmp=b[r][n-1];
            for(int i=n-1; i>0; --i) b[r][i]=b[r][i-1];
            b[r][0]=tmp;
        }
        else
        {
            int r,c;
            scanf(" %d %d",&r,&c);
            --r;
            --c;

            int dr[4]={1,-1,0,0}, dc[4]={0,0,1,-1};

            vvi vis(n,vi(n,0));
            vis[r][c]=1;
            queue<pi> que;
            que.push(pi(r,c));
            while(!que.empty())
            {
                pi v=que.front();
                que.pop();
                rep(i,4)
                {
                    int nr=v.fi+dr[i], nc=v.se+dc[i];
                    if(0<=nr&&nr<n && 0<=nc&&nc<n)
                    {
                        if(!vis[nr][nc] && b[nr][nc]==b[r][c])
                        {
                            vis[nr][nc]=1;
                            que.push(pi(nr,nc));
                        }
                    }
                }
            }

            rep(i,n)rep(j,n)
            {
                if(vis[i][j]) b[i][j]=!b[i][j];
            }
        }

        a=b;
    }

    //output
    rep(i,n)
    {
        rep(j,n)
        {
            if(j) printf(" ");
            printf("%d", a[i][j]);
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 3268
#include<stdio.h>

#define N 101

int main(){
int i,j,n;
int u,k,v;
int a[N][N];

scanf("%d",&n);

for(i=0;i<n;i++){
    for(j=0;j<n;j++){
        a[i][j]=0;
    }
}

for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
        scanf("%d",&v);
        a[u-1][v-1]=1;
    }
}

for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
        printf("%d ",a[i][j]);
    }
    printf("%d\n",a[i][j]);
}

return 0;

}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define mod 1000000007;
#define pi 3.14159265358979323846264
using namespace std;
char c;
int main() {
    scanf("%c", &c);
    if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u') printf("vowel\n");
    else printf("consonant\n");
    return 0;
}

Measured memory_bytes: 764
local a, b, x = io.read("*n", "*n", "*n")
x = x / a
if a * b / 2 < x then
  local bd = (a * b - x) * 2 / a
  print(math.atan2(bd, a) / math.pi * 180)
else
  local ad = x * 2 / b
  print(math.atan2(b, ad) / math.pi * 180)
end


Measured memory_bytes: 632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		long pattern;

		if (n == m){
			pattern = 1;
			for (int i=1; i<=n; i++){
				pattern = (i * pattern) % 1000000007;
			}
			for (int i=1; i<=m; i++){
				pattern = (i * pattern) % 1000000007;
			}
			pattern = 2 * pattern % 1000000007;
		} else if (Math.abs(n - m) == 1){
			pattern = 1;
			for (int i=1; i<=n; i++){
				pattern = (i * pattern) % 1000000007;
			}
			for (int i=1; i<=m; i++){
				pattern = (i * pattern) % 1000000007;
			}
		} else {
			pattern = 0;
		}
		System.out.println(pattern);
	}

}


Measured memory_bytes: 23764
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 

const ll mod = 1e9+7;
const ll inf=1e18+1e17;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}

const ll N=2e5+6;
const long double pi=3.14159265358979323;

vii v[N];
void solve(){
	int n;
	cin>>n;
	for ( int i=0;i<n-1;i++){
		int aa;
		cin>>aa;
		v[aa].pb( i+2);
	}
	for ( int i=1;i<=n;i++)
		cout<<v[i].sz()<<'\n';

	

}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll t=1;
//	cin>>t;
    for (int i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}





Measured memory_bytes: 14492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main(){
    int D, T, S;
    cin >> D >> T >> S;
    if(S * T >= D) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

main(){
  int a;
  int n;
  cin >> n;
  cin >> a;
  int s = n % 500;
  if (s <= a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>
 
using namespace std;
 
int main(void)
{
    double a, b, x, y, theta;
 
    cin >> a >> b >> x;
 
    if((x/a) > a*b/(double)2){
        y = (double)2 * (a*b-(x/a)) / a / a;
 
        theta = atan(y) * (double)180 / M_PI;
    }
 
    else{
        y = b * b / (double)2 / (x/a);
 
        theta = atan(y) * (double)180 / M_PI;
    }
 
    cout << setprecision(10) << theta << endl;
 
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using AtCoderBeginnerContest161.Questions;
using AtCoderBeginnerContest161.Extensions;

namespace AtCoderBeginnerContest161
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

namespace AtCoderBeginnerContest161.Questions
{
    // ここにQuestionクラスをコピペ
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<string> Solve(TextReader inputStream)
        {
            var nm = inputStream.ReadIntArray();
            var n = nm[0];
            var m = nm[1];
            var a = inputStream.ReadIntArray();

            var total = a.Sum();
            var canSelectCount = a.Count(i => i >= (double)total / (4 * m));

            if (canSelectCount >= m)
            {
                yield return "Yes";
            }
            else
            {
                yield return "No";
            }
        }
    }

    #region Base Classes

    public interface IAtCoderQuestion
    {
        IEnumerable<string> Solve(string input);
        IEnumerable<string> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<string> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<string> Solve(TextReader inputStream);
    }

    #endregion
}

#region Extensions

namespace AtCoderBeginnerContest161.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


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

    vector<ll> a;
    ll t=N;
    for(ll i=2; i*i<=N; i++)
    {
        ll k=0;
        while(t%i==0)
        {
            t/=i;
            k++;
        }
        if(k!=0)
        {
            a.push_back(k);
        }
    }

    ll ans=0;
    if(t!=1)
    {
        ans =1;
    }

    vector<ll> sum;
    for(int i=0; i<100; i++)
    {
        sum.push_back(i*(i+1)/2);
    }


    for(auto i : a)
    {
        ans+=upper_bound(sum.begin(), sum.end(), i)-sum.begin()-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
n=int(input())
if 400<=n<=599:
    print("8")
elif 600<=n<=799:
    print("7")
elif 800<=n<=999:
    print("6")
elif 1000<=n<=1199:
    print("5")
elif 1200<=n<=1399:
    print("4")
elif 1400<=n<=1599:
    print("3")
elif 1600<=n<=1799:
    print("2")
elif 1800<=n<=1999:
    print("1")

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

int n, k;

int main() {

	FAST;

	cin >> n >> k;
	vector <int> a(n + 1);
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	for (int i = k + 1; i <= n; i ++) {
		cout << ((a[i] > a[i - k]) ? "Yes\n" : "No\n");
	}
	return 0;
}

Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  char t[h+2][w+2];
  for(int i = 0; i < h+2; i++){
    for(int j = 0; j < w+2; j++){
      if(i == 0 || i == h+1 || j == 0 || j == w+1) t[i][j] = '.';
      else cin >> t[i][j];
    }
  }
  for(int i = 1; i < h+1; i++){
    for(int j = 1; j < w+1; j++){
      if(t[i][j] == '#') cout << "#";
      else{
        int cnt = 0;
        for(int k = i-1; k < i+2; k++)
          for(int l = j-1; l < j+2; l++)
            if(t[k][l] == '#' && !(k == i && l == j)) cnt++;
        cout << cnt;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
alist = list(map(int, input().split()))
matches = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
alist.sort(reverse=True)

dp = [-1 for _ in range(n + 1)]
dp[0] = 0
for a in alist:
    match = matches[a]
    for i in range(n - match + 1):
        if dp[i] == -1:
            continue
        dp[i + match] = max(dp[i + match], dp[i] * 10 + a)

print(dp[-1])

Measured memory_bytes: 16496
a = int(input())
t = list(map(int, input().split()))
dp = [0 for _ in range(a)]
dp[0] = 0
dp[1] = abs(t[1]-t[0])
for n in range (2,a):
    dp[n] = min(dp[n-2]+abs(t[n]-t[n-2]),dp[n-1]+abs(t[n]-t[n-1]))
print(dp[-1])

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vll x(n);
    rep(i,n) cin>>x[i];
    ll ans=1e10;
    rep(i,n-k+1){
        if (x[i]*x[i+k-1]<=0){
            chmin(ans,min(x[i+k-1]*2+abs(x[i]), x[i+k-1]+abs(x[i])*2));
        }else{
            chmin(ans,max(abs(x[i+k-1]),abs(x[i])));
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <iomanip>

int main() {
	double m = 100;
	int n;

	std::cin >> n;
	for (int i = 0; i < n; ++i) {
		m *= 1.05;
		m = std::ceil(m);
	}
	std::cout << std::fixed << std::setprecision(0) << m * 1000 << std::endl;
	return 0;
}

Measured memory_bytes: 1236
from operator import itemgetter

N, M = map(int,input().split())
A = sorted(list(map(int,input().split())))
Q = [list(map(int,input().split())) for _ in range(M)]
Q.sort(key=itemgetter(1), reverse=True)

idx = 0
flag = 0
for i in range(M):
    q = Q[i]
    B = q[0]
    C = q[1]
    for b in range(B):
        if idx >= N:
            flag = -1
            break
        if A[idx] < C:
            A[idx] = C
            idx += 1
        else:
            flag = -1
    if flag == -1 or i == M-1:
        break
print(sum(A))


Measured memory_bytes: 32856
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char x,y;
    cin>>x>>y;
    
    if(x<y)
        cout<<"<\n";
    else if(y<x)
        cout<<">\n";
    else
        cout<<"=\n";
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<float> v(n);

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

    while (1 < v.size())
    {
        sort(v.begin(), v.end());
        v.push_back((v[0] + v[1]) / 2);
        v.erase(v.begin(), v.begin() + 2);
        v.shrink_to_fit();
    }

    cout << v[0] << endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================

	string S;
	cin >> S;

	for (int i = 0; i < S.length(); i++)
	{
		if (S[i] == '7')
		{
			cout << "Yes";
			return 0;
		}
	}

	cout << "No";




}





Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}

signed main()
{
int n;
cin>>n;
if(n%2==0)
    cout<<n/2;
else
{
    cout<<(n/2)+1;
}

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int N,Y;
  	cin>>N>>Y;
  	int res10000=-1,res5000=-1,res1000=-1;
  
  	for(int a=0;a<=N;a++){
     	for(int b=0;a+b<=N;b++){
         	int c=N-a-b;
          	if(10000*a+5000*b+1000*c==Y){
             	res10000=a;
              	res5000=b;
              	res1000=c;
            }
        }
    }
  
  	cout<<res10000<<" "<<res5000<<" "<<res1000<<endl;
}

Measured memory_bytes: 3608
#include<iostream>

using namespace std;

int main(){
    long long int n, a[100009], b[100009], c[100009], dpa[100009], dpb[100009], dpc[100009];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    dpa[0] = a[0];
    dpb[0] = b[0];
    dpc[0] = c[0];
    for(int i=1;i<n;i++){
        dpa[i] = max(dpb[i-1]+a[i], dpc[i-1]+a[i]);
        dpb[i] = max(dpa[i-1]+b[i], dpc[i-1]+b[i]);
        dpc[i] = max(dpa[i-1]+c[i], dpb[i-1]+c[i]);
    }
    cout << max(dpa[n-1], max(dpb[n-1], dpc[n-1])) << endl;
}

Measured memory_bytes: 4992
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        long[] v = new long[N];
        for (int i = 0; i < v.length; ++i) {
            v[i] = sc.nextLong();
        }

        System.out.println(solve(v, A, B));

        sc.close();
    }

    static String solve(long[] v, int A, int B) {
        v = Arrays.stream(v).boxed().sorted(Collections.reverseOrder()).mapToLong(x -> x).toArray();

        long[] v_ = v;
        double avg = IntStream.range(0, A).mapToLong(i -> v_[i]).average().getAsDouble();

        long last = v[A - 1];
        int lastCount = (int) Arrays.stream(v).filter(x -> x == last).count();
        int lastChosen = (int) IntStream.range(0, A).filter(i -> v_[i] == last).count();
        long wayNum = C(lastCount, lastChosen);
        if (v[0] == last) {
            for (int i = A + 1; i <= B && v[i - 1] == last; ++i) {
                ++lastChosen;
                wayNum += C(lastCount, lastChosen);
            }
        }

        return String.format("%f\n%d", avg, wayNum);
    }

    static long C(int n, int r) {
        long result = 1;
        for (int i = 0; i < r; ++i) {
            result = result * (n - i) / (i + 1);
        }

        return result;
    }
}

Measured memory_bytes: 27476
#include<bits/stdc++.h>
#include<bitset>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(ll i=0;i<x;i++)
#define fs(i,s,x) for(int i=s;i<x;i++)
#define fr(i,x) for(int i=x;i>=0;i--)
#define fit(it,s) for(auto it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define srt(vec) sort(vec.begin(),vec.end())
#define mod 1000000007
#define MAX 100005
#define M 32
#define endl "\n"
using namespace std;
ll pow1(ll a,ll b){if(b==0) return 1; ll p=pow1(a,b/2);if(b%2) return ((p*p))*a;return (p*p);}
ll pow2(ll a,ll b){if(b==0) return 1; ll p=pow2(a,b/2);if(b%2) return (((p*p)%mod)*a)%mod;return (p*p)%mod;}
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
int find1(int i,int dsu[]){if(dsu[i]==i) return i; dsu[i]=dsu[dsu[i]]; return find1(dsu[i],dsu);}
void union1(int i,int j,int dsu[]) {dsu[j]=find1(i,dsu);}
ll a[1000005];
double tree[4000020];


int main()
{
    int test;
    test=1;
    for(int z=0;z<test;z++)
    {
        int n;
        cin>>n;
        unordered_map<string,int> ma;
        fn(i,n)
        {
            string s;
            cin>>s;
            ma[s]++;
        }
        vector<pair<int,string> > vec;
        for(auto itr=ma.begin();itr!=ma.end();itr++)
            vec.pb({itr->second,itr->first});
        sort(vec.begin(),vec.end());
        vector<string> vec1;
        vec1.pb(vec[vec.size()-1].se);
        for(int i=vec.size()-2;i>=0;i--)
        {
            if(vec[i].fi==vec[i+1].fi)
                vec1.pb(vec[i].se);
            else
            break;
        }
        sort(vec1.begin(),vec1.end());
        fn(i,vec1.size())
        cout<<vec1[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 31424
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;

static const double eps = 1e-8;

int stage[16][16];
ll bit[100001];

ll sumBIT(int i,ll* bit){
	ll s = 0;
	while(i > 0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void addBIT(int i, int x,ll* bit,int n){
	while(i <= n){
		bit[i] += x;
		i += i & -i;
	}	
}


int main(){
	int n,k;
	while(~scanf("%d %d",&n,&k)){
		if(n==k && k==0) break;
		memset(bit,0,sizeof(bit));
		for(int i=0;i<n;i++){
			int num;
			scanf("%d",&num);
			addBIT(i+1,num,bit,100000);
		}

		ll res = numeric_limits<ll>::min();
		for(int i=1;i+k-1<=n;i++){
			res = max(sumBIT(i+k-1,bit) - sumBIT(i-1,bit),res);
		}

		printf("%lld\n",res);
	}
}

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

int main() {
  int64_t N, A, B;
  cin >> N >> A >> B;
  
  int64_t ans;
  
  if ((B-A) % 2 == 0) {
    ans = (B-A)/2;
  }
  else if (B-A == 1) {
    ans = min(N-A, B-1);
  }
  else if (A-1 < N-B) {
    ans = A-1 + 1 + (B-A-1)/2;
  }
  else {
    ans = N-B + 1 + (B-A-1)/2;
  }
  
  cout << ans << endl;
  
  return 0;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
  vector<long> v;
  for (unsigned i = 1; i < 1111; ++i) {
    for (unsigned j = i; j < 1111; ++j) {
      v.push_back(i * i * i + j * j * j);
    }
  }
  sort(v.begin(), v.end());
  while (1) {
    int n;
    cin >> n;
    n = n * n * n;
    if (n == 0) { break; }
    auto it = lower_bound(v.begin(), v.end(), n);
    cout << max(*it - n, n - *(it - 1)) << endl;
  }
  return 0;
}

Measured memory_bytes: 11064
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n,m; cin >> n >> m;
  int sum = 0;
  for(int i=0;i<m;i++){
    int x;
    cin >> x;
    sum+=x;
  }

  cout << max(-1LL,n-sum);

  

  return 0;
}

Measured memory_bytes: 3656
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
	char s[100010];
	int n;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	if(s[1]=='0'||s[n]=='1')
	{
		printf("-1");
		return 0;
	}
	for(int i=2;i<=(n>>1);i++)
		if(s[i]!=s[n-i+1-1])
		{
			printf("-1");
			return 0;
		}
	int x=1;
	printf("1 2\n");
	for(int i=2;i<n;i++)
	{
		printf("%d %d\n",x,i+1);
		if(s[i]=='1') x=i+1;
	}
}

Measured memory_bytes: 1408
N=int(input())
S=str(input())

if N%2 != 0:
  print('No')
else:
  is_echo=True
  
  for i in range(int(N/2)):
    if S[i] != S[i+int(N/2)]:
      is_echo=False
      
  if is_echo:
    print('Yes')
  else:
    print('No')

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

#define mod 1000000007
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323
#define debug(x) cout<<"Case "<<x<<": "
#define For(i,n) for(long long i=0;i<n;i++)
#define Frabs(i,a,b) for(long long i = a; i < b; i++)
#define Frabr(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	ll n,m;
	cin>>n>>m;
	char arr[n+5][m+5];
	ll dp[n+5][m+5]={0};
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=m;j++)
		{
			cin>>arr[i][j];
			//if(arr[i][j]=='#')
			//	dp[i][j]=-1;
		}
	}
	dp[1][1]=0;
	for(ll i=1;i<=n;i++)
	{
		if(arr[i][1]=='.')
			dp[i][1]=1;
		else
			break;
	}
	for(ll j=1;j<=m;j++)
	{
		if(arr[1][j]=='.')
			dp[1][j]=1;
		else
			break;
	}
	for(ll i=2;i<=n;i++)
	{
		for(ll j=2;j<=m;j++)
		{
			if(arr[i][j]=='#')
				dp[i][j]=0;
			else
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
		}
	}
	cout<<(dp[n][m])%mod<<endl;
	return 0;
}


Measured memory_bytes: 9088
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}

signed main()
{
int n;
cin>>n;
string s[n];
map<string ,int>m;
int mx=0;
for(int i=0;i<n;i++)
{
    cin>>s[i];
    m[s[i]]++;
    mx=max(mx,m[s[i]]);
}
vector<string>v;
for(auto it=m.begin();it!=m.end();it++)
{
    if(it->second==mx)
        v.push_back(it->first);
}
sort(v.begin(),v.end());
for(int i=0;i<v.size();i++)
    cout<<v[i]<<endl;
}





Measured memory_bytes: 28404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N; cin >> N;
    vector<vector<pll>> g(N);
    rep(i, N-1) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].emplace_back(b, i);
        g[b].emplace_back(a, i);
    }

    vector<bool> check(N, false);
    queue<ll> que;
    que.push(0);
    check[0] = true;
    vll ans(N-1), pcolor(N, 0);
    ll cnt = 0;
    while(!que.empty()) {
        ll now = que.front();
        que.pop();
        check[now] = true;

        ll color = 1;
        for(auto next: g[now]) {
            ll nn = next.first;
            ll ne = next.second;
            if(check[nn] == true) continue;

            que.push(nn);
            if(color == pcolor[now]) color++;
            ans[ne] = color, pcolor[nn] = color;
            chmax(cnt, color);
            color++;
        }
    }
    cout << cnt << endl;
    rep(i, N-1) cout << ans[i] << endl;
}


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

/*
  P1(x1, y1) P2(x2, y2) P3(x3, y3) P0(x0, y0)

 <円の中心(x0, y0)>
  2*(x2-x1)*x0 + 2*(y2-y1)*y0 = x2*x2 - x1*x1 + y2*y2 - y1*y1
  2*(x3-x1)*x0 + 2*(y3-y1)*y0 = x3*x3 - x1*x1 + y3*y3 - y1*y1
  x0=((y3-y1)*(x2*x2-x1*x1+y2*y2-y1*y1)+(y1-y2)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*(x2-x1)*(y3-y1)-(y2-y1)*(x3-x1))
  y0=((x1-x3)*(x2*x2-x1*x1+y2*y2-y1*y1)+(x2-x1)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*(x2-x1)*(y3-y1)-(y2-y1)*(x3-x1))

 <円の半径R>
  R = a/(2*sqrt(q-cosA*cosA)) 
  a = sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) ) // P2-P3
  b = sqrt( (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3) ) // P1-P3
  c = sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) ) // P1-P2
  cosA = (b*b + c*c - a*a)/(2*b*c)
 */

int main()
{
    double x1, x2, x3, y1, y2, y3; // 3角形の3点
    double x0, y0; // 円の中心
    double R;
    double a, b, c, cosA;
    int n;
    cin >> n;

    for(int i=0; i<n; i++){
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        x0=((y3-y1)*(x2*x2-x1*x1+y2*y2-y1*y1)+(y1-y2)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)));
        y0=((x1-x3)*(x2*x2-x1*x1+y2*y2-y1*y1)+(x2-x1)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)));
        a = sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) );
        b = sqrt( (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3) );
        c = sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );
        cosA = (b*b + c*c - a*a)/(2*b*c);
        R = a/(2*sqrt(1-cosA*cosA));

        printf("%.3f %.3f %.3f\n", x0, y0, R);
    }

    return 0;
}

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


int gcd(int a, int b){
    if (b == 0)
        return a;

    return gcd(b, a%b);
}

int main(){
    int n;
    cin >> n;

    ll ans = 0;
    rep(i, n) rep(j, n) rep(k, n) ans += gcd(i, gcd(j, k)); 
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int A, B;
  cin >> A >> B;
  
  if(A * B % 2 == 1)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
  return 0;
}    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int f=1;
    while(n--)
    {
        int x;
        scanf("%d",&x);
        if(x%2==0)
        {
            if(x%3!=0&&x%5!=0)f=0;
        }
    }
    if(f)printf("APPROVED");
    else printf("DENIED");
    return 0;
}

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

using namespace std;
typedef long long LL;

const int N=1010,Mod=1e9+7;

struct Matrix
{
	int v[4][4],x,y;
	void Clear();	
	Matrix operator * ( const Matrix &A ) const ;
};

bool mp[N][N];
int n,m;
LL k;

void Matrix::Clear() { for (int i=0;i<x;++i) for (int j=0;j<y;++j) v[i][j]=0; }

Matrix Matrix::operator * ( const Matrix &A ) const 
{
	Matrix ans; ans.x=x; ans.y=A.y; ans.Clear();
	
	for (int i=0;i<ans.x;++i)
		for (int j=0;j<ans.y;++j)	
			for (int k=0;k<y;++k)
				ans.v[i][j]=(ans.v[i][j]+1ll*v[i][k]*A.v[k][j]%Mod+Mod)%Mod;
	
	return ans;
}

void Init()
{
	scanf("%d%d%lld",&n,&m,&k);
	for (int i=0;i<n;++i)
		for (int j=0;j<m;++j)
		{
			char ch=getchar();
			while (ch!='.' && ch!='#') ch=getchar();
			if (ch=='#') mp[i][j]=1;
			else mp[i][j]=0;
		}
}

void pow(Matrix &A,Matrix D,LL k)
{
	while (k)
	{
		if (k&1) A=A*D;
		k>>=1;
		D=D*D;
	}
}

int pow(int x,LL k)
{
	k--;
	for (int y=x;k;k>>=1,y=1ll*y*y%Mod)
		if (k&1) x=1ll*x*y%Mod;
	return x;
}

void Solve()
{
	int t1=0,t2=0,cnt=0;
	for (int i=0;i<n;++i)
		for (int j=0;j<m;++j)
			if (mp[i][j])
			{
				if (j>=1 && mp[i][j-1]) t1++;
				if (i>=1 && mp[i-1][j]) t2++;
				cnt++;
			}
	int p1=0,p2=0;
	for (int i=0;i<n;++i) if (mp[i][0] && mp[i][m-1]) ++p1;
	for (int i=0;i<m;++i) if (mp[0][i] && mp[n-1][i]) ++p2;
	if (p1<p2) swap(p1,p2),swap(t1,t2);
	if (k==1 || p2) { printf("1\n"); return ; }
	if (!p1 && !p2) { printf("%d\n",pow(cnt,k-1)); return ; }
	if (k==2) { printf("%d\n",cnt-t1); return ; }
	Matrix A; A.x=1; A.y=2; A.Clear(); A.v[0][0]=cnt-t1; A.v[0][1]=-p1;
	Matrix D; D.x=2; D.y=2; D.Clear(); D.v[0][0]=cnt; D.v[0][1]=0; D.v[1][0]=t1; D.v[1][1]=p1;
	k-=2;
	pow(A,D,k);
	printf("%d\n",A.v[0][0]);
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 1280
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int h,w; cin >> h >> w;
    vector<vector<char> > s(h,vector<char>(w));
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            cin >> s.at(i).at(j);
        }
    }

    bool ans = true;
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){

            if(s.at(i).at(j) == '.') continue;
            bool hantei = false;

            if((i > 0 && s.at(i-1).at(j) == '#') ||
            (i < h-1 && s.at(i+1).at(j) == '#') || 
            (j > 0 && s.at(i).at(j-1) == '#') ||
            (j < w-1 && s.at(i).at(j+1) == '#')){
                hantei = true;
            }

            if(hantei == false) ans = false;
        }
    }

    if(ans == true) cout << "Yes" << endl;
    else cout << "No" << endl;

}



Measured memory_bytes: 256
import java.util.Scanner;

// 素数系
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }

        int res = 0;
        for(int j = 0; j < N; j++) {
            int tmp = 0;
            while(arr[j] % 2 == 0) {
                tmp++;
                arr[j] /= 2;

            }
            res += tmp;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 35172