akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long long arr[200001],first[200001],idx[200001],N,K,mod=0,pos;
int main(){
	cin>>N>>K;
	for(long long i=1; i<=N; i++){
		cin>>arr[i];
	}
	long long curr=1;
	for(long long i=1; i<=K; i++){
		if(first[curr]==0){
			first[curr]=i;
			idx[i]=curr;
			curr=arr[curr];
		}else{
			mod=i-first[curr];
			pos=first[curr];
			break;
		}
	}
	if(mod==0){
		cout<<curr<<'\n';
	}else{
		cout<<idx[(K+1-pos)%mod+pos]<<'\n';
	}
}

Measured memory_bytes: 7980
# ABピザを使うんなら効率的に使う、をやるとO(1)
a, b, c, x, y = map(int, input().split())
t = (x - y) * a if x > y else (y - x) * b
# 順に、ABピザを「使わない」「一部使う（必要枚数が少ないほうに合わせる。不足するピザはそのピザだけを買う）」「全部使う（必要枚数が多い方に合わせる。あまったピザ上等）」
print(min(a * x + b * y, 2 * c * min(x, y) + t, 2 * c * max(x, y)))


Measured memory_bytes: 9168
#include<stdio.h>
int main(void)
{
	int a[10],i,j,tmp;
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<10;i++){
		for(j=i+1;j<10;j++){
			if(a[i]<a[j]){
				tmp=a[j];
				a[j]=a[i];
				a[i]=tmp;
			}
		}
	}
	printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
	return 0;
}
			
	
	

Measured memory_bytes: 1028
#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];
	int n, i;

	scanf("%s", s), n = strlen(s);
	for (i = 0; i < n; i++)
		s[i] = 'x';
	printf("%s\n", s);
	return 0;
}


Measured memory_bytes: 128
from itertools import *

try:
    while True:
        a, p = 'apple', 'peach'
        b = raw_input()
        for i in count(0):
            if i >= len(b): break
            if b[i:i + len(a)] == a:
                b = b[:i] + p + b[i + len(a):]
            elif b[i:i + len(p)] == p:
                b = b[:i] + a + b[i + len(p):]
        print b
except EOFError:
    pass

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main(){
  int X, Y, Z ,K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X); rep(i,X) cin >> A[i];
  vector<ll> B(Y); rep(i,Y) cin >> B[i];
  vector<ll> C(Z); rep(i,Z) cin >> C[i];
  sort(A.rbegin(), A.rend());
  sort(B.rbegin(), B.rend());
  sort(C.rbegin(), C.rend());

  vector<ll> E;
  
  sort(E.rbegin(), E.rend());

  vector<ll> ans;
  for(int i = 0; i < X; i++){
    for(int j = 0; j < Y; j++){
      for(int k = 0; k < Z; k++){
        if((i+1) * (j+1) * (k+1) <= K) ans.push_back(A[i]+B[j]+C[k]);
        else break;
      }
    }
  }

  sort(ans.rbegin(), ans.rend());
  for(int i = 0; i < K; i++) cout << ans[i] << endl;
  return 0;
}



Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,k;
  cin>>n>>k;
  long long arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  long long dp[n];
  memset(dp,1000000007,sizeof(dp));
  dp[0]=0;
  for(int i=1;i<n;i++)
  {
    for(int j=1;j<=k;j++)
    {
      if(i-j>=0)
      {
        dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
                  }
                  }
                  }
                  cout<<dp[n-1];
}

Measured memory_bytes: 1792
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N;
    scan(N);
    auto lb = (100 * N + 107) / 108;
    auto ub = (100 * (N + 1) + 107) / 108;
    foreach (x ; lb .. ub) {
        if (x * 108 / 100 == N) {
            writeln(x);
            return;
        }
    }
    writeln(":(");
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

int main(){

    int N;
    cin >> N;
    int S;
    S = N%1000;
    int S1 = 0;
    if (S != 0){

        S1 = 1000-S;

    }

    cout << S1 << endl;
}

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

int main() {
  int N;
  long long W;
  cin >> N >> W;
  vector<long long>w(N);
  vector<int>v(N);
  for (int i = 0; i < N; i++) {
    cin >> w.at(i) >> v.at(i);
  }
  long long sum_of_weight = 0;
  int sum_of_value = 0;
  for (int i = 0; i < N; i++) {
    sum_of_weight += w.at(i);
    sum_of_value += v.at(i);
  }
  vector<vector<long long>>dp(N+1, vector<long long>(sum_of_value+1));
  for (int i = 0; i < N+1; i++) {
    for (int j = 0; j < sum_of_value+1; j++) {
      dp.at(i).at(j) = sum_of_weight + 1;
    }
  }
  dp.at(0).at(0) = 0;
  for (int i = 1; i < N+1; i++) {
    for (int j = 0; j < sum_of_value+1; j++) {
      if (j >= v.at(i-1)) {
        dp.at(i).at(j) = min(dp.at(i-1).at(j), dp.at(i-1).at(j-v.at(i-1)) + w.at(i-1));
      }
      else {
        dp.at(i).at(j) = dp.at(i-1).at(j);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N+1; i++) {
    for (int j = 0; j < sum_of_value+1; j++) {
      if (W >= dp.at(i).at(j) && ans < j) {
        ans = j;
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 80256
<?php

class Operator
{
    private $operations;
    private $operations_count;

    public function doOperations()
    {
        fscanf(STDIN, '%d', $this->operations_count);
        $this->operations = new \SplDoublyLinkedList();
        for (;$this->operations_count > 0;$this->operations_count -= 1) {
            $operation = trim(fgets(STDIN));
            if ($operation[0] === 'i') {
                $this->operations->unshift(substr($operation, 7));
            } elseif ($operation[6] === 'F') {
                $this->operations->shift();
            } elseif ($operation[6] === 'L') {
                $this->operations->pop();
            } else {
                foreach ($this->operations as $key => $element) {
                    if ($element === substr($operation, 7)) {
                        $this->operations->offsetUnset($key);
                        break;
                    }
                }
            }
        }
    }

    public function getAnswer()
    {
        while (1) {
            if (count($this->operations) > 0) {
                $keys_operated[] = $this->operations->shift();
            } else {
                break;
            }
        }
        echo implode(' ', $keys_operated), PHP_EOL;
    }
}

$operator = new Operator();
$operator->doOperations();
$operator->getAnswer();



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


int main()
{
        int a,b,c;
        cin >> a>>b>>c;
        if(a==b)
        {
                if(b!= c)
                {       
                        cout << "Yes" << endl;
                }
                else{
                        cout << "No" <<endl;
                }
        }
        else if(b==c)
        {
                if(a!= b)
                {
                        cout << "Yes" << endl;
                }
                else{
                        cout << "No" <<endl;
                }
        }        
        else if(a==c)
        {
                if(b!= c)
                {
                        cout << "Yes" << endl;
                }
                else{
                        cout << "No" <<endl;
                }
        }

        else{
                cout << "No" <<endl;
        }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
using namespace std;


int main(){
	/*input*/
	string s;
	cin >> s ;

	/*calc*/
    int ans = 753;
    int get3;
    int differ;
    for(unsigned int i = 0; i < s.length() - 2; i++){
    	/*i番目から3つ分の文字を取得*/
    	string tmp = s.substr(i, 3);

    	/*string-int*/
    	get3 = stoi(tmp);
//    	get3 = atoi(tmp.c_str());	//tmpのポインタ

    	/*753との差（絶対値）を求める*/
    	differ = abs(753 - get3);
    	ans = min(ans, differ);
    }

    /*output*/
	cout<< ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
	ll l, r;
	cin >> l >> r;

	ll result = 2019;
	if(l == 0 || r - l >= 2019) {
		result = 0;
	} else {
		for(ll i = l; i <= r; i++) {
			for(ll j = i+1; j <= r; j++) {
				result = min(result, (i * j) % 2019);
			}
		}
	}

	cout << result << endl;

	return 0;
}

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

int main()
{
    int r, d, x0;
    cin >> r >> d >> x0;
    for (int i = 2001; i <= 2010; i++)
    {
        int a = x0 * r - d;
        cout << a << endl;
        x0 = a;
    }
    return 0;
}

Measured memory_bytes: 256
/*
    Failure is not the reason for you to stop trying 
       it is actually a remainder that you should 
            KEEP GOING 
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ar[N];
int dp[N];
signed main(){
    SaveTime;
    int T=1;
    // cin >> T;
    while(T--){
        int n;
        cin >> n ;
        if(n&1)return cout<<0,0;
      	 if(n<10)return cout << 0,0;
      int t , f ,ans=0ll;
      f=1ll;
      while(n/f >=1){
      f*=5ll;
        ans+=n/(f*10ll);
      }
      ans+=(n/10ll);
        cout<<ans<<endl;
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}

//124999999999999995
//24999999999999995

Measured memory_bytes: 256
from collections import *
n,k=map(int,input().split())
s=input()
q=deque()
tt=0
f=False
t=0
ans=0
tmp=0
for i in range(n):
    if f:
        if s[i]=="0":
            tmp+=1
            tt+=1
            if tmp>ans:
                ans=tmp
        else:
            q.append(tt)
            f=False
            tt=1
            tmp+=1
            if tmp>ans:
                ans=tmp

    elif f==False:
        if s[i]=="1":
            tmp+=1
            tt+=1
            if tmp>ans:
                ans=tmp
        else:
            t+=1
            f=True
            if t>k:
                d=q.popleft()
                tmp-=d
            tmp+=1
            tt+=1
print(ans)

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+4;
string s;
vector <int> v;
int deg[N];
int main()
{
	cin>>s;
	int n = s.length();
	s = "a" + s;
	if(s[1] == '0' || s[n] == '1') return cout<<-1, 0;
	
	for(int i=1;i<n;i++)
	{
		if(s[i] == '1')
			v.push_back(i);
			
		if(s[i] != s[n-i]) return cout<<-1, 0;
	}

	deg[1] = v[0]-1; 
	for(int i=1;i<(int)v.size();i++)
	{
		deg[i+1] = v[i]-v[i-1]-1;
	}

	int run = 1, idx = 1;
	// for(int i=1;i<=(int)v.size();i++)
	// {
	// 	cout<<deg[i]<<' ';
	// }
	for(int i=1;i<=(int)v.size();i++)
	{
		// cout<<deg[i]<<' ';
		for(int j=1;j<=deg[i];j++)
		{
			cout<<idx<<' '<<++run<<'\n';
		}
		if(run != n)
			cout<<idx<<' '<<++run<<'\n';
		idx = run;
	}
}

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

typedef long long lli;

int main() {
  for(int N; cin >> N;) {
    vector<lli> A(N*4);
    for(int i = 0; i < N; ++i) {
      cin >> A[i];
      A[N+i] = A[2*N+i] = A[3*N+i] = A[i];
    }
    A.insert(A.begin(), 0);
    for(int i = 0; i+1 < A.size(); ++i) A[i+1] += A[i];

    lli res = 0;
    for(int a = 0; a < N; ++a) {
      int L = a+1, R = a+N+1;
      while(R-L) {
        int b = (L+R)/2;
        lli mini = A[b] - A[a];
        int c = lower_bound(A.begin(), A.end(), A[b]+mini) - A.begin();
        int d = lower_bound(A.begin(), A.end(), A[c]+mini) - A.begin();
        if(c-b > 0 && d-c > 0 && d-a <= N) {
          L = b + 1;
        } else {
          R = b;
        }
      }
      res = max(res, A[L-1] - A[a]);
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 8992
a, b = map(int, input().split(" "))

checker = True

if b==1:
    print(0)
    checker = False

if checker and a >= b:
    print(1)
    checker = False

    
counter = 1
tmp = a

while checker:
    tmp += a-1
    if tmp >= b:
        checker = False
        counter += 1
        print(counter)
    else:
        counter += 1


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

#define MOD 1000000007

long long X[100005], A[100005];

long long power(long long N, long long expo)
{
    N%= MOD;
    long long ans = 1;

    while(expo)
    {
        if(expo%2)
            ans = ans*N%MOD;

        N = N*N%MOD;
        expo /= 2;
    }

    return ans;
}

long long solve(long long N)
{
    for(int i=1; i<N; i++)
        A[i] = X[i+1] - X[i];

    N = N-1;
    long long ans = 0;

    for(int i=1; i<=N; i++)
    {
        long long x = (long long)i*(N-i+1)%MOD;
        ans += A[i]*x%MOD;
    }

    return ans%MOD;
}

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

    for(int i=1; i<=N; i++)
        cin >> X[i];

    long long ans = solve(N);

    for(int i=1; i<=M; i++)
        cin >> X[i];

    ans = ans*solve(M)%MOD;

    cout << ans << endl;

    return 0;
}


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

print(0)
lf = input()
if lf == "Vacant":
    exit()

print(n-1)
rf = input()
if rf == "Vacant":
    exit()
l = 0
r = n-1

while True:
    k = (l+r)//2
    print(k)
    f = input()
    if f == "Vacant":
        exit()
    else:
        if (abs(r-k) % 2 == 1 and rf == f) or (abs(r-k) % 2 == 0 and rf != f):
            l = k
            lf = f
        elif (abs(l-k) % 2 == 1 and lf == f) or (abs(l-k) % 2 == 0 and lf != f):
            r = k
            rf = f

Measured memory_bytes: 3660
# -*- coding: utf-8 -*-
import datetime

S = input()

S_datetime = datetime.datetime.strptime(S, '%Y/%m/%d')

last_heisei_datetime = datetime.datetime.strptime('2019/04/30', '%Y/%m/%d')

if S_datetime <= last_heisei_datetime:
    print('Heisei')
else:
    print('TBD')


Measured memory_bytes: 4336
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi;
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;
}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;
}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();
    }
    return ret;
}
#endif

void init_global_C() {}

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

    int N; cin >> N;
    vi a(N); REP(i, N) cin >> a[i];

    deque<int> dq;
    dq.push_back(a[0]);

    FOR(i, 1, N) {
        if (i % 2 == 1) {
            if (N%2==0) dq.push_front(a[i]);
            else dq.push_back(a[i]);
        } else {
            if (N%2==0) dq.push_back(a[i]);
            else dq.push_front(a[i]);
        }
    }

    REP(i, N - 1) {
        cout << dq[i] << " ";
    }
    cout << dq[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 3840
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const ll INF = std::numeric_limits<long long>::max();
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define sz size
const ll mod = 1000000007;
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll n,m,def,ans=1;
int main() {
	cin >> n >> m;
	def = abs(n - m);
	if (def < 2) {
		for (ll i = 1; i <= n;++i) {
			ans *= i;
			ans %= mod;
		}
		for (ll i = 1; i <= m; ++i) {
			ans *= i;
			ans %= mod;
		}
		if (def == 0)ans *= 2;
		ans %= mod;
		cout << ans << endl;
	}
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

template <typename T> T gcd(T x, T y) { return( y ? gcd(y, x % y) : x); }
template <typename T> T lcm(T x, T y) { return( x / gcd(x, y) * y); }
template <typename T> void printVec(vector<T> &vec) {
  cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  string s;
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "AC") {
      ac++;
    } else if (s == "WA") {
      wa++;
    } else if (s == "TLE") {
      tle++;
    } else {
      re++;
    }
  } 
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
	return 0;
}


Measured memory_bytes: 3632
var
i,j,c,d,e,b,n:longint;
s1,s2,s3,s4:string;
s:array[1..100000] of string;
begin
readln(n,c);
for i:=1 to n do
readln(s[i]);
for i:=1 to n-1 do
for j:=i+1 to n do
if s[i]>s[j] then begin s1:=s[i];s[i]:=s[j];s[j]:=s1;end;
for i:=1 to n do
write(s[i]);
end.

Measured memory_bytes: 896
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int power10(int n){
	int m = 1;
	for(int i=0 ; i<n ; i++, m*=10);
	return m;
}

int main(){
	vector<int> hoge;
	char s[10];
	int n, min, max, ans;

	scanf("%d", &n);
	for(int i=0 ; i<n ; i++){
		hoge.clear();
		max = 0;
		min = 0;
		
		scanf("%s", s);

		for(int j=0 ; j<8 ; j++){
			hoge.push_back(s[j]-48);
		}
		sort( hoge.begin() , hoge.end() );
		for(int j=0 ; j<8 ; j++){
			max += hoge[7-j]*power10(7-j);
			min += hoge[j]*power10(7-j);
		}
		ans = max - min;
		printf("%d\n",ans);
	}	
	return 0;
}

Measured memory_bytes: 0
//============================================================================
// Name        : HelloCPP.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <stdio.h>
using namespace std;

int main() {

	int a,b;
	char op;
	double r;
	double pi = 3.141592653589;

	while(1){
		cin >> a >> op >> b;

		if(op == '?'){
			break;
		}

		if (op == '+'){
			printf("%d\n",a + b);
		}else if(op == '-'){
			printf("%d\n",a - b);
		}else if(op == '*'){
			printf("%d\n",a * b);
		}else if(op == '/'){
			printf("%d\n",a / b);
		}

	}

	return 0;
}

Measured memory_bytes: 3180
import math
import itertools

def distance(x0, y0, x1, y1):
  dis = math.sqrt((x0-x1)**2 + (y0 - y1)**2)
  return dis

n = int(input())
x = []
y = []
for i in range(n):
    x1, y1 = [int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

sum_one_dis = 0
sum_all = 0

cnt = 0
for i in itertools.permutations([i for i in range(n)]):
    k = list(i)
    for idx in k:
      if idx >= 1:
        sum_one_dis += distance(x[i[idx-1]], y[i[idx-1]], x[i[idx]], y[i[idx]])
    cnt += 1

ave = sum_one_dis / cnt
print(round(ave, 10))
    


Measured memory_bytes: 3188
import math

def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False
        prime += step
        step = 6 - step
    return True

X = int(input())
while not is_prime(X):
  X += 1
print(X)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>

using namespace std;
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

int main()
{
	ll N, M, K;
	cin >> N >> M >> K;
	
	mint ans = 0;
	mint NN[200001];
	NN[0] = 1;
	for(int i = 1; i <= 200000; i++){
		NN[i] = NN[i-1] * i;
	}
	
	for(int k = 0; k <= K; k++){
		mint M_ = M;
		mint p = M-1;
		mint add = M_ * p.pow(N-k-1);
		add = add * ((NN[N-1] / NN[N-1-k]) /NN[k]);
		ans += add;
	}
	
	cout << ans.x << endl;
	
	return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <vector>
#include <numeric>
#include <iomanip>
using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    vector<double> x(n, 0.0);
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        x[i] = (a + 1.0) / 2.0;
    }
    auto ans = accumulate(x.begin(), x.begin() + k, 0.0); // double
    auto cur = ans;
    for(int i = k; i<n; i++){
        cur += x[i];
        cur -= x[i-k];
        ans = max(cur, ans);
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
		int k[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
		int s;
		scanf("%d",&s);
		printf("%d\n",k[s-1]);
		return 0;
	}
		


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	string s;cin>>s;
	long dp[size][13]={};int t,m;
    int mojulo[6]={1,10,9,12,3,4};
	rep(i,0,s.size()){
		if(s.at(s.size()-1-i)!='?'){
			t=(int)s.at(s.size()-1-i)-48;
			if(i==0){ dp[i][t]=1;continue; }
			rep(j,0,13){
                m=(j+mojulo[i%6]*t)%13;
				dp[i][m]=dp[i-1][j];
			}
		}else{
            if(i==0){
                rep(j,0,13) dp[i][j]=(j<10 ? 1:0);
                continue;
            }rep(j,0,13)rep(k,0,10){
                m=(j+mojulo[i%6]*k)%13;
				(dp[i][m]+=dp[i-1][j])%=mod;
			}
		}
	}cout<<dp[s.size()-1][5]<<endl;
    //pprint(dp,s.size(),13);
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (x)%mo_num
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define sc second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
struct node{
    int to,num;
};
vct T[maxn];
int dp[maxn][4];
queue<node>B;
int32_t main()
{
    IOS
    cin>>n>>m;
    fum(i)
    {
        int u,v;
        cin>>u>>v;
        T[u].pb(v);
    }
    int s,t;
    cin>>s>>t;
    memset(dp,-1,sizeof dp);
    dp[s][0]=0;
    B.push({s,0});
    while(!B.empty())
    {
        auto tp=B.front();
        B.pop();
        int v=tp.to,prenum=tp.num;
        fa(i,T[v])
        {
            int num=(prenum+1)%3;
            if(dp[i][num]==-1)
            {
                dp[i][num]=prenum+1;
                B.push({i,prenum+1});
            }
        }
    }
    if(dp[t][0]!=-1)
    {
        cout<<dp[t][0]/3;
    }else cout<<-1;
    return 0;
}


Measured memory_bytes: 58624
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<long long> A(N);
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	long long ans = 0;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			ans = max(abs(A[i] - A[j]),ans);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,m=0,c=0;
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>> a >>b;
        if(a==b)
            c++;
        if(c==3)
            m++,c=0;
        if(a!=b)
            c=0;
    }
    if(m)
    cout << "Yes";
    else
        cout << "No" ;
}


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

int main(){
  unordered_map<string,int>u;
  int n;
  cin>>n;
  
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    if(u.count(s)==0){
    u[s]=1;}
  }
  cout<<u.size();
  return 0;
}

Measured memory_bytes: 17680
module Main where

import Data.Char

genstr :: Int -> Int -> String
genstr num times = [c | _ <- [1..times]]
  where
    c = chr (num + 0x30)

main :: IO ()
main =
  (map (read :: String -> Int) . words) <$> getLine >>= \[a, b] ->
  let
    aa = genstr a b
    bb = genstr b a
  in case aa `compare` bb of
    EQ -> putStrLn aa
    LT -> putStrLn aa
    GT -> putStrLn bb


Measured memory_bytes: 508
var input=require("fs").readFileSync("/dev/stdin","utf8");

input=input.split("\n");
var r=(input[0]);
var o=3.141592653589;
var S=r*r*o*1000000;
var R=r*2*o*1000000;
S=Math.round(S);
R=Math.round(R);
console.log(S/1000000+" "+R/1000000);


Measured memory_bytes: 15392
from collections import deque

N, M = map(int, input().split())
A = list(map(int, input().split()))
operation = []
ans = 0

for _ in range(M):
    t = tuple(map(int, input().split()))
    operation.append(t)

operation.sort(key=lambda x: x[1], reverse=True)
A.sort()
A = deque(A)
operation = deque(operation)

while A and operation:
    if A[-1] >= operation[0][1]:
        ans += A[-1]
        A.pop()
    else:
        cnt = 0
        for i in range(operation[0][0]):
            if len(A) == i or A[i] > operation[0][1]:
                cnt = i
                break
        else:
            cnt = operation[0][0]
        for _ in range(cnt):
            A.popleft()
        ans += cnt * operation[0][1]
        operation.popleft()

ans += sum(A)

print(ans)


Measured memory_bytes: 22396
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()

	c := 'a'

	for j := 0; j < 26; j++ {
		found := false
		for i := 0; i < len(s); i++ {
			if s[i] == byte(c) {
				found = true
				break
			}
		}
		if found == false {
			fmt.Println(string(c))
			return
		}
		c++
	}

	fmt.Println("None")

}

// ---- readfunc
func scanInit() {
	const cap = 1000 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 2004
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int H, A;
  scanf("%d",&H);
  scanf("%d",&A);
  int ans = (H+A-1)/A;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<iomanip>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 int h, n, ans=INF;
 cin >> h >> n;
 int a[n], b[n];
 int d[20200];
 for(int i=0; i<20200;i++) d[i]=INF;
 d[0]=0;
 for(int i=0; i<n;i++) cin >> a[i] >> b[i];
 for(int i=0;i<h;i++) for(int j=0; j<n;j++) d[i+a[j]]=min(d[i+a[j]],d[i]+b[j]);
 for(int i=h;i<20200;i++) ans=min(ans,d[i]);
 cout << ans;
 return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
int a,b,c,d,p;
scanf("%d%d%d%d",&a,&b,&c,&d);
p=a-c;
int flag=0;
if(p<0)
p=-p;
if(p<=d)
flag=1;
p=a-b;
if(p<0)
p=-p;
int flag2=1;
if(p>d)
flag2=0;
p=b-c;
if(p<0)
p=-p;
if(p>d)
flag2=0;
if(flag2==1)
flag=1;
if(flag==1)
printf("Yes\n");
else
printf("No\n");
return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a,b,n,ans;
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
void tri(int x){
    ans=max(ans,(a*x)/b-a*(x/b));
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>a>>b>>n;
    clock_t start=clock();
    for(int x=min(b-1,n);x<=n;x+=b){
        tri(x);
        if((double)(clock()-start)/CLOCKS_PER_SEC>0.95)break;
    }
    cout<<ans;
}

Measured memory_bytes: 3624
#!/usr/bin/python3
# -*- coding: utf-8 -*-

MOD = 1000000007


N,K = map(int, input().split())
An = list(map(int, input().split()))

Ans = 0
for i in range(N):
  an_all,an_right = 0,0
  for j in range(N):
    if An[i] > An[j]:
      an_all += 1
      if i < j:
        an_right += 1
  Ans = (Ans + K*(K-1)//2*an_all + K*an_right) % MOD
print(Ans)

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

vector<int> a;

int bubblesort(vector<int>& a, int N){
    int cnt = 0;
    bool f = 1;
    int k = 0;
    while(f){
        f = 0;
        for(int j = N - 1; j > k; j--){
            if(a[j - 1] > a[j]){
                swap(a[j - 1], a[j]);
                cnt++;
                f = 1;
            }
        }
        k++;
    }
    return cnt;
}


int main(){
    int n;
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = bubblesort(a, n);
    bool g = 0;
    for(int i = 0; i < n; i++){
        if(g) cout << ' ';
        cout << a[i];
        g = 1;
    }
    cout << endl << ans << endl;
    return 0;
}



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

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

class Point{
    public:
    double x,y;
    Point(double x=0,double y=0):x(x),y(y){}
    Point operator+(const Point &p){
        return Point(x+p.x,y+p.y);
    }
    Point operator-(const Point &p){
        return Point(x-p.x,y-p.y);
    }
    Point operator*(const double &a){
        return Point(a*x,a*y);
    }
    Point operator/(const double &a){
        return Point(x/a,y/a);
    }
    double abs(){
        return sqrt(norm());
    }
    double norm(){
        return x*x+y*y;
    }
    bool operator<(const Point &p){
        return x!=p.x?x<p.x:y<p.y;
    }
    bool operator==(const Point &p){
        return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
    }
};
typedef Point Vector;
struct Segment{
    Point p1,p2;
    Segment(){}
    Segment(Point p1,Point p2):p1(p1),p2(p2){}
};

double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

bool isOrthogonal(Segment s1,Segment s2){
    return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

bool isParallel(Segment s1,Segment s2){
    return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

Point project(Segment s,Point p){
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/base.norm();
    return s.p1+base*r;   
}

int main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d;
    Point p1(a,b),p2(c,d),p3;
    Segment s(p1,p2);
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>e>>f;
        Point p(e,f);
        p3=project(s,p);
        printf("%.10lf %.10lf\n",p3.x,p3.y);
    }
}


Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		if (n==0) {
			System.out.println(0);
			System.exit(0);
		}
		StringBuilder ans = new StringBuilder();
		for (int i=0; n!=0; i++){
			int rem = Math.abs(n%2);
			ans.insert(0, rem);
			n = -((n-rem)/2);
		}
		System.out.println(ans.toString());

	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int vec[3] = {-1,-1,-1};
    for(int i = 0; i < 3; i++){
        cin >> vec[i];
    }
    if(vec[0] < vec[2] && vec[1] > vec[2]){
        cout << "Yes" << "\n";
    }else if(vec[1] < vec[2] && vec[0] > vec[2]){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
}


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

using namespace std;
typedef long long ll;
//typedef pair< ll , string > P;

int main(){
	ll  n,k;
	cin>>n>>k;
	ll ans=0;
	for(ll i=0;;i++){
		ll j = pow(k,i);
		if(j > n){
			if(ans==0) {
				cout<<"1";
				return 0;
			}
			cout<<ans;
			return 0;
		}
		ans++;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)998244353) 
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int main(){
	int n;
	cin >> n;
	priority_queue<double, vector<double>, greater<double>> pq;
	REP(i, n){
		double d;
		cin >> d;
		pq.push(d);
	}
	while(pq.size()>=2){
		double a = pq.top();
		pq.pop();
		double b = pq.top();
		pq.pop();
		pq.push((a+b)/2);
	}
	printf("%.8lf\n", pq.top());
	return 0;
}


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

int main() {

  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;

  if(s == u) {
    a--;
  }else{
    b--;
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
from sys import stdin
n, a, b = [int(x) for x in stdin.readline().rstrip().split()]
sum = 0

for x in range(1,n+1):
   l = x // 10000
   m = (x % 10000) // 1000
   n = (x % 1000) // 100
   o = (x % 100) // 10
   p = x % 10
   if l+m+n+o+p >= a and l+m+n+o+p <= b:
      sum += x

print(sum)

Measured memory_bytes: 9192
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	cin>>n;
	vector<ll> p(n),pos(n+1,0);
	rep(i,n){
		cin>>p[i];
		pos[p[i]] = i+1;
	}
	ll ans = 0;

	multiset<ll> sl,sr;
	sl.insert(0);
	sl.insert(0);
	sr.insert(n+1);
	sr.insert(n+1);
	for (ll now = n; now >= 1; now--){
		ll x_r = *sr.lower_bound(pos[now]);
		if(sr.count(x_r)>1){
			sr.erase(x_r);
			sr.insert(x_r);
		}else{
			sr.erase(x_r);
		}
		ll x_rr = *sr.lower_bound(x_r);
		sr.insert(x_r);

		ll x_l = *sl.lower_bound(-pos[now]);
		if(sl.count(x_l)>1){
			sl.erase(x_l);
			sl.insert(x_l);
		}else{
			sl.erase(x_l);
		}
		ll x_ll = *sl.lower_bound(x_l);
		sl.insert(x_l);

		x_l *=-1;
		x_ll *= -1;
		// cout<<x_ll<<" "<<x_l<<" "<<pos[now]<<" "<<x_r<<" "<<x_rr <<endl;

		ans += now*(x_r-pos[now])*(x_l-x_ll);
		ans += now*(x_rr-x_r)*(pos[now]-x_l);

		// cout<<ans<<endl;

		sr.insert(pos[now]);
		sl.insert(-1*pos[now]);
	}
	cout<<ans<<endl;
	
	return 0;
}

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

int main(){
	int A,B,C,X,way = 0,i,j,k; 
	cin >> A >> B >> C >> X;
  	
  	for(i = 0; i < C+1; i++){  
  	for(j = 0; j < B+1; j++){
  	for(k = 0; k < A+1; k++){
      if(i*50+j*100+k*500 == X){
      	way += 1;
      }
    		}
		}
	}
  cout << way << endl;
}

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

#define mem(ar,a)       memset(ar,a,sizeof ar)
#define iOS           	ios_base::sync_with_stdio(false);cin.tie(NULL); 
#define pb(x)           push_back(x)
#define all(c)          c.begin(), c.end()
#define int             long long
#define ff              first
#define ss              second
#define nl              '\n'

// vector<int> v(200005);
bool divi(int n,vector<int>& v) 
{ 
	if(n==1){
		auto i1=lower_bound(all(v),1);
		auto i2=upper_bound(all(v),1);
		if(i2-i1>1)
			return false;
		else
			return true;
	}
    for (int i=1; i<=sqrt(n); i++) 
    { 
    	if(i==1){
    		if(binary_search(all(v),1))
    			return false;
    		auto i1=lower_bound(all(v),n);
		auto i2=upper_bound(all(v),n);
		if(i2-i1>1)
			return false;
		
    	}
    	else{
        if (n%i == 0) 
        { 
            if (n/i == i) 
                {
                	if(binary_search(all(v),i))
                		return false;
                }
            else {
                if(binary_search(all(v),n/i)
                	or binary_search(all(v),i))
                	return false; 
            }
        } 
    }
    } 
    return true;
} 

int32_t main()
{
	iOS
	int n; cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i];

	int res=0;
	sort(all(v));
	for(int i=0;i<n;i++){
		int num=v[i];
		if(divi(num,v)){
			res++;
		}
	}
	cout<<res;
}



Measured memory_bytes: 4784
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;
static const int M = 22370000;
bool Hash[M];

int convertChartoNum(char c)
{
	if (c == 'A')
	{
		return(1);
	}
	else if (c == 'C')
	{
		return(2);
	}
	else if (c == 'G')
	{
		return(3);
	}
	else if (c == 'T')
	{
		return(4);
	}
}

long long int getKey(string s)
{
	int sum = 0;
	int p = 1;
	for (int i = 0; i < s.size(); ++i)
	{
		sum += p * convertChartoNum(s[i]);
		p *= 4;
	}
	return(sum);
}

int find(string s)
{
	int key = getKey(s);
	if (Hash[key])
	{
		return(1);
	}
	else
	{
		return(0);
	}
}

void insert(string s)
{
	int key = getKey(s);
	if (Hash[key])
	{
		return;
	}
	else
	{
		Hash[key] = true;
		return;
	}
}

void solve()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		string command, str;
		cin >> command >> str;
		if (command[0] == 'i')
		{
			insert(str);
		}
		else
		{
			if (find(str) == 1)
			{
				cout << "yes" << endl;
			}
			else
			{
				cout << "no" << endl;
			}
		}
	}
}

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

Measured memory_bytes: 2568
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Cryptography;
 
class Program
{
    static void Main(string[] args) {
        var n = int.Parse(Console.ReadLine());

        Console.WriteLine(n+n*n+n*n*n);
    }
}

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

int main(void){
    long long int s;
    int n,k;
    
    scanf("%d %d %lld",&n,&k,&s);
    
    for(int i =0;i<n;i++){
        if(k > 0){
            printf("%lld",s);k--;
        }else if(s == 1000000000){
            printf("1");
        }else{
            printf("1000000000");
            }
        printf(" ");
    }
    printf("\n");
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int a[300000];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < 3 * n; ++i) {
		scanf("%d", &a[i]);
	}
	sort(a, a + 3 * n);
	ll sum = 0;
	int cnt = 0;
	for (int i = 3 * n - 1; i >= 0 && cnt < n; --i) {
		if (((3 * n - 1) - i) % 2) {
			sum += a[i];
			++cnt;
		}
	}
	cout << sum << '\n';
	return 0;
}



Measured memory_bytes: 1408
n, k = gets.split.map(&:to_i)
as = Hash.new(0)
gets.split.map(&:to_i).each do |a|
  as[a] += 1
end
as = as.sort { |(k1,v1), (k2,v2)| v1<=>v2 }
ans = 0
n = as.size
if n > k
  for i in 0..(n - k - 1) do
    ans += as[i][1]
  end
end
puts ans

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

int main(){

    int n, c, k; cin >> n >> c >> k;
    vector<int> t(n);
    for(int i = 0; i < n; i++){
        cin >> t[i];
    }

    sort(t.begin(), t.end());

    int bus = 0;
    int i = 0;
    while(i < n){
        int T = t[i] + k;
        //cout << i << " " << T << endl;
        for(int j = i; j <= i + c; j++){
            if(j == i + c || t[j] > T){
                i = j;
                break;
            }
        }
        bus++;
    }

    cout << bus << endl;

    return 0;
}

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

def make_Graph(N, edges):#頂点の名前はi - 1で受け付ける
    graph = [ [] for i in range(N)]
    for edge in edges:
        a, b, c = edge
        graph[a].append((b,c))
        graph[b].append((a,c))
    return graph

def BFS(N, graph, start):
    Q = []
    V = []
    prev = [None] * N
    dd = [float("inf")] * N
    Q.append(start)
    dd[start] = 0
    while len(V) < N:
        a = Q.pop(0)
        V.append(a)
        for b, c in graph[a]:
            if b != prev[a]:
                Q.append(b)
                prev[b] = a
                dd[b] = dd[a] + c
    return dd

def DFS(N, graph, a, p, d):
    dd[a] = d
    for b, c in graph[a]:
        if b == p or dd[b] != 0:
            continue
        else:
            DFS(N, graph, b, a, d + c)

N = int(input())
graph = [ [] for i in range(N)]
for i in range(N-1):
    a, b, c = (int(j) for j in input().split())
    graph[a-1].append((b-1,c))
    graph[b-1].append((a-1,c))

Q, K =(int(i) for i in input().split())
dd = [0] * N

try:
    DFS(N, graph, K-1, -1, 0)
except:
    dd = BFS(N, graph, K-1)

for i in range(Q):
    x, y = (int(a) for a in input().split())
    print(dd[x-1] + dd[y-1])

Measured memory_bytes: 100384
#include<iostream>
using namespace std;
int main()
{int m,n,s=0,k;
cin>>n>>m;
int a[m];
for(int i=0;i<m;i++)
cin>>a[i];
for(int j=0;j<m;j++)
s=s+a[j];
k=n-s;
if(k>-1)
cout<<k<<endl;
else cout<<"-1";
return 0;}

Measured memory_bytes: 3620
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
typedef int long long ll;
//ll N,W;
 //ll dp[1000000001];
int main(){
    ll n,m;
    cin>>n>>m;
    ll x[n+1],y[m+1];
    x[0]=0;y[0]=0;
    rep(i,n){cin>>x[i];}
    rep(i,m){cin>>y[i];}
    
    ll a=0,b=0;
    for(int i=0;i<=n;i++){
        a+=(i-1)*x[i];
        a-=(n-i)*x[i];
       
    }
    for(int i=1;i<=m;i++){
        b+=(i-1)*y[i];
        b-=(m-i)*y[i];
        
    }
    ll z=1000000007;
    a=a%z;b=b%z;
    
    cout<<(a*b)%z<<endl;
return 0;
}


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

public class Main
{




  public static void main(String[] args) throws IOException
  {

    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String[] sl = r.readLine().split("[\\s]+");
    int paper = Integer.parseInt(sl[0]);
    int yen = Integer.parseInt(sl[1]);

    int x, y, z;
    for(x = 0; 10000 * x <= yen && x <= paper; x++)
    {
      int newy = yen - 10000 * x;
      int newp = paper - x;
      int tmp = 5000 * newp - newy;
      if((tmp / 4000) * 4000 == tmp)
      {
        z = tmp / 4000;
        y = newp - z;
        if(y >= 0 && z >= 0)
        {
          System.out.printf("%d %d %d\n", x, y, z);
          System.exit(0);
        }
      }
    }

    System.out.println("-1 -1 -1");
  }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

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

  srep(i,1,3501){
    srep(j,1,3501){
        ll u = (i*j*n);
        ll v = (4*i*j-n*j-n*i);
        if(v == 0) continue;
        ll k = u/v;
        if(k>0 && u%v == 0){
          cout<<i<<" "<<j <<" "<<k<<endl;
          return 0;
        }
      }
    }
  
  return 0;
}

Measured memory_bytes: 384