akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

#define N (1<<17)
//Range Add Query+Range Minimum Query
template<class T>
class RAQ_RMQ {
public:
	T dat[2*N], lazy[2*N], ZERO, DEFAULT;
	function<T(T,T)>merge;
	void init(
		function<T(T,T)>Merge=[](T a,T b){return min(a,b);}, T d = LLONG_MAX) {
		merge=Merge;
		DEFAULT = d;
		ZERO = T();
		rep(i,2*N-1){
			dat[i]=lazy[i]=ZERO;
		}
	}
	inline void push(int k) {
		dat[k] = dat[k] + lazy[k];
		if (k < N - 1) {
			lazy[k * 2 + 1] = lazy[k * 2 + 1] + lazy[k];
			lazy[k * 2 + 2] = lazy[k * 2 + 2] + lazy[k];
		}
		lazy[k] = ZERO;
	}
	inline void update_node(int k) {
		dat[k]=merge(dat[k*2+1],dat[k*2+2]);
	}
	inline void update(int a, int b, T x, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] = lazy[k] + x; push(k); return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
	}
	inline T query(int a, int b, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return DEFAULT;
		if (a <= l&&r <= b)return dat[k];
		T lb = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T rb = query(a, b, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
		return merge(lb,rb);
	}
	inline void update(int a, int b, T x) {
		update(a, b, x, 0, 0, N);
	}
	inline void update(int a, T x) {
		update(a, a + 1, x);
	}
	inline T query(int a, int b) {
		return query(a, b, 0, 0, N);
	}
	inline T query(int a) {
		return query(a, a + 1);
	}
};
int x[200000];
RAQ_RMQ<ll>seg;

int main(){
	seg.init();
	int n,E,T;cin>>n>>E>>T;
	rep(i,n)scanf("%d",&x[i+1]);
	x[n+1]=E;
	seg.update(0,x[1]);
	int s=0;
	for(int i=2;i<=n+1;i++){
		seg.update(0,i-1,x[i]-x[i-1]);
		while((x[i-1]-x[s+1])*2>=T){
			seg.update(s,-T+(x[i-2]-x[s+1])*2);
			s++;
		}
		seg.update(0,s,(x[i-1]-x[i-2])*2);
		seg.update(i-1,seg.query(0,i-1)+T);
	}
	cout<<seg.query(n)<<endl;
	/*
	memset(dp,0x3f,sizeof(dp));
	dp[1][0]=x[1];
	for(int i=2;i<=n+1;i++)rep(j,i-1){
		dp[i][j]=min(dp[i][j],dp[i-1][j]+(x[i]-x[i-1]));
		dp[i][i-1]=min(dp[i][i-1],dp[i-1][j]+max(T,(x[i-1]-x[j+1])*2)+(x[i]-x[i-1]));
	}
	cout<<dp[n+1][n]<<endl;
	*/
}

Measured memory_bytes: 4864
N, M = map(int, input().split())
D = [[] for i in range(N)]

for i in range(M):
    P, Y = map(int, input().split())
    D[P-1].append((Y,i))

ans = [None] * M

for i, d in enumerate(D):
    d.sort()
    for k, (y, j) in enumerate(d):
        ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep='\n')

Measured memory_bytes: 37480
n,k=map(int,input().split())
s=list(input())
if s[k-1]=="A":
    s[k-1]="a"
elif s[k-1]=="B":
    s[k-1]="b"
elif s[k-1]=="C":
    s[k-1]="c"
print("".join(s))


Measured memory_bytes: 9184
input_lines = gets.chop.split.map(&:to_i)

a = input_lines[0]
output = input_lines[1]
nowCount = 0
count = 0
while  output > (nowCount + 1) 
    nowCount = nowCount + (a-1)
    count = count + 1
end

if output == 1
    puts 0
else 
    puts count
end

Measured memory_bytes: 3836
#pragma warning disable IDE1006
#pragma warning disable IDE0011
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] line;

    public void R(params char[] sep) { line = Console.ReadLine().Split(sep); idx = 0; }
    public string S => line[idx++];
    public string[] Ss => line.Skip(idx++).ToArray();
    public char C => char.Parse(line[idx++]);
    public char[] Cs => line.Skip(idx++).Select(char.Parse).ToArray();
    public int I => int.Parse(line[idx++]);
    public int[] Is => line.Skip(idx++).Select(int.Parse).ToArray();
    public long L => long.Parse(line[idx++]);
    public long[] Ls => line.Skip(idx++).Select(long.Parse).ToArray();
    public double F => double.Parse(line[idx++]);
    public double[] Fs => line.Skip(idx++).Select(double.Parse).ToArray();
    public decimal D => decimal.Parse(line[idx++]);
    public decimal[] Ds => line.Skip(idx++).Select(decimal.Parse).ToArray();
    public BigInteger B => BigInteger.Parse(line[idx++]);
    public BigInteger[] Bs => line.Skip(idx++).Select(BigInteger.Parse).ToArray();

    public void Write<T>(params T[] xs)
    {
        Console.Write(xs.First());
        foreach (var x in xs.Skip(1)) Console.Write(" " + x);
        Console.WriteLine();
    }
    public void Write(params object[] xs)
    {
        Console.Write(xs.First());
        foreach (var x in xs.Skip(1)) Console.Write(" " + x);
        Console.WriteLine();
    }
}

static class Extentions
{
}

static class Program
{
    public static void Main()
    {
#if !DEBUG
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
#endif
        Solve(new IO());
        Console.Out.Flush();
    }

    public static void Solve(IO io)
    {
        io.R();
        var n = io.I;
        io.R();
        var a = io.Ls;

        BigInteger s1 = 0;
        Array.ForEach(a, x => s1 += x);
        BigInteger s2 = a[0];

        var min = Abs(a[0] - (s1 - a[0]));

        for (var i = 1; i < n; i++)
        {
            var t = Abs(s2 - (s1 - s2));
            if (t < min) min = t;
            s2 += a[i];
        }

        io.Write(min);
    }

    static BigInteger Abs(BigInteger x) => x * x.Sign;
}

Measured memory_bytes: 32436
import sys

def main():
    for line in sys.stdin:
        w = int(line)
        dic = calcWeights(w)

        l = []
        for k in sorted(dic.keys()):
            if dic[k] > 0:
                l.append(str(k))

        res = ' '.join(l)
        print res


def calcWeights(w):
    dic = {}
    dic[1] = w >> 0 & 1
    dic[2] = w >> 1 & 1
    dic[4] = w >> 2 & 1
    dic[8] = w >> 3 & 1
    dic[16] = w >> 4 & 1
    dic[32] = w >> 5 & 1
    dic[64] = w >> 6 & 1
    dic[128] = w >> 7 & 1
    dic[256] = w >> 8 & 1
    dic[512] = w >> 9 & 1

    return dic


main()

Measured memory_bytes: 4248
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

ll n;
ll p;
map<ll, ll> mp;
vector<ll> idx;

void factoring(ll n)
{
    // 割る数の初期値
    ll a = 2;
    while (n >= a*a) {
        if (n % a == 0) {
			// cout << a << " * ";
			mp[a]++;
			idx.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
	mp[n]++;
    // cout << n << LF;
}

int main()
{
	FAST;

	cin >> n >> p;

	if (n ==1) {
		cout << p << LF;
		return 0;
	}

	factoring(p);
	
	std::sort(idx.begin(), idx.end());
	idx.erase(std::unique(idx.begin(), idx.end()), idx.end());

	ll ans=1;
	rep(i,idx.size()) {
		// cout << mp[idx[i]] << LF;
		if (mp[idx[i]] >= n) {
			ll c = mp[idx[i]]/n;
			ans *= (ll)pow(idx[i], (float)c);
		}
	}

	cout << ans << LF;

	return 0;
}

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

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

    int ans = 1e5;
    bool exist = false;
    for (int i = 0; i < n; i++) {
        int c, s;
        cin >> c >> s;
        if (s <= t) {
            ans = min(ans, c);
            exist = true;
        }
    }

    if (exist) {
        cout << ans << endl;
    } else {
        cout << "TLE" << endl;
    }
}


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

using namespace std;

const int nd[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

int m, num[9];
pair<bool, string> d[10001];
bool chk[100001];

pair<bool, string> f(int n) {
	if (n == 0)
		return { true, "" };

	if (chk[n])
		return d[n];

	chk[n] = true;

	string mx = "";
	for (int i = 0;i < m;++i) {
		if (n - nd[num[i]] >= 0) {
			pair<bool, string> ret = f(n - nd[num[i]]);

			if (ret.first) {
				reverse(ret.second.begin(), ret.second.end());
				ret.second.push_back(num[i] + '0');
				reverse(ret.second.begin(), ret.second.end());

				if (mx.length() < ret.second.length())
					mx = ret.second;
				else if (mx.length() == ret.second.length())
					mx = max(mx, ret.second);
			}
		}
	}

	if (mx != "")
		return d[n] = { true, mx };
	return d[n] = { false, "" };
}

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

	for (int i = 0;i < m;++i)
		scanf("%d", &num[i]);

	string ans = f(n).second;

	cout << ans;

	return 0;
}

Measured memory_bytes: 27648
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		private const int mod = 1000000007;  // 10^9+7

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int s = vs[0];
			int w = vs[1];

			if (s > w) {
				Console.WriteLine("safe");
			} else {
				Console.WriteLine("unsafe");
			}

		}
	}
}


Measured memory_bytes: 28268
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int N;
	unsigned long int Y;
	cin >> N >> Y;
	Y /= 1000;
	int i, j;
	for(i=0;i<=N;i++){
		for(j=0;j<=(N-i);j++){
			if( 10*i + 5*j + (N-i-j) == Y ){
				cout << i << " " << j << " " << (N-i-j) << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}



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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MX = 100010;

int N, Q;
ll q[MX];
ll ans[MX];

int main() {
	scanf("%d %d", &N, &Q);
	rep(i, Q) scanf("%lld", &q[i]);

	vector<ll> vec = {N};
	rep(i, Q) {
		while (vec.size() && vec.back() >= q[i]) {
			vec.pop_back();
		}
		vec.push_back(q[i]);
	}

	vector<ll> num(vec.size());
	num.back() = 1LL;

	for (int i = (int)vec.size() - 1; i > 0; --i) {
		ll cur = vec[i];
		int p = i;

		while (true) {
			auto it = upper_bound(vec.begin(), vec.begin() + p, cur);
			if (it == vec.begin()) break;
			--it;
			int np = it - vec.begin();
			num[np] += num[i] * (cur / *it);
			cur %= *it;
			p = np;
		}
		if (cur) {
			ans[0] += num[i];
			ans[cur] -= num[i];
		}
	}

	rep(i, MX) {
		if (i) {
			ans[i] += ans[i-1];
		}
	}

	rep(i, vec[0]) ans[i] += num[0];

	rep(i, N) printf("%lld\n", ans[i]);
		
	return 0;
}

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

#define ll long long
#define tc(t) int t;cin >> t; while(t--)
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int n, m;
    cin >> n >> m;
    int a[n+1] = {};
    int sum = 0;
    for(int i = 1; i<=n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a+1, a+n+1, greater<int>());
    int ok = 1;
    for(int i = 1; i<=m; i++) {
        int x = 4*m*a[i];
        if(x < sum) {
            ok = 0;
        }
    }
    cout << (ok ? "Yes": "No");

}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
std::vector<string> v = {"Sunny", "Cloudy","Rainy","Sunny"};
int main() {
	int a,b; cin >> a >> b;

	if((a+b)&1){
		cout << "IMPOSSIBLE" << endl;
	}else{
		cout << (a+b)/2 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	/**与えられた行列に対し、それぞれの行と列の和をもとめる。
	 *表の行数と列数の行列を読み込んで、
	 *各行と列の合計を挿入した新しい表を出力するプログラムを作成する。
	 * @param args	行数、列数、行列
	 */
	
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		int gyo = scan.nextInt();
		int retu = scan.nextInt();
		
//		int gyo = Integer.parseInt(args[0]);		//4
//		int retu = Integer.parseInt(args[1]);		//5

		int[] gyo_sum = new int[gyo];								//行（横）の合計値
		int[] retu_sum = new int[retu];							//列（縦）の合計値
		int fin_sum=0;

		for(int k = 0;k < gyo; k++){				//行単位
		
			for(int i=0;i < retu; i++){			//列単位
				int now_cell = scan.nextInt();
				gyo_sum[k] = gyo_sum[k] + now_cell;
				System.out.print(now_cell+" ");
				retu_sum[i] = retu_sum[i] + now_cell;
//				gyo_sum[k] = gyo_sum[k] + Integer.parseInt(args[2+5*k+i]);
//				System.out.print(args[2+5*k+i]+" ");
//				retu_sum[i] = retu_sum[i] + Integer.parseInt(args[2+5*k+i]);
			}
			
		
			System.out.println(gyo_sum[k]);
			fin_sum = fin_sum + gyo_sum[k];
		}
		for(int j = 0;j < retu;j++){
			System.out.print(retu_sum[j] + " ");	//列の和出力
			//fin_sum = fin_sum + retu_sum[j];
		}
		System.out.println(fin_sum);	//最終合計

	}

}



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

#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve() 
{
    long long n,a,b,tmp,x,sum=0;
    cin>>n>>a>>b>>tmp;
    REP(i,n-1){
        cin>>x;
        sum+=min(a*(x-tmp),b);
        tmp=x;
    }cout<<sum<<endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  int h,w,k;
  while(cin>>h>>w){
  int l=h*h+w*w;
  k=0;
  if(h==0 && w==0){return 0;}
  for(int i=h+1;i<w;i++){
    for(int j=w;h<j;j--){
      if(l==i*i+j*j && i<j){
        cout<<i<<" "<<j<<endl;
        k=1;
        i=w;
      }
    }
  }
  
  while (k==0) {
    l++;
    for(h=1;h*h<l/2;h++){
      for(w=sqrt(l);h<w;w--){
        if(l==h*h+w*w && h<w){
          cout<<h<<" "<<w<<endl;
          k=1;
          h=l;
        }
      }
    }
  }
  
  }
  return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << ":" << x << endl

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No") {
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;


}

using namespace atcoder;
set<int>st;
set<vector<int>> check;

void generate(vector<int> v,int num) {
	switch (num) {
	case 3:
		v[0]++;
		break;
	case 5:
		v[1]++;
		break;
	case 7:
		v[2]++;
		break;
	}
	if (check.find(v) != check.end()) {
		return;
	}
	check.insert(v);
	string ret;
	for (int i = 0; i < v[0]; i++) {
		ret.push_back('3');
	}
	for (int i = 0; i < v[1]; i++) {
		ret.push_back('5');
	}
	for (int i = 0; i < v[2]; i++) {
		ret.push_back('7');
	}
	if (ret.size() > 9)
		return;
	do {
		st.insert(stoi(ret));
	} while (next_permutation(ret.begin(), ret.end()));
	generate(v, 3);
	generate(v, 5);
	generate(v, 7);
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int num = stoi(s);
	int ans = 0;
	vector<int> a = { 1,1,1 };
	generate(a, 0);
	vector<int> que(st.begin(),st.end());
	for (int i = 0; i < que.size(); i++) {
		if (que[i] > num)
			break;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define setp(x) setprecision(x)
#define nep(x) next_permutation(x);
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main() {
   int N, K;
   cin >> N >> K;
   vector<ll> H(N);
   for(int i = 0; i < N; i++) cin >> H[i];

   sort(all(H));
   ll min_d = 1000000000;
   for(int i = 0; i < N - K + 1; i++) min_d = min(-H[i] + H[i + K - 1], min_d);

   cout << min_d << endl;
}


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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    int r;
    cin>>r;
    cout<<fixed<<setprecision(10)<<2.0l*acos(-1)*r<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3792
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define REP(i, k) for (decltype(k) i = 0; i < k; i++)
#define LOOP(k) REP (ngtkana_is_a_genius, k)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    i64 a, v, b, w, t;
    std::cin >> a >> v >> b >> w >> t;
    std::cout << (w < v && std::abs(a-b) <= (v - w) * t ? "YES" : "NO") << '\n';
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;

ll k;

ll power(ll base,ll n)
{
    ll r=1;
    while(n)
    {
        if(n%2) r=r*base%k;
        base=base*base%k;
        n/=2;
    }
    return r;
}



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>k;
    ll sum=0;
    int len=1;
    while(1)
    {
        sum+=power(10,len-1)*7;
        sum%=k;
        if(sum%k==0)
        {
            cout<<len<<'\n';
            return 0;
        }
        len++;
        if(len>1e6)
        {
            cout<<-1<<'\n';
            return 0;
        }
    }



}


Measured memory_bytes: 3688
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Main{

    static StringBuilder sb;

    public static void main(String[] args) {
	try {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();

	    for (String line = br.readLine(); line != null; line = br.readLine()) {
		lines.add(line);
	    }

	    // lines.add("47");
	    // lines.add("S 10");
	    // lines.add("S 11");
	    // lines.add("S 12");
	    // lines.add("S 13");
	    // lines.add("H 1");

	    br.close();

	    List<Integer> S = new ArrayList<>(Arrays.asList(1,2,3,4,5,6,7,8,9,10,11,12,13));
	    List<Integer> H = new ArrayList<>(Arrays.asList(1,2,3,4,5,6,7,8,9,10,11,12,13));
	    List<Integer> C = new ArrayList<>(Arrays.asList(1,2,3,4,5,6,7,8,9,10,11,12,13));
	    List<Integer> D = new ArrayList<>(Arrays.asList(1,2,3,4,5,6,7,8,9,10,11,12,13));

	    for (int i = 1; i < lines.size(); i++) {
		String type = lines.get(i).split(" ")[0];
		Integer num = Integer.parseInt(lines.get(i).split(" ")[1]);
		if (type.equals("S")) {
		    S.remove(num);
		} else if (type.equals("H")) {
		    H.remove(num);
		} else if (type.equals("C")) {
		    C.remove(num);
		} else if (type.equals("D")) {
		    D.remove(num);
		}
	    }

	    for (Integer s : S) { System.out.println("S " + s); }
	    for (Integer s : H) { System.out.println("H " + s); }
	    for (Integer s : C) { System.out.println("C " + s); }
	    for (Integer s : D) { System.out.println("D " + s); }

	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    }
}

Measured memory_bytes: 24136
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;

void solve(){
    cin >> n;
    cout << n*n*n << endl;
}

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

Measured memory_bytes: 256
N = int(input())
S = list(input())
ans = ""
A = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(len(S)):
    for k in range(26):
        if S[i] == A[k]:
            if k+N < 26:
                ans += A[k+N]
            else:
                ans += A[k+N-26]
print(ans)

Measured memory_bytes: 3188
from collections import deque
N = int(input())
A = [int(a)-1 for a in input().split()]
M = N + 2
X = [max(min(i-1, j-1, M-2-i, M-2-j), -1) for j in range(M) for i in range(M)]
Y = [min(x, 0) + 1 for x in X]

ans = 0
for a in A:
    aa = (a // N + 1) * M + a % N + 1
    ans += X[aa]
    h = X[aa]
    if h < 0: continue
    Q = deque([(aa, h)])
    X[aa] -= 1
    Y[aa] = 0
    dd = (-1, 1, M, -M)
    while Q:
        i, h = deque.popleft(Q)
        for d in dd:
            j = i + d
            y = Y[j]
            if X[j] >= h + y:
                X[j] -= 1
                deque.append(Q, (j, h + y))
print(ans)

Measured memory_bytes: 173636
import sys
def input(): return sys.stdin.readline().strip()


def main():
    """
    備忘録用に自分のコードの解説。
    まずすぐにKの値を決め打ち二分探索することを思いつく。
    なので任意のKに対して、K文字以上の連続する区間を何回かフリップしてSを"000...0"にできるか判定できれば良い。

    ここで、Sの文字を0-indexedで添え字づけした時にK文字目以降は任意の１桁をフリップできることに気づく。
    というのも例えばm文字目(K <= m)をフリップしたければ[0, m-1], [0, m]の２区間をフリップすれば良い。
    同様に末尾からも考えると、0以上(|S|-K)未満の任意の１桁も自由にフリップできる。

    これよりK=|S|//2の時は必ずSを"000...0"にできることがわかる。
    ではKがこれより大きい時はどうなるだろうか？
    この時自由にフリップができない区間S[(|S|-K):K]が出現する。
    そして2つ目の気づきとして、この区間はどんな区間長K以上のフリップをかけても必ず全体のビットが反転する！

    以上より
        「区間長K以上のフリップをかけてSを"000...0"にできる」
         = 「中央区間S[(|S|-K):K]のビットが全て等しい」
    が結論となる。
    """
    S = input()
    N = len(S)
    if S == '1' * N or S == '0' * N:
        print(N)
        return
    left = N // 2
    right = N
    while right - left > 1:
        mid = (left + right) // 2
        if S[(N - mid):mid] == '1' * (2 * mid - N) or S[(N - mid):mid] == '0' * (2 * mid - N):
            left = mid
        else:
            right = mid
    print(left)

if __name__ == "__main__":
    main()


Measured memory_bytes: 67628
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] A = new int[n];
		for (int i = 0; i < n; i ++) {
			A[i] = in.nextInt();
		}
		in.close();
		
		for (int i = n/2; i >= 0; i--) {
			maxheap(A, i);
		}
		
		for (int i = 0; i < n; i++) {
			System.out.print(" " + A[i]);
		}
		System.out.println();
	
	}
	
	public static void maxheap(int[] A, int i) {
		int l = (i + 1) * 2;
		int r = (i + 1) * 2 + 1;
		int largest = 0;
		if (l <= A.length && A[l - 1] > A[i]) {
			largest = l;
		}else {
			largest = i + 1;
		}
		
		if (r <= A.length  && A[r - 1] > A[largest - 1]) {
			largest = r;
		}
		if (largest - 1 != i) {
			int s = A[i];
			A[i] = A[largest - 1];
			A[largest - 1] = s;
			maxheap(A, largest - 1);
		}
	}
}



Measured memory_bytes: 166732
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
    int a,h,m,s;
    cin>>a;
    h=a/3600;
    m=(a-h*3600)/60;
    s=(a-m*60-h*3600);
    printf("%0d:%0d:%0d\n",h,m,s);
}



Measured memory_bytes: 3156
#include <cstdio>
#include <string.h>

using namespace std;
int n,flag;
int arr[30];
char str[5][10];
int main()
{
    int i;
    char ch;
    strcpy(str[3],"Three");
    strcpy(str[4],"Four");
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf(" %c",&ch);
        arr[ch-'A']=1;
    }
    for(i=0;i<=26;i++) flag+=arr[i];
    printf("%s",str[flag]);
    return 0;
}


Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <limits>
#include <utility>
#include <bitset>
#include <functional>
#include <tuple>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <cmath>

#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
//#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e9;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}


using Weight=int;
struct Edge{
  int src,dst;
  Weight weight;
  Edge():src(0),dst(0),weight(0){}
  Edge(int s,int d,Weight w=0):src(s),dst(d),weight(w){}
};
using Edges=vector<Edge>;
using Graph=vector<Edges>;

vector<int> articulationPoints(const Graph &g) {
  int n = g.size(), id = 0;
  vector<int> ord(n), low(n), arts;
  function<void(int)> dfs = [&](int v) {
    low[v] = ord[v] = ++id;
    for (auto &e : g[v]) {
      int w = e.dst;
      if (ord[w] == 0) {
        dfs(w);
        cmin(low[v], low[w]);
        if (ord[v] == 1 && ord[w] != 2) arts.emplace_back(v);
        if (ord[v] != 1 && ord[v] <= low[w]) arts.emplace_back(v);
      } else {
        cmin(low[v], ord[w]);
      }
    }
  };
  rep(i, n) if (ord[i] == 0) id = 0, dfs(i);
  sort(all(arts));
  arts.erase(unique(all(arts)),arts.end());
  return arts;
}

int main(){
  int v,e;
  cin>>v>>e;
  Graph g(v);
  rep(i,e){
    int s,t;
    cin>>s>>t;
    g[s].emplace_back(s,t);
    g[t].emplace_back(t,s);
  }
  vector<int> ans=articulationPoints(g);
  sort(all(ans));
  for(auto x:ans)cout<<x<<endl;
 return 0;
}



Measured memory_bytes: 5724
#include <bits/stdc++.h>
#define PB push_back
#define SZ(a) ((int)(a).size())
#define LL long long
#define X first
#define Y second
using namespace std;

const int mod = 998244353;
int mult(int a , int b)
{
	return a * (LL)b % mod;
}
int add(int a , int b)
{
	return a + b >= mod ? a + b - mod : a + b;
}

int main()
{
	LL s;
	cin >> s;
	int x1 = 1000 * 1000 * 1000;
	int y2 = (s + x1 - 1) / x1;
	int x2 = 1;
	int y1 = x1 - (s % x1);
	if(y1 == x1)
		y1 = 0;
	cout << 0 << " " << 0 << " " << x1 << " " << y1 << " " << x2 << " " << y2;
	ios_base::sync_with_stdio(0);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <utility>
#include <cctype>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#define LL long long
#define LB long double
#define x first
#define y second
#define Pair pair<int,int>
#define pb push_back
#define pf push_front
#define mp make_pair
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const LL LINF=2e16;
const int INF=2e9;
const int magic=348;
const double eps=1e-10;
const double pi=3.14159265;

inline int getint()
{
    char ch;int res;bool f;
    while (!isdigit(ch=getchar()) && ch!='-') {}
    if (ch=='-') f=false,res=0; else f=true,res=ch-'0';
    while (isdigit(ch=getchar())) res=res*10+ch-'0';
    return f?res:-res;
}

int n;
int a[58],b[58];
bool dp[58][58][58];int DP[58][58];
bool Dp[58][58];
int valid[58],vtot;
int anslist[58],tot;

inline void init_dp()
{
	memset(dp,false,sizeof(dp));
	int i,j,k;
	for (i=0;i<=50;i++) dp[i][i][0]=dp[i][i][1]=true;
	for (i=0;i<=50;i++) dp[i][0][1]=true;
	for (k=2;k<=50;k++)
		for (i=0;i<=50;i++)
			for (j=0;j<=50;j++)
			{
				if (dp[i][j][k-1]) {dp[i][j][k]=true;continue;}
				if (dp[i%k][j][k-1]) {dp[i][j][k]=true;continue;}
				dp[i][j][k]=false;
			}
	for (i=0;i<=50;i++)
		for (j=0;j<=50;j++)
		{
			for (k=0;!dp[i][j][k] && k<=50;k++) {}
			DP[i][j]=k;
		}
}

inline bool judge()
{
	int res=-1;
	int i,j,k,cc;
	for (i=1;i<=n;i++)
	{
		memset(Dp,false,sizeof(Dp));
		Dp[0][a[i]]=true;
		for (j=0;j<=vtot-1;j++)
			for (k=0;k<=50;k++)
				if (Dp[j][k])
				{
					Dp[j+1][k]=true;
					Dp[j+1][k%valid[j+1]]=true;
				}
		if (!Dp[vtot][b[i]]) return false;
	}
	return true;
}

int main ()
{
	n=getint();int i,calc;
	for (i=1;i<=n;i++) a[i]=getint();
	for (i=1;i<=n;i++) b[i]=getint();
	for (i=1;i<=n;i++) if (b[i]*2+1>a[i] && b[i]!=a[i]) {printf("-1\n");return 0;}
	tot=0;
	for (calc=50;calc>0;calc--)
	{
		vtot=0;for (i=1;i<=tot;i++) valid[++vtot]=anslist[i];
		for (i=calc-1;i;i--) valid[++vtot]=i;
		if (judge()) continue;
		anslist[++tot]=calc;
	}
	LL ans=0;for (i=1;i<=tot;i++) ans+=(1ll<<anslist[i]);
	printf("%lld\n",ans);
	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int K;
int N;
int A[1501][1501];
void check(int N) {
	set<vector<int>> S[1002];
	int x,y;
	FOR(y,N) FOR(x,N) {
		vector<int> V;
		V.push_back(A[(y+1)%N][x]);
		V.push_back(A[(y+N-1)%N][x]);
		V.push_back(A[y][(x+1)%N]);
		V.push_back(A[y][(x+N-1)%N]);
		sort(ALL(V));
		S[A[y][x]].insert(V);
	}
	
	FOR(x,K) if(S[x].size()!=1) {
		cout<<"NG "<<x<<" "<<S[x].size()<<endl;
	}
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K;
	
	if(K==1) {
		cout<<1<<endl;
		cout<<1<<endl;
		return;
	}
	
	int step=((K+3)/4)*4;
	N=step/2;
	int cnt[505]={};
	FOR(y,N) FOR(x,N) {
		r=(x+y)%N;
		if(y%2) r+=N;
		if(r>=K) r-=N;
		A[y][x]=r;
	}
	
	check(N);
	cout<<N<<endl;
	FOR(y,N) {

		FOR(x,N) cout<<A[y][x]+1<<" ";
		cout<<endl;
	}
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

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

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

    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    int t_gcd = gcd(a[0], a[1]);
    for (int i = 2; i < n; ++i)
        t_gcd = gcd(t_gcd, a[i]);
    cout << t_gcd << '\n';
}


Measured memory_bytes: 640
from __future__ import division, print_function

def gcd(a,b):
	while(b):
		a,b = b,a%b
	return a
def main():
	k = int(input())
	ans=0
	for a in range(1,k+1):
		for b in range(1,k+1):
			for c in range(1,k+1):
				ans+=gcd(a,gcd(b,c))

	print(ans)

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange
 
import os, sys
from io import IOBase, BytesIO
 
BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0
 
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None
 
    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s
 
    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()
 
    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
 
# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'
 
# Read all remaining integers in stdin, type is given by optional argument, this is fast
def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'0' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'0' [0]:
        A.append(sign*numb)
    return A
 
if __name__ == '__main__':
	main()

Measured memory_bytes: 68700
#!/usr/bin/python
import sys,heapq
if 'pypy' in sys.version.lower():
	import rpython.rlib.streamio
	stream=rpython.rlib.streamio.fdopen_as_stream(sys.stdin.fileno(),'r')
	raw_input=stream.readline
	def cmp_lt(x,y): return x < y
	heapq.cmp_lt=cmp_lt
elif sys.version_info[0]>=3: raw_input=input

INF=1234567890123456789
COMPILE=123456789012
def compile(a,b,c):
	return ((a+COMPILE)<<18) | (b<<9) | c
def decompile(a):
	return ((a>>18)-COMPILE,(a>>9)&511,a&511)

def shortestPath(g,dist,prev):
	n = len(g)-1
	h = [INF]*n+[0]
	for k in range(n+1):
		for i in range(n+1):
			for e in g[i]:
				if h[e[1]]<INF and e[0]<INF and h[e[2]] > h[e[1]] + e[0]:
					h[e[2]] = h[e[1]] + e[0]
					if k==n: return False # negative cycle
	for i in range(n):
		for e in g[i]:
			e[0]+=h[i]-h[e[2]]
	for s in range(n):
		Q=[]
		heapq.heappush(Q,compile(0,s,s))
		while Q:
			e = decompile(heapq.heappop(Q))
			if prev[s][e[2]]!=-2: continue
			prev[s][e[2]] = e[1]
			for f in g[e[2]]:
				if e[0]<INF and f[0]<INF and dist[s][f[2]] > e[0] + f[0]:
					dist[s][f[2]] = e[0] + f[0]
					heapq.heappush(Q,compile(e[0]+f[0],f[1],f[2]))
		for u in range(n):
			if dist[s][u]<INF: dist[s][u] += h[u] - h[s]
	return True

def entry_point(argv):
	V,E=[int(e) for e in raw_input().rstrip().split(' ')]
	g=[[] for i in range(V+1)]
	dist=[[INF]*V for i in range(V)]
	prev=[[-2]*V for i in range(V)]
	for i in range(V): g[i].append([0,i,i])
	for i in range(V): g[V].append([0,V,i])
	for i in range(E):
		s,t,e=[int(e) for e in raw_input().rstrip().split(' ')]
		g[s].append([e,s,t])
	if not shortestPath(g,dist,prev):
		print("NEGATIVE CYCLE")
	else:
		for i in range(V):
			print(' '.join(["INF" if dist[i][j]>=INF else str(dist[i][j]) for j in range(V)]))
	return 0

def target(*args):
	return entry_point, None

if __name__ == '__main__': entry_point([])

Measured memory_bytes: 8464
#include<iostream>
using namespace std;
int main(){
	int n,a[100],i;
		cin>>n;
		for(i=n-1;i>=0;i--){
			cin>>a[i];
		}
			for(i=0;i<n-1;i++){
			cout<<a[i]<<" ";
	}
			cout<<a[i];
			cout<<endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int flag=0;
  string s;
  cin >> s;
  rep(i,s.length()){
    if(!i){
      if(s[i]=='A')flag++;
      else break;
    }
    else if((i<s.length()-1)&&(i>1)){
      if(s[i]=='C'){
        if(flag==1)flag++;
        else{
          flag=0;
          break;
        }
      }
      else if(s[i]<='Z'){
        flag=0;
        break;
      }
    }
    else{
      if(s[i]<='Z'){
        flag=0;
        break;
      }
    }
  }
  if(flag==2)cout << "AC" << endl;
  else cout << "WA" << endl;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
n = INT()
xy = [LIST() for _ in range(n)]
a = list(permutations(xy, n))
l = len(a)
ans = 0
for i in range(l):
    tmp = 0
    for j in range(n - 1):
        tmp += sqrt((a[i][j][0] - a[i][j+1][0]) ** 2 + (a[i][j][1] - a[i][j+1][1]) ** 2)
    ans += tmp
ans /= l
print(ans)

Measured memory_bytes: 70760
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a: [i64;n],
    }
    let mut pi:f64 = 1.0;
    for i in 0..n {
        pi *= a[i] as f64;
    }
    let mut mo: f64 = 0.0;
    for i in 0..n {
        mo += pi/(a[i] as f64);
    }
    let ans:f64 = (pi as f64) / (mo as f64);
    println!("{:.10}", ans);
}

Measured memory_bytes: 4352
use std::io::{BufRead, Read};

pub struct Scanner<R>
where
    R: BufRead,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: BufRead,
{
    pub fn new(reader: R) -> Self {
        Self { reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

#[derive(PartialEq, Debug)]
pub struct Matrix {
    pub row: usize,
    pub col: usize,
    pub data: Vec<Vec<i64>>,
}

impl Matrix {
    pub fn new(data: Vec<Vec<i64>>) -> Self {
        Self {
            row: data.len(),
            col: data[0].len(),
            data: data,
        }
    }

    pub fn product(&self, other: &Matrix) -> Matrix {
        if self.col != other.row {
            panic!("self.col != other.row");
        }
        let mut rows: Vec<Vec<i64>> = Vec::with_capacity(self.row);

        for i in 0..self.row {
            let mut row: Vec<i64> = Vec::with_capacity(other.col);
            for j in 0..other.col {
                let mut sum = 0;
                for k in 0..self.col {
                    sum = sum + self.data[i][k] * other.data[k][j];
                }
                row.insert(j, sum);
            }
            rows.insert(i, row);
        }

        Matrix {
            row: self.row,
            col: other.col,
            data: rows,
        }
    }
}

fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let mut sc = Scanner::new(stdin);

    let (n, m) = (sc.next::<usize>(), sc.next::<usize>());

    // println!("n:{}, m:{}", n, m);

    let mut a: Vec<Vec<i64>> = Vec::with_capacity(n);
    for i in 0..n {
        let mut v = Vec::with_capacity(4);
        for j in 0..m {
            v.insert(j, sc.next());
        }
        a.insert(i, v);
    }

    let mut b: Vec<Vec<i64>> = Vec::with_capacity(m);
    for i in 0..m {
        b.insert(i, vec![sc.next()])
    }

    let m_a = Matrix::new(a);
    let m_b = Matrix::new(b);
    let product = m_a.product(&m_b);

    for i in 0..product.row {
        println!("{}", product.data[i][0]);
    }

}


Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define fill(x,v) memset(x, v, sizeof(x))
#define PI (ld)acos(-1)
#define endl '\n'
#define dbg(x) cout<<#x<<"="<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<endl; 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define IO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
const ld eps=(ld)1e-9;
const ll inf=(ll)1e18;
const ll mod=(ll)1e9+7;
int n, h[100007],dp[100007];
int f(int i){
	if(i==n-1){
		return 0;
	}
	if(dp[i]!=-1){
		return dp[i];
	}
	int ans=INT_MAX;
	if(i+2<n){
		ans=abs(h[i+2]-h[i])+f(i+2);
	}
	return dp[i]= min(ans,abs(h[i+1]-h[i])+f(i+1));
}


void solve(){
	cin>>n;
	fill(dp,-1);
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	cout<<f(0);
}

int main(){fio;
int test=1;
// cin>>test;
while(test--){
	solve();
	cout<<endl;
}
return 0;
}

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

d = max(a)
for i in range(d+1):
    num = max(d-i, i)
    if num in a:
        a.remove(num)
    else:
        print('Impossible')
        exit()

if a == []:
    print('Possible')
    exit()
mini = min(a)
if mini >= (d+1)//2 + 1:
    print('Possible')
else:
    print('Impossible')

Measured memory_bytes: 62024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  double  a,b,x;cin>>a>>b>>x;
  double v=a*a*b;
  double res=0;
  if(v/2<x){
    res=atan(2*(v-x)/a/a/a);
  }
  else {
    res=atan(a*b*b/x/2);
  }
  //cout<<res<<endl;
  res=res/M_PI*180;

  cout<<setprecision(15)<<res<<endl;

  return 0;

}


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

int main() {
  int a, b, c, all;
  int sum;
  cin >> all;
  a = all / 100;
  b = (all - 100 * a) / 10;
  c = all % 2;
  sum = a + b + c;
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int n,ans=0;
int f(int x)
{
    if(x%2==1)
    {
        int tot=0;
        for(int i=1;i<=x;i++)
            if(x%i==0)
                tot++;
        return tot;
    }
    else
    return 0;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {   
        if(f(i)==8)
            ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256