akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int M = sc.nextInt();
			int K = sc.nextInt();
			int[] dp = new int[N * M + 1];
			dp[0] = 1;
			for (int i = 0; i < N; ++i) {
				for (int j = N * M; j >= 0; --j) {
					dp[j] = 0;
					for (int k = 1; k <= M && j - k >= 0; ++k) {
						dp[j] += dp[j - k];
					}
				}
			}
			double all = 1.0;
			for (int i = 0; i < N; ++i) {
				all *= M;
			}
			double ans = 0;
			for (int i = 1; i <= K; ++i) {
				ans += dp[i] / all;
			}
			for (int i = K + 1; i <= N * M; ++i) {
				ans += (i - K) * dp[i] / all;
			}
			System.out.printf("%.9f\n", ans);
		}
	}
}

Measured memory_bytes: 20512
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 100005
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int vis[MN],n,m,a,b;
int main()
{
	n=in();m=in();
	for (int i=1;i<=m;++i){
		a=in();b=in();
		++vis[a];++vis[b];
	}
	for (int i=1;i<=n;++i) if(vis[i]&1) {printf("NO");return 0;} 
	printf("YES");return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

const int N=3;
const int N2=9;

class puzzle
{
public:
	int f[N2];
	int space;
	string path;
	
	bool operator<(const puzzle &p)const
	{
		for(int i=0;i<N2;i++)
		{
			if(f[i]==p.f[i])continue;
			return f[i]>p.f[i];
		}
		return false;
	}
};

const int dx[4]={-1,0,1,0};
const int dy[4]={0,-1,0,1};
const char dir[4]={'u','l','d','r'};

bool istarget(puzzle p)
{
	for(int i=0;i<N2;i++)if(p.f[i]!=i+1)return false;
	return true;
}

string bfs(puzzle s)
{
	queue<puzzle>Q;
	map<puzzle,bool>V;
	puzzle u,v;
	s.path="";
	Q.push(s);
	V[s]=true;
	
	while(!Q.empty())
	{
		u=Q.front();Q.pop();
		if(istarget(u))return u.path;
		int sx=u.space/N;
		int sy=u.space%N;
		for(int r=0;r<4;r++)
		{
			int tx=sx+dx[r];
			int ty=sy+dy[r];
			if(tx<0||tx>=N||ty<0||ty>=N)continue;
			v=u;
			swap(v.f[u.space],v.f[tx*N+ty]);
			v.space=tx*N+ty;
			if(!V[v])
			{
				V[v]=true;
				v.path+=dir[r];
				Q.push(v);
			}
		}
	}
	
	return "unsolvable";
}

int main()
{
	puzzle in;
	for(int i=0;i<N2;i++)
	{
		cin>>in.f[i];
		if(in.f[i]==0)
		{
			in.f[i]=N2;
			in.space=i;
		}
	}
	
	string ans=bfs(in);
	
	if(ans!="unsolvable")cout<<ans.length()<<endl;
	else cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 30600
import java.util.Scanner;
import java.lang.Math;
public class Main {
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int m=scan.nextInt(),n=scan.nextInt();
        if(m==n){
        System.out.println("Yes");
        }
      else{
        System.out.println("No");
        }
    }
}


Measured memory_bytes: 21716
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<(int)n;i++)
#define REP(i,n)	for(int i=0;i<=(int)n;i++)
#define srep(i,a,n)	for(int i=a;i<(int)n;i++)
#define SREP(i,a,n)	for(int i=a;i<=(int)n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	cout<<"case #" << x << ": " << endl
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-15;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

int main() {
	int n;	cin >> n;
	vector<int> a(n), b(n);
	rep(i, n)	cin >> a[i];
	rep(i, n)	cin >> b[i];
	sort(all(a));
	sort(all(b));
	int ret = 0;
	vector<int> amod(n), bmod(n);
	rep(i, 29) {
		rep(j, n)	amod[j] = a[j] % (2 << i);
		rep(j, n)	bmod[j] = b[j] % (2 << i);
		sort(all(bmod));
		int cnt = 0;
		rep(j, n) {
			if (amod[j] & (1 << i)) {
				// ooxxxxxxoo
				cnt += lower_bound(all(bmod), (2 << i) - amod[j]) - bmod.begin();
				cnt += bmod.end() - lower_bound(all(bmod), (3 << i) - amod[j]);
			}
			else {
				// xxxxoooooxx
				auto s = lower_bound(all(bmod), (1 << i) - amod[j]);
				auto t = lower_bound(all(bmod), (2 << i) - amod[j]);
				cnt += t - s;
			}
		}
		ret ^= ((cnt&1) << i);
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
int vectPrint(const vector<ll>& A) {
    int size = A.size();
    for (int i = 0; i < size; i++) {
        cout << A[i] << " ";
    }
    cout << endl;
    return 0;
}
ll max2val(ll a, ll b) {
    if (a > b) {
        return a;
    }
    else {
        return b;
    }
}

int main(void) {
    // Your code here!
    ll N, M, K;
    ll ans, j;

    std::cin >> N;
    std::cin >> M;
    std::cin >> K;
    vector<ll> vecN(N), vecM(M);
    vector<ll> a(1), b(1);
    
    for (ll i = 0; i < N; i++) {
        cin >> vecN[i];
    }
    for (ll i = 0; i < M; i++) {
        cin >> vecM[i];
    }
    //単純増加列
    for (ll i = 0; i < N; i++) {
        a.push_back(a[i] + vecN[i]);
    }
    for (ll i = 0; i < M; i++) {
        b.push_back(b[i] + vecM[i]);
    }

    ans = 0;
    j = M;
    for (ll i = 0; i < N + 1; i++) {
        if (a[i] > K)break;
        while (b[j] > K - a[i]) {
            j -= 1;
        }
        ans = max2val(ans, i + j);
    }

    cout << ans;
    
    return 0;
}


Measured memory_bytes: 11004
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main(){
	string s1,s2,s3;
	cin >> s1;
	cin >> s2;
	cin >> s3;

	printf("%c%c%c\n",s1[0]-32,s2[0]-32,s3[0]-32);

	return 0;
}

Measured memory_bytes: 256
A,B = map(int,input().split())
X = []
for i in range(100):
    defC = "." if i<50 else "#"
    line = [defC for _ in range(100)]
    X.append(line)

h,w = (B-1)//50,(B-1)%50
for i in range(h):
    for j in range(50):
        X[i*2][j*2] = "#"
for i in range(w):
    X[h*2][i*2] = "#"

h,w = (A-1)//50,(A-1)%50
for i in range(h):
    for j in range(50):
        X[i*2+51][j*2] = "."
for i in range(w):
    X[h*2+51][i*2] = "."

print(100,100)
for i in range(100):
    print("".join(X[i]))

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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N+1);
  vector<ll> B(N);
  for (int i = 0; i < N+1; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];

  ll total = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] > B[i]) {
      A[i] = A[i] - B[i];
      total += B[i];
      B[i] = 0;
    } else {
      B[i] = B[i] - A[i];
      total += A[i];
      A[i] = 0;
    }

    if (A[i+1] - B[i] > 0) {
      total += B[i];
      A[i+1] = A[i+1] - B[i];
    } else {
      total += A[i+1];
      A[i+1] = 0;
    }
  }
  cout << total << endl;
}


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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int N, X; cin >> N >> X;
    VI A(N);
    REP(i,N)
    {
        cin >> A[i];
    }
    SORT(A);

    int ans = 0;
    int i=0;
    REP(i, N)
    {
        if (X-A.at(i)<0)
        {
            break;
        }
        X -= A.at(i);
        ans ++;
        if (i==N-1 && X!=0) ans --; 
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 2000 + 5;
const int M = 101;
const int Q = 2e5 + 5;
const int OO = 2e9;
const int mod = 1e9 + 7;

int n,k,fact[N];

int prod(int a, int b) {

    return (1LL*a*b)%mod;

}

int fp(int b, int p) {

    if(!p) return 1;

    int res = fp(b,p>>1);

    return prod(prod(res,res),(p&1 ? b : 1));

}

int inv(int a) {

    return fp(a, mod-2);

}

int main() {

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

    cin >> n >> k;

    fact[0] = 1;

    for (int i = 1; i < N; ++i)
        fact[i] = prod(fact[i-1],i);

    for (int i = 1; i <= k; ++i) {
        if(i>n-k+1) cout << "0\n";
        else {

            int c1 = prod(fact[k-1],prod(inv(fact[k-i]),inv(fact[i-1])));
            int c2 = prod(fact[n-k+1],prod(inv(fact[n-k-i+1]),inv(fact[i])));
            cout << prod(c1,c2) << '\n';

        }
    }

    return 0;
}

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

#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int k, a[100000], mn = 2, mx = 3;

signed main() {
	cin >> k;
	rep(i,k) cin >> a[i];
	// まずa[k-1]で2人になる必要があるのでa[k-1]の直前では、a[k-1]が2なら2人か3人、そうでないなら存在しない
	// a[k-2]の後2人か3人になる必要があるのでa[k-2]が2なら2人か3人 a[k-2]が3なら3人か4人か5人、a[k-2]が4以上なら無理
	// a[k-2]が2なら a[k-3]の後2..3人になる必要があるのでa[k-3]が2なら2人か3人、a[k-3]が3なら3人か4人か5人
	// a[k-2]が3なら a[k-3]の後3..5人になる必要があるのでa[k-3]が2なら4人か5人、
	// 												 a[k-3]が3なら3..5人、a[k-3]が4なら4..7人、a[k-3]が5なら5..9
	// この区間が連続してることが重要？
	if (a[k-1]!=2) {
		cout << -1 << ln;
		return 0;
	}
	
	repr(i,k-2) {
		if (mx<a[i]) {
			cout << -1 << ln;
			return 0;
		}
		int x = (mn+a[i]-1)/a[i];
		int y = mx/a[i] + 1;
		x *= a[i];
		y = y * a[i] - 1;
		if (y<mn || mx<x) {
			cout << -1 << ln;
			return 0;
		}
		// ↓ちがう mn以上の最小のaの倍数だった
		// mxはmxを超える最小のaの倍数-1
		mn = x, mx = y;
		//cout << a[i] << "でmn:" << mn << "、mx:" << mx << ln;
	}
	cout << mn << " " << mx << ln;
}

Measured memory_bytes: 1024
import sys
#import copy
#import numpy as np
#import itertools
import collections
#from collections import deque
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read
count = collections.Counter

def main():
    N = int(readline())
    S = input()

    values = list(count(S).values())
    if len(values) < 3:
        print(0)
        return
    
    ans = values[0] * values[1] * values[2]

    for i in range(N-2):
        for j in range(i+1, N-1):
            k = 2 * j - i
            if k >= N:
                break
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                ans -= 1

    print(ans)
    #print('end')


if __name__ == "__main__":
    main()


Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	int a = 0;
	int b = s.length()-1;
	int r = 0;
	while (a < b) {
		if (s[a] == s[b]) {
			++ a; -- b;
		} else if (s[a] == 'x') {
			++ r; ++ a;
		} else if (s[b] == 'x') {
			++ r; -- b;
		} else {
			r = -1;
			break;
		}
	}
	cout << r << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int N;
    scanf("%d",&N);
    int rem=N%10;
    if(rem == 2 || rem == 4 || rem == 5 || rem == 7 ||rem == 9)
        printf("hon\n");
    else if(rem == 0 || rem == 1 || rem == 6 || rem == 8)
        printf("pon\n");
    else if(rem == 3)
        printf("bon\n");
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

ll dp[60][2];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vl a(n);
	vvl dp(60,vl(2,-1));
	rep(i,60)dp[i][0]=0;
	vb b(60);
	rep(i,n)cin>>a[i];
	bool fl=false;
	rrep(i,59){
		ll m=(1ll<<i);
		ll cnt=0;
		rep(j,n)if(a[j]&m)cnt++;
		if(dp[i+1][0]>=0){
			if(m&k){
				chmax(dp[i][0],dp[i+1][0]+m*(n-cnt));
				chmax(dp[i][1],dp[i+1][0]+m*cnt);
			}
			else chmax(dp[i][0],dp[i+1][0]+m*cnt);
		}
		if(dp[i+1][1]>=0)chmax(dp[i][1],dp[i+1][1]+m*max(cnt,n-cnt));
	}
	cout<<max(dp[0][0],dp[0][1])<<endl;
}


Measured memory_bytes: 1024
from itertools import permutations
import math
n=int(input())
G=[]
for _ in range(n):
  x,y=map(int,input().split())
  G.append([x,y])
  
ans=0 
for v in permutations(range(n),n):
  for i in range(n-1):
    ans+=((G[v[i]][0]-G[v[i+1]][0])**2+(G[v[i]][1]-G[v[i+1]][1])**2)**0.5
    

print(ans/math.factorial(n))

Measured memory_bytes: 68876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
class mint{
    public:
        long long x;
 
    constexpr mint(long long _x = 0) : x((_x%mod+mod)%mod) {}
    constexpr mint operator-() const{
        return mint(-x);
    }
    constexpr mint& operator+=(const mint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint& a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint& a){
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint& a) const{
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint& a) const{
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint& a) const{
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(long long x) const{
        if(!x) return 1;
        mint a = pow(x>>1);
        a *= a;
        if(x&1) a *= *this;
        return a; 
    }
    constexpr mint inv() const{
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint& a){
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint& a) const{
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x; return os;
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin >> n;
    vector<ll> a(n);
    ll t=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        chmax(t,a[i]);
    }
    vector<int> d(t+1);
    for(int i=0;i<n;i++){
        int num=a[i];
        for(int j=2;j*j<=num;j++){
            int cnt=0;
            while(num%j==0){
                num/=j;
                cnt++;
            }
            chmax(d[j],cnt);
        }
        if(num!=1){
            chmax(d[num],1);
        }
    }
    mint lcm=1,ans=0;
    for(int i=2;i<=t;i++){
        mint c=i;
        lcm*=c.pow(d[i]);
    }
    for(int i=0;i<n;i++){
        mint c=a[i];
        ans+=lcm/c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; ++i)
#define for1(i, n) for (int i = 1; i <= n; ++i)
#define fore(i, l, r) for (int i = l; i <= r; ++i)

using namespace std;
using LL = long long;

const int MOD = 1'000'000'007;
vector<int> vert;
vector<int> horiz;

int main(){
	int n, m; cin >> n >> m;
	vert.resize(n);
	horiz.resize(m);
	forn(i, n){
		cin >> vert[i];
	}
	forn(i, m){
		cin >> horiz[i];
	}
	sort (vert.begin(), vert.end());
	sort (horiz.begin(), horiz.end());
	
	LL ans1 = 0;
	LL ans2 = 0;
	forn(i, n){
		ans1 += ((LL)i * vert[i] - (LL)(n-i-1) * vert[i]) % MOD;
		ans1 %= MOD;
	}
	forn(i, m){
		ans2 += ((LL)i * horiz[i] - (LL)(m-i-1) * horiz[i]) % MOD;
		ans2 %= MOD;
	}
	LL final = (ans1 * ans2) % MOD;
	cout << final << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
# Kenri19

s = int(input())
x = [ int(i) for i in list(str(s)) ]
length = len(x)

ans = 0
for bit in range(1<<(length-1)):
    cur = int(x[0])
    for i in range(length-1):
        # i番目の間に + が挿入されていたとき
        if (bit>>i)&1:
            ans += cur
            cur = int(x[i+1])
        # i番目の間に + が挿入されていないとき
        else:
            cur *= 10
            cur += int(x[i+1])
    ans += cur

print(ans)



Measured memory_bytes: 3060
/*

 Remember, Hope is a good thing... May be the best of things... and No Good thing ever Dies !!!

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cout.tie(0);
#define endl "\n"
#define MOD 1000000007
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define N 2010
char st[N];
ll mat[N][N],sumR[N][N],sumC[N][N];
typedef long double ld;
const ll inf=(1LL<<60)-1;
const ll mxn=1e5;
int dx[]= {-1,1,0,0};
int dy[]= {0,0,-1,1};
map<ll,ll>mp;
vector<ll>divs;
void div(ll x)
{
    for(ll i=1; i*i<=x; i++)
    {
        if(x%i==0)
        {
            if(x/i==i)
                divs.push_back(i);
            else
            {
                divs.push_back(x/i);
                divs.push_back(i);
            }
        }
    }
}
void solve()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ll n,x,sum=0;
    cin>>n;
    if(n==0)
        cout<<1<<endl;
    else
        cout<<0<<endl;

}
int main()
{
    IOS;
    //ll t;
    //cin>>t;
    //while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 3612
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 28 09:21:55 2018
ALDS-1-2c
@author: maezawa
"""

def selection(a, n):
    """
    Selection Sort of array a, n=len(a)
    
    配列aｆは参照渡しなのでa自身が変化する（ソートされる）
    """
    cnt = 0
    for i in range(n):
        flag = 0
        minj = i
        for j in range(i+1,n):
            if int(a[j][1]) < int(a[minj][1]):
                minj = j
                flag = 1
        if flag == 1:
            temp = a[minj]
            a[minj] = a[i]
            a[i] = temp
            cnt += 1
    return cnt

def bubble(a, n):
    cnt = 0
    for i in range(n):
        for j in reversed(range(i+1,n)):
            if int(a[j][1]) < int(a[j-1][1]):
                temp = a[j]
                a[j] = a[j-1]
                a[j-1] = temp
                cnt += 1
    return cnt

def print_array(a):
    ans = str(a[0])
    for i in range(1,n):
        ans += ' '+str(a[i])  
    print(ans)

def is_stable(a, b):
    for card1 in range(len(a)):
        for card2 in range(card1+1,len(a)):
            if a[card1][1] == a[card2][1]:
                if b.index(a[card1]) > b.index(a[card2]):
                    return 'Not stable'
    return 'Stable'

n = int(input())
a = input().split()

bub = a[:]
cnt = bubble(bub, n)   
print_array(bub)
print(is_stable(a, bub))

sel = a[:]
cnt = selection(sel, n)   
print_array(sel)
print(is_stable(a, sel))


Measured memory_bytes: 5624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String inpt =  sc.next();
		sc.close();
		String [] sort = inpt.split("");
		String otpt = sort[2]+sort[1]+sort[0];
		System.out.println(inpt.equals(otpt)? "Yes":"No");
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll long long
#define inf 1e8
using namespace std;
inline ll read()
{
	ll t=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')	c=getchar();}
	while(c>='0'&&c<='9')	t=t*10+c-48,c=getchar();
	return t*f;
}
struct mmp{int l,r;}	p[20001];
inline bool cmp(mmp x,mmp y){return x.l<y.l;}
int n,q[10001],top,ans,hz[10001];
char a[10001],b[10001];
inline int get_lower(int x)
{
	int l=1,r=top,ans=-1;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(q[mid]<=x)	ans=mid,l=mid+1;else	r=mid-1;
	}
	if(ans==-1)	return -1;
	return q[ans];
}
inline int get_upper(int x)
{
	int l=1,r=top,ans=-1;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(q[mid]>=x)	ans=mid,r=mid-1;else	l=mid+1;
	}
	if(ans==-1)	return -1;
	return q[ans];
}
inline void solve(int &ANS,int yuan,int x,int zuo,int you)
{
	int tans=0;
	tans=abs(yuan-you)+abs(you-zuo)+abs(zuo-x);
	tans=min(tans, abs(yuan-zuo)+abs(zuo-you)+abs(you-x) );
	ANS=tans;
}
inline void doit(int L,int R)
{
	int tep=n+1-L+R;
	int cnt=0,tans=0;
	For(i,tep,tep+n-1)
	{
		if(a[i-tep+1]==b[i])	continue;
		tans++;
		if(a[i-tep+1]=='0')	continue;
		int tl=i-get_lower(i),tr=get_upper(i)-i;
		if(tl==i+1)	tl=inf;if(tr==-(i+1))	tr=inf;
		p[++cnt].l=tl;p[cnt].r=tr;
	}
	sort(p+1,p+cnt+1,cmp);hz[cnt+1]=0;
	Dow(i,1,cnt)	hz[i]=max(hz[i+1],p[i].r);
	int ANS=inf,QL=0,QR=0,QANS=0;
	For(i,0,cnt)
	{
		QL=p[i].l;QR=hz[i+1];
		QL=max(QL,0);QR=max(QR,0);
		solve(QANS,n+1,tep,tep-QL,tep+QR);
		ANS=min(ANS,QANS+tans);
	}
	ans=min(ANS,ans);
}
int main()
{
	//freopen("flip.in","r",stdin);freopen("flip.out","w",stdout);
	scanf("\n%s",a+1);
	scanf("\n%s",b+1);
	n=strlen(b+1);
	ans=inf;
	For(i,1,n)	b[n+i]=b[2*n+i]=b[i];
	For(i,1,3*n)	if(b[i]=='1')	q[++top]=i;
	For(i,0,n)	doit(i,0);
	For(i,1,n)	doit(0,i);
	if(ans==inf)	puts("-1");else cout<<ans<<endl;
}

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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vp;

double vec[3010];
double dp[3010][3010];

int main(){
	int n;
	si(n);
	for(int i = 1; i <= n; i++)
		scanf("%lf", &vec[i]);
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= i; j++){
			dp[i][j] = dp[i-1][j]*(-vec[i]+1);
			if(j-1 >= 0)
				dp[i][j] += dp[i-1][j-1]*vec[i];
		}
	}
	double ans = 0;
	for(int i = n/2+1; i <= n; i++)
		ans += dp[n][i];
	printf("%.11f\n", ans);
    return 0;
}

Measured memory_bytes: 49844
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();
            Console.WriteLine(Solve(AB[0]-1)^Solve(AB[1]));
        }

        static long Solve(long n)
        {
            if (n < 0) return 0;
            switch (n % 4)
            {
                case 0:
                    return n;
                case 1:
                    return 1;
                case 2:
                    return n + 1;
                case 3:
                    return 0;
            }
            return -1;
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int n;
    cin >> n;
    cout << n / 3 << endl;

}
  

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

 int main(){

 int n,k;
 cin>>n>>k;
 int hei[n];
 for(int i=0;i<n;i++)
    cin>>hei[i];

 sort(hei,hei+n);

 long long int sum=0;
 int diff=n-k;

 if(diff)
 for(int i=0;i<diff;i++)
    sum+=hei[i];

 cout<<sum<<endl;



 return 0;



 }


Measured memory_bytes: 1024
n = gets.to_i
s = gets.chomp.chars.map { |c| c == '#' } # black if true
tmp = s.count { |x| !x } # to all black
res = tmp
n.times do |i| # 0..i white, rest black
  if s[i]
    tmp+=1
  else
    tmp-=1
  end
  res=tmp if tmp<res
end
p res


Measured memory_bytes: 32100
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

struct Restaurant {
    string city;
    int point;
    int idx;

    Restaurant(string city, int point, int idx) {
        this->city = city;
        this->point = point;
        this->idx = idx;
    }
    bool operator<(const Restaurant& restaurant) {
        if (city != restaurant.city) {
            return city < restaurant.city;
        } else {
            return point > restaurant.point;
        }
    }
};

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<Restaurant> restaurants;
    range(i, 0, N) {
        string S;
        int P;
        cin >> S >> P;
        restaurants.emplace_back(S, P, i);
    }
    sort(restaurants.begin(), restaurants.end());
    for (const auto restaurant : restaurants) {
        cout << restaurant.idx + 1 << "\n";
    }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//

int main() {
	int x,ans; cin >> x;
	bool sucflag = 0;

	For(i,1, 160) {
		if (sucflag)break;
		For(j,0,i) {
			if (sucflag)break;
			ans = i * i * i * i * i - j * j * j * j * j;
			if (ans == x) {
				cout << i << " " << j << endl;
				sucflag = 1;
			}
		}
	}

	For(i, 1, 70) {
		if (sucflag)break;
		For(j, 0, i+1) {
			if (sucflag)break;
			ans = i * i * i * i * i + j * j * j * j * j;
			if (ans == x) {
				cout << i << " " << (-1) * j << endl;
				sucflag = 1;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3636
N=int(input())
A=list(map(int,input().split()))
S=[0]
mp={0:1}
for i in range(N):
  S.append(S[-1]+A[i])
  mp[S[-1]]=mp.get(S[-1],0)+1
ans=0
for i in mp:
  ans+=mp[i]*(mp[i]-1)//2

print(ans)

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

#define MOD 1000000007;

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

    //0:dammy, 1:'A' 2:'G', 3:'C', 4:'T'
    ll dp[N + 1][5][5][5] = {0};
    dp[0][0][0][0] = 1;
    for(int n = 0; n < N; n++){
        for(int i = 0; i < 5; i++){
            for(int j = 0; j < 5; j++){
                for(int k = 0; k < 5; k++){
                    for(int l = 1; l < 5; l++){
                        if(i == 1 && j == 2 && l == 3) continue;
                        if(i == 1 && k == 2 && l == 3) continue;
                        if(j == 1 && k == 2 && l == 3) continue;
                        if(j == 2 && k == 1 && l == 3) continue;
                        if(j == 1 && k == 3 && l == 2) continue;
                        dp[n + 1][j][k][l] += dp[n][i][j][k];
                        dp[n + 1][j][k][l] %= MOD;
                    }
                }
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i < 5; i++){
        for(int j = 0; j < 5; j++){
            for(int k = 0; k < 5; k++){
                ans += dp[N][i][j][k];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define ll long long
using namespace std;

inline int read(){
	int sum=0,f=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-') f=-1;c=getchar();}
	while(c<='9'&&c>='0'){sum=sum*10+c-'0';c=getchar();}
	return f*sum;
}

const int N=186;
int n,m,a[N][N],s[N][N];
int f[22][N][N][N];
char ss[N][N];

inline bool S(int x1,int y1,int x2,int y2){
	int sum=s[x2][y2]-s[x2][y1-1]-s[x1-1][y2]+s[x1-1][y1-1];
	return sum==0||sum==(x2-x1+1)*(y2-y1+1);
}

signed main(){
	n=read();m=read();
	for(int i=1;i<=n;i++)
		scanf("%s",ss[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) a[i][j]=(ss[i][j]=='.');
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) s[i][j]=a[i][j]+s[i-1][j]+s[i][j-1]-s[i-1][j-1];
	int K=log2(n)+log2(m)+1;
	for(int u=1;u<=n;u++)
		for(int d=u;d<=n;d++)
			for(int l=m;l>=1;l--){
				if(!S(u,l,d,l)) continue;
				if(l<m&&S(u,l,d,l+1)) f[0][l][u][d]=f[0][l+1][u][d];
				else f[0][l][u][d]=l;
			}
	if(f[0][1][1][n]==m){puts("0");return 0;}
	for(int k=1;k<=K;k++){
		for(int u=1;u<=n;u++)
			for(int d=u;d<=n;d++)
				for(int l=m;l>=1;l--){
					f[k][l][u][d]=f[k-1][l][u][d];
					if(f[k-1][l][u][d]) f[k][l][u][d]=max(f[k][l][u][d],f[k-1][ f[k-1][l][u][d]+1 ][u][d]);
					int L=u,R=d-1;
					while(L<=R){
						int mid=(L+R)>>1;
						int p1=f[k-1][l][u][mid],p2=f[k-1][l][mid+1][d];
						f[k][l][u][d]=max(f[k][l][u][d],min(p1,p2));
						if(p1>p2) L=mid+1;
						else R=mid-1;
					}
				}
		/*
		if(k==2){
			for(int i=1;i<=n;i++)
				for(int u=1;u<=n;u++)
					for(int d=u;d<=n;d++) printf("f[%d][%d][%d][%d]=%d\n",k,i,u,d,f[k][i][u][d]);
		}
		*/
		if(f[k][1][1][n]==m){printf("%d\n",k);return 0;}
	}
	return 0;
}


Measured memory_bytes: 428416
#include<iostream>
#include<string>
// #include<vector>
// #include <algorithm>
// #include <functional>

using namespace std;
int main()
{
  // Input
  int a, b;
  cin >> a >> b;
  
  string out;
  if (a <= b) {
      for (int i = 0; i < b; i++) {
        out += to_string(a);
      }
  } else {
      for (int i = 0; i < a; i++) {
        out += to_string(b);
      }
  }

  cout << out << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
class Program
{
    static void Main()
    {
        long[] ipts = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long k = ipts[0], a = ipts[1], b = ipts[2];
        if (b - a <= 2 || a - 1 >= k)
        {
            Console.WriteLine(k + 1);
            return;
        }
        long bis = a;
        k -= a - 1;
        long c = k / 2;
        bis += (b - a) * c;
        bis += k % 2;
        Console.WriteLine(bis);
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
#include <string.h>
int main(){
  int x=0;
  char s[11],t[12];
  scanf("%s",&s);
  scanf("%s",&t);
  for (int i=0; i<strlen(s);i++){
    if(s[i]!=t[i]){
      x = x+1;
    }
  }
  if(x==0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}

Measured memory_bytes: 1664
class Factorial():
    def __init__(self, mod=10**9 + 7):
        self.mod = mod
        self._factorial = [1]
        self._size = 1
        self._factorial_inv = [1]
        self._size_inv = 1

    def fact(self, n):
        ''' n! % mod '''
        if n >= self.mod:
            return 0
        if self._size < n+1:
            for i in range(self._size, n+1):
                self._factorial.append(self._factorial[i-1]*i % self.mod)
            self._size = n+1
        return self._factorial[n]

    def fact_inv(self, n):
        ''' n!^-1 % mod '''
        if n >= self.mod:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        if self._size < n+1:
            for i in range(self._size, n+1):
                self._factorial.append(self._factorial[i-1]*i % self.mod)
            self._size = n+1
        if self._size_inv < n+1:
            for i in range(self._size_inv, n+1):
                self._factorial_inv.append(self.modinv(self._factorial[i]))
            self._size_inv = n+1
        return self._factorial_inv[n]
    
    def comb(self, n, r):
        ''' nCr % mod '''
        if r > n:
            return 0
        t = self.fact(n) * self.fact_inv(n-r) % self.mod
        t = t * self.fact_inv(r) % self.mod
        return t

    @staticmethod
    def xgcd(a, b):
        '''
        Return (gcd(a, b), x, y) such that a*x + b*y = gcd(a, b)
        '''
        x0, x1, y0, y1 = 0, 1, 1, 0
        while a != 0:
            (q, a), b = divmod(b, a), a
            y0, y1 = y1, y0 - q * y1
            x0, x1 = x1, x0 - q * x1
        return b, x0, y0

    def modinv(self, n):
        g, x, _ = self.xgcd(n, self.mod)
        if g != 1:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        return x % self.mod        

x, y = sorted(map(int, input().split()))
q, r = divmod(x+y, 3)
if r != 0:
    print(0)
else:
    fact = Factorial()
    print(fact.comb(q, y-q))


Measured memory_bytes: 48576
import java.util.Scanner;
 
public class Main{
  public static void main(String[] arg){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n==1){
      System.out.println("Hello World");
      System.exit(0);
    }
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(a+b);
  }
}

Measured memory_bytes: 21844
#A

#B
"""
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = sum(l) - 2*l[-1]
if ans > 0:
    print("Yes")
else:
    print("No")
"""

#C
"""
import bisect
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
xb = [abs(x[i] - x[i + 1]) for i in range(m-1)]
xb.sort(reverse=True)
ans = sum(xb[n - 1::])
print(ans)
"""

#D
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
x = list(map(int, input().split()))
a = 0
b = 0
ans = 0
ansb = 0
mae = 0
b = [0] * 40
for i in range(40):
    for k in x:
        b[i] += (k & (1 << i)) >> i

for i in range(39, -1, -1):
    if m & (1 << i):
        ansb = mae
        ansb += b[i] << i
        for k in range(i):
            if b[k] > n - b[k]:
                ansb += b[k] << k
            else:
                ansb += n - b[k] << k
        if ans < ansb:
            ans = ansb
        mae += n-b[i] << i
    else:
        mae += b[i] << i
ans = max(ans, mae)
print(ans)



        





Measured memory_bytes: 63760
import copy

INF = 10 ** 10
def merge(A, left, mid, right):
	count = 0
	L = A[left:mid] + [(INF, INF)]
	R = A[mid:right] + [(INF, INF)]

	i, j = 0, 0
	for k in range(left, right):
		count += 1
		if L[i][1] <= R[j][1]:
			A[k] = L[i]
			i += 1
		else:
			A[k] = R[j]
			j += 1
	return count

def mergeSort(A, left, right):
	if left + 1 < right:
		mid = (left + right) // 2
		countL = mergeSort(A, left, mid)
		countR = mergeSort(A, mid, right)
		return merge(A, left, mid, right) + countL + countR
	return 0

def partition(A, p, r):
	x = A[r][1]
	i = p - 1
	for j in range(p, r):
		if A[j][1] <= x:
			i += 1
			A[i], A[j] = A[j], A[i]

	A[i + 1], A[r] = A[r], A[i + 1]
	return i + 1

def quickSort(A, p, r):
	if p < r:
		q = partition(A, p, r)
		quickSort(A, p, q - 1)
		quickSort(A, q + 1, r)

n = int(input())
A = [None for _ in range(n)]
for i in range(n):
	a, b = input().split()
	A[i] = (a, int(b))

B = copy.deepcopy(A)
quickSort(A, 0, n - 1)
mergeSort(B, 0, n)

if A == B:
	print("Stable")
else:
	print("Not stable")

for i in range(n):
	print(" ".join(map(str, A[i])))


Measured memory_bytes: 18364
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int num = sc.nextInt();

		int a1=num/100;
		if(a1==1)
			num-=100;
		int a2=num/10;
		if(a2==1)
			num-=10;
		int a3=num/1;

		int sum=a1+a2+a3;
		System.out.println(sum);

		sc.close();
	}

}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int n, t, s, a[3003], b[3003];
int dp[3003][3003];
void dpru(int lower, int upper)
{
	for (int i = 0; i < n; ++i)
	{
		for (int j = lower; j <= upper; ++j)
		{
			max_swap(dp[i + 1][j], dp[i][j]);
			if (j - b[i] >= lower)
				max_swap(dp[i + 1][j], dp[i][j - b[i]] + a[i]);
		}
	}
}
void show(int upper)
{
	printf("****");
	for (int j = 0; j <= upper; ++j)
		printf("%2d ", j);
	puts("");
	for (int i = 0; i <= n; ++i)
	{
		printf("%2d: ", i);
		for (int j = 0; j <= upper; ++j)
			printf("%2d ", dp[i][j]);
		puts("");
	}
	puts("");
}
int main()
{
	scanf("%d%d%d", &n, &t, &s);
	for (int i = 0; i < n; ++i)
		scanf("%d%d", a + i, b + i);

	dpru(0, s);
	for (int i = 0; i <= n; ++i)
		dp[i][s] = *max_element(dp[i], dp[i] + (s + 1));

	dpru(s, t);

	printf("%d\n", *max_element(dp[n], dp[n] + (t + 1)));
}

Measured memory_bytes: 0
/*

                                                          / 
                                                         { 
     _________                      ,.-?????¬?????¬??§  l 
       ??`??°???_   l::::::::}???            l l   -??????__l_;:='/  ', 
             `??°??´???'"?´        l l   ??°??????               i 
                                l l                        l 
                                 l l                       } 
                                  l l                       l 
                                   l l                     ,' 
                           /       ??? ???                 ,' 
                        ./{            } }             ,'   
                           ?????? __    ??? ???             / 
                      ?¨?¨?¨` ??°??? ?´                   / 
                            /   l                    / 
                            ?????? j                   / 
                     ,. -???'"  ??     `???           /____ 
                 _,.-???'" -?????¬?????¬?????¬??????_,,    /             ` ??°???-??? 
                     ?? `??°??´?????´??????'"?????        /                        ??`??°-??? 
                            _ ???  /                                        `??°-???


*/
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
using namespace std;
#define LATTE 10000
 
int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if(A<B && B<C) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 2984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  vector<int> p(3);
  rep(i,3) cin >> p[i];
  sort(p.begin(),  p.end());
  cout << p[0]+p[1] << endl;
  
  return 0;
}


Measured memory_bytes: 256
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let (n,k) = {
        let h:Vec<usize> = get_input().split_whitespace().map(|x| x.parse().unwrap()).collect();
        (h[0], h[1])
    };
    let h:Vec<i64> = get_input().split_whitespace().map(|x| x.parse().unwrap()).collect();

    let mut dp = [0; 100010];

    for i in 1..n {
        dp[i] = dp[i - 1] + i64::abs(h[i] - h[i - 1]);
        for l in 2..k+1 {
            if l > i {
                break;
            }
            dp[i] = std::cmp::min(dp[i], dp[i - l] + i64::abs(h[i] - h[i - l]));
        }
    }

    println!("{}", dp[n-1]);

}

Measured memory_bytes: 7164
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y);
int main(){
  int n,i,j,ans;
  cin>> n;
  vector<int> a(n+1),fg(n+1),bg(n+1);
 // cout << gcd(10000,333);
  for(i=1;i<=n;i++)
  {
    cin >> a.at(i);
  }
  fg.at(0)=0;
  bg.at(0)=0;
  fg.at(1)=a.at(1);
  bg.at(1)=a.at(n);
  for(i=1;i<n;i++)
  {
     fg.at(i)=gcd(fg.at(i-1),a.at(i));
  }
  for(i=1;i<n;i++)
  {
    bg.at(i)=gcd(bg.at(i-1),a.at(n-i+1));
  }
  ans=-1;
  for(i=1;i<=n;i++)
  {
    j=gcd(fg.at(i-1),bg.at(n-i));
    if(ans<=j) ans=j;
  }
   cout << ans << endl;
  
  
}
int gcd(int x,int y)
{ if(x>=y)
{
if(y==0) return x;
  return gcd(y,x%y);
}if(y>x)
{
if(x==0) return y;
  return gcd(x,y%x);
}
 
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
#define loop(n) for (ll i = 0; i < n; i++)
#define loopy(n) for (ll j = 0; j < n; j++)
#define all(v) v.begin(), v.end()
#define pb push_back
#define oo 1e18
#define fr first
#define se second
using namespace std;
const int N = 5e5 + 10;
const int M = 1e7 + 10;
const ll mod = 1e9 + 7;
int main()
{
    int a , b ; cin >> a >> b ; 
    int open = 1 ;
    int i = 0 ; 
    while(open){
        if(open >= b) {
            return cout<< i , 0 ; 
        }
        if(open){
            open += a ; 
            open -- ; 
        }
        i++ ;
    }
    return 0;
}


Measured memory_bytes: 256