akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
const int nax = 1e6+500;
bool sieve[nax]; //0 is prime
vector<int> primes;
void init() {
	for(int i=2;i*i<nax;i++) {
		if(!sieve[i]) {
			for(int j=i*2;j<nax;j+=i) {
				sieve[j] = 1;
			}
		}
	}
	for(int i=2;i<nax;i++) {
		if(!sieve[i]) {
			primes.push_back(i);
		}
	}
}
ll myp(ll n, ll k) {
	if(k==0) return 1;
	ll ret = myp(n,k/2);
	ret = ret*ret;
	if(k%2 == 1) {
		ret *= n;
	}
	return ret;
} 
bool isPrime(ll n) {
	for(ll i=2;i<=sqrt(n);i++) {
		if(n % i == 0) {
			return false;
		}
	}
	return true;
}
set<int> used;
bool isGood(ll n) {
	if(used.count(n)) return false;
	used.insert(n);
	for(auto it:primes) {
		if(it > n) break;
		ll cnt = 1;
		while(myp(it, cnt) <= n) {
			if(myp(it,cnt) == n) {
				debug()<<imie(it) imie(cnt) imie(n);
				return true;
			} else cnt++;
		}
	}
	return false;
}
int main() {
	//init();
	ll n;
	cin >> n;
	if(n == 1) {
		cout<<0;
		return 0;
	}  else if(isPrime(n)) {
		cout<<1;
		return 0;
	}
	ll tot = 0;
	for(ll i=2;i<=sqrt(n);i++) {
		if(n%i == 0) {
			int cnt = 0;
			while(n%i == 0) {
				n/=i;
				cnt++;
			}
			for(int j=1;j<nax;j++) {
				if(cnt < j) break;
				cnt-=j;
				tot++;
			}
		}
	}
	if(n != 1 && isPrime(n)) tot++;
	cout<<tot;
}


Measured memory_bytes: 3656
#include<stdio.h>

int main(void){
    int money;
    int a,b,c,d,e,f;
    int prize1000;
    int prize5;
    scanf("%d\n",&money);
    prize1000 = money/500;
    int sub1 = money%500;
    prize5 = sub1/5;
    int answer = 1000*prize1000+5*prize5;
    printf("%d\n",answer);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int k,x;
    cin >> k >> x;
    for (int i = x-(k-1); i <= x+(k-1); i++)
    {
        if(i<-1000000 || 1000000<i)
            continue;
        cout << i << " ";
    }
    return 0;
}

Measured memory_bytes: 256
n1  = int(input())

n2 = [int(i) for i in input().split()]

r1 = 0
t1 = 0
c1 = 0

for i1 in range(n1):
    if i1 == 0:
        t1 = n2[i1]
    else:
        if t1 >= n2[i1]:
            c1 += 1
        else:
            if r1 < c1:
                r1 = c1
            c1 = 0    
        t1 = n2[i1]

if r1 < c1:
    r1 = c1

print(r1)

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <cstdint>

int main() {
  std::int_fast64_t n;
  std::cin >> n;
  std::vector<std::int_fast64_t> a(n), b(n);
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::int_fast64_t a_i;
    std::cin >> a_i;
    a[i] = a_i;
  }
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::int_fast64_t b_i;
    std::cin >> b_i;
    b[i] = b_i;
  }

  std::int_fast64_t plus_twos = 0, minus_ones = 0;
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::int_fast64_t diff = b[i] - a[i];
    if (diff >= 2) plus_twos += diff / 2;
    else if (diff < 0) minus_ones -= diff;
  }
  std::cout << (plus_twos >= minus_ones ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define maxn 300010
#define LL long long 
using namespace std;
LL a[maxn],cnt1=0,cnt2=0,n;
LL sum1[maxn],sum2[maxn];
int main(){
	cin>>n;
	for(int i=1;i<=3*n;i++){
		scanf("%lld",&a[i]);
	}
	priority_queue<LL,vector<LL>,greater<LL> > Q1;
	priority_queue<LL> Q2;
	for(int i=1;i<=n;i++){
		sum1[i]=sum1[i-1]+a[i];
		Q1.push(a[i]);
	}
	LL p;
	for(int i=n+1;i<=2*n;i++){
		p=Q1.top();
		if(p<a[i]){
			Q1.pop();
			Q1.push(a[i]);
			sum1[i]=(sum1[i-1]-p+a[i]);
		}
		else
			sum1[i]=sum1[i-1];
	}
	for(int i=3*n;i>=2*n+1;i--){
		Q2.push(a[i]);
		sum2[i]=sum2[i+1]+a[i];
	}
	for(int i=2*n;i>=n+1;i--){
		p=Q2.top();
		if(p>a[i]){
			Q2.pop();
			Q2.push(a[i]);
			sum2[i]=(sum2[i+1]-p+a[i]);
		}	
		else sum2[i]=sum2[i+1];
	}
//	for(int i=1;i<=3*n;i++) cout<<i<<' '<<sum1[i]<<' '<<sum2[i]<<endl;
	LL tem,ans=sum1[n]-sum2[n+1];
	for(int i=n;i<=2*n;i++){
		tem=sum1[i]-sum2[i+1];
		if(ans<tem) ans=tem;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8180
fun main(args: Array<String>) {
  val N = readInt()
  val S = readString()
  var l = 0
  var r = 0
  for (i in 0 until N) {
    if (S[i] == '(') {
      r++
    } else {
      if (r <= 0) {
        l++
      } else {
        r--
      }
    }
  }
  repeat(l) { print('(') }
  print(S)
  repeat(r) { print(')') }
  println()
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


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

namespace regio
{
    class Class1
    {
        static void Main()
        {
            string str;
            string[] arr;

            int X, Y;

            str = Console.ReadLine();
            arr = str.Split(' ');

            X = int.Parse(arr[0]);
            Y = int.Parse(arr[1]);

            Y = Y / 2;

            Console.WriteLine("{0}", X + Y);
        }
        
    }
}


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

int main(){
    string s;
    cin>>s;
    int n=s.size();
    vector<int>v(n);
    for(int i=0; i<n; i++){
        v[i]=s[i]-'0';
    }
    reverse(ALL(v));
    int k=1;
    vector<int>x(n+1,0);
    for(int i=0; i<n; i++){
        x.at(i+1)=(x.at(i)+v.at(i)*k)%2019;
        k*=10;
        k%=2019;
    }
    ll ans=0;
    vector<int>c(2019,0);
    for(int i=0; i<n+1; i++){
        c.at(x.at(i))++;
    }
    for(int i=0; i<2019; i++){
        ans+=(c.at(i)*(c.at(i)-1))/2;
    }
    cout<<ans<<endl;
}
    

Measured memory_bytes: 5256
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int a, b, c; cin >> a >> b >> c;
	int e = max(max(a, b), c);
	cout << (a + b + c - e) << endl;

	return 0;
}


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

const int MOD = 1000000000 + 7;

int mul(int a, int b) {
  long long res = a * 1LL * b;
  return res % MOD;
}

int fact(int n) {
  int res = 1;
  for (int i = 1; i <= n; ++ i) {
    res = mul(res, i);
  }
  return res;
}

int main()
{
  int n, m;
  cin >> n >> m;
  
  if (n > m) swap(n, m);
  if (m - n > 1) {
    cout << 0 << endl;
    return 0;
  }

  int res1 = fact(n);
  int res2 = fact(m);
  int ans = mul(res1, res2);
  
  if (n == m) ans = mul(ans, 2);

  cout << ans << endl;

  return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

pll A[100005];

struct UnionFind {
    UnionFind(int n) {
        rank.assign(n, 0);
        parent.resize(n);
        cnt.assign(n, 1);
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
    }

    int find(int x) {
        if (x == parent[x])
            return x;
        return parent[x] = find(parent[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    ll count(int x) {
        return cnt[find(x)];
    }

    void unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;

        if (rank[x] < rank[y]) {
            parent[x] = y;
            cnt[y] += cnt[x];
        }
        else {
            parent[y] = x;
            cnt[x] += cnt[y];
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }

    vector<int> rank;
    vector<int> parent;
    vector<int> cnt;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> X;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
        X.push_back(A[i].first);
    }
    sort(X.begin(), X.end());
    X.erase(unique(X.begin(), X.end()), X.end());

    UnionFind uf(X.size());
    sort(A, A + N, [](pll a, pll b) { return a.second < b.second; });
    REP(i, N - 1) {
        if (A[i].second == A[i + 1].second) {
            ll p = lower_bound(X.begin(), X.end(), A[i].first) - X.begin();
            ll n = lower_bound(X.begin(), X.end(), A[i + 1].first) - X.begin();
            uf.unit(p, n);
        }
    }

    vector<vector<ll>> Y(X.size());
    vector<ll> count(X.size(), 0);
    REP(i, N) {
        ll p = uf.find(lower_bound(X.begin(), X.end(), A[i].first) - X.begin());
        Y[p].push_back(A[i].second);
        count[p]++;
    }

    ll ans = 0;
    vector<bool> U(X.size(), false);
    REP(i, N) {
        ll p = uf.find(lower_bound(X.begin(), X.end(), A[i].first) - X.begin());
        if (U[p])
            continue;
        U[p] = true;
        sort(Y[p].begin(), Y[p].end());
        Y[p].erase(unique(Y[p].begin(), Y[p].end()), Y[p].end());

        ans += Y[p].size() * uf.count(p) - count[p];
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int mostlef = 0;
    int mostrig = w;
    int mostdown = 0;
    int mostup = h;
    rep(i,n) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) mostlef = max(x, mostlef);
        if (a == 2) mostrig = min(x, mostrig);
        if (a == 3) mostdown = max(y, mostdown);
        if (a == 4) mostup = min(y, mostup);
    }
    int area = max(mostrig - mostlef, 0) * max(mostup - mostdown, 0);
    cout << area << endl;
}

Measured memory_bytes: 256
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];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    int[] ki=new int[100001];
    int[] gu=new int[100001];
    for(int i=0;i<n;i+=2){
      gu[a[i]]++;
    }
    for(int i=1;i<n;i+=2){
      ki[a[i]]++;
    }
    int kif=0;
    int kis=0;
    int guf=0;
    int gus=0;
    for(int i=0;i<=100000;i++){
      if(ki[i]>ki[kif]){
        kis=kif;
        kif=i;
      }else if(ki[i]>ki[kis]){
        kis=i;
      }
    }
    for(int i=0;i<=100000;i++){
      if(gu[i]>gu[guf]){
        gus=guf;
        guf=i;
      }else if(gu[i]>gu[gus]){
        gus=i;
      }
    }
    if(kif!=guf){
      System.out.println(n-ki[kif]-gu[guf]);
    }else{
      System.out.println(
        Math.min(
          n-ki[kif]-gu[gus],
          n-ki[kis]-gu[guf]
        )
      );
    }
  }
}

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

class Prime
{
    int i, iLimit;

    public:
        bool isPrime(int a);
};

bool Prime::isPrime(int a)
{
    if (a == 1) return false;

    iLimit = (int)sqrt(a);
    for (i = 2; i <= iLimit; i++) {
        if (a % i == 0) break;
    }
    if (i == iLimit + 1) {
        return true;
    } else {
        return false;
    }
}

int main() {
	int n;
	cin >> n;
	vector<int> num(n);
	rep(i,n) cin >> num[i];
	
	bool elf;
	Prime objPrime;
	
	int ans = 0;
	rep(i,n){
		elf = objPrime.isPrime(num[i]);
		if(elf) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3144
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n, m, k;
	int[][] a;
	P[] ps;

	void run(){
		n=sc.nextInt();
		m=sc.nextInt();
		k=sc.nextInt();
		a=new int[n][m];
		ps=new P[k+1];
		for(int j=0; j<n; j++){
			String s=sc.next();
			for(int i=0; i<m; i++){
				if(s.charAt(i)=='.'){
					a[j][i]=0;
				}else if(s.charAt(i)=='X'){
					a[j][i]=-1;
				}else if(s.charAt(i)=='S'){
					a[j][i]=1;
					ps[0]=new P(i, j);
				}else{
					a[j][i]=s.charAt(i)-'0'+1;
					ps[s.charAt(i)-'0']=new P(i, j);
				}
			}
		}

		int ans=0;
		for(int i=0; i<k; i++){
			ans+=bfs(i);
		}
		println(ans+"");
	}

	int bfs(int s){
		LinkedList<P> que=new LinkedList<P>();
		boolean[][] visited=new boolean[n][m];
		int[][] d=new int[n][m];

		que.offer(ps[s]);
		visited[ps[s].y][ps[s].x]=true;
		int[] dx={0, 0, -1, 1};
		int[] dy={-1, 1, 0, 0};

		for(; !que.isEmpty();){
			P p=que.poll();
			for(int i=0; i<4; i++){
				P q=new P(p.x+dx[i], p.y+dy[i]);
				if(q.x>=0&&q.x<m&&q.y>=0&&q.y<n&&a[q.y][q.x]!=-1
						&&!visited[q.y][q.x]){
					que.offer(q);
					visited[q.y][q.x]=true;
					d[q.y][q.x]=d[p.y][p.x]+1;
				}
			}
		}

		return d[ps[s+1].y][ps[s+1].x];
	}

	class P{
		int x, y;

		P(int x, int y){
			this.x=x;
			this.y=y;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    if (B - A + 1 >= 2 * K) {
        for (int i = 0; i < K; i++) {
            cout << A + i << endl;
        }
        for (int i = K - 1; i >= 0; i--) {
            cout << B - i << endl;
        }
    } else {
        for (int i = A; i <= B; i++) {
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    short i, j;

    for (i = 1; i <= 9; i++) {
        for (j = 1; j <= 9; j++) {
            fprintf(stdout, "%hdx%hd=%hd\n", i, j, i * j);
        }
    }

    return 0;
}

Measured memory_bytes: 524
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    veci H(N);
    REP(i,N) cin >> H[i];
    int m = 0;
    REP(i,N) chmax(m,H[i]);
    vecveci res(m,veci(N));
    for(int i = 0; i < m; i++) {
        for(int j = 0; j < N; j++) {
            if(H[j] >= i+1) res[i][j] = 1;
            else res[i][j] = 0;
        }
    }

    /*
    REP(i,m) {
        cout << i+1 <<":{";
        for(int v:res[i]) cout << v << " ";
        cout << "}" << endl;
    }
    */
   
    int ans = 0;
    REP(i,m) {
        vector<pair<int,int>> a;
        int k = 0;
        while(k < N) {
            int cnt = 1;
            int n = res[i][k];
            while(res[i][k] == res[i][k+cnt]) cnt++;
            k += cnt;
            a.push_back(pair<int,int>(n,cnt));
        }
        for(auto p: a) {
            if(p.first == 1) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;

const int MAXN = 1055;

ll dp[20055];

int A[MAXN], B[MAXN], C[MAXN], O[MAXN];

int N;

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 1; i <= N; i++) cin >> A[i] >> B[i] >> C[i];
	iota(O, O+N+1, 0); sort(O+1, O+N+1, [&](int a, int b) {
		return A[a]+B[a] < A[b]+B[b];
	});

	fill(dp+1, dp+20055, -INFLL);
	for(int oi = 1, i; oi <= N; oi++) {
		i = O[oi];
		for(int j = B[i]; 0 <= j; j--) {
			ll t = dp[j] + C[i];
			if(dp[j+A[i]] < t) dp[j+A[i]] = t;
		}
	}

	cout << *max_element(dp, dp+20055) << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include<numeric>
#include<queue>
#include<climits>
#include<cstdio>
#include<map>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
typedef pair<ll,ll> LL_LLP;
#define INF 1000000007
#define MAX_H 20000
#define MOD 1000000007

typedef struct area{

    int x;
    int y;
    bool color;//true:赤
    bool used;

}AREA;

bool comp(const AREA& a,const AREA& b){
    return a.x < b.x;
}

int main(){

    int n,ans = 0;
    cin >> n;
    vector<AREA> a,b;

    REP(i,n){
        AREA e;
        cin >> e.x >> e.y;
        e.color = true;
        e.used = false;//使われていないとする
        a.push_back(e);
    }

    REP(i,n){
        AREA e;
        cin >> e.x >> e.y;
        e.color = false;
        e.used = false;
        b.push_back(e);
    }
    sort(b.begin(),b.end(),comp);

    /*REP(i,n){
        cout << a[i].x << " " << a[i].y << endl;
    }*/

    for(int i = 0;i < n;i++){
        /*i番目の青を見る*/
        int maxi = -INF;
        int index = -1;
        for(int j = 0;j < n;j++){
            //赤を見る
            if(a[j].x < b[i].x && a[j].y < b[i].y && a[j].color == true && a[j].used == false){
                if(maxi < a[j].y){
                    maxi = a[j].y;
                    index = j;
                }
            }
        }
        //cout << i << index << endl;
        if(index != -1){
            //ペアができる
            a[index].used = true;
            ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
(N,M,K),A,B = $<.map{|ln| ln.split.map(&:to_i) }

n,k,a = 0,K,[]
while 0<A.size && A[0]<=k
	k -= A[0]
	n += 1
	a << A.shift
end
while 0<B.size && B[0]<=k
	k -= B[0]
	n += 1
	B.shift
end
nmax = n
begin
	if 0<a.size
		k += a[-1]
		n -= 1
		a.pop
	end
	while 0<B.size && B[0]<=k
		k -= B[0]
		n += 1
		B.shift
	end
	nmax = n if nmax<n
end while 0<a.size && 0<B.size
p nmax


Measured memory_bytes: 41636
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i)
#define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME
#define REP(...) GET_MACRO_REP(__VA_ARGS__, REP3, REP2) (__VA_ARGS__)
#define RREP2(i, n) for (int i = (n - 1); i >= 0; --i)
#define RREP3(i, l, r) for (int i = (r - 1), i##_len = (l); i >= i##_len; --i)
#define GET_MACRO_RREP(_1, _2, _3, NAME, ...) NAME
#define RREP(...) GET_MACRO_REP(__VA_ARGS__, RREP3, RREP2) (__VA_ARGS__)
#define IN(type, n) type n; cin >> n
#define INALL(type, v) REP(i, v.size()) { IN(type, _tmp); v.at(i) = _tmp; }
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl
#else
#define DEBUG(x)
#endif

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#pragma endregion

int main() {
  IN(int, N);
  vector<ll> x(N);
  vector<ll> y(N);
  REP(i, N) {
    IN(ll, tmp_x);
    x.at(i) = tmp_x;
    IN(ll, tmp_y);
    y.at(i) = tmp_y;
  }

  cout << std::fixed << std::setprecision(6);

  vector<vector<long double> > dist(N, vector<long double>(N, 0));
  REP(i, N - 1) {
    REP(j, i + 1, N) {
      dist.at(i).at(j) = sqrtl((long double)(pow(x.at(i) - x.at(j), 2) + pow(y.at(i) - y.at(j), 2)));
      dist.at(j).at(i) = dist.at(i).at(j);
    }
  }

  vector<int> num;
  REP(i, 0, N) {
    num.push_back(i);
  }

  long double sum = 0;
  do {
    REP(i, N - 1) {
      sum += dist.at(num.at(i)).at(num.at(i + 1));
    }
  } while (next_permutation(ALL(num)));

  ll factorial = 1;
  REP(i, 1, N + 1) {
    factorial *= i;
  }

  long double ans = sum / (long double)factorial;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3760
/*Shivam Bhalla */
  /* f2016941@pilani.bits-pilani.ac.in */



  #include <iostream>
  #include <cstdio>
  #include <cstring>
  #include <cstdlib>
  #include <cctype>
  #include <algorithm>
  #include <map>
  #include <vector>
  #include <list>
  #include <set>
  #include <queue>
  #include <deque>
  #include <stack>
  #include <iostream>
  #include <string>
  #include <cmath>
  #include <cassert>
  #include <bits/stdc++.h>
  #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
  using namespace std;
  long long maxv = 1e9;


  int main()
  {
      int a,b;
      cin>>a>>b;
      if(a<=9 && b<=9)
        cout<<a*b;
      else
        cout<<-1;
      return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int a,b,c,d;
  	cin >> a;
  	cin >> b;
    cin >> c;
    cin >> d;
  	if( (a+b) > (c+d)){
      	cout << "Left" << endl;
    }else if((a+b) == (c+d)){
     	cout << "Balanced" << endl; 
    }else{
     	cout << "Right" << endl; 
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;
struct QES{
	int v,d,c;
	QES(){}
	QES(int x,int y,int z){v=x;d=y;c=z;}
}qes[maxn];
int n,m,q,vis[maxn],col[maxn];
vector<int> eg[maxn];
void dfs(QES nd){
	if(col[nd.v]==0) col[nd.v]=nd.c;
	if(nd.d==0) return;
	for(int i=0;i<eg[nd.v].size();i++){
		if(vis[eg[nd.v][i]]<nd.d-1){
			vis[eg[nd.v][i]]=nd.d-1;
			dfs(QES(eg[nd.v][i],nd.d-1,nd.c));
		}
	}
}
int main(){
	int t1,t2;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&t1,&t2);
		eg[t1].push_back(t2);
		eg[t2].push_back(t1);
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++) scanf("%d%d%d",&qes[i].v,&qes[i].d,&qes[i].c);
	memset(vis,-1,sizeof(vis));
	for(int i=q-1;i>=0;i--){
		if(vis[qes[i].v]<qes[i].d){
			vis[qes[i].v]=qes[i].d;
			dfs(qes[i]);
		}
	}
	for(int i=1;i<=n;i++) printf("%d\n",col[i]);
	return 0;
}

Measured memory_bytes: 9728
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string,string,char
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int SED(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;
	
	int n, h, w;
	cin >> n >> h >> w;

	int x = n - w + 1;
	int y = n - h + 1;
	
	cout << x * y << rt;

	please AC;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define lli long long int
#define all(x) x.begin(),x.end()
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
lli a[13][13];
lli c[14];
int main()
{
		int n,m,x;
		cin>>n>>m>>x;
		for(int i=0;i<n;i++)
		{
			cin>>c[i];
			for(int j=0;j<m;j++)
				cin>>a[i][j];
		}
		lli ans=LLONG_MAX;
		int k=1<<n;
		for(int i=0;i<k;i++)
		{
			vector<lli> cst(m+1,0);
			lli cost=0;
			bool f=false;
			for(int j=0;j<n;j++)
			{
				if((i&(1<<j))!=0)
				{
					cost+=c[j];
					for(int k=0;k<m;k++)
					{
						cst[k]+=a[j][k];
					}
				}

			}
			for(int j=0;j<m;j++)
			{
				if(cst[j]<x)
				{
					f=true;
					break;
				}
			}
			if(f)
				continue;
			else
				ans=min(ans,cost);
		}
		if(ans==LLONG_MAX)
			ans=-1;
		cout<<ans;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct edge{ll from,to,cost;};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<edge> g(m);
    rep(i,m){
        ll a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        g[i]={a,b,-c};
    }
    vector<ll> dist(n,inf);
    dist[0]=0;
    rep(_,2*n){
        for(auto e:g){
            if(dist[e.from]!=inf){
                chmin(dist[e.to],dist[e.from]+e.cost);
            }
        }
    }
    vector<bool> flag(n,false);
    rep(_,2*n){
        for(auto e:g){
            if(dist[e.from]!=inf){
                if(chmin(dist[e.to],dist[e.from]+e.cost)){
                    flag[e.from]=flag[e.to]=true;
                }
            }
            if(flag[e.from]) flag[e.to]=true;
        }
    }
    if(!flag[n-1]) cout<<-dist[n-1]<<endl;
    else cout<<"inf"<<endl;
}

Measured memory_bytes: 384
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL LBn(VL &v,LL a){LL mx=v.size(),mn=-1,md;while(mx-mn>1){md=(mx+mn)/2;if(v[md]<a)mn=md;else mx=md;}return mx;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  FAST;
  LL i,j,k,ans=0,K;
  cin>>K;
  FOR(i,1,K+1)FOR(j,1,K+1)FOR(k,1,K+1)ans+=GCD(i,GCD(j,k));

  cout<<ans<<endl;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int h,w;
char s[555][555];

char red[555][555],blue[555][555];

int main(){
	cin.sync_with_stdio(false);
	cin>>h>>w;
	rep(i,h)rep(j,w)cin>>s[i][j];
	rep(i,h){
		red[i][0]='#',blue[i][w-1]='#';
		red[i][w-1]='.',blue[i][0]='.';
	}
	rep(i,h){
		if(i%2){
			repl(j,1,w-1){
				red[i][j]='#',blue[i][j]='.';
			}
		}else{
			repl(j,1,w-1){
				red[i][j]='.',blue[i][j]='#';
			}
		}
	}
	rep(i,h){
		rep(j,w){
			if(s[i][j]=='#')cout<<'#';
			else cout<<red[i][j];
		}
		cout<<endl;
	}
	cout<<endl;
	rep(i,h){
		rep(j,w){
			if(s[i][j]=='#')cout<<'#';
			else cout<<blue[i][j];
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,c,i,j,count=0;
  cin>>n>>m>>c;
  int b[m];
  for(i=0;i<m;i++) cin>>b[i];
  for(i=0;i<n;i++)
  {
    vector<int> a(m);
    int tmp=c;
    for(j=0;j<m;j++) 
    {
      cin>>a[j];
      tmp+=(a[j]*b[j]);
    }
    if(tmp>0) count++;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 256
// --------------
// Tejas Pandey  |
// 02 - 08 - 20  |
// Atcoder BC 174|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,k;
  cin >> n >> k;
  ll a[n],mx = 0;
  for(int i = 0;i < n;i++) cin >> a[i],mx = max(mx,a[i]);
  ll lo = 1,hi = mx - 1,ans = mx;
  while(!(lo > hi)){
	ll mid = (lo + hi)/2;
	ll cuts = 0;
	for(int i = 0;i < n;i++) cuts += ((a[i] + mid - 1)/mid - 1);
	if(cuts <= k) hi = mid - 1,ans = mid;
	else lo = mid + 1;
  }
  cout << ans << "\n";
  return 0;
}


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

int main(){	
		
int a;

cin >> a;

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

// A - Duplex Printing (solving)


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,ans=0;
  cin >> n;
  string check = "MARCH";
  vector<string> s(n);
  map<char, ll> mp;
  rep(i,n){
    cin >> s[i];
    rep(j,5){
      if(s[i][0]==check[j]) mp[check[j]]++;
    }
  }
  ans += mp['M']*(mp['A']*mp['R']+mp['A']*mp['C']
          +mp['A']*mp['H']+mp['R']*mp['C']+mp['R']*mp['H']
          +mp['C']*mp['H']) + mp['A']*(mp['R']*mp['C']
          +mp['R']*mp['H']+mp['C']*mp['H']) + mp['R']*mp['C']*mp['H'];
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;

constexpr long long MOD = 998244353;
const int MAX_N = 200000;

long long F[MAX_N + 1], RF[MAX_N + 1];

long long Pow(long long X, long long Y) {
	if (Y == 0) return 1;
	if (Y % 2 == 0) {
		long long Z = Pow(X, Y / 2);
		return (Z * Z) % MOD;
	}
	return (X * Pow(X, Y - 1)) % MOD;
}

void init() {
	F[0] = RF[0] = 1;
	for (int i = 1; i <= MAX_N; i++) {
		F[i] = (F[i - 1] * i) % MOD;
		RF[i] = Pow(F[i], MOD - 2);
	}
}

long long Comb(long long X, long long Y) {
	if (Y < 0 || X < Y) return 0;
	long long RET = 1;
	RET *= F[X];
	RET *= RF[Y];
	RET %= MOD;
	RET *= RF[X - Y];
	RET %= MOD;
	return RET;
}

int main() {
	init();
	long long N, M, K;
	cin >> N >> M >> K;
	long long ANS = 0;
	for (int i = 0; i <= K; i++) {
		long long COUNT = 1;
		COUNT = Comb(N - 1, i);
		COUNT *= M;
		COUNT %= MOD;
		COUNT *= Pow(M - 1, N - 1 - i);
		COUNT %= MOD;
		ANS += COUNT;
		ANS %= MOD;
	}
	cout << ANS << endl;
}


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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template <class T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if(b < a) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int l, r;
    cin >> l >> r;

    vi a(2020, -1);
    for(int i = 0; i < 2020 and i <= r - l; i++) {
        if(a[i] >= 0)
            break;
        a[i] = (l + i) % 2019;
        // cout << i << " " << a[i] << endl;
    }

    int ans = 2019;
    REP(i, 2020) FOR(j, i + 1, 2020) {
        if(a[i] == -1 or a[j] == -1)
            continue;
        ans = min(ans, (a[i] * a[j]) % 2019);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[4][20000],m[5][20000];
int main()
{
	int n;
	cin>>n;
	for(int j=1;j<=2;j++)
	for(int i=1;i<=n;i++)
	scanf("%d",&m[j][i]);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=2;j++)
		f[j][i]=max(f[j-1][i],f[j][i-1])+m[j][i];
	}
	cout<<f[2][n];
}


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

//型定義
typedef long long ll;

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

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

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

int main(){
    ll cnt=0;
    string S;
    cin>>S;
    ll ans=0;
    REP(i,S.size()){
        if(S[i]=='R'){
            cnt++;
        }else{
            cnt=0;
        }
        ans=max(cnt,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3588
N = int(input())
HPs = [tuple(map(int, input().split())) for i in range(N)]

HPs.sort(key=lambda x: x[0] + x[1])

INF = float('inf')
dp = [0]
for H, P in HPs:
    if dp[-1] != INF:
        dp += [INF]
    dp = list(map(min, zip([0] + [hgt + P if hgt <= H else INF for hgt in dp], dp)))

dp += [INF]
print(dp.index(INF) - 1)


Measured memory_bytes: 123652
import numpy as np
N, A, B = map(int, input().split())
h = np.sort([int(input()) for i in range(N)])

def enough(A, B, h, T):
    h = np.ceil((h - B * T) / (A - B))
    count = sum(h[h > 0])
    
    return True if count <= T else False
right = 10 ** 9
left = 1
while right != left:
    mid = (left + right) // 2
    if enough(A, B, h, mid):
        right = mid
    else:
        left = mid + 1

print(left)

Measured memory_bytes: 17920
#include <iostream>
#include<cstdio>
#include<map>
#include<string>
using namespace std;

int main()
{
    int n;
    char str[10],com[13];
    map<string,bool> T;
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%s%s",com,str);
        if(com[0]=='i') T[string(str)]=true;
        else{
            if(T[string(str)]) printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}



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

const int inf = 1e9;
const ll linf = 1e18;

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

    int n; cin >> n;
    string s; cin >> s;
    
    cout << ((n % 2 == 0 && s.substr(0, n / 2) == s.substr(n / 2, n / 2)) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int kai, i, j, max1 = 0, max2 = 0;
	int no[10];
	scanf( "%d",&kai );
	for(i = 0; i < kai; i++){
		scanf( "%d %d %d %d %d %d %d %d %d %d", &no[0], &no[1], &no[2], &no[3], &no[4], &no[5], &no[6], &no[7], &no[8], &no[9] );
		for( j = 0; j < 10; j++){
			if(max1 < no[j])
				max1 = no[j];
			else if(max2 < no[j])
				max2 = no[j];
			else
				break;
		}
		if( j == 10 )
			printf( "YES\n" );
		else
			printf( "NO\n" );
		max1 = max2 = 0;
	}
	return 0;
}

Measured memory_bytes: 580
'use strict'
function main(inp) {
  inp = inp.trim().split('\n')
  const N = inp.shift();
  inp = inp.sort();
  let count = 0;
  let max = 0;
  let ans = new Set();
  for(let i = 0; i < N; i++){
  	count++;
    if( i+1 == N || inp[i + 1] != inp[i]){
      if(count > max){
        ans.clear();
        ans.add(inp[i]);
        max = count;
      } else if(count == max){
		ans.add(inp[i]);
      }
      count = 0;
    }
  }
  ans.forEach(a=>console.log(a));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 46584
#include <iostream>
#include <vector>
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
template<typename A> using V = std::vector<A>;
using vi = V<int>;
using vvi = V<vi>;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
const int INF = 1000000000;
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vi c(m);
  rep(i, m) cin >> c[i];
  vi dp(n + 1, INF);
  dp[0] = 0;
  rep(i, dp.size()) rep(j, m) if (i - c[j] >= 0) cmin(dp[i], dp[i - c[j]] + 1);
  cout << dp[n] << endl;
}

Measured memory_bytes: 3132
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastInput in = new FastInput(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ABC178D solver = new ABC178D();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class ABC178D {
	
		static int mod = 1000000007;
		static int n;
		static long[] fac;
		static long[] finv;
		
		public void solve(int testNum, FastInput in, PrintWriter out) {
			
			n = in.nextInt();
			
			if(n < 3) {
				out.println(0);
				return;
			}
			int []dp = new int [n+1];
			dp[0] = 1;
			dp[1] = dp[2] = 0;
			
			for(int i = 3; i <= n ; i++) {
				for(int j = 0 ; j <= i-3 ; j++) {
					dp[i] = (dp[i] + dp[j])%mod;
				}
			}
			
			out.println(dp[n]);
		}
}
static class FastInput{
	private final BufferedReader in;
	private String[] buff;
	private int index = 0;
	
	public FastInput(InputStream is) {
		in = new BufferedReader(new InputStreamReader(is));
	}
	String nextLine() {
		try {
			return in.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	String next() {
		while (buff == null || index >= buff.length) {
			buff = nextLine().split(" ");
			index = 0;
		}
		return buff[index++];
	}
	int nextInt() {
		return Integer.parseInt(next());
	}
	
	long nextLong() {
		return Long.parseLong(next());
	}
	
	Double nextDouble() {
		return Double.parseDouble(next());
	}
	
	BigInteger nextBigInteger() {
		return new BigInteger(next());
	}
	
	BigDecimal nextBigDecimal() {
		return new BigDecimal(next());
	}
	
	public int[] nextIntArray(final int n) {
		final int[] res = new int [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextInt();
		}
		return res;
	}
	
	public long[] nextLongArray(final int n) {
		final long[] res= new long [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextLong();
		}
		return res;
	}
	
	public double[] nextDoubleArray(final int n ) {
		final double[] res = new double [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextDouble();
		}
		return res;
	}
	
	
	public int[][] nextInt2DArray(final int n , final int m){
		int [][]res = new int [n][m];
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j < m ;j++) {
				res[i][j] = nextInt();
			}
		}
		return res;
	}
	public long[][] nextLong2DArray(final int n , final int m){
		long [][]res = new long [n][m];
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j < m ;j++) {
				res[i][j] = nextLong();
			}
		}
		return res;
	}
	
	public char[][] nextChar2DArray(final int n){
		char [][]res = new char [n][];
		
		for(int i = 0 ; i < n ;i++) {
			String s = next();
			res[i] = s.toCharArray();
		}
		
		return res;
	}
}

}


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

int main() {
  int W, H, N;
  cin >> W >> H >> N;

  bool is_black[W][H] = {{0}};

  for (int i = 0; i < N; i++) {
    int xi, yi, ai;
    cin >> xi >> yi >> ai;

    for (int p = 0; p < W; p++) {
      for (int q = 0; q < H; q++) {
        if (ai == 1 && p < xi) is_black[p][q] = 1;
        if (ai == 2 && p >= xi) is_black[p][q] = 1;
        if (ai == 3 && q < yi) is_black[p][q] = 1;
        if (ai == 4 && q >= yi) is_black[p][q] = 1;
      }
    }
  }

  int ans=0;
  for (int p = 0; p < W; p++) {
    for (int q = 0; q < H; q++) {
      if (!is_black[p][q]) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256