akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            //var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int D = input[0];
            int X = input[1];
            int[] A = new int[N];

            long ans = N;
            for (var i = 0; i < N; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
                ans += ((D - 1) / A[i]);

            }
            ans += X;

            Console.WriteLine(ans);

           
            

            //Console.Out.Flush();

        }
    }

    

    public class Calculation
    {

    }

    public class Graph
    {
       
    }
}




Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  map<int, int> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x]++;
  }
  int ans = 0;
  for (auto i = a.begin(); i != a.end(); i++) {
    if ((*i).first <= (*i).second)
      ans += (*i).second - (*i).first;
    else
      ans += (*i).second;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
  string S, T;
  cin >> S >> T;
  string U;
  int i = S.size() - T.size();
  for (; 0 <= i; --i)
  {
    auto b = i + T.size();
    U = S.substr(0, i) + T + S.substr(b, S.size() - b);
    int j = 0;
    for (; j < S.size(); ++j)
      if ((S[j] != U[j]) && ('?' != S[j]))
        break;
    if (S.size() == j)
      break;
  }
  if (i < 0)
    cout << "UNRESTORABLE";
  else
  {
    for (int i = 0; i < U.size(); ++i)
      if ('?' == U[i])
        U[i] = 'a';
    cout << U;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  
  if(a==b){
    if(b==c){
      printf("1\n");
    }else{
      printf("2\n");
    }
  }else{
    if(a==c||b==c){
      printf("2\n");
    }else{
      printf("3\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1592
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string line;
            while((line = Console.ReadLine()) != null)
            {
                for(int i = 0; i < 100; i++)
                {
                    for(int j = 0; j < 26; j++)
                    {
                        var org = new string(line.Select(x => x == ' ' ? x : (char)(((x - 'a') * i + j) % 26 + 'a')).ToArray());
                        if (!org.Contains("that") && !org.Contains("this")) continue;
                        Console.WriteLine(org);
                        goto next;
                    }
                }
            next:
                ;
            }
        }
    }
}

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

void solve()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a > b)
        ans = a - 1;
    else
        ans = a;
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back



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

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++)
	{
		cin>>a[i];
		// cout<<a[i]<<" ";
	}
	cout<<endl;
	// if(n%2==0)
	// {
	// 	ll sum1=0, sum2=0;
	// 	for(int i = 0; i<n; i++)
	// 	{
	// 		if(i%2==0)
	// 			sum1+=a[i];
	// 		else sum2+=a[i];
	// 	}
	// 	cout<<max(sum1, sum2)<<endl;
	// }
	// else
	// {
		vector<ll> p(n+1, 0), dp(n+1, 0);
		for(int i = 1; i <= n; i++)
		{
			p[i] = p[max(0, i-2)]+a[i-1];
		}
		// for(int i:p) cout<<i<<"  ";
			// cout<<endl;
		for(int i = 2; i <= n; i++)
		{
			if(!(i%2))
			{
				dp[i]=max(dp[i-2]+a[i-1], p[i-1]);
			}
			else dp[i]=max(dp[i-2]+a[i-1], dp[i-1]);
		}
		cout<<dp[n]<<endl;
	// }
}

Measured memory_bytes: 7988
import bisect
n = int(input())
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
cl = list(map(int,input().split()))

al.sort()
bl.sort()
cl.sort()

cnt = 0
for b in bl:
    a_num = bisect.bisect_left(al,b)
    c_num = n - bisect.bisect_right(cl,b)
    cnt += a_num*c_num
    # cnt += c_num

print(cnt)

Measured memory_bytes: 23360
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var N = parseInt(tmp[0], 10);
	var K = parseInt(tmp[1], 10);
	//出力
	var ans;
	ans = K*Math.pow(K-1,N-1);
	console.log('%d',ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 20808
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> P(N);
    for(int i=0;i<N;++i){
        cin >> P[i];
    }
    int ans=1, v_min=P[0];
    for(int i=1;i<N;++i){
        if(v_min >= P[i]){
            ++ans;
        }
        v_min = min(v_min, P[i]);
    }
    cout << ans << endl;
}


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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  int dp[H + 1][W];
  int x, y;
  for (y = 0; y < H + 1; y++)
    for (x = 0; x < W; x++)
      dp[y][x] = 0;
  dp[0][0] = 1;
  for (y = 1; y < H + 1; y++) {
    int bitmap = -1; // Horizontal lines
    while (bitmap < (1 << (W - 1)) - 1) {
      bitmap++;
      for (x = 1; x < W - 1; x++)
        if (((bitmap >> x - 1) & 3) == 3)
          break;
      if (x != W - 1 && W > 1)
        continue;
      // cout << bitmap << endl;
      // Valid combination of horizontal lines.
      for (x = 0; x < W; x++) {
        if (x != 0 && (bitmap >> (x - 1)) & 1) { // 左に横棒が存在
          dp[y][x] += dp[y - 1][x - 1];
          // cout << "Swap" << y << ": " << x << ", " << x - 1 << endl;
        } else if (x != W - 1 && (bitmap >> (x)) & 1) { // 右に横棒が存在
          dp[y][x] += dp[y - 1][x + 1];
          // cout << "Swap" << y << ": " << x << ", " << x + 1 << endl;
        } else {
          dp[y][x] += dp[y - 1][x];
          // cout << "Swap" << y << ": " << x << ", " << x << endl;
        }
        dp[y][x] %= 1000000007;
      }
    }
  }
  /*
  for (y = 0; y < H + 1; y++) {
    for (x = 0; x < W; x++)
      cout << dp[y][x] << " ";
    cout << endl;
  }*/
  cout << dp[H][K - 1] << endl;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr

N = int(input())
ans = 0

A = factorization(N)

for x in A:
    e = x[1]
    for y in range(1,N):
        if e >= y:
            e -= y
            ans += 1
        else:
            break

print(ans)

Measured memory_bytes: 9336
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

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

	multimap<int, int> sorted_map;


	int ai, bi;
	int count = 0;

	for(int i=0; i<M; ++i){
		cin >> ai >> bi;
		sorted_map.insert(make_pair(bi, ai));
	}
	int x = 0;
	for(auto iter=sorted_map.begin(); iter != sorted_map.end(); ++iter){
		if (iter->second <= x){
			continue;
		}
		else{
			count++;
			x = iter->first-1;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 4992
dat = input()

n=len(dat)

def judge(s):
    ret = True
    for i in range(int(len(s)/2)):
        if s[i] != s[-i-1]:
            ret = False
    return ret
pre = dat[:int((n-1)/2)]
pos = dat[int((n+3)/2 - 1):]

if judge(dat) and judge(pre) and judge(pos):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = 1LL<<55;
const Int mod = (1e9)+7;
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  
  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;

  int m;
  cin>>m;
  vector<int> B(m);
  cin>>B;
  
  int i = 0, j = 0;
  int cnt = 0;
  while(1){
    if(i == n || j == m) break; 
    
    if(A[i] == B[j]) i++, j++, cnt++;
    else if(A[i] < B[j]) i++;
    else if(A[i] > B[j]) j++;
  }
  
  int ans = cnt == m;
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 4420
n,k=map(int,input().split())
s=list(map(int,str(input())))
if s[0]==1:
  one_st=[0]+[i+1 for i in range(n-1) if s[i]==0 and s[i+1]==1]
  zero_st=[i+1 for i in range(n-1) if s[i]==1 and s[i+1]==0]
else:
  one_st=[i+1 for i in range(n-1) if s[i]==0 and s[i+1]==1]
  zero_st=[0]+[i+1 for i in range(n-1) if s[i]==1 and s[i+1]==0]
if s[n-1]==1:
  one_en=[i for i in range(n-1) if s[i]==1 and s[i+1]==0]+[n-1]
  zero_en=[i for i in range(n-1) if s[i]==0 and s[i+1]==1]
else:
  one_en=[i for i in range(n-1) if s[i]==1 and s[i+1]==0]
  zero_en=[i for i in range(n-1) if s[i]==0 and s[i+1]==1]+[n-1]
if len(zero_st) <= k:
  x=n
else:
  y=[one_en[i+k]-one_st[i]+1 for i in range(len(zero_st)-k+1) if i+k+1<=len(one_en)]
  y=y+[one_en[k-1]+1,n-one_st[len(one_st)-k]]
  x=max(y)
print(x)

Measured memory_bytes: 13612
#include <iostream>
#include <string>

using namespace std;

int main() {
    const string player[2] = {"First", "Second"};

    string s;
    cin >> s;

    // sの長さの偶奇がベース
    // sの先頭と末尾が一致するかで答えが反転する
    cout << player[(s.size() + (s.front() == s.back()) + 1) % 2] << endl;
    return 0;
}


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


typedef std::vector<int> vi;
int main() {
	
	const int INF = 1e9 + 5;
	int n,k;
	cin>>n>>k;
	vi h(n);
	for(int &x:h)
	{
	    scanf("%d",&x);
	}
	vi cost(n,INF);
	cost[0]=0;
	
	for(int i=0;i<n;i++)
	{
	    int j=i;
	    for(int x=0;x<k;x++)
	    {
	        j++;
	        if(j<n)
	        {
	            cost[j]=min(cost[j],cost[i]+abs(h[j]-h[i]));
	        }
	    }
	}
	cout<<cost[n-1];
	
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define mod 1000000007
typedef long long ll;
using namespace std;

const int M = (int)(2e6 + 239);

ll nCr(int n, int r)
{

    ll p=1,k=1;
    if (n-r<r)
    {
        r=n-r;
    }
    if(r!=0)
    {
        while(r)
        {
            p*=n;
            k*=r;
            ll m=__gcd(p, k);
            p /= m;
            k /= m;
            n--;
            r--;
        }
    }
    else
    {
        p=1;
    }
    return p;
}

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

    double a;
    cin>>a;
    a=a/3.0;
    printf("%.12f\n",a*a*a);
}


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

int main (){
    int a , b, c;
    cin >> a >> b>> c ;
    if(a+b+c>= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        String day = sc.nextLine();
        String str[] = day.split("/");
        int a[] = new int[3];
        for (int i = 0; i < str.length; i++)
            a[i] = Integer.parseInt(str[i]);
        if (a[0] > 2019)
            System.out.println("TBD");
        else if (a[0] == 2019 && a[1] > 4)
            System.out.println("TBD");
        else if (a[0] == 2019 && a[1] > 4 && a[2] < 31)
            System.out.println("TBD");
        else
            System.out.println("Heisei");
    }
}

Measured memory_bytes: 21844
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter


def ispalindrome(str): return 1 if str == str[::-1] else 0


n = stdin.readline().rstrip()
pos1 = int((len(n) - 1) / 2)
pos2 = int((len(n) + 3) / 2-1)
pos3 = (len(n))

a = ispalindrome(n)
b = ispalindrome(n[0:pos1])
c = ispalindrome(n[pos2:pos3])

if a & b & c:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38480
n,m=map(int,input().split())
a=[]
ans=0
cnt=0
for i in range(n):
    a.append(list(map(int,input().split())))
a.sort()
for j in range(n):
    if cnt+a[j][1]<m:
        ans+=a[j][0]*a[j][1]
        cnt+=a[j][1]
    else:
        ans+=a[j][0]*(m-cnt)
        break
print(ans)



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

public class Main {

	static final int MAX_LENGTH = 10;
	static final int MAX_WIDTH = 10;
	static final int SMALL_INK = 1;
	static final int MIDDLE_INK = 2;
	static final int LARGE_INK = 3;

	public static void main(String[] args) {
		int field[][] = setField();
		//入力値を読み込む
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		while (true) {
			try {
				input = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (input == null || input.isEmpty()) {
				break;
			}
			String[] inputs = input.split(",");
			//インクを落とす
			dropInk(field, Integer.parseInt(inputs[0]),
					Integer.parseInt(inputs[1]),
					Integer.parseInt(inputs[2]));
		}
		//色のついてないマスの数と最も濃いマス目の濃さを出力
		amountOfWhite(field);
		maxDepth(field);
	}

	private static int[][] setField() {
		int field[][] = new int[MAX_LENGTH][MAX_WIDTH];
		for (int i = 0; i < MAX_LENGTH; i++) {
			for (int j = 0; j < MAX_WIDTH; j++) {
				field[i][j] = 0;
			}
		}
		return field;
	}

	private static void dropInk(int[][] field, int x, int y, int size) {
		switch (size) {
		case SMALL_INK:
			dropSmall(field, x, y);
			break;
		case MIDDLE_INK:
			dropMiddle(field, x, y);
			break;
		case LARGE_INK:
			dropLarge(field, x, y);
			break;
		}

	}

	private static void dropLarge(int[][] field, int x, int y) {

		dropMiddle(field, x, y);

		int dropX[] = { -2, 0, 2, 0 };
		int dropY[] = { 0, -2, 0, 2 };

		for (int i = 0; i < dropX.length; i++) {
			dropping(field, x + dropX[i], y + dropY[i]);
		}
	}

	private static void dropMiddle(int[][] field, int x, int y) {

		dropSmall(field, x, y);

		int dropX[] = { -1, -1, 1, 1 };
		int dropY[] = { 1, -1, 1, -1 };

		for (int i = 0; i < dropX.length; i++) {
			dropping(field, x + dropX[i], y + dropY[i]);
		}
	}

	private static void dropSmall(int[][] field, int x, int y) {
		int dropX[] = { -1, 0, 1, 0 };
		int dropY[] = { 0, -1, 0, 1 };
		dropping(field, x, y);

		for (int i = 0; i < dropX.length; i++) {
			dropping(field, x + dropX[i], y + dropY[i]);
		}
	}

	private static int[][] dropping(int[][] field, int x, int y) {
		if (0 <= x && x < 10 && 0 <= y && y < 10) {
			field[x][y] += 1;
		}
		return field;
	}

	private static void amountOfWhite(int[][] field) {
		int count = 0;
		for (int i = 0; i < MAX_LENGTH; i++) {
			for (int j = 0; j < MAX_WIDTH; j++) {
				if (field[i][j] == 0) {
					count++;
				}
			}
		}
		System.out.println(count);
	}

	private static void maxDepth(int[][] field) {
		int maxDepth = 0;
		for (int i = 0; i < MAX_LENGTH; i++) {
			for (int j = 0; j < MAX_WIDTH; j++) {
				if (maxDepth < field[i][j]) {
					maxDepth = field[i][j];
				}
			}
		}
		System.out.println(maxDepth);
	}
}

Measured memory_bytes: 16924
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;
 
int main() {
ll N;
cin>>N;
int mini=20;
for(ll n=1;n<=sqrt(N);n++){
	if(N%n==0){
		ll k=N/n,l=n;
		int o=0,p=0;
		while(k>0){
			k/=10;
			o++;
		}
		while(l>0){
			l/=10;
			p++;
		}
		mini=min(mini,max(o,p));
	}
}

ce(mini);

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ll N; cin>>N;
  vector<vector<pair<ll,ll>>> graph(N,vector<pair<ll,ll>>(0));
  vector<ll> connect(N-1,-1);
  rep(i,N-1){
    ll a,b; cin>>a>>b; a--; b--;
    graph.at(a).push_back({b,i});
    graph.at(b).push_back({a,i});
  }
  
  //まずは色の数
  ll K=0; rep(i,N) chmax(K,(ll)graph.at(i).size());
  
  //bfs
  queue<ll> que;
  que.push(0);
  while(!que.empty()){
    ll v=que.front(); que.pop();
    ll used_color=-1;
    for(auto p:graph.at(v)){
      ll nv,con; tie(nv,con)=p;
      if(connect.at(con)>-1) used_color=connect.at(con);
    }
    ll color=0; if(color==used_color) color++;
    for(auto p:graph.at(v)){
      ll nv,con; tie(nv,con)=p;
      if(connect.at(con)>-1) continue;
      connect.at(con)=color;
      que.push(nv);
      color++; if(color==used_color) color++;
    }
  }
  
  //解答
  cout<<K<<endl;
  for(auto con:connect) cout<<con+1<<endl;
  return 0;
}

Measured memory_bytes: 14820
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1]%d7 + C[i - 1][j]%d7)%d7;}}}
    return C[n][k]%d7;
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now
   
    string s;
    cin>>s;
    bool t=false;
    fori(3){
        if(s[i]-'0'==s[i+1]-'0'){
            t=true;break;
        }
    }
    cout<<((t)?"Bad":"Good");

//code ends
    return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let mut s: Vec<char> = input::<String>().chars().collect();
    s[5] = ' ';
    s[13] = ' ';
    println!("{}", s.iter().cloned().collect::<String>());
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll f[100];

int main(){
  ll n;
  cin>>n;
  if(n%2==1){
    cout << 0 << endl;
  }
  else{
    ll ans = 0;
    ll c = 0;
    while(n>0){
      ans += n/10;
      c++;
      n /= 5;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {

  def read(): (Int, Int) = {
    val sc: Scanner = new Scanner(System.in)
    val k, x = sc.nextInt
    sc.close()
    (k, x)
  }


  def solve(k: Int, x: Int): String = {
    (x-(k-1) to x+(k-1)).filter(i => i >= -1000000 && i <= 1000000).mkString(" ")
  }


  def main(args: Array[String]): Unit = {
    val (k, x) = read()
    println(solve(k, x))
  }

}


Measured memory_bytes: 27324
#include<iostream>
using namespace std;
int main() {
  int n,ans=0,count;
  cin >> n;
  for(int i=1;i<=n;i+=2){
    count=0;
    for(int j=1;j<=i;j++){
      if(i%j==0) count++;
    }
    if(count==8) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
goto=[[] for i in range(N+1)]
for i in range(M):
    goto[AB[i][0]].append(AB[i][1])
    goto[AB[i][1]].append(AB[i][0])
#print(goto)

parent=[0 for i in range(N+1)]
done=[0 for i in range(N+1)]
done[1]=1

from collections import deque
q=deque([1])

while q:
    r=q.popleft()
    for t in goto[r]:
        if done[t]:
            continue
        parent[t]=r
        done[t]=1
        q.append(t)

#print(parent)

print('Yes')
for i in range(2,N+1):
    print(parent[i])

Measured memory_bytes: 58672
#include <bits/stdc++.h>
using namespace std;
int main()
{

    unsigned long long int n,x,sum=0,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        sum+=x;
    }
    cout<<sum-n<<endl;
    return 0;
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

map<llong, int> PrimeFact(llong n){
	map<llong, int> ret;
	while(n % 2 == 0){
		ret[2]++;
		n /= 2;
	}
	for(llong i = 3; i*i <= n; i += 2){
		while(n%i == 0){
			ret[i]++;
			n /= i;
		}
	}
	if(n != 1)
	ret[n]++;

	return ret;
}

llong getMod(llong num, llong beki){
	if(beki == 1)
		return num;

	llong ret = getMod(num,beki/2);
	ret %= mod;
	ret *= ret;
	ret %= mod;

	if(beki&1)
		return ret*num%mod;
	else
		return ret%mod;
}

llong nCr(llong n, llong r){
	llong ret = 1;
	// cerr << n << " " << r << endl;
	for(llong i = 0; i < r; i++){
		(ret *= n-i) %= mod;
		(ret *= getMod(i+1, mod-2)) %= mod;
	}

	return ret;
}

int main(){
	llong N, M;
	cin >> N >> M;
	auto m = PrimeFact(M);
	llong ans = 1;
	for(auto it = m.begin(); it != m.end(); it++){
		(ans *= nCr(N+it->second-1, it->second)) %= mod;
	}

	cout << ans << endl;

	return 0;
}

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


int main()
{
	int n, q;
	while( cin >> n >> q ){
		vector< int > cnt( n + 1, 0 );
		priority_queue< pair< int, int > > p;
		for( int i = 0; i < q; ++i ){
			pair< int, int > a;
			cin >> a.second >> a.first;
			cnt[ a.second ] += a.first;
			a.first = cnt[ a.second ];
			a.second = -a.second;
			p.push( a );
			while( 1 ){
				pair< int, int > b;
				b = p.top();
				p.pop();
				if( b.first == cnt[ -b.second ] ){
					cout << -b.second << " " << b.first << endl;
					p.push( b );
					break;
				}
			}
		}
	}

	return 0;
}

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

static const int N = 100;

int main()
{
    int n, p[N + 1], m[N + 1][N + 1];
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> p[i - 1] >> p[i];
    }

    for (int i = 1; i <= n; i++){
        m[i][i] = 0;

    }

    for (int l = 2; l <= n; ++l)
    {
        for (int i = 1; i <= n - l + 1; i++){
            int j = i + l - 1;
            m[i][j] = (1 << 30);
            for (int k = i; k <= j - 1; k++)
            {
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }

    cout << m[1][n] << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stdlib.h>
using namespace std;

int main(){
	int H, W;
	cin >> H >> W;
	char masu[H+2][W+2];
	char ans[H][W];
	string line;

	for(int i = 0; i < H + 2; i++){
		for(int j = 0; j < W + 2; j++){
			masu[i][j] = '.';
		}
	}

	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			char in;
			cin >> in;
			masu[i][j] = in;
			ans[i - 1][j - 1] = in;
		}
	}

	/*
	cout << "-------------" << endl;
	for(int i = 0; i < H + 2; i++){
		for(int j = 0; j < W + 2; j++){
			cout << masu[i][j];
		}
		cout << endl;
	}
	*/


	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			if(masu[i][j] == '.'){
				int bomb_num = 0;
				for(int k = -1; k <= 1; k++){
					for(int l = -1; l <= 1; l++){
						if(masu[i + k][j + l] == '#') bomb_num++;
					}
				}
				ans[i - 1][j - 1] = (char)('0'+bomb_num);
			}
		}
	}

	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cout << ans[i][j];
		}
		cout << endl;
	}

	return 0;
}



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

int main(){
    ll a, b, k;
    ll ans, ans2;
    cin >> a >> b >> k;
    if(k <= a) cout << a-k  << " " << b << endl;
    if(k>a && (a+b)>=k) cout << "0" << " " << b-(k-a) << endl;
    if((a+b)<k)  cout << "0" << " " << "0" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

int main() {
	ll n;
	cin >> n;
	
	map<string, ll> m;

	rep(i, n) {
		string s;
		cin >> s;
		m[s]++;
	}

	ll MAX=0;

	for (auto p : m) {
		MAX=max(MAX, p.second);
	}

	for (auto p : m) {
		if (p.second == MAX) {
			cout << p.first << endl;
		}
	}
}

Measured memory_bytes: 25216
#include<iostream>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

string a[256], b[256];

int main() {
  string str;
  cin >> str;
  a['1'] = "";
  a['2'] = "k";
  a['3'] = "s";
  a['4'] = "t";
  a['5'] = "n";
  a['6'] = "h";
  a['7'] = "m";
  a['8'] = "y";
  a['9'] = "r";
  a['0'] = "w";
  b['T'] = "a";
  b['L'] = "i";
  b['U'] = "u";
  b['R'] = "e";
  b['D'] = "o";
  rep (i, str.size() / 2) {
    if (str.substr(i * 2, 2) != "0U") cout << a[(int)str[i * 2]] << b[(int)str[i * 2 + 1]];
    else cout << "nn";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1204
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();
        if (n == 100) {
            n = 101;
        }
        for (int i = 0; i < d; i++) {
            n = n * 100;
        }
        System.out.println(n);
    }
}

Measured memory_bytes: 24276
#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 <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define rep1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
ll gcd(ll x,ll y){
    if(y==0)return x;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
    return x*y/gcd(x,y);
}
int main(void){
    int N,sum=1;
    cin>>N;
    vector<string> s(N);
    rep(i,0,N)cin>>s[i];
    sort(all(s));
    rep(i,0,N-1){
        if(s[i]!=s[i+1])sum++;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 9596
def main():
    n = int(input())
    a = [0] * n
    b = a[:]
    c = a[:]
    for i in range(n):
        a[i], b[i], c[i] = map(int, input().split())
    dp = [[0, 0, 0] for _ in range(n)]
    dp[0][0] = a[0]
    dp[0][1] = b[0]
    dp[0][2] = c[0]
    for i in range(1, n):
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i]
        dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b[i]
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i]
    print(max(dp[n - 1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 64344
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
#define fs first
#define sc second
using namespace std;


typedef pair<ll,ll> P;



int main(){
  ll n,ans = 0;
  cin >> n;
  ll a[3*n];
  rep(i,0,3*n) cin >> a[i];

  sort(a,a+(3*n),greater<ll>());
  rep(i,0,n){
    ans += a[2*i+1];
  }
  cout << ans << endl;

}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

int minp[1234567];
int ok[1234567];
int mod = 998244353;
int s[1234567];
int ss[1234567];
int mu[1234567];
int inv[1234567];
int MAXN = 1000000;
int cnt[1234567];
int w[1234567];

void init() {
	FOR(i,0,MAXN+1) minp[i] = i;
	FOR(i,2,MAXN+1) {
		if (minp[i] == i) {
			for (lint j = i * 1LL * i; j <= MAXN; j+= i) {
				minp[j] = i;
			}
		}
	}
	mu[1] = 1;
	FOR(i,2,MAXN+1) {
		int p = minp[i];
		int x = i/p;
		if (x%p == 0) mu[i] = 0;
		else mu[i] = mod - mu[x];
	}
	inv[1] = 1;
	FOR(i,2,MAXN+1) {
		int q = mod/i;
		int r = mod - q*i;
		inv[i] = ((mod-q) * 1LL * inv[r])%mod;
	}
	FOR(i,0,MAXN+1) w[i] = 0;
}

int main() {
	make(n);
	makev(v, n);
	FOR(i,0,n) {
		cnt[v[i]]++;
	}
	init();
	FOR(i,1,MAXN+1) {
		for (int j = i; j <= MAXN; j+=i) {
			s[i] = (s[i] + cnt[j]*1LL*j)%mod;
			ss[i] = (ss[i] + (cnt[j]*1LL*j*1LL*j))%mod;  
			w[j] = (w[j] + inv[i]*1LL*mu[j/i])%mod;
		}
	}
	int ans = 0;
	FOR(i,1,MAXN+1) {
		if (w[i] != 0) {
			ans = (ans + w[i] * 1LL* (((s[i] * 1LL * s[i] - ss[i]) % mod + mod)%mod)) % mod;
		}
	}
	ans = (ans * 1LL * inv[2]) % mod;
	printf("%d\n", ans);
}





Measured memory_bytes: 34676
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(ll i = (ll)(n)-1;i >= 0;--i)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n;
  cin >> n;
  vi a(n);
  REP(i,n) cin >> a.at(i);
  set<int> st;
  int oth = 0;
  REP(i,n){
    if(a.at(i)<400) st.insert(0);
    else if(a.at(i)<800) st.insert(1);
    else if(a.at(i)<1200) st.insert(2);
    else if(a.at(i)<1600) st.insert(3);
    else if(a.at(i)<2000) st.insert(4);
    else if(a.at(i)<2400) st.insert(5);
    else if(a.at(i)<2800) st.insert(6);
    else if(a.at(i)<3200) st.insert(7);
    else oth++;
  }
  cout << max<int>(st.size(),1) << " " << st.size()+oth << endl;
}

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

int main()
{

  long long n,k ;
  cin >> n >> k  ;

  if(k==1 || n==k){
    cout << 0 << endl ;
    return 0;
  }

  long long tmp = abs(n-k);

  if(n%k==0){
   cout << 0 << endl ;
  }else{
   long long dev =  n%k ;
   if(dev<abs(dev-k)){
       cout << dev << endl ;
   }else{
       cout << abs(dev-k) << endl ;
   }
  }

    return 0;
}



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

#define ll unsigned long long
#define p(a, b) pair<a,b>

using namespace std;

//ifstream cin("Input.txt");
//ofstream cout("Output.txt");`

int main() {
    string s;
    cin >> s;
    bool f1, f2, f3;
    f1 = s[0] == 'A';
    int totc = 0;
    for (int i = 2; i < s.length() - 1; i++) {
        if (s[i] == 'C') {
            totc++;
        }
    }
    f2 = totc == 1;
    int totLow = 0;
    for (int i = 0; i < s.length(); i++) {
        if (islower(s[i])) {
            totLow++;
        }
    }
    f3 = totLow == s.length() - 2;
    if (f1 && f2 && f3) {
        cout << "AC";
    } else {
        cout << "WA";
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int v[n]; for (int i = 0; i < n; i++) cin >> v[i], v[i]--;
    int c0[100000] = {}, c1[100000] = {};
    
    for (int i = 0; i < n; i += 2) c0[v[i]]++;
    for (int i = 1; i < n; i += 2) c1[v[i]]++;
    int val0 = max_element(c0, c0 + 100000) - c0;
    int cnt0 = c0[val0];
    c0[val0] = 0;
    int val01 = max_element(c0, c0 + 100000) - c0;
    int cnt01 = c0[val01];
    int val1 = max_element(c1, c1 + 100000) - c1;
    int cnt1 = c1[val1];
    c1[val1] = 0;
    int val11 = max_element(c1, c1 + 100000) - c1;
    int cnt11 = c1[val11];
    int ans = 1<<30;
    cerr << cnt0 << ' ' << val0 << ' ' << cnt1 << ' ' << val1 << ' ' << cnt01 << ' ' << val01 << ' ' << cnt11 << ' ' << val11 << endl;
    if (val0 != val1) ans = min(ans, n - cnt0 - cnt1);
    else ans = min(n - cnt0 - cnt11, n - cnt01 - cnt1);
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

// vi g[N];
// int a[N];

void solve() {
  int a,b;
  cin >> a >> b;
  int out = 1;
  int ans = 0;
  while(out<b){
    --out;
    out+=a;
    ans++;
  }
  cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    // cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}


Measured memory_bytes: 3660
#include<stdio.h>
int compare(const void *a,const void *b){
	int *pa=(int*)a;
	int *pb=(int*)b;
	int num1=*pa;
	int num2=*pb;
	return num1-num2;
}
int main(){
	int n,j;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	qsort(a,n,sizeof(int),compare);
	int flag=1;
	for(int i=1;i<n;i++){
		if(a[i-1]==a[i]){
			flag=0;
			break;
		}
	}
	if(flag)printf("YES");
	else printf("NO");
	return 0;
} 

Measured memory_bytes: 1788
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
int N;
string input[14];
string dp[1 << 14][14];
int cover[14][14];

int solve(const vector<string>& names) {
	int n = names.size();
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i == j) continue;
			cover[i][j] = 0;
			for (int k = min(names[i].size(), names[j].size()) - 1; k > 0; --k) {
				if (names[i].substr(names[i].size() - k) == names[j].substr(0, k)) {
					cover[i][j] = k;
					break;
				}
			}
		}
	}
	for (int i = 0; i < (1 << n); ++i) {
		fill(&dp[i][0], &dp[i][n], string());
	}
	for (int i = 0; i < n; ++i) {
		dp[1 << i][i] = names[i];
	}
	for (int i = 1; i < (1 << n); ++i) {
		for (int j = 0; j < n; ++j) {
			if (dp[i][j].empty()) continue;
			for (int k = 0; k < n; ++k) {
				if (i & (1 << k)) continue;
				if (dp[i|(1<<k)][k].empty()
					 	|| dp[i|(1<<k)][k].size() > dp[i][j].size() + names[k].size() - cover[j][k]) {
					dp[i|(1<<k)][k] = dp[i][j] + names[k].substr(cover[j][k]);
				}
			}
		}
	}
	int ret = 999;
	for (int i = 0; i < n; ++i) {
		ret = min(ret, (int)dp[(1 << n) - 1][i].size());
	}
	return ret;
}

int main() {
	while (true) {
		cin >> N;
		if (N == 0) break;
		for (int i = 0; i < N; ++i) {
			cin >> input[i];
		}
		vector<string> names;
		for (int i = 0; i < N; ++i) {
			bool contains = false;
			for (int j = 0; j < N; ++j) {
				if (j == i) continue;
				if (input[j].find(input[i]) != string::npos) {
					contains = true;
					break;
				}
			}
			if (!contains) names.push_back(input[i]);
		}
		cout << solve(names) << endl;
	}
}

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

#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

#define debug(x) cout << "> " << #x << " = " << x << endl;
#define debug_at(arr, at) cout << "> " << #arr << "[" << at << "] = " << arr[at] << endl;
#define debug_pair(p) cout << "> " << #p << " = (" << p.first << ", " << p.second << ")" << endl;

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    map<int, int> have;

    fori(i, 0, n) {
        int val;
        cin >> val;
        ++have[val];
    }

    int m;
    cin >> m;
    map<int, int> need;

    fori(i, 0, m) {
        int val;
        cin >> val;
        ++need[val];
    }

    bool ans = true;
    for(auto p : need) {
        if(have[p.first] < p.second) {
            ans = false;
        }
    }
    cout << (ans ? "YES" : "NO") << "\n";

    return 0;
}


Measured memory_bytes: 19072
n = readline.strip.to_i
hs = readline.strip.split.map(&:to_i)

cur = hs[0]
res = true
1.upto(n - 1).each do |i|
  if hs[i] < cur
    res = false
    break
  end
  if hs[i] == cur
    next
  else
    cur = hs[i] - 1
  end
end
puts res ? 'Yes' : 'No'


Measured memory_bytes: 9604
#define debug_switch
#ifdef debug_switch
#define debug if(1) puts("debug");
#define dout if(1) cout
#else
#define debug if(0) puts("debug");
#define dout if(0) cout
#endif
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

const int N = 1e6 + 7;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-7;
using namespace std;
bool vis[N];
int prime[N],pnum=0,mu[N];//,sum[N];
void Mobius()
{
	//memset(vis,0,sizeof vis);
	vis[0] = vis[1] = mu[1] = 1;
	for(int i = 2; i < N; i++){
		if(!vis[i]){
			prime[++pnum] = i;
			mu[i] = -1;
		}
		for(int j = 1;j <= pnum && prime[j]*i < N; j++){
			vis[prime[j]*i] = 1;
			if(i % prime[j] == 0){
				mu[prime[j]*i] = 0;
				break;
			}
			mu[prime[j]*i] = -mu[i];
		}
	}
//	for(int i = 1;i < N; i++)  //求前缀和，用于分块优化
//		sum[i] = sum[i-1] + mu[i];
}
int cnt[N];
int nn = 1e6;
int mp[N];
ll cal(int x){
	if(mp[x] != -1)return mp[x];
	ll res=0;
//	for(int i=x;i<=nn;i+=x){
//		res = (res + 1ll * (i/x) * cnt[i] % mod) % mod;
//	}
	for(int i=1;i<=nn/x;i++){
		res = (res + 1ll * i * cnt[i*x] % mod) % mod;
	}
	return mp[x] = res * res % mod;
}
ll qpow(ll a, int n){
	ll res=1;
	while(n){
		if(n&1)res=res*a%mod;
		a = a*a%mod;
		n >>= 1;
	}
	return res;
}
int main()
{
	int n,x;
	ll sum=0;
	Mobius();
	memset(mp, -1, sizeof mp);
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		sum += x; 
		cnt[x]++;
	}
	sum %= mod;
	ll ans=0;
	for(int i=1;i<=nn;i++){
		ll tmp=0;
		for(int j=1;j<=nn/i;j++){
			if(mu[j])
				tmp = (tmp + 1ll * mu[j] % mod * j % mod * j % mod * cal(1ll*i*j) % mod) % mod;
		}
		//cout<<tmp<<endl;
		ans = (ans + tmp * i % mod) % mod;
		//cout<<ans<<endl;
	}
	ans = ((ans - sum) % mod + mod) % mod;
	cout<<(ans * qpow(2, mod-2) % mod)<<endl;
	return 0;
}






Measured memory_bytes: 14848
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18


int main(){
   int N,M; cin >> N >> M;
   vector<long long> dp(N+10);
   vector<int> a(M);
   rep(i,M){
       cin >> a[i];
   }
   if(M != 0){
    dp[0] = 1;
    if(*lower_bound(a.begin(),a.end(),1) == 1) dp[1] = 0;
    else dp[1] = 1;
    rep(i,N){
            if(*lower_bound(a.begin(),a.end(),i+2) == i+2) dp[i+2] = 0;
            else dp[i+2] = dp[i+1] + dp[i];
            dp[i+2] %= MOD;
    }
    rep(i,M-1){
        if(a[i+1] == a[i]+1){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << dp[N] << endl;
   }
   else{
       dp[0] = 1;
       dp[1] = 1;
       rep(i,N){
           dp[i+2] = (dp[i+1] + dp[i]) % MOD;
       }
       cout << dp[N] << endl;
   }
}
  


  


Measured memory_bytes: 1408
def isPrimeNum(in_num):
    if in_num <= 1:
        return False
    elif in_num == 2:
        return True
    elif in_num % 2 == 0:
        return False
    else:
        if pow(2, in_num-1, in_num) == 1:
            return True
        else:
            return False


num_len = int(input())
cnt = 0
for i in range(num_len):
    num = int(input())
    if isPrimeNum(num)==True:
        cnt = cnt + 1

print(str(cnt))

Measured memory_bytes: 7720