akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int read() {
	int x = 0, fh = 1;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') fh = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		x = (x << 1) + (x << 3) + c - '0';
		c = getchar();
	}
	return x * fh;
}
const int N = 1e6 + 10;
int n, k, i, j, v[N];
double fac, ans;
int main() {
	n = read(); k = read();
	for (i = 1; i <= n; i++) for (j = i; j < k; j <<= 1, v[i]++);
	for (i = 1; i <= n; i++) {
		fac = 1.0 / n;
		for (j = 1; j <= v[i]; j++) fac *= 0.5;
		ans += fac;
	}
	printf("%.12lf", ans);
	return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
void trace(int A[],int N){
for(int i=0;i<N;i++){
if(i>0)cout<<" ";
cout<<A[i];
}
cout<<endl;
}
void insertionSort(int A[],int N){
int v,i,j;
for(i=1;i<=N-1;i++){
v = A[i];
j = i - 1;
while(j >= 0&&A[j] > v){
A[j+1] = A[j];
j--;
}
A[j+1] = v;
trace(A,N);
}
}
int main(){
int N;
cin>>N;
int A[N];
for(int i=0;i<N;i++)cin>>A[i];
trace(A,N);
insertionSort(A,N);
return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, L;
  cin >> N >> L;
  map<int, int> mp;
  vector<int> ans;
  int a[N];
  FOR(i,0,N) cin >> a[i];
  FOR(i,0,L) mp[a[i]]++;
  FOR(i,L,N) {
    ans.push_back(mp.begin()->first);
    mp[a[i]]++; 
    if(--mp[a[i-L]] == 0) {
      mp.erase(a[i-L]);
    }
  }
  ans.push_back(mp.begin()->first);
  FOR(i,0,N-L+1) cout << ans[i] << (i == N - L ? '\n' : ' ');
}


Measured memory_bytes: 15580
#include<iostream>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a=="SUN"){
		cout<<"7";
		return 0;
	}
	if(a=="MON"){
		cout<<"6";
		return 0;
	}
	if(a=="TUE"){
		cout<<"5";
		return 0;
	}
	if(a=="WED"){
		cout<<"4";
		return 0;
	}
	if(a=="THU"){
		cout<<"3";
		return 0;
	}
	if(a=="FRI"){
		cout<<"2";
		return 0;
	}
	if(a=="SAT"){
		cout<<"1";
		return 0;
	}
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    set<int> s;
    rep (i, N) {
        char S;
        cin >> S;
        if (S == 'G') {
            s.insert(1);
        }
        if (S == 'W') {
            s.insert(2);
        }
        if (S == 'Y') {
            s.insert(3);
        }
        if (S == 'P') {
            s.insert(4);
        }
    }

    if (s.size() == 3) {
        cout << "Three" << endl;
    } else {
        cout << "Four" << endl;
    }
    return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int x;cin>>x;
  flagfunc(x<1200,"ABC","ARC");
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);

    int n, m, k;
    cin >> n >> m >> k;

    for(int i=0; i<=n; i++){
        for(int j=0; j<=m; j++){
            if(n*j + m*i - 2*j*i == k){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");

    
    return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n = readint;

    int m = cast(int)sqrt(1.0 * n);
    writeln(m * m);
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

maxCount = 0
count = 0
i = 0

while i < N - 1:
    if H[i] >= H[i + 1]:
        count += 1
    else:
        count = 0
    if count > maxCount:
        maxCount = count
    i += 1

print(maxCount)


Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    vec<int> k(M);
    vec<vec<int>> s(M, vec<int>());
    rep(i, M) {
        cin >> k[i];
        rep(j, k[i]) {
            int sj;
            cin >> sj;
            --sj;
            s[i].push_back(sj);
        }
    }

    vec<int> p(M);
    rep(i, M) cin >> p[i];

    int ans = 0;
    rep(i, 1 << N) {
        int light = 0;
        rep(j, M) {
            int val = 0;
            for (auto e : s[j])
                if(i & (1 << e)) ++val;
            if(val%2 == p[j]) ++light;
        }
        if(light == M) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
#include <queue>

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;



void solve() {
	int h, w;
	cin >> h >> w;
	vector<string> v(h, string(w, '.'));
	VVI visited(h, VI(w, 1e9));

	rep(i, h) {
		cin >> v[i];
	}
	queue<pair<int, int>> q;
	q.push(make_pair(0, 0));
	visited[0][0] = 0;

	while (!q.empty())
	{
		pair<int, int> cur = q.front();
		q.pop();
		
		int x = cur.first, y = cur.second;
		if (x > 0 && v[x - 1][y] != '#' && visited[x - 1][y] > visited[x][y] + 1) {
			q.push(make_pair(x - 1, y));
			visited[x - 1][y] = visited[x][y] + 1;
		}
		if (x < h - 1 && v[x + 1][y] != '#' && visited[x + 1][y] > visited[x][y] + 1) {
			q.push(make_pair(x + 1, y));
			visited[x + 1][y] = visited[x][y] + 1;
		}
		if (y > 0 && v[x][y - 1] != '#' && visited[x][y - 1] > visited[x][y] + 1) {
			q.push(make_pair(x, y - 1));
			visited[x][y - 1] = visited[x][y] + 1;
		}
		if (y < w - 1 && v[x][y + 1] != '#' && visited[x][y + 1] > visited[x][y] + 1) {
			q.push(make_pair(x, y + 1));
			visited[x][y + 1] = visited[x][y] + 1;
		}

	}

	int walls = 0;
	rep(i, h) {
		rep(j, w) if (v[i][j] == '#') walls += 1;
	}
	if (visited[h - 1][w - 1] == 1e9) cout << -1 << endl;
	else cout << w * h - visited[h - 1][w - 1] - walls - 1 << endl;

}


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

	solve(); 
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        sc.close();
        Collection<Character> set = new HashSet<>();
        for (int i=0; i<S.length(); i++){
            set.add(S.charAt(i));
        }
        System.out.println(set.size() == S.length() ? "yes" : "no");
    }
}

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

int ans[30];
int main() {
	int w, n; cin >> w >> n;
	vector<P>vec;
	rep(i, n) {
		int a, b; scanf("%d,%d", &a, &b);
		vec.push_back(P(a, b));
	}
	for (int i = 1; i <= w; i++) {
		int pos = i;
		rep(j, vec.size()) {
			if (vec[j].first == pos)pos = vec[j].second;
			else if (vec[j].second == pos)pos = vec[j].first;
		}
		ans[--pos] = i;
	}
	rep(i, w) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3172
#include <iostream>
#include <cmath>

#define EPS (10e-10)
#define PI 3.1415926535

using namespace std;

double radian(int angle) {
  return (double)angle * PI / 180.0;
}

int main() {
  int a, b, num, angle = 0;
  double x = 0, y = 0;
  char s;
  while (cin >> a >> s >> b) {
    if (a == 0 && b == 0) break;
    num = a;
    y += cos(radian(angle)) * num;
    x += sin(radian(angle)) * num;
    angle += b;
  }
  cout << (int)x << endl << (int)y << endl;
  return 0;
}

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

int main(){
	double a,b,C;
	double S,L,h;
	
	cin >> a >> b >> C ;
	
	C = C * 3.14159265359 / 180;
	
	h = b*sin(C);
	L = a + b + sqrt(pow(b*cos(C)-a,2) + pow(b*sin(C),2));
	S = a * h / 2;
	printf("%f\n%f\n%f\n",S,L,h);
	return 0;
}

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

int main(){
    int n,m;
    cin >>n >> m;
    
    int m1 [n][m] ;
    
    for (int i =0;i<n;i++){
        for(int j =0;j<m;j++){
            m1[i][j]=0;
        }
    }
    
    for(int k=0;k<n;k++){
        for(int l=0; l<m;l++){
            cin >>m1[k][l];
        }
    }
    
    int m2[m];
    
    for (int c=0;c<m;c++){
        m2[c]=0;
    }
    
    for(int a=0;a<m;a++){
        cin >>m2[a]; 
    }
    int sum[n];
    for (int c=0;c<n;c++){
        sum[c]=0;
    }
    for(int d=0;d<n;d++){
        for(int e=0;e<m;e++){
            sum[d] +=(m1[d][e])*(m2[e]);
        }
    }
    for(int i=0;i<n;i++){
            cout << sum[i] <<endl; 
    }
    return 0;
}


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

int main(void){
    int N,K,sum=0;
    cin>>N>>K;
    int x[N];

    for(int i=0;i<N;i++){
        cin>>x[i];
        if(x[i]>abs(x[i]-K))
            sum+=abs(x[i]-K)*2;
        else
            sum+=x[i]*2;
    }
        cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i, j;
	char s[5];

	scanf("%s", s);
	for (i = 0; i < 3; i++) {
		j = i + 1;
		if (s[i] == s[j]) {
			printf("Bad\n");
			return 0;
		}
	}
	printf("Good\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>


using namespace std;


int main()
{
   int a,b;
   cin >> a >> b;
   
   if (a == b)
       cout << "a == b" << endl; 
   else if (a > b)
       cout << "a > b" << endl;
   else if (a < b)
       cout << "a < b" << endl;
   
   return 0;
}



Measured memory_bytes: 3108
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int[] d = new int[n];
        for(int i = 0; i < n; i ++) d[i] = sc.nextInt();
        Arrays.sort(d);
        
        int arc_min = d[n/2];
        int abc_max = d[n/2-1];
        
        // K = abc_max+1, ... , arc_min
        int ans = arc_min - abc_max;
        System.out.println(ans);
    }
}

Measured memory_bytes: 50184
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;

//繰り返し2乗法
ll reppow(ll n, ll p) {
	if (p == 1) return n % mod;
	if (p % 2 == 1) return n * reppow(n, p - 1) % mod;
	ll t = reppow(n, p / 2);
	return t * t % mod;
}

//nCk
ll combination(ll n, ll k) {
	ll x = 1, y = 1, i;
	for (i = 0; i < k; i++) {
		x = x * (n - i) % mod; //分子
		y = y * (i + 1) % mod; //分母
	}
	return x * reppow(y, mod - 2) % mod; //x*逆元
}

int main() {

	ll n, a, b;

	cin >> n >> a >> b;

	ll ans = reppow(2, n) - 1;

	ans -= combination(n, a);
	ans -= combination(n, b);

	cout << (ans % mod + mod) % mod << endl;

	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p)
{
    return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc)
{
    o << "sz = " << vc.size() << endl
      << "[";
    for (const T& v : vc)
        o << v << ",";
    o << "]";
    return o;
}
using ll = long long;
constexpr ll MOD = 1000000007;

int data[50][50];

int main()
{
    int N, M;
    cin >> N >> M;
    rep(i, M)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        data[a][b]++;
        data[b][a]++;
    }
    rep(i, N)
    {
        int cnt = 0;
        rep(j, N)
        {
            cnt += data[i][j];
        }
        cout << cnt << endl;
    }

    return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1001001001;

const int mod = 1000000007;

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

    vector<int> ds(n);
    rep(i, n) {
        cin >> ds[i];
    }

    sort(ds.begin(), ds.end());

    int bu = ds[n / 2 - 1];
    int bo = ds[n / 2];

    cout << bo - bu << endl;
}

Measured memory_bytes: 640
a,b,c,x,y = map(int, input().split())
ans = float('inf')

for i in range(10**5+1):
    tmp = i*2*c
    if i>=x:
        pass
    else:
        tmp += (x-i)*a
    if i>=y:
        pass
    else:
        tmp += (y-i)*b
    if ans > tmp:
        ans = tmp

print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const ll INF = 1e10;

ll d[110][110];
int A[100100];
int B[100100];
int C[100100];

int main(){
    ll N, M;
    cin >> N >> M;

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i == j) d[i][j] = 0;
            d[i][j] = INF;
        }
    }

    REP(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        a--, b--;
        d[a][b] = c;
        d[b][a] = c;
        A[i] = a;
        B[i] = b;
        C[i] = c;
    }

    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i < M; i++){
        int a = A[i];        
        int b = B[i];        
        int c = C[i];        
        if(c != d[a][b]){
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a;
    int temp = 0;
    for (int i = 0; i < n; ++i) {
        cin >> temp;
        a.push_back(temp);
    }
    sort(a.begin(), a.end(), std::greater<int>());
    int alice = 0, bob = 0;

    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            alice += a[i];
        }
        else {
            bob += a[i];
        }
    }

    cout << alice - bob << endl;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void solve(){
	int n = read.to!int;
	S[] ws;
	foreach(i; 0 .. n) ws ~= S(read.to!long, read.to!long);
	
	ws.sort!"a.b<b.b"();
	
	long t = 0;
	foreach(w; ws){
		t += w.a;
		if(t > w.b){
			"No".writeln;
			return;
		}
	}
	
	"Yes".writeln;
	return;
	
}
/*
締切時刻で貪欲。

なぜなら、もし
締切の早いやつやつ（Ａ）よりも
締切が遅いやつ（Ｂ）を先にやる方がよいなら
Ｂが終わったあとＡをやってもＡは間に合うということなので
その場合はＡ→Ｂの順に変えても大丈夫だから

*/

struct S{
	long a, b;
}


Measured memory_bytes: 4988
#include <bits/stdc++.h>
//#define int ll
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int MAX = 1e5 + 10;
using namespace std;

int solve() {
    int d,t,s;
    cin>>d>>t>>s;
    cout<<(t*s>=d?"Yes":"No")<<endl;
    return 0;
}

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

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int Ma = scan.nextInt();
        int Mb = scan.nextInt();
        int[] a = new int[N+1];
        int[] b = new int[N+1];
        int[] c = new int[N+1];
        for (int i = 1; i <= N; i++) {
            a[i] = scan.nextInt();
            b[i] = scan.nextInt();
            c[i] = scan.nextInt();
        }
        int[][][] dp = new int[N+1][N*10+1][N*10+1];
        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= N*10; j++) {
                for (int k = 0; k <= N*10; k++) {
                    dp[i][j][k] = Integer.MAX_VALUE;
                }
            }
        }
        dp[0][0][0] = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= N*10; j++) {
                for (int k = 0; k <= N*10; k++) {
                    if (dp[i - 1][j][k] == Integer.MAX_VALUE) {
                        continue;
                    }
                    dp[i][j][k] = Math.min(dp[i][j][k], dp[i - 1][j][k]);
                    dp[i][j + a[i]][k + b[i]] = Math.min(dp[i][j + a[i]][k + b[i]], dp[i - 1][j][k] + c[i]);
                }
            }
        }
        int answer = Integer.MAX_VALUE;
        for (int i = 1; i <= N*10; i++) {
            for (int j = 1; j <= N*10; j++) {
                if (dp[N][i][j] == Integer.MAX_VALUE) {
                    continue;
                }
                if (i * Mb == j * Ma) {
                    answer = Math.min(answer, dp[N][i][j]);
                }
            }
        }
        if (answer == Integer.MAX_VALUE) {
            answer = -1;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 54356
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int count = 0;

        while (true) {
            boolean ok = true;
            for (int i = 0; i < n; i++) {
                if (arr[i] % 2 != 0) {
                    ok = false;
                    break;
                }
                arr[i] = arr[i] / 2;
            }
            if (!ok) break;
            count++;
        }

        System.out.println(count);
    }


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

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 23124
H, W = map(int, input().split())

def fun(H, W):
    ans = 1e20
    for w in range(1, W):
        w_a = (W - w) // 2
        w_b = W - w - w_a
        S1 = H * w
        ans = min(ans, max(S1, H * w_a, H * w_b) - min(S1, H * w_a, H * w_b))

        h_a = H // 2
        h_b = H - h_a
        S2 = h_a * (W - w)
        S3 = h_b * (W - w)
        ans = min(ans, max(S1, S2, S3) - min(S1, S2, S3))
    return ans

print(min(fun(H, W), fun(W, H)))


Measured memory_bytes: 3188
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int T = sc.nextInt();
		final int E = sc.nextInt();
		
		int suc = -1;
		
		for(int i = 0; i < N; i++){
			final int TIMER = sc.nextInt();
			
			for(int j = 0; j <= T + E; j += TIMER){
				if(j >= T - E){
					suc = i + 1;
					break;
				}
			}
		}
		
		System.out.println(suc);
	}

}

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

int main()
{
    long long i = 0, j = 0, k = 0, ans = 0;
	long long n, m;
	cin >> n >> m;

	if(llabs(m-n)>1){
		cout << 0 << endl;
		return 0;
	}

	ans = 1;
	for (i = n; i >= 1; i--)
	{
		ans = (ans*i)%1000000007;
	}
	for (i = m; i >= 1; i--)
	{
		ans = (ans*i)%1000000007;
	}
	if(n==m)
		ans =(2*ans)%1000000007;

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n,q;
  cin>>n>>q;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int c=0;c<q;c++){
    Int x;cin>>x;
    Int ans=0;
    for(Int i=0,j=0,s=0;i<n;i++){
      s+=a[i];
      while(s>x) s-=a[j++];
      ans+=i-j+1;
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main() {
    int n,k;
    cin >> n >> k;
    
    vector<int> p(n);
    for (int i = 0; i < n; i++){
        cin >> p.at(i);
    }

    vector<int> p_sum(n-k+1,0);
    for (int i = 0; i < k; i++){
        p_sum[0]=p_sum[0]+p[i];
    }
    for (int i = 1; i < n-k+1; i++){
        p_sum[i]=p_sum[i-1]-p[i-1]+p[i-1+k];
    }

    int maxp_sum=0;
    for (int i = 0; i < n-k+1; i++){
        maxp_sum=max(maxp_sum,p_sum[i]);
    }
    double ans=0.5*(double)k+(double)maxp_sum/2.0;

    cout << fixed << setprecision(13) << ans << endl;
}


Measured memory_bytes: 4764
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
ab = [None]*n
cd = [None]*n
for i in range(n):
    ab[i] = tuple(map(int, input().split()))
for i in range(n):
    cd[i] = tuple(map(int, input().split()))
import networkx as nx
g = nx.DiGraph()
for i in range(2*n+2):
    g.add_node(i)
s = 2*n
t = 2*n+1
for i in range(n):
    g.add_edge(s,i, capacity=1)
for i in range(n, 2*n):
    g.add_edge(i, t, capacity=1)
for i in range(n):
    for j in range(n, 2*n):
        if ab[i][0]<cd[j-n][0] and ab[i][1]<cd[j-n][1]:
            g.add_edge(i,j, capacity=1)
val = nx.maximum_flow(g, s, t)
print(val[0])

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


//aとbの最大公約数を返す
long long gcd(long long a, long long b){
    while (a != 0 && b != 0){
        if (a >= b) a %= b;
        else b %= a;
    }
    return a + b;
}

//aとbの最小公倍数を返す
long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}


signed main(){
    ll A, B;
    cin >> A >> B;
    PRINT(lcm(A, B));
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine());
        int ans=0,i,j,max=(int)Math.sqrt(n-1);
        for(i=1;i<=max;i++)
        for(j=i;j*i<n;j++) ++ans;
        ans*=2;
        ans-=max;
        System.out.print(ans);
    }
}


Measured memory_bytes: 32744
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    private static final PrintStream so = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        String s = sc.next();
        String t = sc.next();
        for (int i = 0; i < s.length(); i++) {
            s = s.substring(1) + s.charAt(0);
            if (s.equals(t)) {
                so.println("Yes");
                return;
            }
        }
        so.println("No");
    }
}


Measured memory_bytes: 21716
#include<stdio.h>

int main ()
{
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    if(C>=A && C<=B){
        printf("Yes");
    }
    else if(A==B==C){
        printf("Yes");
    }
    else{
        printf("No");
    }
return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main
{
  public static void main(String arga[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int arr[]=new int[n];
    for(int i=0;i<n;i++)
      arr[i]=sc.nextInt();
    Arrays.sort(arr);
    long sum=0;
    for(int i=0;i<n-k;i++)
      sum+=(long)arr[i];
    System.out.println(sum);
  }
}


Measured memory_bytes: 86288
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

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

  vector<long long> v(n);
  for (auto &x : v) cin >> x;

  long long ans = 0;
  long long sum = 0;
  map<long long, long long> values;
  values[0] = 1;

  for (auto &x : v) {
    sum += x;
    ans += values[sum];
    values[sum]++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 14336
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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

	ll N, M;

	cin >> N;


	cout << 180 * (N - 2) << endl;


	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int R,C;
bool A[11][10010];

int main() {
    while(1) {
        cin >> R >> C;
        if(R == 0 && C == 0) break;
        for(int i=0; i<R; i++) {
            for(int j=0; j<C; j++) cin >> A[i][j];
        }
        int res = 0;
        for(int k=0; k < (1<<R); k++) {
            int tmp = 0;
            for(int j=0; j<C; j++) {
                int cnt = 0;
                for(int i=0; i<R; i++) {
                    if((A[i][j] == 0 && ((k>>i)&1) == 0) || (A[i][j] == 1 && ((k>>i)&1) == 1)) cnt++;
                }
                tmp += max(cnt, R-cnt);
            }
            res = max(res,tmp);
        }
        cout << res << endl;
    }
}


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

typedef long long ll;
typedef unsigned long long ull;

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

  ll ans = 0;
  for (ll i = 1; i <= n; ++i) {
    ostringstream o;
    o << i;
    if (o.str().size() % 2 == 0) continue;
    ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{   int n;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    int l[n],r[n],cnt=0;
    l[0]=0;
    for(int i=0;i<n;i++){
        if(i==0)continue;
        if(s[i]=='E'){
            cnt++;
        }
    }
    r[0]=cnt;
    for(int i=1;i<n;i++){
        if(s[i-1]=='W'){
            l[i]=l[i-1]+1;
        }else{
            l[i]=l[i-1];
        }
        if(s[i]=='E'){
            r[i]=r[i-1]-1;
        }else{
            r[i]=r[i-1];
        }
    }
    int min=1145140;
    for(int i=0;i<n;i++){
        if(r[i]+l[i]<min){
            min=r[i]+l[i];
        }
    }
    printf("%d",min);

    return 0;
}


Measured memory_bytes: 2816
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll ans = 0;
    rep(i,0,n){
        ll a; cin >> a;
        if((a & 1) && (~i & 1))ans++;
    }

    cout << ans << "\n";
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

int main()
{
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    int sm1 = 0;
    int sm2 = 0;
    vi A(n);
    rep(i,0,n){
        cin >> A[i];
        sm2 += A[i];
    }
    int mn = INF;
    rep(i,0,n-1){
        sm1 += A[i];
        sm2 -= A[i];
        mn = min(mn, abs(sm1-sm2));
    }
    cout << mn << endl;
    return 0;
}


Measured memory_bytes: 256
// file creato da gio il 2020-03-31 21:23:51.244903

#include <iostream>
#define FAST 

#ifdef FAST
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

#define S second
#define F first
#define PB push_back
using namespace std;
int arr[2000];
//[2000]
int main(){
	//freopen("output","w",stdout);
	//freopen("input","r",stdin);
#ifdef FAST
	ios::sync_with_stdio(0);
  	cin.tie(0);
#endif

	int N,X,Y;
	cin >> N>>X>>Y;
	X-=1;
	Y-=1;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			int d=j-i;
			arr[min(d,abs(X-i)+abs(Y-j)+1)]++;
		}	
	}
	for(int i=1;i<N;i++){
		cout <<arr[i]<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	int n;
	cin >> n;
	int p[n];
	for(int i = 0; i < n; i++)cin >> p[i];
	sort(p, p + n);
	int total = 0;
	for(int i = 0; i < n - 1; i++)total += p[i];
	total += p[n - 1] / 2;
	cout << total << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char a[10010][30],b[30],c[30];
int main()
{
    int n,i,j,k,m,x,y;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0;i<n;i++)
            scanf("%s",a[i]);
        scanf("%s",b);
        x=n+1;
        y=1;
        for(i=0;i<n;i++)
        {
            k=strlen(a[i]);
            strcpy(c,a[i]);
            for(j=0;j<k;j++)
                if(c[i]=='?')
                    c[i]='a';
                if(strcmp(b,c)>=0)
                {
                    y++;
                }
                strcpy(c,a[i]);
                for(j=0;j<k;j++)
                if(c[j]=='?')
                    c[j]='z';
                if(strcmp(b,c)<=0)
                {
                    x--;
                }
        }
        for(i=x;i<=y;i++)
        {
            if(i!=x)
                printf(" ");
            printf("%d",i);
        }
        printf("\n");
    }
    return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
    return (0);
}


Measured memory_bytes: 256
#include<stdio.h>

int ketanowa(int N){
	
	int sum=0;
	while(N>0){
		
		sum+=N%10;
		N/=10;
	}
	
	return sum;
}

int main(){
	
	int N,A,B,sumA,sumB,i,sum=0,ans=100;
	scanf("%d",&N);
	
	for(i=1;i<N;i++){
		sumA=ketanowa(i);
		sumB=ketanowa(N-i);
		
		sum=sumA+sumB;
		
		if(ans>sum){
			ans=sum;
			
		}
		
	}
	
	printf("\n%d\n\n",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
//#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007ll
#define pb push_back
#define fi first
#define se second
#define mk(a, b) make_pair(a, b)
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int n;
vector<int> a;

signed main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        int b;
        cin >> b;
        a.pb(b);
    }
    sort(a.begin(), a.end());
    int cnt = 1, res = 0;
    for(int i = 1; i < n; i++){
        if(a[i] != a[i - 1]){
            res += ((cnt + 1) % 2);
            cnt = 1;
        }
        else cnt++;
    }
    res += ((cnt + 1) % 2);
    a.erase(unique(a.begin(), a.end()), a.end());
    cout << a.size() - (res % 2) << endl;


    return 0;
}
/*


*/


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


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

    int mi = 404;
    int sum = 0;
    rep(i, N) {
        int s;
        cin >> s;
        sum += s;
        if(s%10) mi = min(mi, s);
    }

    if(sum%10) cout << sum << endl;
    else {
        if(mi==404) cout << 0 << endl;
        else cout << sum-mi << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc152/tasks/abc152_d

s = gets.chomp
N = s.to_i
l = s.size

ans = 0

1.upto(N) do |i|
  add = 0
  t = i.to_s
  next if t[-1] == '0'
  1.upto(l) do |k|
    if k == 1
      add += t[0] == t[-1] ? 1 : 0
    elsif k < l
      add += 10**(k - 2)
    elsif t[-1] < s[0]
      add += 10**(l - 2)
    elsif t[-1] == s[0]
      add += ('0' + s[1..-2]).to_i
      add += 1 if s[-1] >= t[0]
    end
  end
  # puts "i:#{i} add:#{add}"
  ans += add
end

puts ans


Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,c,k;
int now,ans;
int t[100000+10];
int main(){
	scanf("%d%d%d",&n,&c,&k);
	for(int i=1;i<=n;i++)scanf("%d",&t[i]);
	sort(t+1,t+n+1);
	for(int i=1;i<=n;i+=c){
		ans++;
		for(int j=i+1;j<=i+c-1&&j<=n;j++)
			if(t[j]-t[i]>k){
				i=j-c;
				break;
			}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    long long mod = 1e9 + 7;
    string K;
    int D;
    cin >> K >> D;
    long long dp[K.size() + 1][2][D + 1];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    for (int i = 0; i < K.size(); ++i) {
        for (int j = 0; j <= 1; ++j) {
            int lim = j ? 9 : K[i] - '0';
            for (int k = 0; k < D; ++k) {
                for (int l = 0; l <= lim; ++l) {
                    (dp[i + 1][j || l < lim][(k + l) % D] += dp[i][j][k]) %= mod;
                }
            }
        }
    }
    cout << (dp[K.size()][0][0] + dp[K.size()][1][0] - 1 + mod) % mod << endl;

    return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    pii arr[n];
    rep(i,0,n)cin>>arr[i].F>>arr[i].S;

    ll fac=1;
    rep(i,1,n)fac*=i;
    double ans=0;
    rep(i,0,n)
    {
        rep(j,i+1,n)
        {
            double dist=sqrt((arr[i].F-arr[j].F)*(arr[i].F-arr[j].F)+(arr[i].S-arr[j].S)*(arr[i].S-arr[j].S));

            ans+=dist*fac*2;
        }
    }
    cout<<fixed << setprecision(9)<<ans/(fac*n);
    return 0;
}



Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.next()
    val b = sc.next()
    if (a.length == b.length - 1 && b.startsWith(a)) {
        println("Yes")
    } else {
        println("No")
    }
}

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

void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}

int N, A, B, C, D;
string S;

bool check2(int s, int e, int o = -1)
{
    bool f = false;
    for (int i = s; i < e - 1; i++) {
        if (S[i] == '.') {
            f = false;
        } else if (S[i] == '#' || i == o) {
            if (f) {
                return false;
            } else {
                f = true;
            }
        }
    }
    return true;
}

bool check1()
{
    //Bを両サイドが空いているマスまで移動させる
    bool b_ok = false;
    int my_B;
    for (int i = B; i <= D;) {
        if (S[i-2]=='.'&&S[i]=='.') {
            my_B = i;
            b_ok = true;
            break;
        }
        if (S[i] == '.')
            i++;
        else if (S[i+1] == '.')
            i+=2;
        else
            break;
    }
    return b_ok && check2(A,C,my_B) && check2(my_B, D);
}

int main()
{
    cin >> N >> A >> B >> C >> D >> S;

    bool f;

    if (D < C) {
        // A-C が B-Dを内包する場合
        f = check1();
    } else if (A < B && C < D) {
        // A-Cの一部とB-Dの一部が重なる場合
        f = check2(B, D) && check2(A, C);
    } else {
        // A-C, B-Dが重ならない場合        
        f = check2(A,C) && check2(B,D);
    }
    
    Yes(f);
}


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

int H, W;
int white_num = 0;
vector<vector<char>> maze(H, vector<char>(W));
vector<vector<int>> dist(H, vector<int>(W, -1));

void input()
{
    cin >> H >> W;
    maze = vector<vector<char>> (H, vector<char>(W));
    dist = vector<vector<int>> (H, vector<int>(W, -1));
    for (int i=0; i<H; i++)
    {
        string row;
        cin >> row;
        for (int j=0; j<W; j++)
        {
            maze[i][j] = row[j];
            if (row[j]=='.') white_num++;
        }
    }
}

void solve()
{
    auto check = [](int h, int w)
    {
        if (h>=0 && h<H && w>=0 && w<W && maze[h][w]=='.' && dist[h][w]==-1) return true;
        else return false;
    };

    int dh[4] = {1, -1, 0, 0};
    int dw[4] = {0, 0, 1, -1};

    queue<pair<int, int>> que;
    pair<int, int> start={0, 0};
    dist[0][0] = 1;
    que.push(start);

    while(!que.empty())
    {
        pair<int, int> v = que.front();
        que.pop();
        for (int i=0; i<4; i++)
        {
            pair<int, int> next;
            next.first = v.first + dh[i];
            next.second = v.second + dw[i];
            if (check(next.first, next.second))
            {
                que.push(next);
                dist[next.first][next.second] = dist[v.first][v.second]+1;
            }
        }
    }
    int ans;
    if (dist[H-1][W-1]!=-1) ans = white_num - dist[H-1][W-1];
    else ans = -1;
    cout << ans << endl;

    //デバッグ用
    /*
    for (int i=0; i<H; i++)
    {
        for (int j=0; j<W; j++)
        {
            cout << dist[i][j] << " ";
        }
        cout << endl;
    }
    */
}

int main()
{
    input();
    solve();
}

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

// positive only
int get_int() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return -1;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}
int get_str(char *str) {
    int c = getchar_unlocked();
    if(c == -1) return -1;
    while(c > 32) {
        *str++ = (char)c;
        c = getchar_unlocked();
    }
    *str = 0;
    return 0;
}

#define M 49762109
char dic[M][13];

int str_key(char *str){
    int key = 0;
    for(int i = 1; *str; i*=3) {
        key += *str++ * i;
    }
    return key;
}
#define hash_key(k) ((k) % M)
#define hash_alt(k) (1 + ((k) % (M - 1)))
#define hash(k, i) ((hash_key(k) + (i) * hash_alt(k)) % M)
int dic_find(char *str){
    int key = str_key(str);
    size_t len = strlen(str);
    int hash;
    for(int i = 0;; ++i) {
        hash = hash(key, i);
        if(strlen(dic[hash]) == len && strncmp(dic[hash], str, len) == 0) return 1;
        if(strlen(dic[hash]) == 0) return 0;
    }
}
void dic_insert(char *str){
    int key = str_key(str);
    size_t len = strlen(str);
    int hash;
    for(int i = 0;; ++i) {
        hash = hash(key, i);
        if(strlen(dic[hash]) == len && strncmp(dic[hash], str, len) == 0) return;
        if(strlen(dic[hash]) == 0){
            strcpy(dic[hash], str);
            return;
        }
    }
}

int main(int argc, char **argv) {
    int n = get_int();
    char c[13];
    for(int i = 0; i < n; ++i) {
        get_str(c);
        if(*c == 'i') {
            get_str(c);
            dic_insert(c);
        } else {
            get_str(c);
            if(dic_find(c)) puts("yes");
            else puts("no");
        }
    }
    return 0;
}



Measured memory_bytes: 44612
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
 
namespace shoboi_program
{
    class MainClass
    {
        public static void Main(string[] args)
        {
          string[] firstLine = Console.ReadLine().Split();
          string[] secondLine = Console.ReadLine().Split();
          
          var x = int.Parse(firstLine[0]);
          var y = int.Parse(firstLine[1]);
          
          long sum = 0;
          	for(var n = 0; n < y; n++)
            {
              sum +=  int.Parse(secondLine[n]);
            }
          
        
          if(sum == x)
          {
            Console.Write("0");
          }
          else if(sum > x)
          {
Console.Write("-1");
          }
          else
          {
            Console.Write("{0}", x-sum);
          }
          
        }
    }
}

Measured memory_bytes: 28440
n = int(input())
list_w = [input() for i in range(n)]
list_ok = [list_w[0]]

if len(list_w) != len(set(list_w)):
    print("No")

else:
    for i in range(1, n):
        if list_w[i - 1][-1] == list_w[i][0]:
            list_ok.append(list_w[i])
            i += 1
    if len(list_ok) == len(list_w):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3060