akhauriyash/Code-Regression huggingface dataset:
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
dp = [[0] * 3 for _ in range(n)]

a, b, c = na()
dp[0][0], dp[0][1], dp[0][2] = a, b, c

for i in range(1, n):
    a, b, c = na()
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a
    dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c

print(max(dp[n-1]))

Measured memory_bytes: 22772
import itertools
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
Ps = ''
Qs = ''
for i in P:
    Ps += str(i)
for i in Q:
    Qs += str(i)
seq = (str(i) for i in range(1,N+1))
per = itertools.permutations(seq)
a = 0
b = 0
for i,s in enumerate(per):
    str1 = ''
    for c in s:
        str1 += c
    if str1 == Ps:
        a = i + 1
    if str1 == Qs:
        b = i + 1

print(abs(a-b))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d", &tmp);v.push_back(tmp);}}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong a, b, c;
  scanf("%lld %lld %lld", &a, &b, &c);

  if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
    printf("0\n");
    return 0;
  }
  
  printf("%lld\n", min({a * b, b * c, c * a}));

  return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 64;
const int N = (int)5e5 + 7;
const int MAXN = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)2e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e18;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

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

void solve() {
	int n; cin >> n;
	map <string, int> mapa;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		mapa[s]++;
	}
	cout << "AC x " << mapa["AC"] << endl;
	cout << "WA x " << mapa["WA"] << endl;
	cout << "TLE x " << mapa["TLE"] << endl;
	cout << "RE x " << mapa["RE"] << endl;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 3688
#include<iostream>
using namespace std;
int main(){
	int n;
	int s=0,mx=0;
	int a;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		s+=a;
		if(mx<a)mx=a;
	}
	s-=mx/2;
	cout<<s<<endl;
	return 0;
}


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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int n;
  cin >> n;
  rep(i, 0, n) {
    int k, p;
    cin >> k >> p;
    if(k % p == 0) cout << p << endl;
    else cout << (k % p) << endl;
  }
}



Measured memory_bytes: 3212
import math

N, K = map(int,input().split())
ans = 0
for i in range(1, N+1):
    if i < K:
        n = math.ceil(math.log(K/i, 2))
        ans += (1/N) * (1/2)**n
    else:
        ans += 1/N

print(ans)

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

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

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

char S[114514];

char Sriv[114514];

int main(void) {
	int i, l;
	if (scanf("%114513s", S) != 1) return 1;
	l = (int)strlen(S);
	for (i = 0; i < l; i++) {
		Sriv[l - 1 - i] = S[i];
	}
	Sriv[l] = '\0';
	for (i = 0; Sriv[i] != '\0';) {
		if (strncmp(Sriv + i, "maerd", 5) == 0) i += 5;
		else if (strncmp(Sriv + i, "remaerd", 7) == 0) i += 7;
		else if (strncmp(Sriv + i, "esare", 5) == 0) i += 5;
		else if (strncmp(Sriv + i, "resare", 6) == 0) i += 6;
		else {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

/*
maerd
remaerd
esare
resare

こうすると多分いい
*/


Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int a,b,c,i,j;
  j=0;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++){
    if(c % i == 0){
      j++;
    }
  }
  printf("%d\n",j);
  
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    string s;
    cin >> s;
    if(s == "ARC") cout << "ABC";
    else cout << "ARC";
    return 0;
}


Measured memory_bytes: 3612
import java.util.*
import kotlin.*

import java.io.InputStream
import java.lang.NumberFormatException
import java.lang.StringBuilder


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = FastScanner()
        val a = sc.nextInt()
        val b = sc.nextInt()
        val c = sc.nextInt()
        val d = sc.nextInt()
        println(Math.min(a, b) + Math.min(c, d))
    }
}


class FastScanner {
    companion object {
        val input: InputStream = System.`in`
        val buffer = ByteArray(1024) { 0 }
        fun isPrintableChar(c: Int): Boolean = c in 33..126
    }

    var ptr = 0
    var buflen = 0
    private fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = input.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }

    private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b)
            b = readByte()
        }
        return sb.toString()
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextDouble(): Double = next().toDouble()
}


Measured memory_bytes: 31656
n,s = map(int, input().split())
a = list(map(int, input().split()))
ans = float("inf")
ma = 0
mi = 0
v = 0
for i in range(n):
    v += a[i]
    if v >= s:
        ma = i
        while v >= s:
            v -= a[mi]
            mi += 1
        ans = min(ans, ma-mi+2)
ans = ans if ans != float("inf") else 0
print(ans)


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

long long n, t, ans = 1, c[1005];
bool v[1005];
int main()
{
    int i, j;
    cin >> n;
    for (i = 2; i <= n; i++) {
        if (v[i]) continue;
        for (j = i * 2; j <= n; j *= i) v[j] = 1;
    }
    for (i = 2; i <= n; i++) {
        t = i;
        for (j = 2; j <= n; j++) {
            if (!v[j]) {
                while (t % j == 0) {
                    t /= j;
                    c[j]++;
                }
            }
        }
    }
    for (i = 2; i <= n; i++) {
        if (!v[i]) ans = ans * (c[i] + 1) % 1000000007;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
local x1, y1 = io.read("*n", "*n")
local x2, y2 = io.read("*n", "*n")
local y3 = y2 + (x2 - x1)
local x3 = x2 - (y2 - y1)
io.write(x3 .. " " .. y3.. " ")
local y4 = y3 + (x3 - x2)
local x4 = x3 - (y3 - y2)
io.write(x4 .. " " .. y4.. "\n")


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

int depth(int k) {
  int p = 0;
  while(k > 0) {
    k /= 2;
    p++;
  }
  return p;
}

int main(){
  int n;
  cin >> n;
  int v[n+1], w[n+1];
  rep(i,n) cin >> v[i+1] >> w[i+1];
  int b = min(n,1<<9);
  vector<vector<int>> dp(b+1,vector<int>(MAX));
  for(int i = 1; i <= b; i++) {
    vector<int> c;
    int p = i;
    while(p > 0) {
      c.push_back(p);
      p /= 2;
    }
    int l = c.size();
    rep(j,1<<l) {
      int we = 0, va = 0;
      rep(k,l) {
        if(j & (1<<k)) {
          we += w[c[k]];
          va += v[c[k]];
        }
      }
      if(we <= MAX) dp[i][we] = max(dp[i][we],va); 
    }
    for(int j = 1; j < MAX; j++) dp[i][j] = max(dp[i][j],dp[i][j-1]);
  }
  int q;
  cin >> q;
  int ans[q];
  rep(i,q) {
    int p, l;
    cin >> p >> l;
    if(depth(p) <= 9) ans[i] = dp[p][l];
    else {
      ans[i] = 0;
      vector<int> c;
      while(depth(p) > 9) {
        c.push_back(p);
        p /= 2;
      }
      int s = c.size();
      rep(j,1<<s) {
        int we = 0, va = 0;
        rep(k,s) {
          if(j & (1<<k)) {
            we += w[c[k]];
            va += v[c[k]];
          }
        }
        if(we <= l) ans[i] = max(ans[i],va+dp[p][l-we]); 
      }
    }
  }
  for(auto x : ans) cout << x << endl;
  return 0;
}


Measured memory_bytes: 206700
m,n=map(int,input().split())
l=[list(input()) for _ in range(m)]
# print(l)
dx=[1,1,0,-1,-1,-1,0,1]
dy=[0,1,1,1,0,-1,-1,-1]

for i in range(m):
    for j in range(n):
        if l[i][j]=="#":
            # print(i,j)
            continue
        elif l[i][j]==".":
            cnt=0
            for k in range(8):
                x=dx[k]+i
                y=dy[k]+j
                if (x<0 or x>=m or y<0 or y>=n):continue
                elif l[x][y]=="#" :
                    cnt+=1
            l[i][j]=str(cnt)
for i in range(m):
    print("".join(l[i]))

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll a,b,t,ans=0;
  cin>>a>>b>>t;
  for (int i=a; i<=t; i += a) {
    ans+=b;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {	
	public static int check(long p,int[] T,int k,int n){
		int i =0;
		for(int j=0;j<k;j++){
			long  s = 0;
			while(s+T[i]<=p){
				s +=T[i];
				i++;
				if(i==n) return n;
			}
		}
		return i ;
	}
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n,k;
		n = sc.nextInt();
		k = sc.nextInt();
		int[] T = new int[n];
		for(int i=0;i<n;i++){
			T[i] = sc.nextInt();
		}
		long l=0;
		long r = 100000*10000;
		long mid=0 ;
		while(r-1>l){
			 mid = l+(r-l)/2;
			int v = check(mid,T,k,n);
			if(v>=n) r=mid;
			else l = mid;
		}
		System.out.println(r);
		
	}
}

Measured memory_bytes: 70436
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  bool flag = false;
  while (n--) {
    int a;
    cin >> a;
    if (a % 2 == 1)
      flag = true;
  }
  cout << (flag ? "first" : "second") << endl;
}

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

int main()
{
    string s;
    cin >> s;
    if (s == "Sunny")
    {
        cout << "Cloudy" << endl;
    }
    if (s == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    if (s == "Rainy")
    {
        cout << "Sunny" << endl;
    }
    return 0;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    string s;
    cin >> s;

    int ans = 0;
    if(s == "RRR"){ ans = 3; }
    else if(s == "RRS" || s == "SRR") { ans = 2; }
    else if(s == "SSS") { ans = 0;}
    else ans = 1;
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
int main()
{
    int a,  d1, d2;
    scanf("%d", &a);
    d1 = a/10;
    d2 = a%10;
    if(d1==9)
    {
        printf("Yes");
    }
    else if(d2==9)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1732
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        for(int i=1;i<=N;i++){
            A[i]=sc.nextInt();
        }
        long ans = 0;
        for(int i=1;i<=N;i++){
            if(A[i]%2==1){
                ans += A[i]/2;
                A[i]=1;
            }
            else if(A[i]%2==0&&A[i]>=2){
                ans += (A[i]-2)/2;
                A[i]=2;
            }
        }
        for(int i=1;i<=N;i++){
            if(A[i]==0) continue;
            if(A[i]==1){
                if(A[i-1]==1){
                    ans += 1;
                    A[i-1]=0;
                    A[i]=0;
                }
            }
            else if(A[i]==2){
                if(A[i-1]==0){
                    ans += 1;
                    A[i]=0;
                }
                else{
                    ans += 1;
                    A[i-1]=0;
                    A[i]=1;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 51248
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		long a =0 ,b =0 ,x =fr.nextLong() ,nm ,dn ;
o: 		for (a =0 ; a<120 ; ++a) {
 			for (b =0 ; b<a ; ++b) {
 				nm =pow (a,5) ;	dn =pow (b,5) ;
 				if (nm-dn == x)	break o ;
 				if (nm+dn == x)	{	b*=-1 ;	break o ;	}
 			}
 		}
		op.println(a+" "+b) ;	op.flush();	op.close();
	}
	static long pow (long b , long e) {
		if (e==0l)	return 1l;
		if (e==1l)	return b;
		long dm =pow(b,e/2l) ;	dm *= dm ;
		if ((e&1l)==1l)	dm *= b ;
		return dm ;
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
}

Measured memory_bytes: 36892
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (a > b) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll n; cin >> n;
  
  if (n % 2) cout << n * 2 << endl;
  else cout << n << endl;

  return (0);
}


Measured memory_bytes: 3668
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define N 0
#define INF 0x3f3f3f3f
#define LL long long
#define mz(x) ms(x,0)
#define ms(x,y) memset(x,y,sizeof(x))
#define mc(x,y) memcopy(x,y,sizeof(y))
#define MOD 1000000007

using namespace std ;

int main()
{
	LL n ;
	scanf ("%lld", &n) ;
	
	stack<char> st ;
	while (n)
	{
		char c ;
		if (n % 26 == 0)
			c = 'z' ;
		else
			c = n % 26 - 1 + 'a' ;
		st.push (c) ;
		
		n /= 26 ;
		if (c == 'z')
			n-- ;
	}
	
	while (!st.empty())
	{
		cout << st.top () ;
		st.pop () ;
	}

	return 0 ;
}

Measured memory_bytes: 3132
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iostream>
typedef long long ll;
using namespace std;
int main()
{
	int n;
	cin >> n;
	int x = n%1000;
	if(x>0){
		int temp = 1000 +(n-x);
		cout << temp-n;
	}
	else{
		cout << x;
	}
}

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

int main (){
    int N, S, A, B, C;
    string s, a, b, c;
    int ans = 0;
    cin >> s >> a;
    for (size_t i = 0; i < s.size(); i++)
    {
        if (s.at(i) != a.at(i))
        {
            ans++;
        }
        
    }
    
    

    cout << ans << endl;    
}

Measured memory_bytes: 3920
n=int(input())
l = list(map(int,input().strip().split()))[:n] 
rs= 1
l.sort()
if l[0]==0 :
    rs=0
else:
    for i in range(n):
        if(10**18 // rs < l[i]):
            rs = -1
            break
        rs=l[i]*rs
print(rs)

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q.r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
    ll n; cin >> n;
    ll ans = 0;
    vll a(n); rep(i, n) cin >> a[i];
    while(n)
    {
        for(ll i = 1;i < n;i++)
        {
            if(a[i - 1] > a[i])
            {
                swap(a[i - 1], a[i]);
                ans++;
            }
        }
        n--;
    }
    for(ll i = 0;i < a.size() - 1;i++) cout << a[i] << " ";
    cout << a[a.size() - 1] << endl;
    fin(ans)
    return;
}

//前処理
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20); //高精度少数表示
    Main();
    return 0;
}



Measured memory_bytes: 3172
N,M = map(int,input().split())
info = [list(map(int,input().split())) for i in range(M)]
info_new = sorted(info,key=lambda x:(x[0],x[1]))
note = info_new[0][0]
cnt = 1
for i in range(M):
    if info_new[i][0] == note:
        info_new[i][1] = cnt
        cnt += 1
    else:
        note = info_new[i][0]
        cnt = 1
        info_new[i][1] = cnt
        cnt += 1
        
for i in range(M):
    pri = str(info[i][0])
    bir = str(info[i][1])
    number = "0"*(6-len(pri)) + pri + "0"*(6-len(bir)) + bir
    print(number)

Measured memory_bytes: 37696
#include <bits/stdc++.h>
/*...
  ...
  author 
  @
  Aman Kothari
  .....
  .....*/
using namespace std;
#define ll unsigned long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  
    ll n;
    cin>>n;
    bool ans=true;
    ll seven=7,count=-1;
    if(n%2==0 || n%5==0){
    	cout<<"-1"<<"\n";
    }
    else{
    	ll i=10;
    while(ans){
    	if(seven%n==0){
    		count++;
    		ans=false;
    		break;
    	}
    	else{
    		 count++;
    		 seven=(seven*i)+7;
    		 seven=seven%n;
    	}
    }
    cout<<((count+1))<<"\n";
    }
	
    return 0;
}

Measured memory_bytes: 3636
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  vector<int> a(n);
  REP(i,n) a[i] = getInt();

  int ans = 0;
  int cur = 1;

  REP(i,n){
    if(a[i] == cur){
      cur++;
    } else {
      ans++;
    }
  }

  if(ans == n) ans = -1;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <cmath>

using namespace std;

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

	int* map = new int[n];
	int x;
	int sum = 0;
	
	for (int i = 0; i < n; i++) {
		cin >> x;
		map[i] = x;
		sum += x;
	}

	int ans = -1;
	int diff = INT_MAX;

	for (int i = 0; i < n; i++) {
		if (diff > abs(n * map[i] - sum)) {
			diff = abs(n * map[i] - sum);
			ans = i;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;
int n;
int l[10];
int a[3];
int ans=123456789;
void dfs(int bm,int k,int cost){
    if(k==3){
        ans=min(cost,ans);
        return;
    }
    for(int s=1;s<(1<<n);++s){
        if(bm&s)continue;
        int cnt=0,len=0;for(int i=0;i<n;++i)if(s&(1<<i))++cnt,len+=l[i];
        int cur=0;
        if(cnt>1)cur+=10*(cnt-1);
        cur+=abs(a[k]-len);
        dfs(bm|s,k+1,cost+cur);
    }
}

int main() {
    cin>>n>>a[0]>>a[1]>>a[2];
    for(int i=0;i<n;++i){
        cin>>l[i];
    }
    dfs(0,0,0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<cstring>
#include<vector>

using namespace std;

typedef long long ll;

int main(){
  int n,m,ans=0;
  vector<int>graph[100];
  vector<int>perm;
  
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  
  for(int i=2;i<=n;i++){
    perm.push_back(i);
  }
  
  do{
    int now=1,next;
    for(int i=0;i<n-1;i++){
      next=perm[i];
      if(find(graph[now].begin(),graph[now].end(),next)==graph[now].end()){
	break;
      }
      if(i==n-2) ans++;
      now=next;
    }
  }while(next_permutation(perm.begin(),perm.end()));

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


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

using ll = int64_t;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

const int maxN = 50 + 5;
ll dp[maxN][maxN][maxN * maxN];

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

  int n, a;
  std::cin >> n >> a;
  vi card(n);
  rep(i, n) cin >> card[i];
  ll ma = *max_element(rng(card));
  rep(i, n + 1) dp[i][0][0] = 1;
  rrep(i, n) rrep(j, n) rrep(k, n * ma) {
    if (k < card[i - 1])
      dp[i][j][k] = dp[i - 1][j][k];
    else
      dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - card[i - 1]];
  }
  ll ans = 0;
  for (int i = 1; i <= n && i * a <= n * ma; i++)
    ans += dp[n][i][i * a];
  std::cout << ans << "\n";
}


Measured memory_bytes: 66560
{
  const _mod = 10 ** 9 + 7

  const main = (input: string) => {
    const r = reader(input)
    const [n, _m] = r.ns()
    const a = r.nls()

    const dp: number[] = Array(n + 1)

    dp.fill(0)
    a.forEach(ai => (dp[ai] = -1))
    dp[0] = 1

    for (let i = 0; i < n; i++) {
      // console.log(dp.join(' '))
      if (dp[i] === -1) continue

      if (dp[i + 1] !== -1) {
        dp[i + 1] = (dp[i + 1] + dp[i]) % _mod
      }
      if (dp[i + 2] !== -1) {
        dp[i + 2] = (dp[i + 2] + dp[i]) % _mod
      }
    }
    console.log(dp[n])
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')

  main(getInput())
}


Measured memory_bytes: 16868
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007LL
#define pi 3.141592653589
//#define mod 998244353 
using namespace std;

int power(int x, int y) ;
int gcd(int a, int b) ;

/*___________________________TEMPLATE END______________________________*/

vi v[1000001] ;
bool vis[1000001] ;
int dis[1000001] ;

void bfs(int src) {
    queue<int> q ;
    q.push(src) ;
    vis[src] = true ;
    dis[src] = 0 ;
    while(!q.empty()) {
        int curr = q.front() ;
        q.pop() ;
        for(int i=0; i<v[curr].size(); i++) {
            if(!vis[v[curr][i]]) {
                q.push(v[curr][i]) ;
                dis[v[curr][i]] = dis[curr] + 1 ;
                vis[v[curr][i]] = true ;
            }
        }
    }
}

signed main() {
    quickie
    int n, m ;
    cin >> n >> m ;
    rep(i, 0, m) {
        int a, b ;
        cin >> a >> b ;
        v[a].pb(b) ;
        v[b].pb(a) ;
    }
    bfs(1) ;
    rep(i, 2, n+1) {
        if(dis[i] == 0) {
            cout << "No\n" ;
            return 0 ; 
        }
    }
    cout << "Yes\n" ;
    rep(i, 2, n+1) {
        for(auto it : v[i]) {
            if(dis[it] == dis[i]-1) {
                cout << it << "\n" ;
                break ;
            }
        }
    }
} 

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

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

Measured memory_bytes: 34264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL<<61LL;

int main(){
	ll M, K;
	cin >> M >> K;
	if(M == 0){
		if(K == 0)
			cout << "0 0" << endl;
		else
			cout << "-1" << endl;
	}else if(M == 1){
		if(K == 0)
			cout << "0 0 1 1" << endl;
		else
			cout << -1 << endl;
	}else{
		bool flag = true;
		set<ll> k;
		for(ll i=0;i<40;i++){
			if((1LL<<i) & K){
				k.insert(1LL<<i);
				if(i>=M)
					flag = false;
			}
		}
		vector<ll> ansl;
		vector<ll> ansr;
		for(ll i=0;i<1LL<<M;i++){
			if(k.find(i) == k.end())
				ansl.push_back(i);
			else
				ansr.push_back(i);
		}
		if(flag){
			for(auto &&x : ansl)
				cout << x << " ";
			for(auto &&x : ansr)
				cout << x << " ";
			reverse(ansl.begin(), ansl.end());
			reverse(ansr.begin(), ansr.end());
			for(auto &&x : ansl)
        cout << x << " ";
      for(auto &&x : ansr)
				cout << x << " ";
			cout << endl;
		}else
			cout << -1 << endl;
	}
}


Measured memory_bytes: 2936
#include <iostream>
using namespace std;
char a[5]={'a','e','i','o','u'},b;
int main(){
	cin>>b;
	for(int i=0;i<5;i++){
		if(b==a[i]){
			cout<<"vowel"<<endl;return 0;
		}
	}
	cout<<"consonant"<<endl;
	return 0;
} 

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll X;
    cin >> X;
    if(X >= 30) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


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

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}


vector<string> split(const string &str, char delim)
{
  istringstream iss(str); string tmp; vector<string> res;
  while(getline(iss, tmp, delim)) res.push_back(tmp);
  return res;
}

void solve(string s)
{
  vector<string> words = split(s,0x20);
  for(auto t : words)
  {
    if(t.size() != 4) continue;
    else
    {
      FOR(a,1,25)
      {
        if(gcd(a,26)!=1) continue;
        FOR(b,0,25)
        {
          string tmp = t;
          REP(j,4) tmp[j] = 'a'+((a*(tmp[j]-'a')+b)%26);
          if(tmp == "this" || tmp == "that")
          {
            REP(i,s.size()) if(s[i] != 0x20)s[i] = 'a'+((a*(s[i]-'a')+b)%26);
            printf("%s\n",s.c_str());
            return;
          }
        }
      }
    }
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n; cin.ignore();
  REP(i,n)
  {
    string s;
    getline(cin,s);
    solve(s);
  }
  return 0;
}

Measured memory_bytes: 3016
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var A = input[1].split(" ").map(i => BigInt(i));
  A.sort();
  var ans = 1n;
  for(var i=0;i<N;i++){
    ans = ans * A[i];
    if(ans > 1000000000000000000n){
      ans = -1;
      break;
    }else if(ans === 0n){
      break;
    }
  }
  ans = ans.toString();

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 60116
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::{BinaryHeap, VecDeque};


#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, m) = (line[0], line[1]);

    let mut work_vec: Vec<(usize, usize)> = Vec::new();
    let mut heap = BinaryHeap::new();


    for _ in 0..n{
        let line = read_as_vec();
        work_vec.push((line[0], line[1]));
    }


    let mut sum_payment: usize = 0;
    //println!("{:?}", work_vec);
    work_vec.sort();
    work_vec.reverse();
    //println!("{:?}", work_vec);

    for i in 1..m+1{
        while work_vec.len() > 0 && work_vec.last().unwrap().0 <= i{
            heap.push(work_vec.pop().unwrap().1);
        }

        if let Some(payment) = heap.pop(){
            sum_payment += payment;
        }
    }

    println!("{:?}", sum_payment);
    //for work in work_vec{
    //}
}


Measured memory_bytes: 8444
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
#define rep1(i,n) for(int i=1;i<= (n);i++)
using namespace std;
typedef long long ll;
const static ll MOD = (1e+9)+7;
const static ll INF = LLONG_MAX;


int main(){
    int x,y,z;cin>>x>>y>>z;
    swap(x,y);swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;		// c:入力
  string res = "consonant";		// res:結果
  
  cin >> c;		// ｃの入力
  if(c == 'a' || c == 'i' || c=='u' || c=='e' || c=='o'){
    res = "vowel";
  }

  cout << res << endl;
}

Measured memory_bytes: 256
//In the name of God

#include <bits/stdc++.h>
using namespace std;

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

const int N = 1e5+10 , mod = 1e9+7;

int pw[N] , cnt[26];

int32_t main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   pw[0] = 1;
   for(int i = 1 ; i < N ; i++)
      pw[i] = 1ll * pw[i - 1] * 2 % mod;
   int n;
   cin >> n;
   string s;
   cin >> s;
   for(int i = 0 ; i < n ; i++)
      cnt[s[i] - 'a']++;
   int ret = 1 , ans = pw[n] , num = n;
   for(int i = 0 ; i < 26 ; i++){
      num -= cnt[i];
      if(cnt[i] < 2){
         ret = ret * (cnt[i] + 1) % mod;
         continue;
      }
      int x = pw[cnt[i]] - cnt[i] - 1;
      if(x < 0)
         x += mod;
      x = 1ll * x * pw[num] % mod * ret % mod;
      ans -= x;
      if(ans < 0)
         ans += mod;
      ret = 1ll * ret * (cnt[i] + 1) % mod;
   }
   cout << ans - 1;
   return 0;
}


Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <iostream>
#include <complex>
using namespace std;

#define REP(i, n)           REPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;

void solve(int n){
    P p(1,0);
    REP(i,n) p += polar(1.0, arg(p) + M_PI_2);
    printf("%f\n%f\n", p.X, p.Y);
}

int main(){
    int n;
    while(cin >> n, n > 0) solve(n-1);
    return 0;
}

Measured memory_bytes: 1272
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a + b / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {

        static void Main(string[] args)
        {
          //入力を受け取る
          var N = int.Parse(Console.ReadLine());
          long[][] map = new long[N][];
          
          for(int i = 0; i< N; i++){
            map[i] = new long[2];
            map[i] = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
          }
          
          //割る数を求める
          var waru = 1;
          for(int i = 1; i<= N; i++){
            waru *= i;
          }
          
          var kakeru = 1;
          for(int i = 1; i<= N-2; i++){
            kakeru *= i;
          }
          kakeru *= N-1;
          if(N <= 2){
            kakeru = 1;
          }
          double dis = 0;
          for(int i = 0; i< N; i++){
            for(int j = 0; j< N; j++){
              dis += kei(map[i],map[j]);
            }
          }
          
          
          Console.WriteLine(kakeru*dis/waru);
        }
        
        public static double kei(long[] i,long[] j){
          double dis = 0;
          dis = Math.Sqrt(Math.Pow(i[0]-j[0],2)+Math.Pow(i[1]-j[1],2));
          return dis;
        }
        // 最小公倍数
        public static long Lcm(long a, long b) {
            return a * (b / Gcd(a, b));
        }

        // ユークリッドの互除法 
        public static long Gcd(long a, long b) {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
  
}


Measured memory_bytes: 13396
#include <string>
#include <iostream>
#include<list>
#include<array>
#include<vector>
#include <algorithm>
#include <functional>
using namespace std;




int main()
{
	string N;

	cin >> N;

	int mod = 0;
	for (int i = 0; i < N.length(); i++) {
		mod = (mod + stoi(N.substr(i, 1))) % 9;
	}
	if (mod == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}



Measured memory_bytes: 3752
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


enum Type{
	FULL_MATCH,
	ELSE,
};

ll SHISHIMARU;
ll length,POW[16];
ll num_array[20];
ll dp[20][10000][2][2];

ll getNUM(ll pre_num,ll next){
	return (10*pre_num+next)%10000;
}

bool is_OK(ll number){
	if((number/1000)%10 != 5)return false;
	if(number-5000 <= 99 || number-5000 >= 200)return false;
	if(number%10 != 3)return false;
	return true;
}

ll recursive(ll pre_num,ll digit,Type type,bool is_completed){

	if(digit == length){
		if(is_completed)return 1;
		else{
			return 0; //G数が成立しないならreturn 0;
		}
	}

	if(dp[digit][pre_num][type][is_completed] != -1){
		return dp[digit][pre_num][type][is_completed]; //計算済ならreturn
	}

	if(is_completed == true && type == ELSE){
		return dp[digit][pre_num][type][is_completed] = POW[length-digit];
	}else if(is_completed == true && type == FULL_MATCH){
		return dp[digit][pre_num][type][is_completed] = (SHISHIMARU%POW[length-digit])+1;
	}

	ll ret = 0;
	ll limit;
	if(type == FULL_MATCH){
		limit = num_array[digit]-1;
	}else{
		limit = 9;
	}

	ll tmp;

	for(int next = 0; next <= limit; next++){
		tmp =  getNUM(pre_num,next);
		ret += recursive(tmp,digit+1,ELSE,is_completed||is_OK(tmp));
	}

	if(type == FULL_MATCH){
		tmp = getNUM(pre_num,num_array[digit]);
		ret += recursive(tmp,digit+1,FULL_MATCH,is_completed||is_OK(tmp));
	}

	return dp[digit][pre_num][type][is_completed] = ret;
}


int main(){

	for(int i = 0; i < 16; i++){
		POW[i] = pow(10,i);
	}

	ll N;
	scanf("%lld",&N);

	if(N <= 5102){
		printf("0\n");
		return 0;
	}

	SHISHIMARU = N;

	stack<ll> S;

	//Nを桁別に分解する
	while(N > 0){
		S.push(N%10);
		N /= 10;
	}

	ll index = 0;

	while(!S.empty()){
		num_array[index++] = S.top();
		S.pop();
	}

	length = index;

	for(int digit = 0; digit <= length-1; digit++){
		for(int pre_num = 0; pre_num <= 9999; pre_num++){
			for(int p = 0; p <= 1; p++){
				for(int k = 0; k <= 1; k++){
					dp[digit][pre_num][p][k] = -1;
				}
			}
		}
	}

	printf("%lld\n",recursive(0,0,FULL_MATCH,false));

	return 0;
}




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

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

    int ans;

    if (N%2 == 0) {
        ans = N/2;
    } else {
        ans = N/2 + 1;
    }
    
    cout << ans << endl;


    
    return 0;
}

Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 100000;
int N;
int a[3*MAX_N+1];
ll front[MAX_N+1], back[MAX_N+1];

int main() {
  cin >> N;
  for (int i = 1; i <= 3*N; ++i) cin >> a[i];

  priority_queue<int, vector<int>, greater<int> > fque; 
  for (int i = 1; i <= N; ++i) {
    front[0] += a[i]; fque.push(a[i]);
  }

  for (int i = 1; i <= N; ++i) {
    fque.push(a[N+i]);
    int mi = fque.top(); fque.pop();
    front[i] = front[i-1]+a[N+i]-mi;
  }

  priority_queue<int> bque; 
  for (int i = 3*N; i > 2*N; --i) {
    back[N] += a[i]; bque.push(a[i]);
  }

  for (int i = N-1; i >= 0; --i) {
    bque.push(a[N+i+1]);
    int ma = bque.top(); bque.pop();
    back[i] = back[i+1]+a[N+i+1]-ma;
  }

  ll ans = -1e18;
  for (int i = 0; i <= N; ++i) {
    ans = max(ans, front[i] - back[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a);
        a=(a*a);
        b/=2;
        if(res>INT_MAX){
            return INT_MAX;
        }
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro%mod);
}
vector<int> prime;
void seive(){
    vector<bool > isprime(101,true);
    for(int i=2;i*i<=100;i++){
        if(isprime[i]){
            for(int j=i*i;j<=100;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=100;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> arr(n);
    map<ll,int> m;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        m[arr[i]]=i;
    }
    ll c=0;
    sort(arr.begin(),arr.end());
    for(int i=0;i<n;i++){
        if(abs(i-m[arr[i]])%2==1) c++;
    }
    c=c/2;
    cout<<c;
    return 0;
}


Measured memory_bytes: 7296
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<stack>
#include<map>
using namespace std;
map<char,int>m;
int main(){
	char s[100000];
	cin>>s;
	int n;
	n=strlen(s);
	for(int i=0;i<n;i++)
		m[s[i]]++;
	printf("%d\n",m['1']);
}



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

int main() {
  // ここにプログラムを追記
  int m;
  int LAST_DAY_HOURS = 24;
  cin >> m;
  int last_time = 24 - m;
  cout << LAST_DAY_HOURS + last_time << endl;
}

Measured memory_bytes: 256