akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<string>
#include<sstream>
#include<ctime>
#define eps 1e-9
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define MAXN 10005
#define MAXM 40005
#define INF 0x3fffffff
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define lc (k<<1)
#define rc ((k<<1)|1)
#define mii ((l+r)>>1)
#define fk puts("fuck!")
#define clr(x,y) memset(x,y,sizeof(x))
using namespace std;
typedef long long LL;
int i,j,k,n,m,x,y,T,mx,mi,cas,num,len;
bool flag;


const int inf = 0x3f3f3f3f;
struct edgenode
{
    int from,to,next,flag;
    int cap;
}edge[MAXM];
int Edge,head[MAXN],ps[MAXN],dep[MAXN];

void add_edge(int x,int y,int c,int flag)
{
    edge[Edge].from=x;
    edge[Edge].to=y;
    edge[Edge].cap=c;
    edge[Edge].flag=flag;
    edge[Edge].next=head[x];
    head[x]=Edge++;

    edge[Edge].from=y;
    edge[Edge].to=x;
    edge[Edge].cap=0;
    edge[Edge].flag=flag;
    edge[Edge].next=head[y];
    head[y]=Edge++;
}

int dinic(int n,int s,int t)
{
    int tr,flow=0;
    int i,j,k,l,r,top;
    while(1){
        memset(dep,-1,(n+1)*sizeof(int));
        for(l=dep[ps[0]=s]=0,r=1;l!=r;)//BFS部分，将?定?分?
        {
            for(i=ps[l++],j=head[i];j!=-1;j=edge[j].next)
            {
                if (edge[j].cap&&-1==dep[k=edge[j].to])
                {
                    dep[k]=dep[i]+1;ps[r++]=k;
                    if(k==t)
                    {
                        l=r;
                        break;
                    }
                }
            }
        }
        if(dep[t]==-1)break;

        for(i=s,top=0;;)//DFS部分
        {
            if(i==t)//当前点就是?点?
            {
                for(k=0,tr=inf;k<top;++k)
                    if(edge[ps[k]].cap<tr)tr=edge[ps[l=k]].cap;

                for(k=0;k<top;++k)
                    edge[ps[k]].cap-=tr,edge[ps[k]^1].cap+=tr;

                flow+=tr;
                i=edge[ps[top=l]].from;
            }

            for(j=head[i];j!=-1;j=edge[j].next)//找当前点所指向的点
                if(edge[j].cap&&dep[i]+1==dep[edge[j].to]) break;

            if(j!=-1)
            {
                ps[top++]=j;//当前点有所指向的点，把?个点加入?中
                i=edge[j].to;
            }
            else
            {
                if (!top) break;//当前点没有指向的点，回溯
                dep[i]=-1;
                i=edge[ps[--top]].from;
            }
        }
    }
    return flow;
}

vector<int> ans;
int main()
{
    memset(head,-1,sizeof(head));
    Edge=0;
	scanf("%d%d",&n,&m);
    for (i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        add_edge(x,y,1,1);
        add_edge(y,x,1,0);
    }
    int S,T;
    scanf("%d%d",&S,&T);
    printf("%d\n",dinic(n+3,S,T));

    ans.clear();
    for (i=0;i<Edge;i+=2)
    {
        if (edge[i].flag==0 && edge[i].cap==0)
        {
            ans.PB(i/4+1);
        }
    }
    printf("%d\n",ans.size());
    for (i=0;i<ans.size();i++)
    {
        printf("%d\n",ans[i]);
    }
	return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, L; cin >> n >> L;
    int sum = 0;
    rep(i, 1, n+1) sum += (L + i - 1);

    int minabs = 12345;
    int a = -1;
    rep(i, 1, n+1){
        int cur = L + i - 1;
        if(chmin(minabs, abs(cur))) a = cur;
    }
    cout << sum - a << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int h,k;
char s[50][50];
int main(void){
  cin>>h>>k;
  for(int i=0;i<h;i++)for(int j=0;j<k;j++)cin>>s[i][j];
  for(int i=0 ;i<h;i++)
    for(int j=0 ;j<k;j++){
      bool t=0;
      if(s[i][j]=='#'){
        if(i!=0&&s[i-1][j]=='#')t=1;
        if(i!=h&&s[i+1][j]=='#')t=1;
        if(j!=0&&s[i][j-1]=='#')t=1;
        if(j!=k&&s[i][j+1]=='#')t=1;
        if(!t){
          cout<<"No";
          return 0;
        }
      }
    }
  cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int n;
void merge_sort (int array[], int left, int right) {
  int i, j, k, mid;
  int work[n];  
  if (left < right) {
    mid = (left + right)/2; 
    merge_sort(array, left, mid);  
    merge_sort(array, mid+1, right);  
    for (i = mid; i >= left; i--) { work[i] = array[i]; } 
    for (j = mid+1; j <= right; j++) {
      work[right-(j-(mid+1))] = array[j]; 
    }
    i = left; j = right;
    for (k = left; k <= right; k++) {
      if (work[i] < work[j]) { array[k] = work[i++]; }
      else                   { array[k] = work[j--]; }
    }
  }
}
int main(void){
int k;
scanf("%d%d",&n,&k);
int arr[n];
for(int i=0;i<n;i++)scanf("%d",&arr[i]);
merge_sort(arr,0,n-1);
int ans=0;
for(int i=n-1;i>=n-k;i-=1){
ans+=arr[i];
}
printf("%d\n",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main(){
    int N;
    cin >> N;
    int count = 0 , t = 1e9;
    vector <int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
        if(A.at(i) < t){
            count++;
            t = A.at(i);
        }
    }
    cout << count << endl;
}

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

using namespace std;
using ll = long long int;

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    A -= K;
    K = 0;
    if (A < 0){
        K = -A;
        A = 0;
    }

    B -= K;
    if (B < 0){
        B = 0;
    }
    cout << A << " " << B << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<vector<int>> v;
    for (int i = 0; i < n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        v.push_back({a, b, c});
    }
    vector<vector<int>> dp(n, vector<int>(3, 0));
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            for (int j = 0; j < 3; j++) {
                dp[i][j] = v[i][j];
            }
            continue;
        }
        for (int j = 0; j < 3; j++) {
            dp[i][j] = max(dp[i - 1][(j+1)%3] + v[i][j], dp[i - 1][(j+2)%3] + v[i][j]);
        }
    }
    cout << *max_element(dp[n - 1].begin(), dp[n - 1].end()) << "\n";
}

Measured memory_bytes: 11696
/* ex7_1
  kt125 */

#include<stdio.h>

//二次元の座標を持つ構造体
typedef struct point{
    int x_elem;
    int y_elem;
}point;

//p2を中心にp1を90°回転した点を返す関数
point turn90(point p1, point p2){
    point p3;
    //p1からp2への方向ベクトルを反時計回り90°回転させて、p2に足してp3を求める
    p3.x_elem = p2.x_elem + (p2.y_elem - p1.y_elem);
    p3.y_elem = p2.y_elem + (p1.x_elem - p2.x_elem);
    return p3;
}

int main(void){
    point p1,p2,p3,p4; //各頂点
    scanf("%d %d %d %d", &p1.x_elem, &p1.y_elem, &p2.x_elem, &p2.y_elem);

    p4 = turn90(p2, p1); //p1を中心にp2を90°回転
    p3 = turn90(p1, p4); //p4を中心にp1を90°回転

    printf("%d %d %d %d\n", p3.x_elem, p3.y_elem, p4.x_elem, p4.y_elem);
    return 0;
}

Measured memory_bytes: 1680
import math
n = int(input())

def yakusu(n):
    l = []
    for i in range(1,int(math.sqrt(n))+1):
 #       print(i)
        if n%i == 0:
            l.append(i)
            l.append(n//i)
    return(l)

l = yakusu(n)

ans = 0
for m in l:
    if m-1 > 0 and n == int(n/(m-1))*m:
        ans += m-1
    
#print(l)
print(ans)

Measured memory_bytes: 3304
package main

import "fmt"

func main() {

	var a int
	var b int
	var c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	d := b / a
	if d > c {
		fmt.Println(c)
	} else {
		fmt.Println(d)
	}

}

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

using namespace std;

int main() {
    int n,q;
    cin >> n >> q;
    vector<stack<int>> S(n);
    while (q--) {
        int code;
        cin >> code;
        switch (code) {
            case 0: {
                int t,x;
                cin >> t >> x;
                S[t].push(x);
            } break;
            case 1: {
                int t;
                cin >> t;
                if (S[t].size()) cout << S[t].top() << endl;
            } break;
            case 2: {
                int t;
                cin >> t;
                if (S[t].size()) S[t].pop();
            }
            break;
        }
    }
    return 0;
}


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

int main() {
	int n, k, h;
	int ans = 0;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &h);
		if (h >= k) ans++;
	}

	printf("%d\n", ans);
}

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

bool solve(const std::vector<int> &a, size_t i, int m) {
  if (m == 0)
    return true;
  if (i >= a.size())
    return false;
  return solve(a, i + 1, m) || solve(a, i + 1, m - a.at(i));
}

int main() {
  int n, q;
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i)
    std::cin >> a.at(i);
  std::cin >> q;
  for (int i = 0; i < q; ++i) {
    int m;
    std::cin >> m;
    std::cout << (solve(a, 0, m) ? "yes" : "no") << std::endl;
  }
}



Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
//#include <math.h>
#include <cmath>

using namespace std;

int main()
{
  int n, t, a;
  cin >> n >> t >> a;
  vector<int> h(n, 0);
  for(int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  vector<double> ch(n);
  for(int i = 0; i < n; i++)
  {
    ch[i] = t - 0.006 * h[i];
  }
  int result = 0;
  for(int i = 0; i < n; i++)
  {
    double diff = abs(a - ch[i]);
    if(diff < abs(a - ch[result]))
    {
      result = i;
    }
  }
  cout << result + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
	int N, M;
	int a[55], b[55];
	int ans[55] = {};

	cin >> N >> M;

	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		ans[a[i]]++;
		ans[b[i]]++;
	}

	for (int i = 1; i <= N; i++) {
		cout << ans[i] << endl;
	}
	cin >> N;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef vector<int> vi;
#define pb push_back
typedef long long ll;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,m,a[N],b[N],fa[N],id[N];
ll s[N],f[N];
vi E[N];
bool vis[N];

int getf(int x) {
	return x==fa[x]?x:fa[x]=getf(fa[x]);
}

bool cmp(int x,int y) {
	return a[x]<a[y];
}

int main() {
	cin>>n>>m;
	for(int i=1;i<=n;i++) {
		a[i]=gi(),b[i]=gi();
		a[i]=max(a[i]-b[i],0);
		id[i]=fa[i]=i;s[i]=b[i];f[i]=a[i]+b[i];
	}
	for(int i=1,u,v;i<=m;i++) u=gi(),v=gi(),E[u].pb(v),E[v].pb(u);
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++) {
		int u=id[i];vis[u]=1;
		for(auto v:E[u])
			if(vis[v]) {
				int x=u,y=getf(v);
				if(x!=y) {
					fa[y]=x;f[x]=min(s[x]+max((ll)a[x],f[y]),s[y]+f[x]);s[x]+=s[y];
				}
			}
	}
	cout<<f[getf(1)];
	return 0;
}


Measured memory_bytes: 9084
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    s = input()
    abcd = [i for i in s]
    op = ["-","-","-"]
    for i in range(1<<3):
        for j in range(3):
            if (i>>j)&1:
                op[j] = "+"
        if eval(abcd[0]+op[0]+abcd[1]+op[1]+abcd[2]+op[2]+abcd[3]) == 7:
            print(abcd[0]+op[0]+abcd[1]+op[1]+abcd[2]+op[2]+abcd[3]+"=7")
            exit()
        op = ["-","-","-"]
if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 5172
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

map <int, int> ss;
int a[nax];
int b[nax];
int ca[nax];
int cb[nax];
pair <int, int> c[nax];
pair <int, int> d[nax];
int n;

int top;

int main () {
    scanf("%d", &n);

    for (int i = 1 ; i <= n ; ++ i) {
        scanf("%d %d", a + i, b + i);
        ca[i] = a[i];
        cb[i] = b[i];
        c[i] = make_pair(ca[i], cb[i]);
    }
  //  cb[0] = INT_MAX;

    sort(ca + 1, ca + 1 + n);
    sort(cb + 1, cb + 1 + n);



    sort(c + 1, c + 1 + n);


    int cR = c[1].second;
    int cL = c[1].first;
    for (int i = 2 ; i <= n ; ++ i) {

        if (c[i].first > cR) {
            d[++ top] = make_pair(cL, cR);
            cR = c[i].second;
            cL = c[i].first;
        } else {
            cR = max(cR, c[i].second);
        }
    }

    d[++ top] = make_pair(cL, cR);


    long long ans = 0;
    if (n % 2) {
        for (int i = 1 ; i <= top ; ++ i) {
            int l = d[i].first, r = d[i].second;

            int min_bound = ca[(n + 1) / 2];
            int max_bound = cb[(n + 1) / 2];

            l = max(l, min_bound);
            r = min(r, max_bound);

            if (l > r) continue;

            ans += r - l + 1;
        }

        cout << ans;
    } else {

       /// throw;
        #define int long long

        int l_min = INT_MAX, l_max = INT_MIN;

        for (int i = 1 ; i <= top ; ++ i) {
            int l = d[i].first, r = d[i].second;

            int min_bound = ca[n / 2];
            int max_bound = cb[n / 2];

            l = max(l, min_bound);
            r = min(r, max_bound);

            if (l > r) continue;

            l_min = min(l_min, l);
            l_max = max(l_max, r);

        }


        int r_min = INT_MAX, r_max = INT_MIN;


        for (int i = 1 ; i <= top ; ++ i) {
            int l = d[i].first, r = d[i].second;
            int min_bound = ca[n / 2 + 1];
            int max_bound = cb[n / 2 + 1];

            l = max(l, min_bound);
            r = min(r, max_bound);

            if (l > r) continue;

            r_min = min(r_min, l);
            r_max = max(r_max, r);

        }


        int all = r_max + l_max - r_min - l_min;

        cout << all + 1;
    }


}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 9912
//
//AtCoder Beginner Contest 169
//C - Multiplication 3
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#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 FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    ll a;
    ld b;
    cin >> a >> b;

    ll ans = a*b;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3724
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
countAlice = 0
countBob = 0
for i in range(n):
    if i%2 == 0:
        countAlice += a[i]
    else:
        countBob += a[i]
print(countAlice-countBob)

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

class Program
{

    static void Main(string[] args)
    {
        ProblemA();
    }

    static void ProblemA()
    {
        int[] n = System.Console.ReadLine().Split(' ').Select((i) => int.Parse(i)).ToArray();

        if ((n[0] < n[2]) && (n[2] < n[1])
            || (n[1] < n[2]) && (n[2] < n[0]))
        {
            System.Console.WriteLine("Yes");
        }else{
            System.Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <functional>

using namespace std;

#define MAXN 1000016

int isprime[MAXN];

void sieve(int n)
{
	int i, j, num, p = 0;
	fill(isprime, isprime + MAXN + 1, 1);
	for (i = 2, num = 1; i <= n; i++)
	{
		if (isprime[i])
		{
			isprime[i] = num++;
			for (j = 2 * i; j <= n; j += i)
				isprime[j] = 0;
		}
	}
}

int main()
{
	int n;
	sieve(MAXN);
	while (scanf("%d", &n) != EOF)
	{
		if (n == 1)
		{
			printf("0\n");
			continue;
		}
		while (!isprime[n])
		{
			n--;
		}
		printf("%d\n", isprime[n]);
	}
	return 0;
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int const MAX = 101;
int const NIL = -1;
struct Node {
  int parent, left, right;
} T[MAX];

void preParse(int u) {
  if (u == NIL) return;
  printf(" %d", u);
  preParse(T[u].left);
  preParse(T[u].right);
}

void inParse(int u) {
  if (u == NIL) return;
  inParse(T[u].left);
  printf(" %d", u);
  inParse(T[u].right);
}

void postParse(int u) {
  if (u == NIL) return;
  postParse(T[u].left);
  postParse(T[u].right);
  printf(" %d", u);
}

int main() {
  int n;
  cin >> n;
  rep(i,n) T[i].parent = T[i].left = T[i].right = NIL;

  int id, left, right;
  rep(i,n) {
    cin >> id >> left >> right;
    T[id].left = left;
    T[id].right = right;
    if (left != NIL) T[left].parent = id;
    if (right != NIL) T[right].parent = id;
  }
  int root;
  rep(i,n) {
    if (T[i].parent == NIL) root = i;
  }

  cout << "Preorder" << endl;
  preParse(root);
  cout << endl;
  cout << "Inorder" << endl;
  inParse(root);
  cout << endl;
  cout << "Postorder" << endl;
  postParse(root);
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 3256
#include <algorithm>
#include <chrono>
#include <iostream>
#include <vector>
#include <cassert>
#include <queue>

using namespace std;
using namespace std::chrono;

const int LIM = 20;
const int INF = 1e+9;

template<class T, class U>
void show(T l, U r, long long add_to_left, long long add_to_right) {
  cout << l.size() << r.size() << endl;
  vector<long long> pts;
  while (!l.empty()) {
    pts.push_back(l.top() + add_to_left);
    l.pop();
  }
  reverse(pts.begin(), pts.end());
  while (!r.empty()) {
    pts.push_back(r.top() + add_to_right);
    r.pop();
  }

  for (long long i : pts)
    cout << i << ' ';
  cout << endl;
}

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  priority_queue<long long> l;
  priority_queue<long long, vector<long long>, greater<long long>> r;
  long long add_to_left = 0, add_to_right = 0, ans = 0;

  vector<pair<long long, long long>> rect(n);
  for (int i = 0; i < n; ++i)
    cin >> rect[i].first >> rect[i].second;

  l.push(rect[0].first);
  r.push(rect[0].first);

  //show(l, r, add_to_left, add_to_right);

  for (int i = 1; i < n; ++i) {
    add_to_right += (rect[i - 1].second - rect[i - 1].first);
    add_to_left -= (rect[i].second - rect[i].first);

    long long real_left = l.top() + add_to_left;
    long long real_right = r.top() + add_to_right;

    if (rect[i].first < real_left) {
      ans += real_left - rect[i].first;
      r.push(real_left - add_to_right);
      l.pop();
      l.push(rect[i].first - add_to_left);
      l.push(rect[i].first - add_to_left);
    } else if (rect[i].first > real_right) {
      ans += rect[i].first - real_right;
      l.push(real_right - add_to_left);
      r.pop();
      r.push(rect[i].first - add_to_right);
      r.push(rect[i].first - add_to_right);
    } else {
      l.push(rect[i].first - add_to_left);
      r.push(rect[i].first - add_to_right);
    }

    //show(l, r, add_to_left, add_to_right);
  }

  cout << ans << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 3572
n = int(input())
s = input()
ans = []

for i in range(n-1):
    left = set(s[:i+1])
    right = set(s[i+1:])
    cnt = 0
    for j in left:
        if j in right:
            cnt += 1
    ans.append(cnt)

print(max(ans))

Measured memory_bytes: 3060
#include <stdio.h>
#include <cmath>


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

int main(){

    int n, k;
    scanf("%d %d", &n, &k);
    int x[100000];
    int pos = 0;
    for (int i = 0; i < n; i++){
        scanf("%d", &x[i]);
        if(x[i] < 0) pos++;
    }

    int ans = 2000000000;
    k--;
    if( pos - k - 1 >= 0) ans = min(0-x[pos-k-1], ans);
    if( pos + k < n ) ans = min(x[pos+k], ans);
    for (int i = pos-k; i < pos; i++){
        if( i < 0 ) continue;
        if( i == pos ) break;
        if( i + k >= pos && i + k < n) {
            ans = min(0-x[i]*2+x[i+k], ans);
            ans = min(0-x[i]+x[i+k]*2, ans);
        }
    }
    printf ("%d\n", ans);

    return 0;

}

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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    A, B = map(int, readlines())
    list = [1, 2, 3]
    list.remove(A)
    list.remove(B)
    print(list[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int maxn=1e5+7;
int pres[maxn],pret[maxn];
int main()
{
	string s,t;
	cin>>s>>t;
	for(int i=1;i<=s.length();i++)
		pres[i]=pres[i-1]+(s[i-1]=='A'?1:2);
	for(int i=1;i<=t.length();i++)
		pret[i]=pret[i-1]+(t[i-1]=='A'?1:2);
	int q;
	cin>>q;
	while(q--)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if((pres[b]-pres[a-1])%3==(pret[d]-pret[c-1])%3)
			cout<<"YES\n";
		else cout<<"NO\n";
	}

}


Measured memory_bytes: 1664
#include <iostream>
using namespace std;
typedef long long int LLI;

LLI gcd(LLI a, LLI b)
{
	LLI tmp;
	while( b != 0 )
	{
		a %= b;
		tmp = a;
		a = b;
		b = tmp;
	}
	return a;
}

int main()
{
    LLI n, second = 1, first, tmp = 1;
    cin >> n;
    
    if( n >= 1 ){
    	cin >> first;
    	tmp = first;
	}
	if( n >= 2 ){
		second = first;
		cin >> first;
		tmp = first / gcd(first,second) * second;
	}
    for(int i = 2; i < n; i++){
    	second = tmp;
		cin >> first;
    	tmp = first / gcd(first,second) * second;
	}
	cout << tmp;
}

Measured memory_bytes: 3612
a,b,c,d,e,f=map(int,input().split())
sw=set()
for i in range(30//a+1):
  for j in range(30//b+1):
    w=a*i+b*j
    if 0<w*100<=f: sw|={w}
ss=set()
for i in range(3000//c+1):
  for j in range(3000//d+1):
    s=c*i+d*j
    if s<=f: ss|={s}
lt=[]
for w in sw:
  for s in ss:
    t=w*100+s
    if t<=f and s<=w*e: lt+=[(-s/w,t,s)]
lt.sort()
print(*lt[0][1:])

Measured memory_bytes: 4340
const main = input => {
  const [W, a, b] = input.trim().split(' ').map(x => parseInt(x))
  if (a > b) {
    console.log(Math.max(a - (b + W), 0))
  } else if (a < b) {
    console.log(Math.max(b - (a + W), 0))
  } else {
    console.log(0)
  }
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30556
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 2e3 + 10;

int n, kth, two[N], dp[N][N][2];

int main() {
	scanf("%d%d", &n, &kth);
	two[0] = 1;
	for (int i = 0; i < n; ++i)
		two[i + 1] = (two[i] << 1) % mod;
	dp[n + 1][0][1] = 1;
	for (int i = n + 1; i > 1; --i) {
		for (int j = n; j >= 0; --j)
			(dp[i][j][0] += dp[i][j + 1][0]) %= mod;
		for (int j = 0; j <= n; ++j)
			for (int k = 0; k < 2; ++k) {
				(dp[i - 1][j + 1][1] += dp[i][j][k]) %= mod;
				(dp[i - 1][j][0] += dp[i][j][k]) %= mod;
			}
	}
	int ans = (long long)dp[1][n - kth][0] * two[max(0, n - kth - 1)] % mod;
	printf("%d\n", ans);
}

Measured memory_bytes: 31744
#include<bits/stdc++.h>
using namespace std;
#define f(x,y,z) for(int x=y;x<z;++x)
typedef long long ll;
int n, h;
string s;
map<string,bool> m;
int main() {
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin >> n;
    while(n--) {
        cin >> s;
        if(!m[s]) ++h, m[s] = true;
    }
    cout << h << '\n';
}

Measured memory_bytes: 19252
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)


string f(ll n) {
    if (n == 0) return "";
    n--;
    return f(n/26) + string(1, 'a'+n%26);
}


int main()
{
    ll n;
    cin >> n;
    cout << f(n) << endl;
    return 0;
}


Measured memory_bytes: 3612
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int total = 0;
    total = n<10 ? n:n<100 ? 9:n<1000 ? n-90:n<10000 ? 909:n<100000 ? n-9090:90909;
    System.out.println(total);    
  } 
}

Measured memory_bytes: 23124
s = int(input())
a=[]
a.append(s)

for i in range(1, 100000):
    if a[i-1]%2==0:
        a.append(a[i-1]//2)
    else:
        a.append(3*a[i-1]+1)
l=[]
for i in range(len(a)):
    for j in range(i+1, len(a)):
        if a[i]==a[j]:
            l.append(j+1)
            break

print(l[0])

Measured memory_bytes: 7848
#include<iostream>
using namespace std;
int main(void){
  
  int N, i;
  char S;
  bool Y = false;
  
  cin >> N;
  
  for(i = 0; i < N; i++){
    
    cin >> S;
    if(S == 'Y'){
      Y = true;
    }
  }
  
  if(Y){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define eps 1e-9

using namespace std;

struct vec2d{
	double x, y;
	vec2d(){}
	vec2d(double x, double y){
		this->x = x, this->y = y;
	}
	double add(double a, double b){
		if(fabs(a+b) < eps * (fabs(a) + fabs(b))) return 0.0;
		return a+b;
	}
	vec2d operator+(vec2d ope){
		return vec2d(add(x, ope.x), add(y, ope.y));
	}
	vec2d operator-(vec2d ope){
		return vec2d(add(x, -ope.x), add(y, -ope.y));
	}
	vec2d operator*(double t){
		return vec2d(x*t, y*t);
	}
	vec2d operator/(double t){
		return vec2d(x/t, y/t);
	}
	double dot(vec2d ope){
		return add(x*ope.x, y*ope.y);
	}
	double cross(vec2d ope){
		return add(x*ope.y, -y*ope.x);
	}
	double norm(){
		double d2 = dot(*this);
		if(d2 > 0) return sqrt(d2);
		return 0.0;
	}
};

bool isInTriangle(vec2d p, vec2d q, vec2d r, vec2d x)
{
	p = p - r, q = q - r, x = x - r;
	double s = p.cross(x) / p.cross(q), t = x.cross(q) / p.cross(q);
	return s >= -eps && t >= -eps && s+t <= 1 + eps;
}

char xp, xq;
int dp, lp, dq, lq;

int solve(int d, int l)
{
	double ang = 3.14159265358979 / 180.0 * (d-30), h = sqrt(3) / 2;
	vec2d p = vec2d(l * cos(ang), l * sin(ang));
	vec2d u = vec2d(h, 0.5), v = vec2d(h, -0.5);
	
	
	for(int i = 0; i <= 25; i++){
		for(int j = 0; j <= i; j++){
			int id;
			if(i % 2){
				if(j % 2) id = 2; else id = 1;
			}else{
				if(j % 2) id = 3; else id = 0;
			}
			double y = -i/2.0 + j;
			vec2d q = vec2d(h*i, y);
			if(isInTriangle(q, q+u, q+v, p)) return 3 - id;
			if(j != 0 && j != i){
				if(isInTriangle(q, q-u, q-v, p)) return 3 - id;
			}
		}
	}
	return -1;
}

int perm(int id, char x)
{
	if(id == 0) return 0;
	id--;
	if(x == 'C') id = (id+1)%3;
	if(x == 'D') id = (id+2)%3;
	return id+1;
}

int main(void)
{
	char c;
	cin >> xp >> c >> dp >> lp;
	cin >> xq >> c >> dq >> lq;
	
	if(perm(solve(dp, lp), xp) == perm(solve(dq, lq), xq)) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 3304
#agc022a

c='abcdefghijklmnopqrstuvwxyz'
s=raw_input()
if len(s)<26:
 for v in c:
  if v not in s:
   res=s+v
   print res
   break
elif s==c[::-1]:
 print -1
else:
 s=s[::-1]
 i=0
 t=''
 while s[i]<s[i+1]:
  t+=s[i]
  i+=1
 t+=s[i]
 l=s[i+1:]
 r=ord('z')
 for v in t:
  if ord(v)>ord(l[0]):
   r=min(ord(v),r)
 res=chr(r)
 res=l[::-1][:-1]+res
 print res


Measured memory_bytes: 2568
#include <stdio.h>

int gcd(int N, int W)
{
    int amari = N % W;
    
    if (amari == 0) {
        return W;
    }
    
    return gcd(W, amari);
}

int main(void)
{
    int K;
    int a, b, c;
    int sum = 0;
    
    scanf("%d", &K);
    
    for (a = 1; a <= K; a ++) {
        for (b = 1; b <= K; b ++) {
            for (c = 1; c <= K; c ++) {
                sum += gcd(gcd(a, b), c);
            }
        }
    }
    
    printf("%d\n", sum);
    
    return 0;
}

Measured memory_bytes: 1732
def main():
    H, W = map(int, input().split())
    grid = [list(input()) for _ in range(H)]
    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]
    D = [[0] * W for _ in range(H)]
    U = [[0] * W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if grid[h][w] == '#':
                continue
            if w == 0:
                L[h][w] = 1
            else:
                L[h][w] = L[h][w-1] + 1
            if h == 0:
                U[h][w] = 1
            else:
                U[h][w] = U[h-1][w] + 1
    for h in range(H - 1, -1, -1):
        for w in range(W - 1, -1, -1):
            if grid[h][w] == '#':
                continue
            if w == W - 1:
                R[h][w] = 1
            else:
                R[h][w] = R[h][w + 1] + 1
            if h == H - 1:
                D[h][w] = 1
            else:
                D[h][w] = D[h + 1][w] + 1
    ans = 0
    for h in range(H):
        for w in range(W):
            ans = max(ans, L[h][w] + R[h][w] + U[h][w] + D[h][w] - 3)
    print(ans)


if __name__ == '__main__':
    main()

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

int main(void){
	int q;
	while(cin >> q){
		if(q==-1) break;
		double x=1.0*q/2.0;
		while(abs(x*x*x-q)>0.00001*q){
			x=x-(x*x*x-q)/(3.0*x*x);
		}
		cout.precision(6);
		cout << fixed << x << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, long long K) { cout << min(N % K, K - N % K) << endl; }

int main() {
    long long N;
    long long K;
    scanf("%lld", &N);
    scanf("%lld", &K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static boolean[] primes;

	static void primeSet(final int MAX){
		primes = new boolean[MAX+1];

		primes[2] = true;
		for(int i=3;i<=MAX;i+=2){
			primes[i] = true;
		}
		int rt = (int) Math.sqrt(MAX);
		for(int i=3;i<=rt;i+=2){
			if(primes[i]){
				for(int j=i*2;j<=MAX;j+=i){
					primes[j] = false;
				}
			}
		}
	}

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

		while(true){
			int max = 0;
			int n = stdIn.nextInt();

			if(max<n){
				primeSet(n);
				max=n;
			}
			
			if(n==0){
				break;
			}

			// if(ï) then "0" ÈóÅÍÈ¢Bn=7 ... [2,5]

			int cnt = 0;
			for(int i=2;i<=n/2;i++){
				if(primes[i]&&primes[n-i]){
//					System.out.println("["+i+","+(n-i)+"]");
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 13000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		String ss[] = new String[3];
		sc.close();

		int count = 0;
		for(int i = 0; i < ss.length; i++) {
			ss[i] = str.substring(i , i + 1);
			if(ss[i].equals("1")) {
				count++;
			}else {
				continue;
			}
		}

		System.out.println(count);
	}
}

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

int main(){
    int64_t n, k;
    cin >> n >> k;
    int64_t a[200100];
    int64_t count[200100]={};
    for(int64_t i=1; i<=n; i++){
        cin >> a[i];
        count[a[i]]++;
    }
    int64_t ans = 0;
    sort(count, count+200100,  greater<>());
    for(int64_t i=k; i<200100; i++){
        ans += count[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
w, h, c = gets.split
w = w.to_i
h = h.to_i

edge = '+' + '-' * (w - 2) + '+'
center = '|' + '.' * ((w - 3) / 2) + c + '.' * ((w - 3) / 2) + '|'

puts edge

((h - 3) / 2).times do
  puts '|' + '.' * (w - 2) + '|'
end

puts center

((h - 3) / 2).times do
  puts '|' + '.' * (w - 2) + '|'
end

puts edge



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

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N;
  string s;
  cin >> N >> s;
  vector<int> a(2,0);

  for(char c: s){
    if(c=='(') a[0]++;
    else {
      if(a[0] > 0) a[0]--;
      else a[1]++;
    }
  }
  rep(i, a[1]){
    cout << "(";
  }
  cout << s;
  rep(i, a[0]){
    cout << ")";
  }

  cout << endl;

}


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

int top, S[1000];

void push(int x) {
    top++;
    S[top] = x;
}

int pop() {
    top--;
    return S[top+1];
}

int main(){
    int a,b;
    top = 0;
    char s[100];

    while( scanf("%s", s) != EOF) {
        if(s[0] == '+') {
            a = pop();
            b = pop();
            push(a+b);
        } else if (s[0] == '-') {
            a = pop();
            b = pop();
            push(b-a);
        } else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(a*b);
        } else {
            push(atoi(s));
        }
    }

    printf("%d\n", pop());

    return 0;
    

}


Measured memory_bytes: 2748
N = int(input())
e = []
ed = {}
g = [[] for i in range(N)]
c = [0]*(N-1)
ny = [0]*N
for i in range(N-1):
    a, b = (int(i) for i in input().split())
    ny[a-1] += 1
    ny[b-1] += 1
    g[a-1].append(b-1)
    g[b-1].append(a-1)
    e.append((a-1,b-1))
    ed[(a-1, b-1)] = i

mac = max(ny)
for i in range(N):
    if ny[i] == mac:
        oya = i
        break

Q = [(0, oya)]
prev = [False]*N
while Q:
    col, v = Q.pop()
    prev[v] = True
    l = g[v]
    ucol = 0
    for u in l:
        if not prev[u]:
            ucol += 1
            if col == ucol:
                ucol += 1
            Q.append((ucol, u))
            a, b = min(u, v), max(u, v)
            c[ed[(a, b)]] = ucol
print(mac)
for i in range(N-1):
    print(c[i])

Measured memory_bytes: 95136
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

char calc_max_c(const string &s) {
    char ans = 'a';
    for (auto &c : s) {
        chmax(ans, c);
    }
    return ans;
}

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

    vector<string> as;
    as.push_back("a");

    for (int i = 1; i < N; i++) {
        vector<string> old;
        swap(as, old);
        for (auto & s : old) {
            char max_c = calc_max_c(s);
            for (char c = 'a'; c <= max_c + 1; c++) {
                as.push_back(s + c);
            }
        }
    }

    for (auto &a : as) {
        cout << a << endl;
    }

    return 0;
}


Measured memory_bytes: 9164
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abc145_c();
	}
  
  	public static void solve_abc145_c(){

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();

		double[] x = new double[N];
		double[] y = new double[N];
		
		for(int i=0;i<N;i++){
			x[i] = sc.nextDouble();
			y[i] = sc.nextDouble();
		}
		
		double[][] dist = new double[N][N];
		
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				dist[i][j] = dist[j][i] = Math.sqrt((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]));
			}
		}
		
		StringBuilder sb = new StringBuilder("");
		for(int i=0;i<N;i++) sb.append(i);
		
		List<String> townList = new ArrayList<>();
		solve_abc145_c_permtation("",sb.toString(),townList);

		//for(String ti:townList) System.out.println(ti);

		
		
		double sum = 0;
		double count = (double)townList.size();
		
		for(String ti:townList){
			for(int i=0;i<ti.length()-1;i++){
				int startTown = Character.getNumericValue(ti.charAt(i));
				int endTown = Character.getNumericValue(ti.charAt(i+1));
				//System.out.println("startTown:" + startTown + "\t endTown:" + endTown);
				sum += dist[startTown][endTown];
				
				//System.out.println("sum:"+sum+"\t count:"+count);
				
			}
		}
		
		double ans = sum / count;
		System.out.println(ans);
		sc.close();

	}
	
	public static void solve_abc145_c_permtation(String ans, String rest, List<String> ansArray){
		
		if(rest.length() == 1){
			ansArray.add(ans + rest);
		}
		
		//new ans  = ans  + rest[i]: String ans  = ans  + rest.charAt(i)
		//new rest = rest - rest[i]: String rest = rest[0,i] + rest[i,]
		for(int i=0;i<rest.length();i++){
			solve_abc145_c_permtation(ans + rest.charAt(i), rest.substring(0,i) + rest.substring(i+1), ansArray);
		}
	}
}

Measured memory_bytes: 51476
//
//  main.cpp
//  Contests
//
//  Created by Roman Nikitin on 09.06.17.
//  Copyright © 2017 NikRom. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
#include <numeric>
#include <queue>
#include <chrono>
#include <functional>

using namespace std;

#define int long long
#define len(v) (int)v.size()
#define pb push_back
#define x first
#define y second

typedef long long ll;

namespace ConvenientStream {
    
    void useFiles(string s) {
        freopen((s + ".in").c_str(), "r", stdin);
        freopen((s + ".out").c_str(), "w", stdout);
    }
    
    template <class T_First, class T_Second>
    ostream& operator<<(ostream& os, const pair<T_First, T_Second> &p) {
        os << p.first << " " << p.second;
        return os;
    }
    
    template <class T>
    ostream& operator<<(ostream& os, const vector<T> &v) {
        if (v.empty())
            return os;
        for (int i = 0; i < len(v) - 1; i++) {
            os << v[i] << " ";
        }
        os << v[len(v) - 1];
        return os;
    }
    
    template <class T>
    ostream& operator<<(ostream& os, const vector<vector<T>> &v) {
        if (v.empty())
            return os;
        for (int i = 0; i < len(v) - 1; i++) {
            os << v[i];
            os << endl;
        }
        os << v[len(v) - 1];
        return os;
    }
    
    
    template <class T_First, class T_Second>
    istream& operator>>(istream& is, pair<T_First, T_Second> &p) {
        is >> p.first >> p.second;
        return is;
    }
    
    template <class T>
    istream& operator>>(istream& is, vector<T> &v) {
        for (auto &x : v) {
            is >> x;
        }
        return is;
    }
    
    template<class T>
    istream &operator,(istream &is, T &obj) {
        is >> obj;
        return is;
    }
    
    template<class T>
    ostream &operator,(ostream &os, const T &obj) {
        return (os << obj);
    }
    
    const string nl = "\n";
    const string sp = " ";
    const string tb = "\t";
}

using namespace ConvenientStream;

void time_debug(function<void()> &f) {
    auto start_time = chrono::high_resolution_clock::now();
    f();
    auto end_time = chrono::high_resolution_clock::now();
    auto delta = chrono::duration_cast<chrono::milliseconds>(end_time - start_time);
    cout << "TIME: " << delta.count() << " ms" << endl;
}

int d[52][52];

signed main() {

    int n, p;
    cin >> n >> p;
    vector<int> mas(n);
    cin >> mas;
    
    d[0][0] = 1;
    d[0][1] = 0;
    
    for (int i = 0; i < n; i++) {
        if (mas[i] % 2) {
            d[i + 1][1] = d[i + 1][0] = d[i][1] + d[i][0];
        }
        else {
            d[i + 1][1] += d[i][1] * 2;
            d[i + 1][0] += d[i][0] * 2;
        }
    }
    
    cout << d[n][p];
    
    return 0;
}


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

int main(){
	std::string str;
	while(std::cin>>str){
		int c_joi=0,c_ioi=0;
		for(int i=2;i<str.size();i++){
			char back1=str[i-1],back2=str[i-2];
			if(str[i]=='I'&&back1=='O'){
				if(back2=='J')c_joi++;
				if(back2=='I')c_ioi++;
			}
		}
		std::cout<<c_joi<<std::endl;
		std::cout<<c_ioi<<std::endl;
	}
	return 0;
}

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

using ll = long long;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
    int N, a, ans = 0;
    cin >> N;
    vector<int> c(9, 0);
    rep(i, N) {
        cin >> a;
        c[min(a / 400, 8)]++;
    }
    rep(i, 8) {
        if (c[i] > 0) ans++;
    }
    cout << max(1, ans) << " " << ans + c[8] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 200100

pi A[MAXN];
ll N,L,R;
ll ans;
vi V;
multiset<ll> lset,rset;

int main(){
	cin>>N;
	for (ll i=1;i<=N;++i)cin>>A[i].f>>A[i].s;
	for (ll i=1;i<=N;++i){
		L+=A[i].f;
		R+=A[i].s;
	}
	ans = min(L,R);
	ll T = 0;
	for (int i=1;i<=N;++i){lset.insert(A[i].f);T += A[i].f;}
	for (int i=1;i<=N;++i){lset.insert(A[i].s);T += A[i].s;}

	for (ll i=1;i<=N;++i){
		if (i>1){
			lset.insert(A[i-1].f);
			lset.insert(A[i-1].s);
			T += A[i-1].f;
			T += A[i-1].s;
		}
		for (int i=0;i<2;++i){
			T -= *(--lset.end());
			rset.insert(*(--lset.end()));
			lset.erase(--lset.end());
		}
		if (lset.find(A[i].f) == lset.end()){
			rset.erase(rset.find(A[i].f));
		}else{
			lset.erase(lset.find(A[i].f));
			T -= A[i].f;
		}
		if (lset.find(A[i].s) == lset.end()){
			rset.erase(rset.find(A[i].s));
		}else{
			lset.erase(lset.find(A[i].s));
			T -= A[i].s;
		}
		while (SZ(lset) > N-2){
			T -= *(--lset.end());
			rset.insert(*(--lset.end()));
			lset.erase(--lset.end());
		}
		while (SZ(lset) < N-2){
			T += *(rset.begin());
			lset.insert(*(rset.begin()));
			rset.erase(rset.begin());
		}
		ans = min(ans,T+A[i].f+A[i].s);
		assert(SZ(lset) == N-2);
		// for (auto i : lset)cout<<i<<' ';cout<<'\n';
		// cout<<T<<'\n';
	}
	cout<<ans;
}

Measured memory_bytes: 11136
"""
bit全探索
"""

D, G = map(int, input().split())
P = []
C = []
for i in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)
ans = 100000000

for i in range(2 ** D):
    a = 0
    b = 0
    for j in range(D):
        if i >> j & 1:
            a += 100 * P[j] * (j + 1) + C[j]
            b += P[j]
    for k in range(D-1, -1, -1):
        if i >> k & 1:
            continue
        if a >= G:
            break
        for l in range(P[k] - 1):
            a += 100 * (k + 1)
            b += 1
            if a >= G:
                break
    if a >= G:
        ans = min(ans, b)
print(ans)

Measured memory_bytes: 3064