akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

/**
 * 0007:Debt Hellの解答
 * 
 * @author MS14A
 * @version 2015/04/15
 */
public class Main {

    /** 初期借金額：10万円 */
    private static final BigDecimal INITIAL_DEBT = BigDecimal.valueOf(100000L);

    /** 利子：5% */
    private static final BigDecimal INTEREST_RATE = new BigDecimal("0.05");

    /** \1000未満の繰り上げ計算用 */
    private static final BigDecimal DIVISOR_FOR_ROUND_UP = BigDecimal.valueOf(1000L);

    /**
     * n 週間後の借金の残高を出力する。<br>
     * ※n は 100 以下とする。
     * 
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        // 標準入力読み取り
        int weeks = getWeeks();

        // n週間後の借金額計算して表示。
        System.out.println(calcDebt(weeks));
    }

    /**
     * 標準入力を読み取り、"n"の値を返す。
     * 
     * @return n：入力値
     * @throws IOException
     *             標準入力読取り失敗時
     */
    private static int getWeeks() throws IOException {

        InputStreamReader streamReader = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(streamReader);

        int weeks = Integer.parseInt(bufferedReader.readLine());
        
        bufferedReader.close();
        streamReader.close();
        
        return weeks;
    }

    /**
     * n週間後の借金額を計算する。
     * 
     * @param weeks
     * @return n週間後の借金額
     */
    private static BigDecimal calcDebt(int weeks) {
        BigDecimal finalDebt = INITIAL_DEBT;

        for (int i = 0; i < weeks; i++) {
            // 利子額計算。1000で割った小数部を繰り上げる。
            BigDecimal interestAmount = finalDebt.multiply(INTEREST_RATE)
                    .divide(DIVISOR_FOR_ROUND_UP, 0, BigDecimal.ROUND_UP);

            // 借金額 = 前週の借金額 + 利子額
            finalDebt = finalDebt.add(interestAmount.multiply(DIVISOR_FOR_ROUND_UP));
        }

        return finalDebt;
    }

}

Measured memory_bytes: 17160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    int N;
    cin >> N;

    vector<string> v(N);
    for(int i = 0; i < N; i++){
        cin >> v[i];
        sort(all(v[i]) );
    }

    sort(all(v));

    vector<ll> cnts;    
    ll tmp = 1;
    for(int i = 1; i < N; i++){
        if(v[i] == v[i-1]){
            tmp ++;
        }
        else{
            cnts.push_back(tmp);
            tmp = 1;
        }
    }
    cnts.push_back(tmp);

    ll ans = 0;
    for(int i = 0; i < cnts.size(); i++){
        ans +=  cnts[i] * (cnts[i] - 1) / 2; 
    }
    cout << ans << endl;


}

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

int main() {
    ll n;
    cin >> n;
    vector<ll> b(n-1);
    rep(i,n-1) cin >> b[i];
    ll ans = b[0];
    rep(i,n-2) {
        ans += min(b[i], b[i+1]);
    }
    ans += b[n-2];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args){
		
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
        int D = input.nextInt();
        long remain = (long)(2 * Math.pow(10,9)) * 2;
        for (long i = N; i < D; i++) {
            for (long j = i + 1; j <= D; j++) {
                if((i*j)%2019 < remain)
                    remain = (i*j)%2019;
                if(remain == 0)
                    break;
            }
            if(remain == 0)
                break;
        }
		System.out.println(remain);
	}
}

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

int main(){
    string S;
    string T;

    //入力
    cin >> S >> T;
    int t_size = T.size();
    int min=t_size;
    for(int i=0;i < int(S.size()-t_size+1);i++){
        int count=0;
        for(int j=0;j<t_size;j++){
            if(S[i+j]!=T[j])count+=1;
        }
        if(count<min) min = count;
    }

    cout << min << endl;
}

Measured memory_bytes: 3584
/***
  knapsack with high capacity

  https://atcoder.jp/contests/dp/tasks/dp_e
  
*/
#include <bits/stdc++.h>
using namespace std;
#define maxN 101
#define maxV 1003
#define INF 1e17
#define ll long long 
#define endl "\n"

ll dp[maxN*maxV+5];
vector<ll> wt,profit;

ll get_profit(ll cap, ll n)
{
    ll i,j,ans=0LL;

    for(i=0; i<=maxN*maxV; i++)
        dp[i]=INF;
    dp[0]=0;

    for(i=0; i<n; i++)
    {
        for(j=ans+profit[i]; j>=profit[i]; j--)
        {
            if(dp[j-profit[i]]+wt[i]<=cap)
            {
                dp[j]=min(dp[j], dp[j-profit[i]]+wt[i]);
                ans=max(ans,j);
            }
        }
    }

    return ans;
}
int main()
{   
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int i,j,n;
    ll cap,sum=0,v,w;
    cin>>n>>cap;
    for(i=0; i<n; i++)
    {
        cin>>w>>v;
        wt.push_back(w);
        profit.push_back(v);
    }
    cout<<get_profit(cap,n)<<endl;
    return 0;
}


Measured memory_bytes: 4420
import java.util.Scanner;

public class Main{
	static int numerator;
	static int denominator;
	static int maxproduct;
	static int parts;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			numerator = sc.nextInt();
			denominator = sc.nextInt();
			maxproduct = sc.nextInt();
			parts = sc.nextInt();
			if(parts==0) break;
			int count = 0;
			count += Judge(numerator, denominator, parts, 1, 0);
			System.out.println(count);
		}
	}

	static int Judge(int p, int q, int separate, int now_pro, int prev_deno){
		int count = 0;
		if(p==0){
			count++;
		}
		if(separate<=0) return count;

		int deno = maxproduct/now_pro + 1;
		while(separate*q<p*deno) deno--;
		while(p*deno >= q && prev_deno<=deno){
			int subtraction_deno = q * deno;
			int subtraction_nume = p * deno - q;
			if(now_pro*deno<=maxproduct){
				count += Judge(subtraction_nume, subtraction_deno, separate-1, now_pro*deno, deno);
			}
			deno--;
		}
		return count;
	}
}

Measured memory_bytes: 33828
#include <stdio.h>

#define NMAX 50

int main(void) {
	int N, M;
	int A[NMAX], B[NMAX];
	int road[NMAX];
	int i;
	
	scanf("%d %d", &N ,&M);
	
	for (i = 0; i < M; i++) {
		scanf("%d %d", &A[i], &B[i]);
	}
	
	for (i = 0; i < N; i++) {
		road[i] = 0;
	}
	
	for (i = 0; i < M; i++) {
		road[A[i] - 1]++;
		road[B[i] - 1]++;
	}
	
	for (i = 0; i < N; i++) {
		printf("%d\n", road[i]);
	}
	
	return 0;
}



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

to_cost = [[] for i in range(n + 1)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    to_cost[u].append([v, w % 2])
    to_cost[v].append([u, w % 2])
ans = [-1] * (n + 1)
stack = [(1,1)]
while stack:
    a, w = stack.pop()
    ans[a] = w
    for to, cost in to_cost[a]:
        if ans[to] < 0:
            stack.append((to, w ^ cost))

for a in ans[1:]:
    print(a)

Measured memory_bytes: 42680
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

struct Card {
    char suit,value;
};

void bubble_sort(Card C[],int n) {
    rep(i,n) {
        for(int j=n-1;j>=i+1;j--) {
            if(C[j].value < C[j-1].value) swap(C[j-1], C[j]);
        }
    }
}
void selection_sort(Card C[], int n) {
    rep(i,n) {
        int min_idx = i;
        for(int j=i+1;j<n;j++) {
            if(C[j].value < C[min_idx].value) min_idx=j;
        }
        swap(C[i],C[min_idx]);
    }
}

bool is_stable(Card C1[],Card C2[],int n) {
    bool res=true;
    rep(i,n) res&=C1[i].suit == C2[i].suit;
    return res;
}

int main() {
    int n;
    Card C1[40],C2[40];
    cin>>n;
    rep(i,n) cin>>C1[i].suit>>C1[i].value;
    rep(i,n) C2[i]=C1[i];
    bubble_sort(C1,n);
    selection_sort(C2,n);
    rep(i,n) cout<<(i==0?"":" ")<<C1[i].suit<<C1[i].value;
    cout<<endl;
    cout<<"Stable"<<endl;
    rep(i,n) cout<<(i==0?"":" ")<<C2[i].suit<<C2[i].value;
    cout<<endl;
    if(is_stable(C1,C2,n)) cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
    return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
 
using namespace std;
 
long long a[100007];

int main(){

    int N; cin >> N;
    int two_cnt=0, cnt = 0, one_cnt = 0, zero_cnt=0; 
    for(int i=1; i<=N; i++){
        cnt = 0;
        cin >> a[i];
        long long num = a[i];
        while(num % 2 == 0){
            cnt++;
            num /= 2;
            if(cnt == 2){
                two_cnt++;
                break;
            }
        }
        if(cnt == 0){
            zero_cnt++;
        }else if(cnt == 1){
            one_cnt++;
        }
    }

    if(one_cnt>0){
        if(two_cnt >= zero_cnt){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if(two_cnt+1 >= zero_cnt){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
import bisect
S=input()
T=input()
N=len(S)
M=len(T)
chardict=dict()
for i in range(26):
    chardict[chr(i+97)]=[]
for i in range(2*N):
    chardict[S[i%N]].append(i)
dp=[0 for i in range(M+1)]
dp[0]=-1
for i in range(M):
    nowpoint=dp[i]%N
    cycle=dp[i]//N
    #cycle 周していて　nowpoint番目にいる
    if len(chardict[T[i]])==0:
        print(-1)
        exit()
    tmp=bisect.bisect_right(chardict[T[i]],nowpoint)
    dp[i+1]=cycle*N+chardict[T[i]][tmp]
print(dp[M]+1)


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

class Program
{
    /**
     * 0と1の連続する数を配列に格納する
     * 1010111の場合
     * 0- 0 0
     * 1-1 1 3 => 10103
     * 0を1に変えていけばよいからK=1の場合
     * 0を変えた直後の1の数を数えるので2*1+1回分の1をかぞえる
     * 1010111 => 1110111であれば最初の111で3個
     * 1010111 => 1011111であれば3～7(3+2*1+1-1)を数える
     * 
     * 
     */

    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        int N = int.Parse(inputs[0]);
        int K = int.Parse(inputs[1]);
        var S = Console.ReadLine();

        var nums = new List<int>();
        int val = 1;
        int count = 0;
        for(int i = 0; i < N; i++)
        {
            if(S[i] == ('0' + val))
            {
                count++;
            }else
            {
                val = 1 - val;
                nums.Add(count);
                count = 1;
            }
        }
        if (count != 0) nums.Add(count);
        // 0の後ろにある1の数を含めたいので奇数にする
        if (nums.Count % 2 == 0) nums.Add(0);

        var acumSum = new int[nums.Count + 1];
        for(int i = 0; i < nums.Count; i++)
        {
            acumSum[i + 1] = acumSum[i] + nums[i];
        }
        int maxK = 2 * K + 1;
        int max = 0;
        
        for(int i = 0; i < nums.Count; i+=2)
        {
            int left = i;
            int right = Math.Min(i + maxK, nums.Count);
            max = Math.Max(max, acumSum[right] - acumSum[left]);
        }
        Console.WriteLine(max);
    }



}



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

int main() {
    int r, g, b;
    cin >> r >> g >> b;

    int ans = r * 100 + g * 10 + b;

    if (ans % 4 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3596
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  double T, X;

  sc.scan(T, X);

  writeln(T / X);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(long long i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    string s;
    cin >> s;
    long long n = s.size();
    long long dp[n+2][13];
    rep(i,n+2){
        rep(j,13){
            dp[i][j] = 0LL;
        }
    }
    dp[0][0] = 1LL;
    long long beki = 1LL;
    long long a,b;
    for(long long i = n-1;i>=0;i--){
        if(s[i]=='?'){
            rep(j,10){
                rep(k,13){
                    b = (beki*j)%13LL;
                    dp[n-i][(b+k)%13]+=dp[n-i-1][k];
                    dp[n-i][(b+k)%13]%=MOD;
                }
            }
        }
        else{
            a = (s[i]-'0');
            b = (beki*a)%13LL;
            rep(j,13){
                dp[n-i][(b+j)%13]+=dp[n-i-1][j];
                dp[n-i][(b+j)%13]%=MOD;
            }
        }
        beki*=10LL;
        beki%=13;
    }
    cout << dp[n][5] << endl;
}

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

using namespace std;

const int MAXN = 100005;

int a[MAXN], travl[MAXN], travr[MAXN];

int n;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        travl[i] = travl[i - 1] + abs(a[i] - a[i - 1]);
    for (int i = n; i >= 1; i--)
        travr[i] = travr[i + 1] + abs(a[i] - a[i + 1]);
    for (int i = 1; i <= n; i++)
        cout << travl[i - 1] + travr[i + 1] + abs(a[i + 1] - a[i - 1]) << endl;
    return 0;
}


Measured memory_bytes: 2432
#include<iostream>

using namespace std;

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

int main() {
	int val[] = {6000, 4000, 3000, 2000};
	rep (i, 4) {
		int a, b;
		cin >> a >> b;
		--a;
		cout << val[a] * b << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
import sys


def solve(D: int, G: int, p: "List[int]", c: "List[int]"):

    # bit全探索
    mc = sum(p)
    for i in range(1 << D):
        s = 0
        cc = 0
        for j in range(D):
            if((i >> j) & 1):
                s += (j+1)*p[j]*100+c[j]
                cc += p[j]
        # if(s >= G):
        #     mc = min(mc, cc)
        # 以下はuwiさんの回答を参考
        for j in range(D-1, -1, -1):
            # ここはもう全部解くことが決まっている
            if((i>>j)&1):
                continue
            # 「すべて解く」のみで目的スコアに達する場合はそのまま抜けて良い　＆　前回の足して合計に達するならば出て良い
            if(s >= G):
                break
            # g: 最大のスコアの問題の一問あたりのスコア
            g = (j+1)*100
            # got: どのくらいとくか
            # g-1を足すことで、math.ceilを使わなくて良い(//で表現できる)
            got = (G-s+g-1)//g
            s += min(got, p[j])*g
            cc += min(got, p[j])
        mc = min(cc, mc)

    print(mc)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    p = [int()] * (D)  # type: "List[int]"
    c = [int()] * (D)  # type: "List[int]"
    for i in range(D):
        p[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(D, G, p, c)

if __name__ == '__main__':
    main()


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;

typedef long long int ll;

void solve(){
	int N, K;
	cin >> N >> K;
	vector<int> vec(N);
	for(int i = 0; i < N; i++) cin >> vec[i];
	
	sort(all(vec));
	
	vector<vector<bool> > dp(K+1,vector<bool>(N,false));
	
	for(int i = 0; i <= K; i++){
		int l = i/vec[0];
		if(l%2 == 0) dp[i][0] = false;
		else dp[i][0] = true;
	}
	
	for(int i = 1; i <= K; i++){
		for(int j = 1; j < N; j++){
			if(vec[j] > i){
				dp[i][j] = dp[i][j-1];
			}
			else{
				for(int k = j; k >= 0; k--){
					if(dp[i-vec[k]][j] == false){
						dp[i][j] = true;
						break;
					}
				}
			}
		}
	}
//	for(int i = 0; i <= K; i++){
//		for(int j = 0; j < N; j++){
//			cout << dp[i][j] << " ";
//		}
//		cout << endl;
//	}
	if(dp[K][N-1]){
		cout << "First" << endl;
	}
	else cout << "Second" << endl;
}

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int T;
//	cin >> T;
	T = 1;
	while(T--){
		solve();
	}
	return 0;
}




Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
vector<ll> ans(2001,0);

int main(){
    ans.at(0) = 1;
    ll s; cin >> s;
    for(int i=3;i<=s;i++){
        ll x = 0;
        for(int j=0;j<=i-3;j++){
            x = (x+ans.at(j))%mod;
        }
      	ans.at(i)=x;
    }
    cout << ans.at(s);
    return 0;
}

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

 
int main(){
   int h,w,n;
   scanf("%d %d %d", &h,&w,&n);
   if(h>w){
     if(n%h==0){
     	printf("%d", (n/h));
     } else{
        printf("%d", (n/h)+1);
     }
   } else{
   	if(n%w==0){
     	printf("%d", (n/w));
     } else{
        printf("%d", (n/w)+1);
     }
   }
	return 0;
 
}

Measured memory_bytes: 128
//
//  main.cpp
//  A - Rounding
//
//  Created by Hashizo on 2019/06/16.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef INT_MAX
#undef INT_MIN

#define INT_MAX	2147483647
#define INT_MIN	(-INT_MAX  -1)

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define REPLACE(s, f, t) regex_replace(s, regex(f), t)

int main(int argc, const char * argv[]) {
	int x,a;
	cin >> x >> a;

	if(x >= a ) {
		cout << 10 << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}


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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

long long completed[52][2];

pair<long long, long long> precomp(long long n){

    if(n == 1LL){
        return make_pair(3LL, 2LL);
    }

    pair<long long, long long> state = precomp(n - 1LL);

    completed[n - 1][0] = state.first;
    completed[n - 1][1] = state.second;

    return make_pair(state.first * 2LL + 1LL, state.second * 2LL + 2LL);

}

long long helper(long long n, long long x){

    if(n == 1){
        if(x < 1)
            return 0LL;
        return x - 1LL - (x >= 5LL ? 1LL : 0LL);
    }

    long long half = completed[n - 1][0] + completed[n - 1][1] + 2LL;

    if(x >= half * 2LL - 3LL){
        return completed[n][0];
    } else if(x >= half){
        return completed[n - 1][0] + 1LL + helper(n - 1LL, x - half);
    } else {
        return helper(n - 1LL, x - 1LL);
    }

}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long long n, x;
    cin >> n >> x;

    pair<long long, long long > state = precomp(n);
    completed[n][0] = state.first;
    completed[n][1] = state.second;

    cout << helper(n, x);

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        @SuppressWarnings("resource")

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n - 1];
        int[] b = new int[n - 1];
        ArrayList<Integer>[] list = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            list[i] = new ArrayList<>();
        }

        for (int i = 0; i < n - 1; i++) {
            a[i] = Integer.parseInt(sc.next())  - 1;
            b[i] = Integer.parseInt(sc.next()) - 1;
            list[a[i]].add(b[i]);
            list[b[i]].add(a[i]);
        }
        int k = 0;
        for (int i = 0; i < n; i++) {
            k = Math.max(k, list[i].size());
        }
        Map<Long, Integer> map = new HashMap<>();
        Queue<Integer> queue = new ArrayDeque<>();
        queue.add(0);
        Set<Integer> seen = new HashSet<>();
        int[] parent = new int[n];
        seen.add(0);

        while (queue.size() != 0) {
            int now = queue.poll();
//            int color[] = new int[k];
            int color_num = 0;
            for (Integer next : list[now]) {
                if (!seen.contains(next)) {
                    color_num++;
                    seen.add(next);
                    if (color_num == parent[now]) {
                        color_num++;
                    }
                    long min = Math.min(now, next);
                    long max = Math.max(now, next);
                    map.put(100000 * min + max, color_num);
                    parent[next] = color_num;
                    queue.add(next);
                }
            }
//            for (Integer x : list[now]) {
//                long min = Math.min(now, x);
//                long max = Math.max(now, x);
//                if (map.containsKey(100000 * min + max)) {
//                    color[map.get(100000 * min + max)]++;
//                }
//            }
//            int idx = 0;
//            for (Integer x : list[now]) {
//                if (!seen.contains(x)) {
//                    long min = Math.min(now, x);
//                    long max = Math.max(now, x);
//                    while (color[idx] != 0) {
//                        idx++;
//                    }
//                    map.put(min * 100000 + max, idx);
//                    color[idx]++;
//                    queue.add(x);
//                    seen.add(x);
//                }
//            }
        }

        System.out.println(k);
        for (int i = 0; i < n - 1; i++) {
            System.out.print(map.get((long) a[i] * 100000 + b[i]));
            System.out.print("\n");
        }


    }

}


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

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

  string s;
  cin >> s;

  int cnt_a = 0, cnt_b = 0;

  for (auto c : s) {
    if (c == 'a' && cnt_a + cnt_b < a + b) {
      puts("Yes");
      ++cnt_a;
    } else if (c == 'b' && cnt_a + cnt_b < a + b && cnt_b < b) {

      puts("Yes");
      ++cnt_b;
    } else
      puts("No");
  }
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    double a, b;
    cin >> a >> b;

    // a + (a-1)*(n-1) > b
    double n = (b-1)/(a-1);
    cout << ceil(n) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>


using namespace std;

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

	vector<long long int> a;
	long long int wk;
	for (int i = 0; i < n; i++) {
		cin >> wk;

		a.push_back(wk);

	}

	vector<long long int> sub;
	long long int mini = INT_MAX;

	for (int i = 0; i < n; i++) {
		if (a[i] <= mini) {
			sub.push_back(a[i]);
			mini = a[i];
		}
		else {
			for (int j = 0; j < sub.size(); j++) {
				if (a[i] > sub[j]) {
					sub[j] = a[i];
					if (j == sub.size() - 1)mini = sub[j];


					break;
				}
			}
		}
	}

	int ans;
	ans = sub.size();

	cout << ans << endl;

	return 0;



}



Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e12;
const int MOD = 1e9 + 7;

#define MAX_N 100
#define MAX_V 1000

ll dp[MAX_N + 1][MAX_N * MAX_V + 1];

signed main(){
	int N;
	ll W;
	cin >> N >> W;
	ll w[N];
	int v[N];
	REP(i,N){
		cin >> w[i] >> v[i];
	}
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= N * MAX_V; j++){
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= N * MAX_V; j++){
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			if(j - v[i] >= 0){
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
			}
		}
	}
	int ans = 0;
	for(int i = 0; i <= N * MAX_V; i++){
		if(dp[N][i] <= W){
			ans = max(ans, i);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 79104
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
	public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var aArray = retreiveLongArray();

			var count = 0;
			for (int i = 0; i < N; i++) {
				if (aArray[i]==i+1) {
					count++;
					i++;
				}
			}

			//答えの出力
			var ans = count;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}

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

#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif


typedef long long ll;
typedef pair<ll, ll> pll;
typedef gp_hash_table<long long, long long> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7
#define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; return 0;
#else
#define endl '\n'
#define trace(...)
#define end_routine() return 0;
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) {return fabs(a - b) < 1e-9;}
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = 500005;

void solve(){
    ll n,l; cin>>n>>l;
    ll low = inf;
    ll flav = 0;
    rep(i,n){
        flav += (l+i);
        if(abs(l+i)<abs(low)){
            low = l+i;
        }
    }
    flav -= low;
    cout<<flav;
}

int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(10); //cout<<fixed;
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    solve();
    end_routine();
}

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

using namespace std;

int main(){
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  if(A1 + A2 + A3 >= 22){
    cout << "bust";
  }else{
    cout << "win";
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 5
int find(int board[10][N],int h);
void seiti(int board[10][N],int h);
int main(void){
  int board[10][N],h,j,i,point,point_sum=0;
  //  int z,a;
  while(1){
    scanf("%d",&h);
    if(h==0)
      break;
    point=0;
    point_sum=0;
    for(i=0;i<h;i++){
      
      for(j=0;j<N;j++){
	scanf("%d",&board[i][j]);
      }
    }
    while(1){
      point=find(board,h);
      if(point==0)
	break;
      point_sum=point+point_sum;
      /*
	printf("mae\n");
      for(a=0;a<h;a++){
	for(z=0;z<N;z++){
	  printf("%d ",board[a][z]);
	}
	printf("\n");
      }
      printf("s%d\nseiti\n",point_sum);
      */
      seiti(board,h);
      /*
	for(a=0;a<h;a++){
	for(z=0;z<N;z++){
	  printf("%d ",board[a][z]);
	}
	printf("\n");
      }
      */
    }
    printf("%d\n",point_sum);
  }
    return 0;
}
int find(int board[10][N],int h){
  int i,j,count,x,len,point,point_sum=0;
  
  for(i=0;i<h;i++){
    count=0;
    point=0;
    for(j=1;j<N;j++){
      if(board[i][j]==board[i][j-1] && board[i][j]!=0){
	count++;
      }
      else{
	count=0;
      }
      if(count>=2){
	point=board[i][j-count]*(count+1);
	len=count;
	x=j-count;
      }
    }
    if(point!=0){
      for(j=x;j<x+len+1;j++){
	board[i][j]=0;
      }
      point_sum=point+point_sum;
    }
  }
    return point_sum;
}
void seiti(int board[10][N],int h){
  int i,j,flag,count=0;
  while(1){
    flag=0;
    for(i=h-1;i>0;i--){
      for(j=0;j<N;j++){
	if(board[i][j]==0){
      	  if(board[i-1][j]==0){
	    flag=1;
	  }
	  //	  printf("%d %d,",i,j);
	  board[i][j]=board[i-1][j];	  
	  board[i-1][j]=0;
	}
      }
    }
    if(flag==1)
      count++;
    if(flag==0 || count==h)
      break;
  }
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define fileopen(filename) if (fopen(filename".INP", "r")) {freopen(filename".INP", "r", stdin);freopen(filename".OUT", "w", stdout);}
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,n) for (int i=1;i<=n;++i)
#define eb emplace_back
#define pb push_back
#define memset(a,i) memset(a,i,sizeof(a))
#define upper(v,a) upper_bound(v.begin(), v.end(), a)
#define lower(v,a) lower_bound(v.begin(), v.end(), a)
#define ii pair<int,int>
#define fi first
#define se second
#define endl '\n'
#define gcd __gcd
const int maxn=1e5+1;
const int INF=1e9+1;

bool used[maxn];
vector<ii> adj[maxn];

void dfs(int dis[],int node, int dist)
{
	used[node]=1;
	for (ii i : adj[node])
		if (!used[i.fi])
		{
			dis[i.fi]=dist+i.se;
			dfs(dis,i.fi,dist+i.se);
		}	
		else if (dist+i.se!=dis[i.fi])
		{
			//cout<<node<<' '<<i.fi;
			cout<<"No";exit(0);
			
		}
}

signed main()
{
	fastio;
	int n,m;cin>>n>>m;
	while (m--)
	{
		int a,b,c;cin>>a>>b>>c;
		adj[a].eb(ii(b,c));
		adj[b].eb(ii(a,-c));
	}
	rep(i,n)if (!used[i])
	{
		int a[n+1];
		a[i]=0;
		dfs(a,i,0);
	}
	cout<<"Yes";
}

Measured memory_bytes: 19848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
    ll n;
	cin >> n;
    vector<string> v(n);
    REP(i, n) cin >> v[i];
    ll ans = 1;
    ll i, j;

    sort(ALL(v));
    for(i = 0; i < n - 1;){
        for(j = i + 1; j < n; j++){
            if(v[i] != v[j]) {
                ans++;
                break;
            }
        }
    i = j;
    j = i + 1;
    //cout << i << ", " << j << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9588
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):a[i]*=-1
a.sort()
from bisect import bisect_left,bisect_right
def check(mid):
  mm=0
  for i in range(n):
    if -(a[i]+a[0])<mid:break
    mm+=bisect_right(a,-(mid+a[i]))
  return mm
ok=0
ng=10**10+7
while ng!=ok+1:
  mid=(ok+ng)//2
  if check(mid)>=m:ok=mid
  else:ng=mid
b=[0]
for i in a:b.append(b[-1]+i)
ans=0
for i in range(n):
  if -(a[i]+a[0])<ok:break
  ind=bisect_right(a,-(ok+a[i]))
  ans+=a[i]*ind
  ans+=b[ind]
print(-(ans+(check(ok)-m)*ok))

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


void solve(long long N, long long M, std::vector<long long> H, std::vector<long long> A, std::vector<long long> B){
    vector<set<int>> v(N);
    for(int i = 0;i < N;i++)v[i].insert(-1e9);
    for(int i = 0;i < M;i++){
        A[i]--, B[i]--;
        v[A[i]].insert(H[B[i]]);
        v[B[i]].insert(H[A[i]]);
    }
    int cnt = 0;
    for(int i = 0;i < N;i++){
        if(*v[i].rbegin() < H[i]){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(H), std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 24316
#include<stdio.h>
#include<string.h>
typedef struct d{int card[2],cost;}d;

int N,C[100][2],i,j,k,l,p;
d dp[105][105];


d dfs(int r,int l)
{
	int i;
	d res,a,b,t;
	res.cost=100000000;
	if(dp[r][l].cost>0)
		return dp[r][l];
	if(l-r==0)
	{
		res.cost=0;
		memcpy(res.card,C[r],sizeof(res.card));
	}
	else
	{
		for(i=r;i<l;i++)
		{
			a=dfs(r,i);
			b=dfs(i+1,l);
			t.cost=a.cost+b.cost+(a.card[0]*a.card[1]*b.card[0]*b.card[1]);
			t.card[0]=a.card[0];
			t.card[1]=b.card[1];
			if(res.cost>t.cost)
			{
				res=t;
			}
		}
	}
	return dp[r][l]=res;
}

int main()
{
	memset(dp,-1,sizeof(dp));
	scanf("%d",&N);
	for(i=0;i<N;i++)
		scanf("%d%d",&C[i][0],&C[i][1]);
	printf("%d\n",dfs(0,N-1).cost);
	return 0;
}

Measured memory_bytes: 740
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b;
    c=0;d=1;
    while(a>=d){
        d*=b;c++;
    }
    cout<<c;
    return 0;
}

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


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

    V = [[-1, -1] for _ in range(N)]  # 頂点の[親, 親への辺の色]
    ans = [-1]*(N-1)
    import collections
    Q = collections.deque()
    Q.append(0)
    while Q:
        i = Q.popleft()
        color = 0
        for c, ei in G[i]:
            if c == V[i][0]:
                continue
            V[c][0] = i
            color += 1
            if color == V[i][1]:
                color += 1
            V[c][1] = ans[ei] = color
            Q.append(c)
    print(max(ans))
    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	ll n,a,b;
	cin>>n>>a>>b;
	ll x[n];
	rep(i,n)cin>>x[i];

	ll ans=0;
	rep(i,n-1){
		if((x[i+1]-x[i])*a>b)ans+=b;
		else ans+=(x[i+1]-x[i])*a;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1024
<?php
//前提条件$size>=2
$size = fgets(STDIN);
$v = fgets(STDIN);
//$vを配列にする
$array = explode(" ", $v);

//配列内に0があれば出力は配列絶対値の和
if(in_array(0,$array)){
  $allPlus = true;
}else{
  $allPlus = false;
}

$arrayAbs = [];
if($allPlus){
  foreach($array as $n){
    if($n < 0){
      $n = abs($n);
    }
    $arrayAbs[] = $n;
  }
  echo array_sum($arrayAbs);
//配列内のマイナスの数が偶数なら出力は絶対値合計、奇数なら絶対値最小値1つのみマイナス
}else{
  $min = abs($array[0]);
//  $min = $array[0];
  $minusCounter = 0;
  foreach($array as $n){
    if($n < 0){
      $n = abs($n);
      $minusCounter++;
    }
    if($min > abs($n)){
      $min = $n;
    }
    $arrayAbs[] = $n;
  }
  if($minusCounter%2 === 0){
    echo array_sum($arrayAbs);
  }else{
    //最小値のみ引くことと、全ての和から最小値を2回引くことは同義
    echo array_sum($arrayAbs)-2*$min;
  }
}


Measured memory_bytes: 36852
#include <iostream>
#include <vector>
#include <cstdlib>
#include<set>
#include <map>
using namespace std;


   
#include <iostream>

using namespace std;
int R;
int main()
{
    cin >> R;
    cout << 2 * 3.1415 * R;
   return 0;
}


Measured memory_bytes: 3192
# include <bits/stdc++.h>
/// my holy template
# define F first    
# define S second
# define mp make_pair
# define pii pair<int,int>         
/// eveything goes according to plan
# define long long long  
# define pb push_back
# define sz(a) (int)(a.size())
/// countdown BEGAN. 10 , 9 , 8 ...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right     

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long MXLL = 9223372036854775807;
const int Sz = 1110111;

using namespace std;

inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
}
int n, m;     
                              
int main() 
{
  Read_rap ();
                            
  string s;
  cin >> s;
             
  cout << s[0] << sz(s) - 2 << s.back();



  return 0;
} 










// Coded by Z...

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

int main(){
	float x,y;
	scanf ("%f %f",&x,&y);
	float hasil =(x+y)/2;
	printf ("%d\n",(int)round(hasil));
	//printf ("%d\n",(x+y)/2);
	
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end()
#define sortv(v) sort(all(v))
#define sortg(v) sort(all(v), greater<int>())
#define countv(v, c) count(all(v), c)
#define gcd __gcd
#define rep(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define _rep(i, n) rep(i, 0, n)
#define rev(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define _rev(i, n) rev(i, n, 0)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
	if(cin >> f){in(r...);return true;}
	else{return false;}
}
#define inv(x) each(i, x) in(i)
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define printv(x) each(i, x) out(i), space(); indent()
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
#define debugv(x) debughead(x); each(i, x) debugout(i); debugindent()
#define YN(x) out((x) ? "YES" : "NO"), indent()
#define Yn(x) out((x) ? "Yes" : "No"), indent()
#define yn(x) out((x) ? "yes" : "no"), indent()
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
const int dx[] = {0, 0, 1, 0, -1, -1, 1, 1, -1};
const int dy[] = {0, -1, 0, 1, 0, -1, -1, 1, 1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
int lcm(int a, int b){return a / gcd(a, b) * b;}
int factorial(int a){return a < 2 ? 1 : factorial(a - 1) * a;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}
int combination(int n, int r){
	int res = 1;
	rep(i, 1, r + 1){
		res *= n--, res /= i;
	}
	return res;
}
bool isPrime(int n){
	rep(i, 2, sqrt(n) + 1){
		if(i > 3){
			i++;
		}
		if(!(n % i)){
			return false;
		}
	}
	return true;
}
vector<int> divisor(int n){
	vector<int> ans;
	rep(i, 1, sqrt(n) + 1){
		if(!(n % i)){
			ans.pb(i);
			if(i * i < n){
				ans.pb(n / i);
			}
		}
	}
	return ans;
}
map<int, int> factorization(int n){
	map<int, int> ans;
	rep(i, 2, sqrt(n) + 1){
		if(i > 3){
			i++;
		}
		while(!(n%i)){
			ans[i]++, n /= i;
		}
	}
	if(n > 1){
		ans[n]++;
	}
	return ans;
}
signed main(){INCANT;
	/*-----------------------------------------------*/
	
	int N; in(N);
	set<int> A;
	_rep(i, N){
		int a; in(a);
		A.insert(a);
	}
	YN(sz(A) == N);

	/*-----------------------------------------------*/
}

Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        //Random rnd = new Random();
        //Stopwatch sw = new Stopwatch();

        // A B C
        int N = cin.Nextint;
        int M = cin.Nextint;



        long t = 1;
        for(int i=0;i<M;i++){
            t = t*2;
        }
        //Console.WriteLine("t:{0}",t);
        long r = (1900*M +100*(N-M))*t;

        // N
        // a1 a2 ... aN
        /*
        int N;
        int[] A;

        N = cin.Nextint;
        A = cin.Scanint;
        */

        // N M
        // a1 b1
        // ...
        // aM bM
        /*
        int N;
        int M;
        int[] A = new int[M];
        int[] B = new int[M];

        N = cin.Nextint;
        M = cin.Nextint;

        for(int i=0; i<M; i++)
        {
            A[i] = cin.Nextint;
            B[i] = cin.Nextint;
        }
         */




        /** ここに記述 */

        Console.WriteLine(r);
        //Console.WriteLine(result ? "Yes" : "No");
        Console.Out.Flush();
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length)
            {
                return s[i++];
            }
            string st = Console.ReadLine();
            while (st == "")
            {
                st = Console.ReadLine();
            }

            s 
            = st.
                Split
                (cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 11220
# ALDS1_4_A: Linear Search

# 番兵
def linearSearch(l, key):
  index = 0
  l.append(key)
  while l[index] != key:
    index += 1
  else:
    if index == (len(l) -1):
      return -1
    else:
      return index

def main():
  n = int(input())
  S = list(map(int, input().split()))
  m = int(input())
  T = list(map(int, input().split()))
  count = 0
  for i in T:
    if linearSearch(list(S), i) != -1:
      count += 1
  print(count)

main()



Measured memory_bytes: 6552