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



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N);
        Array.Sort(A);
        int pre = -1;
        int num = 0;
        int ans = 0;
        foreach (var item in A)
        {
            if (pre != item)
            {
                pre = item;
                ans += (num % 2);
                num = 1;
            }
            else num++;
        }
        ans += num % 2;
        Console.WriteLine(ans);

    }
    


}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 15444
'''
Introduction to Heuristics Contest
A - AtCoder Contest Scheduling
'''

def main():
    # 本番テストケースは365
    D = int(input())

    # コンテストタイプごとの満足度の下がりやすさ
    C = list(map(int, input().split()))

    # 満足度row日目にコンテストcolタイプを開催したときの満足度の増加
    S = []
    for _ in range(D):
        sday = list(map(int, input().split()))
        S.append(sday)

    def calc_score(T):
        # さいごに開催したコンテストの日付
        last = [-1] * 26
        # 満足度と不満度を計算して出力
        val = 0
        for d in range(D):
            idx = T[d] - 1
            satis = S[d][idx]
            last[idx] = d
            complain = 0
            for j in range(26):
                complain += C[j] * (d - last[j])
            val += satis - complain
        return val

    import random
    smax = 0
    ans = [1] * D
    for _ in range(100):
        trand = [random.randint(1,26) for _ in range(D)]
        score = calc_score(trand)
        if smax < score:
            ans = trand
    print(*ans, sep='\n')

main()

Measured memory_bytes: 10004
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

ll dp[2001][2001]={};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<pair<ll,int>> a(n);
    fr(i,n){
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(a.rbegin(),a.rend());
    ll ans{};
    fr(i,n+1) fr(j,n+1-i){
        if(i==0&&j==0) continue;
        if(i) chmax(dp[i][j],dp[i-1][j]+a[i+j-1].first*abs(a[i+j-1].second-i+1));
        if(j) chmax(dp[i][j],dp[i][j-1]+a[i+j-1].first*(n-j-a[i+j-1].second));
        if(i+j==n) chmax(ans,dp[i][j]);
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 26236
use input::Input;

fn main() {
    let mut input = Input::default();

    let n = input.parse();
    let mut a = (0..n).map(|_| input.parse()).collect::<Vec<_>>();
    a.sort();

    let mut ans = 1u64;
    for x in a.iter() {
        ans *= x;
        if ans > 1000000000000000000 || (ans > 1000000000 && *x > 1000000000) {
            println!("{}", -1);
            return;
        }
    }
    println!("{}", ans);
}

#[allow(dead_code)]
pub mod input {
    #[derive(Default)]
    pub struct Input(Vec<String>);

    impl Input {
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok().expect("read error");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            let x = if let Some(x) = self.0.pop() {
                x
            } else {
                let s = self.read_line();
                self.0 = s.split_whitespace().map(String::from).rev().collect();
                self.0.pop().expect("reached EOF")
            };
            x.parse().ok().expect("parse error")
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a,b;
    cin>>a>>b;
    int ans=0;
    if(a>9 || b>9) ans=-1;
    else ans=a*b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def solve(x,q,e):
    if abs(x**3-q) < e:
        return x
    x -= (x**3-q)/(x**2)/3
    return solve(x,q,e)


while True:
    q = input()
    if q == -1:
        break
    x1 = float(q)/2.0
    err = 0.00001*q
    print solve(x1,q,err)

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a-1;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define len(a) (int)(a.length())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)
#define CC(x) cout<<x<<endl


void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.in","r",stdin);
   freopen("output.out","w",stdout); 
   #endif
} 

int main(){
   //Fast_IO();
   string s;
   cin>>s;
   ll sum=0;
   f(i,0,len(s)){
      sum+=s[i]-'0';
   }
   if(sum%9==0) CC("Yes");
   else CC("No");


}





Measured memory_bytes: 3724
from math import factorial
from itertools import permutations

n = int(input())
v = []

for _ in range(n):
    x, y = [int(x) for x in input().split()]
    v.append((x, y))

sum = 0

for r in permutations(v):
    d = 0
    x1, y1 = r[0]
    for u in r[1:]:
        x2, y2 = u
        d += ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
    sum += d

print(sum / factorial(n))

Measured memory_bytes: 3064
import math
from functools import reduce

N = int(input())

def gcd_list(nums):
    return reduce(math.gcd, nums)

total = 0

for a in range(N):
    for b in range(N):
        for c in range(N):
            total += gcd_list([a+1, b+1, c+1])

print(total)

Measured memory_bytes: 74832
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public final class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String in = br.readLine();
		System.out.println(new Solver().solve(in));
	}
}

class Solver {

	String solve(String in) {
		HashMap<String, Boolean> m = new HashMap<String, Boolean>();
		m.put("dream", true);
		m.put("dreamer", true);
		m.put("erase", true);
		m.put("eraser", true);
		int i;
		for (i = 0; i < in.length() - 4;) {
			if (i + 4 < in.length() && m.containsKey(in.substring(i, i + 5))) {
				if (i + 6 < in.length() && m.containsKey(in.substring(i, i + 7))) {
					if (i + 9 < in.length() && m.containsKey(in.substring(i + 5, i + 10))) {
						i += 5;
					} else {
						i += 7;
					}
				} else if (i + 5 < in.length() && m.containsKey(in.substring(i, i + 6))) {
					i += 6;
				} else {
					i += 5;
				}
			} else {
				return "NO";
			}

		}
		return i >= in.length() ? "YES" : "NO";

	}
}


Measured memory_bytes: 26964
/**
    Sweet!
**/
#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pp pop_back()
#define ll long long
#define ld long double
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define rand() rand() >> 16 * rand()

using namespace std;

const int N = 2e5+10;
const int inf = 2e9+7;
const ll linf = 1e18+9;

ll n, a, b, l, r, L, R;

int main() {
    cin >> n >> a >> b >> l >> r;
    if(a > b)
        swap(a, b);
    for(int i = 1; i <= n - 1; i++) {
        if(a >= b) {
            a -= l;
            L += (r - l);
        }
        else {
            a += l;
            R += (r - l);
        }
    }
    if(a > b) {
        if(a - b <= L) puts("YES");
        else puts("NO");
    }
    else {
        if(b - a <= R) puts("YES");
        else puts("NO");
    }
}



Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
//const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}

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






int main() {

	int A, B;
	cin >> A >> B;

	cout << max(A - 2 * B, 0) << endl;

	
	return 0;
}

Measured memory_bytes: 256
using System;

class Test
{
    public static void Main()
    {
        while(true)
        {
            string s = Console.ReadLine();
            string[] ss = s.Split(' ');
            int x = int.Parse(ss[0]);
            int y = int.Parse(ss[1]);
            
            if(x == 0 && y == 0)
            {
                break;
            }
            
            if(x < y)
            {
                Console.WriteLine(x + " " + y);
            }
            else
            {
                Console.WriteLine(y + " " + x);
            }
            
            
            
            
        }
    }
}


Measured memory_bytes: 15824
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int r,c;
        r = input.nextInt();
        c = input.nextInt();
        int[][] grid = new int[r+1][c+1];
        for (int i = 0; i < r; i++){
            for (int j = 0; j < c; j++){
                grid[i][j] = input.nextInt();
                grid[i][c] += grid[i][j];
                grid[r][j] += grid[i][j];
                grid[r][c] += grid[i][j];
            }
        }
        for (int i = 0; i < r+1; i++){
            for (int j = 0; j < c+1; j++){
                if (j == c){
                    System.out.println(grid[i][j]);
                } else {
                    System.out.printf("%d ",grid[i][j]);
                }
            }
        }
    }
}


Measured memory_bytes: 51820
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

///////////////////////////

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

	if (N%K == 0) { cout << 0; }
	else { cout << 1; }
	
	system("PAUSE");
}

Measured memory_bytes: 504
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M   1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}

int main()
{
    ll N;
    cin>>N;
    ll D=N/5;
    ll A=N/500,B=N%500;
    ll ans=A*1000;
    B=B/5;
    ans+=B*5;
    cout<<max(ans,D*5);



}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

long long int C[55][55];

void CALC(void) {
	
	C[0][0] = 1;
	C[1][0] = 1; C[1][1] = 1;

	for (int n = 2; n <= 50; n++) {
		C[n][0] = 1;
		for (int m = 1; m <= n - 1; m++) { C[n][m] = C[n - 1][m - 1] + C[n - 1][m]; }
		C[n][n] = 1;
	}
}

int N,A,B;
vector<long long int > v;

int main(void) {

	cin >> N>>A>>B;

	CALC();
	long long int tmp;
	for (int i = 0; i < N; i++) {
		cin >> tmp; v.push_back(tmp);
	}

	sort(v.rbegin(), v.rend());

	long double max_ave=0.0;

	for (int i = 0; i < A; i++) {
		max_ave += v[i];
	}
	max_ave /= 1.0L*A;
	cout << fixed<<setprecision(9) << max_ave << endl;

	long long int ans = 0;
	if (v[0] != v[A - 1]) {
		//=== case 1
		int m1 = 0;
		for (int i = 0; i < A; i++) { if (v[A - 1] == v[i]) { m1++; } }
		int M = 0;
		for (int i = 0; i < N; i++) { if (v[A - 1] == v[i]) { M++; } }
		ans = C[M][m1];
	}
	else {
		//=== case 2
		long long int VAL = v[A - 1];
		int H = 0; for (int i = 0; i < N; i++) { if (v[i] > VAL) { H++; } }
		int M = 0; for (int i = 0; i < N; i++) { if (v[i] == VAL) { M++; } }

		for (int I = A; I <= min(H + M, B); I++) {
			int m1 = 0; for (int i = 0; i < I; i++) { if (v[i] == VAL) { m1++; } }
			ans += C[M][m1];
		}

	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

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


void solve(long long N, std::vector<long long> a){
    std::vector<long long> ans(N, 0l);
    long long cnt;
    do {
        cnt = 0l;
        for (int i = 0; i < N; i++){
            if(a[i]%2==0){
                a[i] /= 2;
                ans[i]++;
                cnt++;
            }
        }
    }while(cnt > 0l);
    cout << accumulate(ans.begin(), ans.end(), 0l) << endl;
}

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


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var A int
var B int
var K int

func main() {
	A = nextInt()
	B = nextInt()
	K = nextInt()
	min := MinIn2Values(A, B)
	ans := []int{}
	for i := 1; i < 1+min; i++ {
		if A%i == 0 && B%i == 0 {
			ans = append(ans, i)
		}

	}
	fmt.Printf("%v", ans[len(ans)-K])
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

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

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

func MinIn2Values(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pb push_back
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0)
const ll INF=4e18;
const ll MAX=1e5+5;
const ll MOD=1e9+7;
//}}}
ll n,l,t,ans;
ll p[MAX];
int d[MAX];
ll ed[MAX];
int f(){
	if(d[0]==1){
		for(int i=n-1;i>=0;i--)
			if(ed[i]==(p[0]+t%l*d[0]+l)%l)
				return i;
	}
		for(int i=0;i<n;i++)
			if(ed[i]==(p[0]+t%l*d[0]+l)%l)
				return i;
}
int main(){
	IOS;
	cin>>n>>l>>t;
	for(int i=0;i<n;i++){
		cin>>p[i];
		cin>>d[i];	if(d[i]==2)	d[i]=-1;
		ed[i]=(p[i]+t%l*d[i]+l)%l;
	}
	ll p0=ed[0];
	sort(ed,ed+n);
	ll cnt=0;
	for(int i=1;i<n;i++){
		if(d[i]!=d[0]){
			if(d[0]==1){
				ll x=( (p[0]-p[i]+l)%l +t*2)/l;
				cnt+=x;
			}
			else{
				ll x=( (p[i]-p[0]+l)%l +t*2)/l;
				cnt+=x;
			}
		}
	}
	debug(cnt);
	cnt%=n;
	ans=(d[0]*cnt+n)%n;
	int qq=f();
//	cout<<ans<< '\n';
//	cout<<qq<< '\n';
	int m=(qq-ans+n)%n;
	debug(m);
	rotate(ed,ed+m,ed+n);
	for(int i=0;i<n;i++){
		cout<<ed[i]<< '\n';
	}
	return 0;
}

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

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  
  int tuuka=0;
  int kaigai=0;
  string s;
  cin >> s;

  for(int i=0; i < s.size(); i++){
    if(s.at(i) == 'c'){
      cout << "No" << endl;
    }
    
    if(s.at(i) == 'a'){
      if(tuuka < a+b){
        cout << "Yes" << endl;
        tuuka++;
      }
      else{
         cout << "No" << endl;
      }
    }
    
    if(s.at(i) == 'b'){
      if(tuuka < a+b && kaigai < b){
        cout << "Yes" << endl;
        tuuka++;
        kaigai++;
      }
      else{
         cout << "No" << endl;
      }
    }
  }
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N],b[N];
map<int,int>p;
inline int bel(int i){
	return i==p[i]?i:p[i]=bel(p[i]);
}
int main(){
	cin>>n;
	multiset<int>c,d;
	for(int i=1;i<=n;++i)
		cin>>a[i],a[0]^=a[i],c.insert(a[i]);
	c.insert(a[0]);
	for(int i=1;i<=n;++i)
		cin>>b[i],b[0]^=b[i],d.insert(b[i]);
	d.insert(b[0]);
	if(c!=d)
		return!~puts("-1");
	for(int i=1;i<=n;++i)
		if(a[i]!=b[i])
			p[a[i]]=a[i];
	p[a[0]]=a[0];
	int s=-1;
	for(int i=1;i<=n;++i)
		if(a[i]!=b[i])
			p[bel(a[i])]=bel(b[i]),++s;
	for(auto e:p)
		if(e.first==e.second)++s;
	cout<<s<<endl;
}

Measured memory_bytes: 17536
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,x,y;
  int ans = 0;
  cin >> a >> b >> c >> x >> y;
  if(a+b<= 2*c){
    ans += a*x+b*y ;
  }
  else{
    if(x<=y && 2*c<=b){
      ans += 2*c*y;
    }else if(y<=x && 2*c<=a){
      ans += 2*c*x;
    }else if(x<=y && b <= 2*c){
      ans += 2*c*x+(y-x)*b;
    }else if(y<=x && a <= 2*c){
      ans += 2*c*y +(x-y)*a;
    }
  }
  cout << ans <<endl;
}
    
  

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let s_array: Vec<i32> = (0..n).map(|_| read::<i32>()).collect();
    let q: usize = read();
    let t_array: Vec<i32> = (0..q).map(|_| read::<i32>()).collect();

    let mut cnt = 0;

    for t in t_array {
        match s_array.clone().into_iter().find(|&v| v == t) {
            Some(_v) => cnt += 1,
            _ => {}
        }
    }

    println!("{}", cnt);
}



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

int main () {
  int n; 
  cin >> n;
  vector<pair<pair<string,int>,int>> a(n);
    rep(i,n) {
    cin >> a.at(i).first.first >> a.at(i).first.second;
      a.at(i).second = i+1;
    a.at(i).first.second *= -1;
  }
  sort(a.begin(),a.end());
  rep(i,n) cout << a.at(i).second << endl;
}

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

// AtCoder Beginner Contest 138
//オーバーフローに注意！！
//焦らずに！！
int main(){

    string s, t; cin >> s >> t;
    int sz = (int)s.size();

    typedef long long ll;
    const int inf = 1000000;

    vector<vector<int>> al(sz, vector<int>(26, inf));
    vector<int> now(26, inf);
    string u = s + s;
    for(int i = sz + sz - 1; i >= sz; i--){
        now[u[i] - 'a'] = i % sz;
    }

    for(int i = sz - 1; i >= 0; i--){
        rep(j, 26)al[i][j] = now[j];
        now[u[i] - 'a'] = i % sz;
    }

    // rep(i, sz){
    //     rep(j, 26){
    //         if(al[i][j] == inf)cout << setw(3) << -1;
    //         else cout << setw(3) << al[i][j];
    //     }
    //     cout << endl;
    // }

    ll ans = 0;
    int pos = 0;

    bool found = false;
    rep(i, sz){
        if(t[0] == s[i]){
            found = true;
            pos = i;
            ans = i + 1;
            break;
        }
    }

    if(!found){
        cout << -1 << endl;
        return 0;
    }

    rep(i, (int)t.size()){
        if(i == 0)continue;
        int tmp = al[pos][t[i] - 'a'];
        if(tmp == inf){
            cout << -1 << endl;
            return 0;
        }
        if(tmp > pos){
            ans += tmp - pos;
            pos = tmp;
        } else {
            ans += tmp + sz - pos;
            pos = tmp;
        }
    }


    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 13952
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n, N) for(ll i=(n);i<(N);i++)
#define RREP(i, n, N) for(ll i=(N-1);i>=(n);i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(), (v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll K, N;
ll h[100010];

int main() {
    cin>>N>>K;
    REP(i,0,N){
        cin>>h[i];
    }

    sort(h, h+N);

    ll ans = inf;

    REP(i,0,N-K+1){
        ans = min(ans, h[i+K-1]-h[i]);
    }

    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a < b && b < c && a < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17220
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

lin n;
lin a[101];

int main(void)
{
    cin >> n;
    lin t = 0;
    rep(i,n)
    {
        cin >> a[i];
        t += a[i];
        a[i] *= n;
    }

    lin res = 0;
    lin diff = inf;
    rep(i,n)
    {
        lin newDiff = abs(a[i]-t);
        if (diff > newDiff)
        {
            res = i;
            diff = newDiff;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b = IL()
if max(a,b) > 9:
  print(-1)
else:
  print(a*b)

Measured memory_bytes: 38384
// RGB Sequence
// * frank_c1
// * 2017 / 11 / 09

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

const int maxn = 305;
const int mo = (int)(1e9) + 7;
vector<pii> nxt[maxn];
int f[2][maxn][maxn][3];

inline void add(int& x, int v) {
	x += v; if (x >= mo) x -= mo;
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		int l, r, x; scanf("%d%d%d", &l, &r, &x);
		if (r == 1 && x > 1) return printf("0\n"), 0;
		nxt[r].push_back(make_pair(l, x));
	}
	int now = 0, lst = 0, ret = 0;
	for (int i = 0; i < 3; ++i) f[now][0][0][i] = 1;
	for (int i = 1; i <= n; ++i) {
		now = lst ^ 1;
		memset(f[now], 0, sizeof(f[now]));
		for (int j = 0; j < i; ++j) {
			for (int k = 0; k < i; ++k) {
				for (int w = 0; w < 3; ++w) {
					int a = 0, b = 0, c = 0;
					if (w == 0) {
						a = i; b = j; c = k;
					} else if (w == 1) {
						a = j; b = i; c = k; 
					} else if (w == 2) {
						a = j; b = k; c = i;
					}
					int succ = 1;
					for (int e = 0; e < (int)nxt[i].size(); ++e) {
						int l = nxt[i][e].first, x = nxt[i][e].second;
						x -= (l <= a) + (l <= b) + (l <= c); if (x) {
							succ = 0; break;
						}
					}
					if (succ) {
						if (i == n) add(ret, f[lst][j][k][w]);
						else {
							for (int s = 0; s < 3; ++s) {
								int na = a, nb = b, nc = c;
								if (s == 0) na = i + 1;
								else if (s == 1) nb = i + 1;
								else if (s == 2) nc = i + 1;
								int nj = 0, nk = 0, nw = 0;
								if (na == i + 1) nj = nb, nk = nc, nw = 0;
								else if (nb == i + 1) nj = na, nk = nc, nw = 1;
								else if (nc == i + 1) nj = na, nk = nb, nw = 2;
								add(f[now][nj][nk][nw], f[lst][j][k][w]);
							}
						}
					}
				}
			}
		}
		lst = now;
	}
	return printf("%d\n", ret), 0;
}

Measured memory_bytes: 2432
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    // cout << fixed << setprecision(15) << solve<string>() << endl;
    int S; cin >> S;
    while(S--){
        vector<ll> N(9); for(auto& in:N) cin >> hex >> in;
        // cout << N << endl;
        
        ll K = 0;
        for(int i = 0; i < 32;i++){
            ll S = 0;
            for(int j = 0; j < 8;j++){
                S += N[j]^K;
            }
            S %= 1LL<<(i+1);
            ll n = (N[8]^K) % (1LL<<(i+1));
            if(S != n) K += (1LL<<i);
        }
        cout << hex << K << endl;
    }
    return 0;
}



Measured memory_bytes: 3116
# -*- coding: utf-8 -*-

def main():
    n = input()
    k = int(input())

    print(tmp(n, k))

def tmp(x, k):
    # k が 桁数以上の場合、パターンなし
    if len(x) < k:
        return 0
    # k が 0 の場合、全て 0 の 1パターン
    if k <= 0:
        return 1
    if len(x) == k == 1:
        return int(x)
    else:
        int_x = list(map(int, list(x)))
        next_x = str(int(x[1:]))

        # 最大桁を k の 1つとする場合、最大値の場合と それ以外の場合で計算が異なる。
        a = tmp(next_x, k-1)
        # 最大値, 0 以外の場合は、以下の桁は全ての値を取り得る
        b = (int_x[0]-1) * pow(9, k-1) * combination(len(x)-1, k-1)
        # 最大桁を k の 1つとしない場合（最大桁を0とみなす）
        c = pow(9, k) * combination(len(x)-1, k)

        return a + b + c

def combination(n, k):
    m = 1
    l = 1
    for i in range(n, n-k, -1):
        m = m * i

    for j in range(k, 0, -1):
        l = l * j
    
    return int(m / l)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
/*
 * I'm strong. Stronger than all of you. Extremely strong.
 * I can kill all those Titans there. Even if I'm alone.
 * You're either incompetent or you're spineless cowards.
 * How pathetic.
 * You can sit here and suck on your fingers. Yeah, do that.
 * ~ Mikasa Ackerman
 */

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

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

#define endl '\n'
const int N = 2e5 + 10;
int x[N];
int main() {
  fast_io;
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    x[a]++;
  }
  VII a;
  for (int i = 0; i < N; i++)
    if (x[i])
      a.PB({x[i], i});
  sort(ALL(a));
  int ans = 0;
  for (int i = 0; i < SZ(a) - k; i++)
    ans += a[i].F;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3188
#include<stdio.h>

int main(){
    int n;
    scanf("%d",&n);
    char s[n];
    scanf("%s",s);

    int x=0;
    int max=0;;
    for(int i=0;i<n;i++){
        if(s[i]=='I'){
            x++;
        }else{
            x--;
        }
        if(x>max){
            max=x;
        }
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 1692
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string S; cin >> S;
  if(S[2] == S[3] && S[4] == S[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main( ){
  int n,a,max=-1000001,min=1000001;
  long long sum=0;
  scanf("%d",&n);
  for( int i = 0 ; i <= n-1 ; i++ ){
    scanf("%d",&a);
    if( a > max ){
      max = a ;
    }
    if( a < min ){
      min = a ;
    }
    sum += a ;
  }
  printf("%d %d %lld\n",min,max,sum);
  return 0;
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll n;
    cin>>n;
    vector<ll>a(n);
    ll maxa[n+1];
    maxa[0]=0;
    rep(0,i,n){
        cin>>a[i];
        maxa[i+1]=max(maxa[i],a[i]);
    }
    bool t=true;
    rep(0,i,n){
        if(maxa[i+1]-a[i]>1)t=false;
    }
    if(t)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 1792
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入
// UnionFind
struct UnionFind {
    vector< int > data;
    
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
 
    bool unite(int x, int y) {//要素xとyの各々の木を併合（もともと同じ木ならfalse）
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
    
    int find(int k) {//要素kが属する木の根を得る
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
    
    int size(int k) {//要素kが属する木の要素数
        return (-data[find(k)]);
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }

};

int main(){
    int N,M,K;
    cin>>N>>M>>K;
    UnionFind friends_candi(N);
    int a,b;
    vector<vector<int>> No(N);
    REP(i,M){
        cin>>a>>b;
        a--;
        b--;
        No[a].push_back(b);
        No[b].push_back(a);
        friends_candi.unite(a,b);
    }

    REP(i,K){
        cin>>a>>b;
        a--;
        b--;
        No[a].push_back(b);
        No[b].push_back(a);
    }
    int ans;
    REP(i,N){
        ans=friends_candi.size(i)-1;
        REP(j,No[i].size()){
            if(friends_candi.same(i,No[i][j])){
                ans--;
            }
        }
        cout<<ans;
        if(i!=N-1) cout << " ";
        else cout<<endl;
    }


}

Measured memory_bytes: 7936
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<cstring>
#include<fstream>
//#include<queue>
//#include<stack>
using namespace std;

int main()
{
	string s;
	const string target = "keyence";

	cin >> s;
	if (s == target) {
		cout << "YES" << endl;
		return 0;
	}
	int n = s.size();

	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			string t;
			for (int k = 0; k < n; k++) {
				if (i <= k && k < j)
					continue;
				t.push_back(s[k]);
			}
			if (t == target) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;

}

Measured memory_bytes: 256
n = input()
lenn = len(n)

dp = [0, 10000]
for d in reversed(n):
    d = int(d)
    dp = [min(d + dp[0], d + 1 + dp[1]), min(10 - d + dp[0], 9 - d + dp[1])]

print(min(dp[0], 1 + dp[1]))

Measured memory_bytes: 75988
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,ans;
	cin>>n;
	m=(n-n%100)/100;
	ans=m*111;
	if(ans<n)
	{
		ans=(m+1)*111;
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // スペース区切りの整数の入力
    int N,K;
    cin >> N >> K;

	int ans;
	if (N % K == 0){
		ans = 0;
	}else{
		ans = 1;
	}

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

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

int main()
{
  i64 X, Y;
  cin >> X >> Y;
  i64 ans = 0;
  if (X == 3)
    ans += 100000;
  else if (X == 2)
    ans += 200000;
  else if (X == 1)
    ans += 300000;
  if (Y == 3)
    ans += 100000;
  else if (Y == 2)
    ans += 200000;
  else if (Y == 1)
    ans += 300000;
  if (X == 1 && Y == 1)
    ans += 400000;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
long long n,k,a,ans;
long long num[12][8]={-1,-1,-1,-1,-1,-1,-1,-1,
					  -1,-1,4,2,0,9,7,-1,
					  -1,-1,1,10,8,6,4,-1,
					  -1,-1,9,7,5,3,1,-1,
					  -1,-1,6,4,2,0,9,-1,
					  -1,-1,3,1,10,8,6,-1,
					  -1,-1,0,9,7,5,3,-1,
					  -1,-1,8,6,4,2,0,-1,
					  -1,-1,5,3,1,10,8,-1,
					  -1,-1,2,0,9,7,5,-1,
					  -1,-1,10,8,6,4,2,-1,
					  -1,-1,7,5,3,1,10,-1};
int main()
{
	scanf("%lld%lld",&n,&k);
	n-=2;
	ans=(n/11)*5;
	a=n%11;
	for(int i=1;i<=a;i++)
	for(int j=1;j<=7;j++)
	if(num[i][j]==k) ans++;
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = Integer.parseInt(in.nextLine());
        final int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        in.nextLine();
        long curr = 1000;
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] - arr[i - 1] > 0) {
                final long buy = curr / arr[i - 1];
                curr %= arr[i - 1];
                final long profit = arr[i] * buy;
                curr += profit;
            }
        }
        System.out.println(curr);
    }
}


Measured memory_bytes: 36100
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <queue>
using namespace std;

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

int main(){
    int k,n ;
    cin >> n >> k ;
    vector<int> p(n) ;
    for (int i = 0; i < n; i++)
    {
        cin >> p.at(i) ;
    }
    sort(p.begin(),p.end()) ;
    int ans = 0 ;
    for (int i = 0; i < k; i++)
    {
        ans += p.at(i) ;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
 
  public static void main(String[] args) {
  	Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int a2 = a * a;
    int a3 = a2 * a;
    System.out.println(a + a2 + a3);
  }
}


Measured memory_bytes: 35784
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string str;
long long cnt[216000];
int main(){
  cin >> str;
  for(int i = 0;i < str.size();i++)cnt[str[i]]++;

  long long res = str.size();
  res = res * (res + 1) / 2;
  for(int i = 'a';i <= 'z';i++){
    res -= cnt[i] * (cnt[i] + 1) / 2;
  }
  cout << res + 1 << endl;

  return 0;
}

Measured memory_bytes: 832
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };

string a;

signed main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	cin >> a;
	REP(i, 4) {
		cout << a[i];
	}

	cout << " ";

	FOR(i, 4, 12) {
		cout << a[i];
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal N = decimal.Parse(ReadLine());
            Write(N % 2 == 0 ? Floor(N /2)/N : (Floor(N / 2) + 1)  /N);
        }
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <stdio.h>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>

using namespace std;

#define x first
#define y second
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(),x.end()
#define SZ(x) int(x.size())
#define rep(i, a, b) for(int i = a; i < b; i++)
#define per(i, a, b) for(int i = b-1; i >= a; i--)
#define DBG(x) cerr << (#x) << "=" << x << "\n";
#define ll long long
#define inf 1000000007
#define mod 998244353 //1000000007
#define N 405

template<typename U, typename V> void Min(U &a, const V & b){if(a > b)a = b;}
template<typename U, typename V> void Max(U &a, const V & b){if(a < b)a = b;}
template<typename U, typename V> void add(U &a, const V & b){a = (a + b) % mod;} 
template<typename U> U gcd(U a, U b){
	if(a == 0)return b;
    if(b == 0)return a;
	if(a >= b)return gcd(a-b, b);
	else return gcd(a, b - a);
} 
int pow(int a, int b){
    int ans = 1;
    while(b){
        if(b & 1)ans = 1LL * ans * a % mod;
        a = 1LL * a * a % mod;
        b >>= 1;
    }
    return ans;
}

int a[N], b[N], dp[N][N], p[N][N], f[N], inv[N];
int main(){
    int T, m, n, i, j, k, K;
    f[0] = 1;
    rep(i, 1, N)f[i] = f[i-1] * (ll)i % mod;
    inv[N-1] = pow(f[N-1], mod-2);
    per(i, 0, N-1)inv[i] = inv[i+1] * (ll)(i+1) % mod;
    scanf("%d", &n);
    rep(i, 0, n)scanf("%d%d", &a[i], &b[i]);
    rep(i, 1, N){
        p[i][0] = 1;
        rep(j, 1, N){
            p[i][j] = 1LL * p[i][j-1] * i % mod;     
        }
    }
    dp[0][0] = mod-1;
    int sa = 0, sb = 0;
    rep(i, 0, n){
        per(j, 0, sa+1){
            per(k, 0, sb+1){
                int &w = dp[j][k];
                if(!w)continue;
                rep(l, 0, b[i]){
                    add(dp[j+a[i]][k+l], mod -1LL * w * p[a[i]][l] % mod * inv[l] % mod);
                }
            }
        }
        sa += a[i];
        sb += b[i];
    }
    ll ans = 0;
    rep(i, 0, sa+1){
        rep(j, 0, sb){
            if(dp[i][j]){
                int w = pow(p[i][j+1], mod-2);
                ans += 1LL * dp[i][j] * w %mod * f[j] % mod;
            }
        }
    }
    ans = ans % mod * sa % mod;
    printf("%lld\n", ans);
}


Measured memory_bytes: 1536
import java.util.Scanner;

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

		yobo=new int[M][2];
		int[] range=new int[2];
		int hashi=1;

		for(int i=0; i<M; i++) {
			yobo[i][0]=sc.nextInt();
			yobo[i][1]=sc.nextInt();
		}
		quick_sort(yobo, 0, M-1);
		for(int i=0; i<M; i++) {
			if(i==0) {
				range[0]=yobo[0][0];
				range[1]=yobo[0][1];
			}
			else {
				if(Math.min(range[1],yobo[i][1])-Math.max(yobo[i][0], range[0])>=1) {
					range[0]=Math.max(yobo[i][0], range[0]);
					range[1]=Math.min(yobo[i][1], range[1]);
				}
				else {
					hashi++;
					range[0]=yobo[i][0];
					range[1]=yobo[i][1];
				}
			}
		}
		System.out.println(hashi);
	}
	    static void quick_sort(int[][] d, int left, int right) {
	        if (left>=right) {
	            return;
	        }
	        int p = d[(left+right)/2][0];
	        int l = left, r = right, tmp,tmp1,tmp2;
	        while(l<=r) {
	            while(d[l][0] < p) { l++; }
	            while(d[r][0] > p) { r--; }
	            if (l<=r) {
	                tmp = d[l][0]; d[l][0] = d[r][0]; d[r][0] = tmp;
	                tmp1=d[l][1]; tmp2=d[r][1]; d[l][1]=tmp2; d[r][1]=tmp1;
	                l++; r--;
	            }
	        }
	        quick_sort(d, left, r);
	        quick_sort(d, l, right);
	    }
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    string s;
    cin >> s;
    
    int counter = 0;
    
    for (int i = 0; i < 4; i++) {
        if (s.at(i) == '+') counter++;
        if (s.at(i) == '-') counter--;
    }
    
    cout << counter << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h> 
#include <vector>
#include <algorithm>
#include <iomanip>      // std::setprecision
#include <map>
#include <unordered_map>
#include <string>
#include <set>

using namespace std;

int main()
{

	double N = 0;
	std::unordered_map<string, int> vote_map;
	std::set<string> sol;
	std::cin >> N;
	int max_count = 0;
	for (int i = 0; i < N; i++)
	{
		std::string key;
		std::cin >> key;
		vote_map[key]++;
		if (vote_map[key] > max_count)
		{
			max_count = vote_map[key];
		}
	}

	for (auto it = vote_map.begin(); it!=vote_map.end(); ++it)
	{
		if (it->second == max_count)
		{
			sol.insert(it->first);
		}
	}

	for (auto it = sol.begin(); it != sol.end(); ++it)
	{
		std::cout << *it << std::endl;
	}
}


Measured memory_bytes: 33480
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Array.Sort(line);
            Console.WriteLine(line[0] + line[1] == line[2] ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 11220
fun main(args: Array<String>) {
    val ints = rspint()
    function(ints)
}

fun function(ints: List<Int>) {
    println("${ints[2]} ${ints[0]} ${ints[1]}")
}

fun rl() = readLine()!!
fun rsp() = readLine()!!.split(" ")
fun rint() = readLine()!!.toInt()
fun rspint() = readLine()!!.split(" ").map { it.toInt() }

Measured memory_bytes: 37728
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll h,w;
	cin>>h>>w;
	ll dp[h+1][w+1];
	char a;
	for(ll i=1;i<=h;i++)
	{
	    for(ll j=1;j<=w;j++)
	    {
	        cin>>a;
	        if(a=='#')
	        dp[i][j]=0;
	        if(a=='.')
	        dp[i][j]=-1;
	    }
	}
	

	
	
	
	for(ll i=1;i<=h;i++)
	{
	    for(ll j=1;j<=w;j++)
	    {
	        if(dp[i][j]!=0)
	        {
	            if(i==1&&j==1)
	            dp[i][j]=1;
	            else if(i==1 && j>1)
	            dp[i][j]=dp[i][j-1];
	            else if(j==1 && i>1)
	            dp[i][j]=dp[i-1][j];
	            else{
	                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007;
	            }
	        }
	    }
	}
	
/*	for(ll i=1;i<=h;i++)
	{
	    for(ll j=1;j<=w;j++)
	    cout<<dp[i][j]<<" ";
	    cout<<endl;
	}   */
	
	
	cout<<dp[h][w];
	
	return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int a[200000],b[200000];
int main(){
	int n,m;cin>>n>>m;
	vector<P>v;
	rep(i,n){
		scanf("%d%d",&a[i],&b[i]);
		v.push_back(P(b[i],a[i]));
	}
	sort(v.begin(),v.end(),[](P a,P b){return a.second<b.second;});
	priority_queue<P>que;
	int s=0;
	ll sum=0;
	for(int i=0;i<=m;i++){
		while(s<v.size()&&v[s].second<=i){
			que.push(v[s++]);
		}
		if(!que.empty()){
			P p=que.top();que.pop();
			sum+=p.first;
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3316
#-*-coding:utf-8-*-

def main():
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())

    if k < n:
        ans = k * x + (n - k) * y
    else:
        ans = n * x
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060