akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 using namespace std;
int main(){
  long h,w,k,i,j,ans;
  int **c;
  bool hf[6];
  bool wf[6];
  string s;
  cin >> h >> w >> k;
  c = new int*[h];
  for(i=0;i<h;i++){
    c[i] = new int[w];
    cin >> s;
    for(j=0;j<w;j++) {
      char c1 = s[j];
      if (c1 == '#')
        c[i][j] = 1;
      else
        c[i][j] = 0;
    }
  }
  int ct;
  int h2,w2;
  int i2,j2;
  h2 = pow(2,h);
  w2 = pow(2,w);
  
  ans = 0;
  for(i=0;i<h2;i++){
    if (i & 1) hf[0] = true; else hf[0] = false;
    if (i & 2) hf[1] = true; else hf[1] = false;
    if (i & 4) hf[2] = true; else hf[2] = false;
    if (i & 8) hf[3] = true; else hf[3] = false;
    if (i & 16) hf[4] = true; else hf[4] = false;
    if (i & 32) hf[5] = true; else hf[5] = false;
    for(j=0;j<w2;j++){
      if (j & 1) wf[0] = true; else wf[0] = false;
      if (j & 2) wf[1] = true; else wf[1] = false;
      if (j & 4) wf[2] = true; else wf[2] = false;
      if (j & 8) wf[3] = true; else wf[3] = false;
      if (j & 16) wf[4] = true; else wf[4] = false;
      if (j & 32) wf[5] = true; else wf[5] = false;
      ct = 0;
      for(i2=0;i2<h;i2++)
        for(j2=0;j2<w;j2++)
          if (!hf[i2] && !wf[j2])
            if (c[i2][j2])
              ct++;
      //cout << i << " " << j << " " << hf[1] << endl;
      if (ct == k)
        ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4100
#include <iostream>

using namespace std;

int main() {
    long long n, x, c, d, e, f, i = 0, ans = 0;
    cin >> n >> x;
    long long a[1000000];
    while (cin >> c) {
        a[i] = c;
        i++;
    }
    for (int j = 0; j < n - 1; j++) {
//        cout << a[j]+a[j+1];
        if (a[j] + a[j + 1] > x) {
//            if (a[j + 1] - (a[j] + a[j + 1] - x) < 0) {
//                ans += a[j] + a[j + 1] - x;
//                a[j] =
//                a[j+1]=0;
//
//            } else {
            if (j == 0) {
                if (a[j + 1] - (a[j] + a[j + 1] - x) < 0) {
                ans += a[j] + a[j + 1] - x;
//                a[j] =
//                a[j+1]=0;
                    a[0] = x;
                    a[1] = 0;
//            }
                } else{

                    ans += a[j + 1] - (x - a[j]);
                    a[j + 1] = x - a[j];
                }
            } else {
                ans += a[j + 1] - (x - a[j]);
                a[j + 1] = x - a[j];
            }

        }
    }


    cout << ans << endl;
    return 0;
}
//while (cin >> str) {
///* 何か処理 */
//}
//long long n,t;
//long long a[100005];
//long long uru[100005]={0};
//cin>>n>>t;
//for(int i=0;i<n;i++){
//cin>>a[i];
//}
//#include<stdio.h>
//#include<algorithm>
//using namespace std;
//char in[110000];
//int main(){
//    scanf("%s",in);100
//    int ret=0;
//    for(int i=0;in[i];i++){
//        if(i&&in[i]!=in[i-1])ret++;
//    }
//    printf("%d\n",ret);
//}

//int a,b;scanf("%d%d",&a,&b);
//for(int i=0;i<a;i++)scanf("%d",p+i);
//#include <iostream>
//#define REP(i,n) for (int i=0;i<(n);i++)

//int main() {
//
//    std::cout << "Hello, World!" << std::endl;
//    return 0;
//}

Measured memory_bytes: 1024
N,K = [int(x) for x in input().split()]
h = [0 for x in range(N)]
for i in range(N):
    h[i] = int(input())
h = sorted(h)
dis = []
for i in range(N-K+1):
    dis.append(h[i+K-1]-h[i])
print(min(dis))


Measured memory_bytes: 16760
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <vector>
#include <stack>
#include <map>
#include <queue>
#include <string.h>
#include <algorithm>
#include <iostream>
#define ll long long
#define db double
#define INFINITE 9999999

using namespace std;

string func(string s){
    int l=s.size();
    for(int i=0,j=l-1;i<j;i++,j--){
        swap(s[i],s[j]);
    }
    return s;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    string s;
    getline(cin,s);
    cout<<func(s)<<endl;
    return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <map> 
#include <queue>
#include <stack>
#include <iomanip>
#include <sstream>
#define MP make_pair
#define PB push_back
#define S size()
#define B begin()
#define E end()
#define ll long long
#define REP(i,a,n) for(ll i=a; i<n; ++i)
#define RED(i,n,a) for(ll i=n; i>=a; --i)
#define m9 1000000007
#define endl "\n"
#define F first
#define SE second
#define ld long double



using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
ld area(ld x1, ld y1, ld x2, ld y2, ld x3, ld y3){
    return abs(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2;
}
 


int main(){
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    ll n,k;
    cin>>n>>k;
    vector <ll> v(n);
    REP(i,0,n){
        cin>>v[i];
    }
    vector <ll> dp(k+1,0);
    dp[0]=1;
    REP(i,0,n){
        vector <ll> temp(k+1);
        for(ll used=k; used>=0; used--){
            ll l=used+1;
            ll r=used+min(k-used,v[i])+1;
            if(r<k+1){
                temp[l]+=dp[used];
                temp[l]%=m9;
                temp[r]-=dp[used];
                temp[r]%=m9;
            }
            else{
                if(l<k+1){
                    temp[l]+=dp[used];
                    temp[l]%=m9;
                }
            }
            
            /*for(ll here=1; here<=min(k-used,v[i]); ++here){
                dp[used+here]+=dp[used];
                dp[used+here]%=m9;
            }*/
        }
        REP(i,1,k+1){
            temp[i]+=temp[i-1];
            dp[i]+=temp[i];
            dp[i]%=m9;
        }
    }
    cout<<dp[k];
    
    
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
struct edge { int to, cost; };
int n, a[111111];
int solve(int x) {
	rep(i, n) {
		x -= (x % a[i]);
	}
	return x;
}
int solve2(int x) {
	rep(i, n) {
		x -= (x % a[i]);
	}
	return x;
}

signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	int ok = 100000000000000000, ng = 0;
	while (ok - ng > 1) {
		int mid = (ok + ng) / 2;
		if (solve(mid)>=2)ok = mid;
		else ng = mid;
	}
	if(solve(ok)==2)cout << ok << " ";
	else {
		puts("-1");
		return 0;
	}
	ok = 100000000000000000, ng = 0;
	while (ok - ng > 1) {
		int mid = (ok + ng) / 2;
		if (solve2(mid)>2)ok = mid;
		else ng = mid;
	}
	if (solve(ng) == 2)cout << ng << endl;
	else {
		puts("-1");
		return 0;
	}
	return 0;
}


Measured memory_bytes: 1024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, core.bitop;

enum P = 998244353;

void main()
{
    auto ns = readln.split.to!(long[]);
    auto N = ns[0];
    auto S = ns[1];
    auto as = readln.split.to!(long[]);
    auto DP = new long[][][](N+1, S+1, 2);
    foreach (i; 0..N) {
        if (as[i] < S) {
            DP[i+1][as[i]][0] = i+1;
        } else if (as[i] == S) {
            DP[i+1][S][1] = ((i+1) * (N-i)) % P;
        }
        foreach (s; 0..S) {
            DP[i+1][s][0] = (DP[i+1][s][0] + DP[i][s][0]) % P;
            if (as[i] + s < S) {
                DP[i+1][as[i] + s][0] = (DP[i+1][as[i] + s][0] + DP[i][s][0]) % P;
            } else if (as[i] + s == S) {
                DP[i+1][S][1] = (DP[i+1][S][1] + DP[i][s][0] * (N-i)) % P;
            }
        }
        DP[i+1][S][1] = (DP[i+1][S][1] + DP[i][S][1]) % P;
    }
    writeln(DP[N][S][1]);
}

Measured memory_bytes: 437500
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007;

int main() {
	int N, s = 0;
	cin >> N;
	vector<int> W(N);
	for (int i = 0;i < N;i++) {
		cin >> W[i];
		s += W[i];
	}
	int ans = 512411, cnt = 0;
	for (int i = 0;i < N;i++) {
		cnt += W[i];
		ans = min(abs(2 * cnt - s), ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    n,y = map(int,input().split())
    for i in range(n+1):
        for j in range(n+1):
            if y - 10000*i - 5000 * j >= 0 and n-i-j >= 0 and (y - 10000*i - 5000 * j) // 1000 == n -i-j:
                return [i,j,n-i-j]
    return [-1,-1,-1]

print(" ".join(map(str,main())))

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	
	cout << (K < N ? K * X + (N - K) * Y : N * X);
	return 0;
}

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

int main() {
  int a , b ,c,d;
  cin >> a >> b;
  double x = (a + b) / 2.0;
  c=a%2;
  d=b%2;
  if(c==d){
    cout << x << endl;
  }else{
  cout << x+0.5 << endl;
  }
}

Measured memory_bytes: 256
# union-find

n, m = list(map(int, input().split()))

list = [list(map(int, input().split())) for x in range(m)]

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

for i in list:
  unite(i[0]-1, i[1]-1)

max = 0

for i in range(len(par)):
    if max<size(i):
        max = size(i)
print(max)

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

int main() {

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

    priority_queue<long long> que;

    for (int i = 0; i < n; i++){
        long long ai;
        cin >> ai;
        que.push(ai);
    }

    for (int i = 0; i < m; i++){
        long long t;
        t=que.top();
        que.pop();
        que.push(t/2);
    }

    long long ans=0;
    while(!que.empty()){
        ans+=que.top();
        que.pop();
    }

    cout << ans << endl;
}





Measured memory_bytes: 4288
#include <iostream>
#include <cstring>
using namespace std;
int pd[100010],arr[100010];
int main()
{
    int n;
    while (cin>>n) {
        memset(pd,0,sizeof(pd));
        int x,Max=0;
        for(int i=0;i<n;i++)
        {
            cin>>x;
            pd[x]++;
            pd[x+1]++;
            if(x!=0) pd[x-1]++;
            if(x!=0) Max=max(max(pd[x+1],pd[x-1]),max(Max,pd[x]));
            else Max=max(pd[x+1],max(Max,pd[x]));
        }
        cout<<Max<<endl;
        
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    reverse(bit.begin(), bit.end());
    return bit;
}

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

    ll N;
    cin >> N;
    cout << (N+999)/1000 * 1000 - N << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    fp((s[0]==s[1])&&(s[1]==s[2])||(s[1]==s[2])&&(s[2]==s[3]));
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace AtCoder.ABC._102
{
    class c
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var N = int.Parse(line);
            line = Console.ReadLine().Trim();
            var A = Array.ConvertAll<string, int>(line.Split(' '), new Converter<string, int>(s => int.Parse(s)));
            for(var i = 0; i < N; ++i)
            {
                A[i] -= i + 1;
            }
            Array.Sort(A);
            var b = new int[2];
            var flg = false;
            if (N % 2 == 0)
            {
                b[0] = A[N / 2 - 1];
                b[1] = A[N / 2];
                flg = true;
            }
            else
            {
                b[0] = A[N / 2];
            }
            var sum = 0L;
            for(var i = 0; i < N; ++i)
            {
                sum += Math.Abs(A[i] - b[0]);
            }
            if(flg && b[0] != b[1])
            {
                var sum2 = 0L;
                for (var i = 0; i < N; ++i)
                {
                    sum2 += Math.Abs(A[i] - b[0]);
                }
                if (sum2 < sum) sum = sum2;
            }
            Console.WriteLine(sum);
        }
    }
}


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

#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

double distance(int x1, int y1, int x2, int y2) {
    return sqrt((x1  - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
int factorial(int n) {
    if (n == 0) {
        return 1;
    }
    return n * factorial(n-1);
}

int main() {
    int n;
    cin >> n;
    int x[n];
    int y[n];
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
        cin >> y[i];
        v.push_back(i);
    }
    double sum = 0;
    cout << setprecision(10);
    do {
        for (int i = 0; i < n - 1; ++i) {
            sum += distance(x[v[i]], y[v[i]], x[v[i+1]], y[v[i+1]]);
        }
    } while (next_permutation(v.begin(), v.end()));
    cout << sum / factorial(n);
}


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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;

string res;
ll sum = 0;

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    println(max(a * b, c * d));
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

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

int main() {
    int h, w; cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    rep(i, h)rep(j, w) cin >> s[i][j];

    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '.') continue;
            bool can = false;
            rep(k, 4) {
                int x = i+dx[k];
                int y = j+dy[k];
                if (0<=x && x<=h-1 && 0<=y && y<=w-1) {
                    if (s[x][y] == '#') {
                        can = true;
                        break;
                    }
                }
            }
            if (can) continue;
            else {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	O := nextLine()
	E := nextLine()
	ans := make([]rune, len(O)+len(E))
	for i := 0; i < len(O)+len(E); i++ {
		switch i % 2 {
		case 0:
			ans[i] = rune(O[i/2])
		case 1:
			ans[i] = rune(E[i/2])
		}
	}
	fmt.Println(string(ans))
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}


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

const int N = 10;
vector< int> conn[N];
bool seen[N];
int n, m, res;

void dfs(int u, int k) {
    if(k == n) {
        res++;
        return;
    }

    for(int v: conn[u]) {
        if(seen[v]) continue;
        seen[v] = true;
        dfs(v, k + 1);
        seen[v] = false;
    }
}


int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        conn[a].emplace_back(b);
        conn[b].emplace_back(a);
    }

    seen[1] = true;
    dfs(1, 1);
    cout << res << endl;
}

Measured memory_bytes: 256
N = int(input())
hs = list(map(int, input().split(' ')))
 
now = 0
 
result = 0
count = 0

for i in range(N):
  if hs[i] <= now:
    count += 1
  else:
    result = max(result, count)
    count = 0
  now = hs[i]
result = max(result, count)
 
print(result)

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

int main() {
    int n, q, S[10010], T[510], C = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> S[i];
    cin >> q;
    for (int i = 0; i < q; ++i) cin >> T[i];

    for (int i = 0; i < q; ++i) {
        for (int j = 0; j < n; ++j) {
            if (T[i] == S[j]) {
                ++C;
                break;
            }
        }
    }

    cout << C << endl;
    
    return 0;
}


Measured memory_bytes: 3128
/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;

void solve(){
	int i,j;
	int n,sum=0;
	cin >> n;
	vector<long double > v(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i];
	}

	vector<vector<long double>> dp(n+1,vector<long double>(n+1,0));

	dp[0][0]=(long double)1;

	for (int i = 1; i < n+1; ++i)
	{
		for (int j = 0; j < n+1; ++j)
		{
			if(j){
				dp[i][j]=dp[i-1][j-1]*v[i-1];
			}
			dp[i][j]+=dp[i-1][j]*(1-v[i-1]);
		}
	}
	long double ans=0;
	for (int i = 0; i < n+1; ++i)
	{
		if(i>n-i)ans+=dp[n][i];
	}

	printf("%.10Lf\n",ans);


	
}


int main(){
	int T=1;
	// cin >> T;
	while (T--){
		solve();
	}
}


Measured memory_bytes: 144204
#include <stdio.h>
int main(void)
{
	int N, Max = 0, sum = 0, p = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &p);
		sum += p;
		Max = Max > p ? Max : p;
	}
	printf("%d", sum - Max / 2);
}
	

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


int main() {
  string s, t = "";
  cin >> s;
  int i = 0, sz = s.size();
  while(i < sz-1) {
    if(s[i]=='B'&&s[i+1]=='C') {
      t += 'D';
      i++;
    }
    else t += s[i];
    i++;
  }
  ll ans = 0, num = 0;
  int tz = t.size();
  for(int i = 0; i < tz; i++) {
    if(t[i]=='A') num++;
    else if(t[i]=='D') ans += num;
    else num = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3924
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll a,b,c,d,e,ans=INF;
ll x[500005],y[500005],z[100005];
ll dp[100][100];
char s[100005];

int main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x[i];
		x[i] -=i;
	}
	sort(x,x+n);
	for(i=n/2-3;i<=n/2+3;i++){
		sum=0;
		for(j=0;j<n;j++){
			sum += abs(x[j]-x[i]);
		}
		ans = min(ans,sum);
	}
	p(ans);
	
	
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
void YES(bool anser){
    if(anser)printf("YES\n");
    else printf("NO\n");
}
void Yes(bool anser){
    if(anser)printf("Yes\n");
    else printf("No\n");
}
void yes(bool anser){
    if(anser)printf("yes\n");
    else printf("no\n");
}
ll n,t,ans=INF;
int main(void){
    cin>>n>>t;
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        if(b<=t)ans=min(ans,a);
    }
    if(ans==INF)cout<<"TLE\n";
    else cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define cont continue  
#define MOD 998244353
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll INF = 1e17;
const double pi = 3.141592653589793;

int T;

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

  int A, B;
  cin >> A >> B;
  cout << A * B << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int A,B; cin >> A >> B;
    int ans = max(A-2*B,0);
    cout << ans << endl;

}

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[] L = new int[N * 2];
		for (int i = 0; i < L.length; i++) {
			L[i] = in.nextInt();
		}
		Arrays.sort(L);
		int ans = 0;
		for (int i = 0; i < L.length; i += 2) {
			ans += L[i];
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  ll x; cin >> x;

  ll tmp = (x/500) * 1000;
  x -= (x/500) * 500;
  tmp += (x / 5)* 5;

  cout << tmp << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        if (N % 1000 == 0) {
            System.out.println(0);
        } else {
            System.out.println(1000 - N % 1000);
        }
        sc.close();
    }
}

Measured memory_bytes: 35860
r, c= map(int, input().split())
list = [list(map(int,input().split())) for i in range(r)]
for i in range(r):
    list[i].append(sum(list[i]))
for i in range(r):
    for j in range(c):
        print(list[i][j], end = ' ')
    print(list[i][c])
for i in range(c):
    a = 0
    for j in range(r):
        a += list[j][i]
    print(a, end = ' ')
a = 0
for j in range(r):
    a += list[j][c]
print(a)



Measured memory_bytes: 6228
n = int(input())
a = n//1.08

if int((a-1)*1.08) == n:
  print(int(a-1))
elif int(a*1.08) == n:
  print(int(a))
elif int((a+1)*1.08) == n:
  print(int(a+1))
else:
  print(':(')

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int main(){
	ll n;
	cin>>n;
	if(n>=30)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl; 
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define MAX 5000005
#define ll long long 
using namespace std;
inline int read() {
                                 int x=0, tmp=1;
                               char ch=getchar();
                            //233333333333333333333333
                          while( (ch<'0') || (ch>'9') ){
                         if(ch=='-')tmp=-1; ch=getchar();}
                          while( (ch>='0')&&(ch<='9') ){
                            x=x*10+ch-'0';ch=getchar();
                               }//233333333333333
                                 return (x*tmp);

}
int main(){
    int n=read(),k=read();
    int ans=0;
    if(k%2){
        cout<<(ll)(n/k)*(n/k)*(n/k)<<endl;
    }
    else{
        cout<<(ll)(2*n/k/2)*(2*n/k/2)*(2*n/k/2)+(ll)(2*n/k-2*n/k/2)*(2*n/k-2*n/k/2)*(2*n/k-2*n/k/2)<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=2005;
int n,m,K,k,hd[maxn],ans,tt;
struct edd{
	int nt,v;
}e[maxn*maxn*2];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

inline void add(int a,int b){
	e[k].v=b; e[k].nt=hd[a]; hd[a]=k++;
}

void dfs(int x,int fa,int d){
	if(d <= K/2) tt++;
	view(i,x){
		int v=e[i].v; if(v == fa) continue;
		dfs(v,x,d+1);
	}
}

int main(){
	memset(hd,-1,sizeof(hd)); k=0;
	n=rd(); K=rd(); int a,b;
	go(i,n,1){
		a=rd(); b=rd();
		add(a,b); add(b,a);
	}
	int ans=0;
	if(K%2 == 0){
		go(i,n+1,1){
			dfs(i,0,0);
			ans=max(ans,tt); tt=0;
		}
	}else{
		for(rg int i=0;i<k;i+=2){
			int u=e[i].v,v=e[i^1].v;
			dfs(u,v,0); dfs(v,u,0);
			ans=max(ans,tt); tt=0;
		}
	}
	printf("%d",n-ans);
	return 0;
}//Faze


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp(a, b) make_pair(a, b)

const long long MOD = 1000000007;


int main(){
    std::cout<<std::fixed<<std::setprecision(10);
    ll n;
    cin >> n;
    ll v[n];
    rep(i, n){
        cin >> v[i];
    }
    sort(v, v+n);
    double o = (double)v[0];

    for(ll i = 1; i < n; i++){
        o = (o+v[i])/2.0;
    }

    cout << o << endl;
    
    return 0;
}


Measured memory_bytes: 256
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def reads():
  return [int(x) for x in input().split()]

(N, K) = reads()

L = K

board = [[0] * K for _ in range(K)]

NW = 0
for _ in range(N):
    (x, y, c) = input().split()
    (x, y) = (int(x), int(y))
    c = (x // K + y // K + int(c == "W")) & 1 # W -> 1, B -> 0
    (x, y) = (x % K, y % K)
    NW += c
    board[y][x] += 1 if c == 1 else -1 # W - B
NB = N - NW

psumr = [[0] * (K+1) for _ in range(K)]

for i in range(K):
    for j in range(K):
        psumr[i][j+1] = psumr[i][j] + board[i][j]

psum = [[0] * (K+1) for _ in range(K+1)]

for i in range(K):
    for j in range(K):
        psum[i+1][j+1] = psum[i][j+1] + psumr[i][j+1]

result = 0
for i in range(K+1):
    for j in range(K+1):
        summ = psum[i][K] + psum[K][j] - 2 * psum[i][j]
        result = max(result, NB + summ, NW - summ)
print(result)

Measured memory_bytes: 60460
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }

    
int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  
  int n;
  int ans = 0;
  cin>>n;
  int cur = 1;
  RE (i, n) {
    int a;
    cin>>a;
    if (a > cur) {
      ans += (a - 1) / cur;
    } else {
      maxi(cur, a + 1);
    }
    maxi(cur, 2ll);
  }
  cout<<ans<<endl;
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;
}


Measured memory_bytes: 384
//Utkarsh-raj

#include<bits/stdc++.h>

#define ll long long int
#define vc vector
#define mod 100000000007
#define mp make_pair
#define pb push_back
#define nl cout<<endl;
#define ff first
#define ss second

using namespace std;

double prob[3001];
double dp[3001][3001];

double f(int n, int nh){
	// base case
	if(nh == 0)
		return 1.0;
	if(n == 0)
		return 0;

	if(dp[n][nh] != -1.0){
		return dp[n][nh];
	}

	// rec case
	double p1 = prob[n]*f(n-1, nh-1);
	double p2 = (1 - prob[n])*f(n-1, nh);
	return dp[n][nh] = (p1 + p2);
}

int main()
{
	ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    for(int i=0; i<=3000; i++){
    	for(int j=0; j<=3000; j++){
    		dp[i][j] = -1;
    	}
    }

    int n;
    cin>>n;
    for(int i=1; i<=n; i++){
    	cin>>prob[i];
    }

    int nh = (n/2 + 1);

    cout<<setprecision(10)<<f(n, nh)<<endl;

	return 0;
}


Measured memory_bytes: 70784
#![allow(unused_imports)]
#![allow(non_snake_case)]
 
use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
 
/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}
 
/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}
 
/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
 
    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

use std::ascii::AsciiExt;
 
fn main() {
    let (r, D, x) = read!(usize, usize, usize);
    let mut temp = x;
    for i in 0..10{
        temp = r * temp - D;
        println!("{}", temp);
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#define PI 3.14159265359
using namespace std;

int main() {
    double r, s, c;
    cin >> r;
    s = PI * r * r;
    c = 2 * PI * r;
    
    cout << fixed << setprecision(5) << s << ' ' << c << endl;
    return 0;
}


Measured memory_bytes: 3268
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        
        int s = scanner.nextInt();
        int sec, min, hour;
        
        hour = s/3600;
        s = s - hour*3600;
        min = s/60;
        s = s - min*60;
        sec = s;

        System.out.println(hour+":"+min+":"+sec);

        scanner.close();
    }
}



Measured memory_bytes: 26208
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

N, X =map(int, input().split())
x = list(map(int, input().split()))

x.append(X)
x=sorted(x)

diff=[]
ans=0

for i in range(N):
    temp=x[i+1]-x[i]
    diff.append(temp)
    
diff=sorted(diff)


if N > 1:
    ans=gcd(diff[0],diff[1])
    for i in range(1,N):
        ans=gcd(ans,diff[i])
    print(ans)
else:
    print(diff[0])

Measured memory_bytes: 14228
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500 * i + 100 * j + 50 * k == X:
                ans += 1
print(ans)

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

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

    vector<int> p={2};
    bool not_prime=false;
    int i=2;

    while(i<=x || (not_prime==true && i>x)){
        not_prime=false;
        for(int j=0; j<p.size(); j++){
            if(i%p[j]==0){
                not_prime=true;
                break;
            }
        }
        if(not_prime==false){
            p.push_back(i);
        }
        i++;
    }

    cout<<(x==2 ? 2 : p[p.size()-1])<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N,M,K;
    cin >> N >> M >> K;
    vector <ll> A(N+1), B(M+1), prefsumB(M+1,0);
    ll ans;
    loop(i,1,N+1) cin >> A[i];
    loop(i,1,M+1) {cin >> B[i]; prefsumB[i]=prefsumB[i-1]+B[i];}
    int index=lower_bound(prefsumB.begin(), prefsumB.end(), K)-prefsumB.begin();
    if (index==M+1) ans=M;
    else if (prefsumB[index]==K) ans=index;
    else ans=index-1;
    ll sum=0;
    for (int i=1; i<=N; ++i)
    {
        sum+=A[i];
        if (sum>K) break;
        int index=lower_bound(prefsumB.begin(), prefsumB.end(), K-sum)-prefsumB.begin();
        if (index==M+1) ans=max(ans, i+M);
        else if (prefsumB[index]==K-sum) ans=max(ans, (ll)i+index);
        else ans=max(ans,(ll)i+index-1);
    } 
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 7936
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <cmath>
#include <cstdio>
#include <iomanip>
 using namespace std;
 int factorial(int n){
   int l = 1;
   for(int i = 2; i <= n; i++){
     l *= i;
   }
   return l;
 }
int main()
{
  int n = 0;
  cin >> n;
  int x[n];
  int y[n];
  double counter = 0.0;
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i];
  }
  string example = "";
    for(int i = 1; i <= n; i++){
      example += (to_string(i));
    }
    sort(example.begin(), example.end());
    do {
        //cout << example << '\n';
        for(int i = 0; i < n - 1; i++){
          int f = example[i] - '0';
          int s = example[i+1] - '0';
          f--;
          s--;
          counter += sqrt((x[f]-x[s]) * (x[f]-x[s]) + (y[f]-y[s]) * (y[f]-y[s]));
        }
    } while (next_permutation(example.begin(), example.end())); 

    counter /= factorial(n);

    cout << std::setprecision(20) << counter << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<vector>
#include<deque>
#include<map>
using namespace std;

int main() {
	int n, a, b;
	long long answer = 0;
	int arr[100001];
	scanf("%d %d %d", &n, &a, &b);
	for (int i = 0; i < n; i++)scanf("%d", &arr[i]);
	for (int i = 1; i < n; i++) {
		answer += min((long long)(arr[i] - arr[i - 1]) * a, (long long)b);
	}
	printf("%lld", answer);
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
#define MOD int(1e9 + 7)

int main()
{
    long long X, Y, Z;
    cin >> X >> Y >> Z;

    cout << Z;
    cout << ' ';
    cout << X;
    cout << ' ';
    cout << Y;

}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	
	public static void main(String[] args) throws Exception{	
		Scanner sc = new Scanner(System.in);

		int sum=0;
		int max=0;
		int t;
		for(int i=0; i<3; i++){
			t = sc.nextInt();
			sum += t;
			if(max < t) max = t;
		}
		
		
		if(sum == max*2) System.out.println("Yes");
		else System.out.println("No");
		
		sc.close();
	}
}

Measured memory_bytes: 9684
//Solution By SlavicG
#include "bits/stdc++.h"
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int  main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int turns1 = (c + b - 1) / b, turns2 = (a + d-1) / d;
	if(turns1 <= turns2)
	{
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
}

Measured memory_bytes: 3548
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
	static int N =0;

	static string[] line = new string[10]{"a", "b", "c", "d", "e", "f", "g",
"h", "i", "j"};

	static void DFS(string str, int max){
		//文字数Nに達した場合
		if(str.Length == N){
				Console.WriteLine(str);
		}
		//まだ達していない場合
		else{
				//iに応じて、次の層でのmaxの値が異なる
				//（i=maxの場合のみ、次の層でのmaxが+1される）
				for(int i=0; i<=max; i++){
						DFS(str+line[i], ((i == max) ? max+1 : max));
				}
		}


	}

	static void Main(string[] args)
	{
		//読み込む
		N =int.Parse(Console.ReadLine());

		//DFS（深さ優先探索）を実践
		DFS("", 0);

	}
}


Measured memory_bytes: 14408
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = join (solve <$> readInts)

solve :: [Int] -> IO ()
solve input = putStrLn $ if sort input == [5, 5, 7] then "YES" else "NO"

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;

int main(){
    int N,X; cin >> N >> X;
    vector<int> n(N+2);
    vector<int> L(N+2);
    int ct = 1;
    rep(i,N){
        cin >> L[i];
    }
    n[0] = 0;
    n[1] = 0;
    rep(j,N){
        n[j+2] = n[j+1] + L[j];
        if(n[j+2] <= X){
            ct++;
            continue;
        }
        else{
            break;
        }
    }
    cout << ct << endl;

}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace Program
{
    class Ex1
    {
      public static void Main()
      {
        var str = Console.ReadLine();
        var values = str.Split(' ').Select(e => int.Parse(e)).ToArray();
        var a = values[0];
        var p = values[1];
        
        Console.WriteLine((a * 3 + p) / 2);
      }
    }
}

Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [0] + [int(x) for x in input().split()] + [0]
    sm = 0
    for i in range(n+1):
        sm += abs(a[i] - a[i+1])

    for i in range(n):
        x = abs(a[i] - a[i+2]) - (abs(a[i] - a[i+1]) + abs(a[i+2]-a[i+1]))
        print(sm + x)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""


Measured memory_bytes: 20904
from collections import deque

n, q = map(int, input().split())
edge = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    edge[a].append(b)
    edge[b].append(a)

imos = [0 for _ in range(n)]
for i in range(q):
    p, x = map(int, input().split())
    p -= 1
    imos[p] += x

dq = deque([(0, -1)])
while dq:
    v, p = dq.popleft()
    for u in edge[v]:
        if u == p:
            continue
        imos[u] += imos[v]
        dq.append((u, v))

print(' '.join([str(x) for x in imos]))


Measured memory_bytes: 124108
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int turi = 10000 - sc.nextInt();
        int kt1=0;
        int kt2=0;
        int kt3=0;


        if(turi!=0) {
             kt1 = turi % 10; //1桁目
            turi = turi / 10;
        }
        if(turi!=0) {
             kt2 = turi % 10; //2桁目
            turi = turi / 10;
        }
        if(turi!=0) {
             kt3 = turi % 10; //3桁目
        }

        int ans = kt3*100+kt2*10+kt1;

        System.out.println(ans);
    }
}



Measured memory_bytes: 35632