akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
ll a[100010];
ll dp[100010];

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

  cin>>n;
  rep(i,n)cin>>a[i];

  ll res=0;
  for(ll i=n-2;i>=0;i--){
    if(a[i]>=a[i+1]){
      dp[i]=dp[i+1]+1;
    }else{
      dp[i]=0;
    }
    maxch(res,dp[i]);
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 1792
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	k := getNextInt(scanner)

	aa := make([]int, n)
	m := 0
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
		if m < aa[i] {
			m = aa[i]
		}
	}
	g := aa[0]
	for i := 1; i < n; i++ {
		g = gcd(g, aa[i])
	}

	ans := "IMPOSSIBLE"

	if m >= k && (m-k)%g == 0 {
		ans = "POSSIBLE"
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}

func gcd(m, n int) int {
	if n == 0 {
		return m
	}
	return gcd(n, m%n)
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
const int MN = 1e5+3;
int main () {
	int a,b,c;
  	scanf ("%d %d %d",&a,&b,&c);
  	printf ("%s\n",a+b+c>=22?"bust\n":"win\n");
	return 0;
}

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

int par0[200000], rank0[200000], par1[200000], rank1[200000];
int find0(int a) {
	if (par0[a] == a)return a;
	return par0[a] = find0(par0[a]);
}
void unite0(int a, int b) {
	a = find0(a);
	b = find0(b);
	if (rank0[a]>rank0[b]) {
		par0[b] = a;
	}
	else if (rank0[a]<rank0[b]) {
		par0[a] = b;
	}
	else {
		par0[b] = a;
		rank0[a]++;
	}
}
int find1(int a) {
	if (par1[a] == a)return a;
	return par1[a] = find1(par1[a]);
}
void unite1(int a, int b) {
	a = find1(a);
	b = find1(b);
	if (rank1[a]>rank1[b]) {
		par1[b] = a;
	}
	else if (rank1[a]<rank1[b]) {
		par1[a] = b;
	}
	else {
		par1[b] = a;
		rank1[a]++;
	}
}
int main() {
	int a, b, c; cin >> a >> b >> c;
	for (int d = 0; d< a; d++) {
		par0[d] = d;
		par1[d] = d;
	}
	for (int d = 0; d< b; d++) {
		int e, f; scanf("%d%d", &e, &f); e--; f--;
		unite0(e, f);
	}
	for (int d = 0; d< c; d++) {
		int e, f; scanf("%d%d", &e, &f); e--; f--;
		unite1(e, f);
	}
	unordered_map<int, unordered_map<int,int>>U;
	for (int d = 0; d< a; d++) {
		U[find0(d)][find1(d)]++;
	}
	for (int i = 0; i < a; i++) {
		if (i)printf(" ");
		printf("%d", U[find0(i)][find1(i)]);
	}
	puts("");
}

Measured memory_bytes: 29896
N = int(input())
b = list(map(int, input().split()))
bb = [0 for _ in range(N+1)]
ans = []

for num, val in list(enumerate(b))[::-1]:
    if not sum(bb[::num+1]) % 2 == val:
        bb[num+1] = 1
        ans.append(str(num+1))
print(len(ans))
if len(ans):
    print(' '.join(ans))

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

using namespace std;

#define ll long long

int main() {
	int first, last;
	first = last = -1;

	int k, t;
	scanf("%d %d", &k, &t);

	set<pair<int, int>, greater<pair<int, int>>> vec;

	for (int i = 0; i < t; i++) {
		int a;
		scanf("%d", &a);
		vec.emplace(a, i);
	}

	auto p = *vec.begin();
	first = last = p.second;
	vec.erase(vec.begin());
	if (p.first > 1) vec.emplace(p.first - 1, p.second);

	// printf("usei o %d\n", first);

	for (int i = 1; i < k; i++) {
		bool done = false;
		for (auto p : vec) {
			if (p.second != first) {
				// printf("usando o %d\n", p.second);
				first = p.second;
				vec.erase(p);
				if (p.first > 1) {
					vec.emplace(p.first - 1, p.second);
				}
				done = true;
				break;
			} else if (p.second != last) {
				last = p.second;
				vec.erase(p);
				if (p.first > 1) {
					vec.emplace(p.first - 1, p.second);
				}
				done = true;
				break;
			}
		}

		if (!done) {
			printf("%d\n", vec.begin()->first);
			return 0;
		}
	}

	printf("0\n");

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;


typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};

ll i,j,k,l,ii,jj;
ll n,m;
ll x;
ll p[20005];
ll a[20005],b[20005],c[20005];
ll syo=0;


int main(){
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>p[i];
        c[p[i]]=i;
    }
    for(i=1;i<=n;i++){
        a[i]=i;
        b[i]=c[i]-a[i];
    }
    ll sa=0;
    for(i=1;i<n;i++){
        if(b[i+1]-b[i]>sa){
            sa=b[i+1]-b[i];
        }
    }
    ll num=sa;
    for(i=1;i<=n;i++){
        a[i]=a[i]-(n-i)*(num+1);
        if(a[i]<0 && a[i]<syo)syo=a[i];
    }
    cout<<endl;
    for(i=1;i<=n;i++){
        b[i]=b[i]+(n-i)*(num+1);
        if(b[i]<0 && b[i]<syo)syo=b[i];
    }
    syo=(-1)*syo;
    syo+=3;
    for(i=1;i<=n;i++){
        cout<<a[i]+syo<<" ";
    }
    cout<<endl;
    for(i=1;i<=n;i++){
        cout<<b[i]+syo<<" ";
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 5888
main = interact $ unlines . map (show . itp1_7_b . map read . words) . init . lines
itp1_7_b [n,x] = length [(a1,a2,a3)| a1<-[1..n], a2<-[1..n], a3<-[1..n], (a1<a2)&&(a2<a3), a1+a2+a3==x]

Measured memory_bytes: 5072
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

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

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <typename T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    int N;
    cin >> N;
    using P = pair<int, int>;
    vector<P> tasks(N);
    cin >> tasks;

    sort(ALL(tasks), [](P p1, P p2) { return p1.second < p2.second; });

    int time = 0;
    REP(i, N) {
        time += tasks[i].first;
        if (time > tasks[i].second) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1792
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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; }




// ***************************************


int main(){

    int N;
    cin >> N;

    vector<ll> A(N + 1);
    vector<ll> dif(N);
    FOR(i, 1, N + 1) {
        cin >> A[i];

        ll idx = i - A[i];
        if (idx >= 0 && idx < N){
            dif[idx]++;
        }
    }

    ll ans = 0;
    FOR(i, 1, N + 1){
        ll idx = i + A[i];
        if (idx < N){
            ans += dif[idx];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6412
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	int a, b, c;

	cin >> a >> b >> c;

	if (c >= a&&c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

for i in range(2, N+1):
    if N%i == 0:
        a = i
        b = N//i
        if a <= 9 and b <= 9:
            break

if N <= 2:
    print("Yes")
elif a <= 9 and b <= 9:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
 
int main(void){
 
  char card[201];
  char f;
  int i, ii, iii, m, h, a, o;
 
  for(o = 0; o > -1; o++){
    scanf("%s", card);
    if(card[0] == '-') return 0;
    a = strlen(card) -1;
    scanf("%d", &m);
    for(i = 0; i < m; i++){
      scanf("%d", &h);
      for(ii = 0; ii < h; ii++){
    f = card[0];
    for(iii = 0; iii < a; iii++){
      card[iii] = card[iii+1];
    }
    card[a] = f;
      }
    }
    printf("%s\n", card);
  }
}
 

 

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

int n, A, B, x, y, z, dp[500][500], ans;

int main () {
	
	scanf("%d%d%d", &n, &A, &B);
	
	FOR(i, 0, 500) FOR(j, 0, 500) dp[i][j] = 1007483647;
	
	ans = 1007483647;
	
	dp[0][0] = 0;
	
	FOR(tt, 0, n) {
		scanf("%d%d%d", &x, &y, &z);
		FOD(i, 500, x) FOD(j, 500, y) 
			dp[i][j] = min(dp[i][j], dp[i - x][j - y] + z);
	}
	
	FOE(i, 1, 500) {
		if (A * i >= 500 || B * i >= 500) break;
		ans = min(ans, dp[A * i][B * i]);
	}
	
	if (ans == 1007483647) printf("-1\n");
	else printf("%d\n", ans);
	
	return 0;
	
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#else
template<class...T>void dprint(T&&...t){_print(cerr,t...);}
#endif
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<<(ostream&o,const multiset<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}


int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    string s;
    cin>>s;
    if(s.size()!=26){
        bool c[26]={};
        REPA(i,s)c[s[i]-'a']=1;
        REP(i,26)if(!c[i]){
            cout<<s+(char)(i+'a')<<endl;
            break;
        }
    }else{
        REPR(i,25){
            if(s[i+1]>s[i]){
                dprint(i);
                bool c[26]={};
                REP(j,i)c[s[j]-'a']=1;
                REP(i,26)cerr<<c[i]<<' ';cerr<<endl;
                cout<<s.substr(0,i);
                REP(j,s[i]+1-'a',26){
                    dprint(j);
                    if(!c[j]){
                        cout<<(char)(j+'a')<<endl;
                        break;
                    }
                }
                break;
            }
            else if(i==0){
                cout<<-1<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = count = 0; pro = 1

s=collections.deque(input())
t=input()
for i in range(len(s)):
    s.rotate(1)
    if "".join(s)==t:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 38640
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll target;

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

    ll maxi=0,f=0,mini=INF,sum=0;
    string str,str2;
    ll h,w;
    ll n,x,m;
    ll a,b,d,c;
    multiset<int> s;
    vector<ll> v(100);
    v[0]=2;
    v[1]=1;
    cin>>target;
    for(ll i=2;i<87;i++){
        v[i]=v[i-1]+v[i-2];
    }
    cout<<v[target];
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r
    return a

l=[0]*(n+1)
for i in range(n):
    l[i+1]=gcd(l[i],a[i])

print(l[n])


Measured memory_bytes: 62704
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

ll n,s;
ll a[3030];
ll MOD=998244353;
ll dp[3030][3030];

ll f(ll x, ll y){
	if(y<0)return 0;
	ll &r=dp[x][y];
	if(r>=0)return r;
	if(y==a[x]){
		r=x+1;
		if(x>0)r+=f(x-1,y),r%=MOD;
		return r;
	}
	if(x==0){
		return r=0;
	}
	/*if(y==s){
		r=(f(x-1,y-a[x])*(n-x))%MOD;
		return r;
	}else{*/
		r=(f(x-1,y)+f(x-1,y-a[x]))%MOD;
	//	cout<<x<<" "<<y<<" "<<r<<"\n";
		return r;
	//}
}

int main(){FIN;
	cin>>n>>s;
	fore(i,0,n)cin>>a[i];
	mset(dp,-1);
	ll res=0;
	fore(i,0,n)res+=f(i,s),res%=MOD;
	cout<<res;
	return 0;
}

Measured memory_bytes: 72192
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int money,age;
    
    cin >> age >> money;
    
    if(age >= 6 && age <= 12){
        money = money / 2;
    }
    
    if(age <= 5){
        money = 0;
    }
    
    cout << money << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c,m=0;
    cin>>n;
    ll arr[n+1],brr[n];
    for(i=0;i<n+1;i++) cin>>arr[i];
    for(i=0;i<n+1;i++) m+=arr[i];
    for(i=0;i<n;i++) cin>>brr[i];
    for(i=0;i<n;i++)
    {
        if(arr[i]>=brr[i])
        {
            arr[i]-=brr[i];
            brr[i]=0;
        }
        else
        {
            brr[i]-=arr[i];
            arr[i]=0;
        }
        if(brr[i]>0)
        {
            if(arr[i+1]>=brr[i])
            {
                arr[i+1]-=brr[i];
                brr[i]=0;
            }
            else
            {
                brr[i]-=arr[i+1];
                arr[i+1]=0;
            }
        }
    }
    for(i=0;i<n;i++) if(brr[i]>0) arr[i+1]-=brr[i];
    ll sum=0;
    for(i=0;i<n+1;i++) if(arr[i]>0) sum+=arr[i];
    cout<<m-sum;
}

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

int lcs(const string &a, const string &b)
{
	int la = a.size(), lb = b.size();
	vector<vector<int>> dp(la + 1, vector<int>(lb + 1, 0));

	for (int i = 0; i < la; i++) {
		for (int j = 0; j < lb; j++) {
			dp[i + 1][j + 1] = max(dp[i][j] + (a[i] == b[j] ? 1 : 0), max(dp[i][j + 1], dp[i + 1][j]));
		}
	}
	return dp[la][lb];
}

int main()
{
	string S, T = "AKIHABARA", U = "KIHBR";
	cin >> S;
	if (lcs(S, T) == S.size() && lcs(S, U) == 5) {
		puts("YES");
	}
	else {
		puts("NO");
	}
	return 0;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    double suma = 0;
    rep(i, n) suma += a[i];
    suma = suma/(4*m);
    
    int cnt = 0;
    rep(i, n) {
        if (a[i] >= suma) cnt++;
    };
    bool f = (cnt >= m);
    cout << (f?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll i,o,t,j,l,s,z;
	cin>>i>>o>>t>>j>>l>>s>>z;
	ll cnt=0;
	cnt+=o;
	if((i%2==1&&j%2==1&&l>0)||(j%2==1&&l%2==1&&i>0)||(l%2==1&&i%2==1&&j>0)) {
		i--;j--;l--;
		cnt+=3;
	}
	cnt+=(i/2)*2;
	cnt+=(j/2)*2;
	cnt+=(l/2)*2;
	cout<<cnt<<endl;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

int H,W;
map<int,int> loca_dis;
set<pair<int,int>> dis_loca;

int main()
{
    cin >> H >> W;
    _rep(i,1,W){
        loca_dis[i] = 0;
        dis_loca.insert(MP(0,i));
    }

    _rep(i,1,H){
        int a,b;
        cin >> a >> b;
        auto ite = loca_dis.lower_bound(a);
        int dis = inf;
        while(ite != loca_dis.end() && ite->first <= b + 1){
            if(b != W){
                dis = min(dis,b + 1 - ite->first + ite->second);
            }

            pair<int,int> dele_e = MP(ite->second,ite->first);
            ite = loca_dis.erase(ite);
            dis_loca.erase(dele_e);
        }
        if(dis != inf){
            loca_dis[b+1] = dis;
            dis_loca.insert(MP(dis,b+1));
        }
        if(dis_loca.size() == 0){
            printf("-1\n");
        }else{
            printf("%d\n",i+dis_loca.begin()->first);
        }

    }


    return 0;
}


Measured memory_bytes: 22436
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
const int N=1e5+5;
typedef long long lint;
int n,val[N];

template <class T> inline void apx(T &x,const T y){
	x<y?x=y:0;
}

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

namespace G{
	int rt,cnt,dgr[N],fir[N];
	lint req[N];
	class edge{
		public:
			int to,nx;
	}eg[N<<1];

	inline void add(const int a,const int b){
		++dgr[a],++dgr[b];
		eg[++cnt]=(edge){b,fir[a]};
		fir[a]=cnt;
		eg[++cnt]=(edge){a,fir[b]};
		fir[b]=cnt;
	}

	inline void get_rt(){
		for(; dgr[rt]<2; ++rt);
		assert(rt<=n);
	}

	bool dfs(const int x,const int fa){
		if(dgr[x]==1){
			req[x]=val[x];
			return 1;
		}
		lint mx_req=0,req_sum=0;
		for(int i=fir[x]; i; i=eg[i].nx){
			const int y=eg[i].to;
			if(y!=fa){
				if(!dfs(y,x)||req[y]>val[x]) return 0;
				req_sum+=req[y];
				apx(mx_req,req[y]);
			}
		}
		if(req_sum<val[x]) return 0;
		lint link_need=req_sum-val[x];
		lint link_able=std::min(req_sum>>1,req_sum-mx_req);
		if(link_need>link_able) return 0;
		req[x]=req_sum-(link_need<<1);
		return 1;
	}
}

int main(){
	n=nxi();
	if(n==2){
		puts(nxi()==nxi()?"YES":"NO");
		nxi(),nxi();
		return 0;
	}
	for(int i=1; i<=n; ++i){
		val[i]=nxi();
	}
	for(int i=1; i<n; ++i){
		const int a=nxi(),b=nxi();
		G::add(a,b);
	}
	G::get_rt();
	if(!G::dfs(G::rt,0)) puts("NO");
	else puts(G::req[G::rt]?"NO":"YES");
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct FordFulkerson {
  struct edge { ll to, cap, rev, idx; bool isrev; };
  vector<vector<edge>> adj;
  vector<ll> used;
  ll timestamp;
  FordFulkerson(ll n) : timestamp(0) { adj.resize(n); used.resize(n,-1); }
  void add_edge(ll from, ll to, ll cap, ll idx = -1) {
    adj[from].push_back({to, cap, (ll)adj[to].size(), idx, false});
    adj[to].push_back({from, 0, (ll)adj[from].size()-1, idx, true});
  }
  ll dfs(ll now, ll to, ll flow) {
    if (now==to) return flow;
    used[now] = timestamp;
    for (auto &x: adj[now]) {
      if (x.cap>0 && used[x.to]!=timestamp) {
        ll d = dfs(x.to, to, min(flow, x.cap));
        if (d>0) {
          x.cap -= d;
          adj[x.to][x.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
  ll max_flow(ll from, ll to) {
    ll result = 0;
    for (ll f; (f=dfs(from,to,LLINF))>0; timestamp++) result += f;
    return result;
  }
  void output() {
    rep(i,adj.size()) {
      for (auto &x: adj[i]) {
        if (!x.isrev) {
          edge rev = adj[x.to][x.rev];
          cout << x.idx << ":" << i << "->" << x.to << " " << rev.cap << "/" << x.cap+rev.cap << endl;
        }
      }
    }
  }
};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  ll N; cin >> N;
  ll a[N]; rep(i,N) cin >> a[i];
  ll sum = 0, mi = 0; rep(i,N) { sum += a[i]; mi = min(mi,a[i]); }
  sum -= mi*N;

  FordFulkerson ff(N+2);
  rep(i,N) ff.add_edge(0,i+1,a[i]-mi);
  rep(i,N) ff.add_edge(i+1,N+1,-1*mi);

  rep(i,N) repr(j,1,N/(i+1)) ff.add_edge((i+1)*(j+1),i+1,LLINF);
  ll result = sum - ff.max_flow(0,N+1);
  cout << result << endl;
  return 0;
}

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

using namespace std;

#define ios         ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll          long long
#define cn          37
#define sn          2007
#define bn          1000007
#define M           100000007
#define inf         LLONG_MAX

ll f[bn],f2[bn];

int main()
{
        ios;
        ll n,m = 0; cin >> n;
        for(ll i = 1; i <= n; i++)
        {
                ll x; cin >> x; f[x]++;
                m = max(m,x);
        }
        bool a1 = 1,a2 = 1;
        for(ll i = 2; i <= m; i++)
        {
                if(f2[i]) continue;
                ll c = 0;
                for(ll j = i; j <= m; j += i)
                {
                        c += f[j];
                        f2[j] = 1;
                }
                if(c > 1) a1 = 0;
                if(c == n) a2 = 0;
        }
        if(a1) cout << "pairwise coprime";
        else if(a2) cout << "setwise coprime";
        else cout << "not coprime";
}



















































/*

*/


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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int, int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _ % MOD
#define __ %= MOD

#define each(it, s) for (auto it = s.begin(); it != s.end(); ++it)
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.begin(), v.end(), greater<auto>())
#define fill(a) memset(a, 0, sizeof(a))

#define swap(a, b) \
	{              \
		a = a + b; \
		b = a - b; \
		a = a - b; \
	}
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repA(i, a, n) for (ll i = a; i <= (n); ++i)
#define repD(i, a, n) for (ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) << endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

#define pv(a)                                 \
	{                                         \
		rep(i, a.size()) cout << a[i] << " "; \
		cout << endl;                         \
	}
#define mark(v) cout << "Here--" << v << endl;

const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}
ll power(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y & 1)
			res = res * x;
		y = y >> 1;
		x = x * x;
	}
	return res;
} // modular exponent

int main()
{
	ios_base::sync_with_stdio(false); // don't use printf and scanf
	cin.tie(NULL);					  // cout<<fixed<<setprecision
	ll n;
	cin >> n;
	ll x;
	cin >> x;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll cnt = 0;
	repA(i, 1, n - 1)
	{
		ll s = a[i - 1] + a[i];
		if (s > x)
		{
			cnt += s - x;
			a[i] = max(a[i] - (s - x), 0ll);
				}
	}
	cout << cnt << endl;

	return 0;
}

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

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    string n;
    cin>>n;

    int sum=0;
    for(int i=0;i<n.size();i++){
        sum+=n[i]-48;
    }

    if(sum%9==0){
        cout<<"Yes"<<"\n";
    }

    else{
        cout<<"No"<<"\n";
    }

    return 0;
}

Measured memory_bytes: 3764
public class Main {

  private static void solve() {
    long d = ni();

    if (d % 9 > 0) {
      System.out.println(0);
      return;
    }
    
    d /= 9;
    long ret = 0;
    long p11 = 1;
    for (int i = 2; i <= 18; i ++) {
      long tot = (i % 2 == 1) ? 10 : 1;
      ret += tot * dfs(d, p11, 1);
      p11 = p11 * 10 + 1;
    }
    System.out.println(ret);
  }
  
  static long dfs(long a, long t, int first) {
    if (t == 0) return a == 0 ? 1 : 0;
    long v = (a % 10 + 10) % 10;
    
    long ret = 0;
    ret += (10 - v- first) * dfs((a - t*v)/10, t/100, 0);
    ret += (v- first) * dfs((a + (10 - v) * t)/10, t/100, 0);
    return ret;
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = System.getProperty("debug");
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 24660
#include<iostream>
#include<cstdio>
using namespace std;
int a[10000],b[10000];
int main()
{
	int n;
	cin>>n;
	int t;
	cin>>t;
	int i=0;
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
	}
	int minn=1000000;
	for(int j=0;j<i;j++)
	{
		if(b[j]<=t)
		{
			if(a[j]<minn) minn=a[j];
		}
	}
	if(minn==1000000) cout<<"TLE"<<endl;
	else cout<<minn<<endl;
 } 

Measured memory_bytes: 256
#include<stdio.h>

unsigned long long int maxim(unsigned long long int x){
	return ((x+1)*x)/2;
}

int main(void){
	unsigned long long int n,i,r,k=1;
	scanf("%llu",&n);
	while(1){r = maxim(k);if(r >= n){break;}k++;}
	r = n;
	for(i = k;i>=1;i--){if(r>=i){printf("%llu\n",i);r-=i;}}
}

Measured memory_bytes: 128
s = list(input())
t = list(input())
flag = False
for i in range(len(s)-len(t)+1) :
    for j in range(len(t)) :
        if s[i+j] != t[j]  and s[i+j] != '?' :
            break
    else :
        flag = True 
        begin = i

if flag :
    ans = ''
    for i in range(len(t)) :
        s[begin+i] = t[i]
    for i in range(len(s)) :
        if s[i] == '?' :
            s[i] = 'a'
        ans += s[i]
    print(ans)
else :
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int partition(int *,int);
void swapping(int *,int *,int *);

int main(){
  int *A,n,i,box;

  scanf("%d",&n);
  A = (int *)malloc(1 + n * sizeof(int));
  for(i = 1;i < n + 1;i++) scanf("%d",&A[i]);

  box = partition(A,n);


  for(i = 1;i < box;i++) printf("%d ",A[i]);
  printf("[%d] ",A[box]);
  for(i = box + 1;i < n + 1;i++){
    printf("%d",A[i]);
    if(i != n) printf(" ");
  }
  printf("\n");
  
  free(A);
  return 0;
}

int partition(int *A,int n){
  int x,i,j,hako = 0;
  x = A[n];
  i = -1;
  for(j = 0;j < n;j++){
    if(A[j] <= x){
      i += 1;
      swapping(&A[i],&A[j],&hako);
    }
  }
  swapping(&A[i + 1],&A[n],&hako);
  
  return i + 1;
}

void swapping(int *A,int *AA,int *dust){
  *dust = *A;
  *A = *AA;
  *AA = *dust;
}



Measured memory_bytes: 2108
W,H,N=map(int,input().split())
U=[H]
D=[0]
R=[W]
L=[0]

for i in range(N):
  x,y,a=map(int,input().split())
  if a==1:
    L.append(x)
  if a==2:
    R.append(x)
  if a==3:
    D.append(y)
  if a==4:
    U.append(y)
#print(U)
#print(D)
#print(R)
#print(L)

#print(min(U))
#print(max(D))
#print(min(R))
#print(max(L))

H2=max(min(U)-max(D),0)
W2=max(min(R)-max(L),0)
print(H2*W2)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
	
	int W,a,b;
	cin>>W>>a>>b;
	if(b>a && b<=a+W){	
		cout<<0<<endl;
	}
	if(a<=b+W && a+W>b+W){
		cout<<0<<endl;
	}
	if(a==b){
		cout<<0<<endl;
	}
	if(a+W<b){
		cout<<b-(a+W)<<endl;
	}
	if(a>b+W){
		cout<<a-(b+W)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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;
}

int main()
{
    ll n; cin>> n;
    vector<vector<int> > a(n,vector<int>(2));
    for(int i=0;i<n;i++)for(int j=0;j<2;j++)cin >> a[i][j];
    sort(a.begin(),a.end());

    double res = 0.0;
    int count = 0;
    do{
        for(int i=0;i+1<n;i++) res += sqrt(pow(a[i][0]-a[i+1][0],2)+pow(a[i][1]-a[i+1][1],2));
        count++;
    }while(next_permutation(a.begin(),a.end()));

    cout << fixed << setprecision(6);
    cout << res/count << endl;
}
    

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = Read().Int();
            var l = new int[n];
            var r = ReadSplit();
            for (int i = 0; i < n; i++)
            {
                l[i] = r[i].Int();
            }
            Array.Sort(l);
            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = i + 1; j < n - 1; j++)
                {
                    int min = j;
                    int max = n;
                    while (max - min > 1)
                    {
                        int mid = min + (max - min) / 2;
                        if (l[mid] >= l[i] + l[j]) max = mid;
                        else min = mid;
                    }
                    if (min - j != 0)
                    {
                        ans += min - j;
                    }
                }
            }
            WriteRead(ans);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



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

#define         eps         10e-9
#define         pi          2*acos(0.0)
#define         P1          1e9+7
#define         P2          1e9+9
#define         lli         long long int

using namespace std;

///ISNNJB

/**int fx[]={+1,-1,+0,+0};
int fy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};*/

int main()
{
    /***freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/

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

    lli a,b,c,x,y;
    cin>>a>>b>>c;

    x=c-a-b;
    if(x<=0)
        cout<<"No\n";
    else
    {
        x=x*x;
        y=4*a*b;
        if(x>y)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}


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

int main() {
    int x = 0;
    for (int i = 0; i < 4; i++) {
        int a;
        cin >> a;
        x += a;
    }
    
    cout << x / 60 << endl;
    cout << x % 60 << endl;
}


Measured memory_bytes: 3104
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

int main()
{
  int n;
  int k;
  cin>>n>>k;
  int x,y;
  int ans;
  for(int i = 0;i < k;i++){
    cin >>x>>y;
    x =min(x,n-x+1);
    y =min(y,n-y+1);
    if(x<y)
      ans =x%3;
    else
      ans =y%3;
    cout <<(ans==0?3:ans)<<endl;
  }
  return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    ll sum = 0;
    for(ll i=1;i<=n;i++){
        if(i % 3 == 0 || i % 5 == 0) continue;
        sum += i;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3644
class UnionFind:
    
    def __init__(self,n):
        self.p = [i for i in range(n)]
        self.component = n
    
    def root(self,x):
        if self.p[x] == x:
            return x
        else:
            self.p[x] = self.root(self.p[x])
            return self.p[x]
    
    def unite(self,x,y):
        x,y = self.root(x),self.root(y)
        if x != y:
            self.p[x] = y
            self.component -=1
    
    def same(self,x,y):
        return (self.root(x)==self.root(y))

n = int(input())
MAX = 100010
UF = UnionFind(2*MAX)
for _ in range(n):
    x,y = map(int,input().split())
    UF.unite(x,y+MAX)

cnt_x,cnt_y = [0]*2*MAX,[0]*2*MAX

for i in range(MAX):
    cnt_x[UF.root(i)] += 1


for i in range(MAX,2*MAX):
    cnt_y[UF.root(i)] += 1

print(sum(cnt_x[i]*cnt_y[i] for i in range(2*MAX))-n)



Measured memory_bytes: 88572