akhauriyash/Code-Regression huggingface dataset:
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func calcPrime(N int) []int {
	prime := make([]int, N)
	for i := 0; i < N; i++ {
		prime[i] = i
	}
	for i := 2; i*i < N; i++ {
		if prime[i] == -1 {
			continue
		}
		for j := i * 2; j < N; j += i {
			prime[j] = -1
		}
	}
	return prime
}

func main() {
	sc.Split(bufio.ScanWords)
	X := getInt()

	p := calcPrime(1000000)

	for i := X; ; i++ {
		if p[i] != -1 {
			out(p[i])
			break
		}
	}
}


Measured memory_bytes: 8704
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef pair<pii,pii> piiii;
typedef vector<pii> vii;
typedef vector<ll> vi;
typedef queue<ll> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,ll> mpci;
typedef map<ll,ll> mpii;
typedef map<string,ll> mpsi;
typedef set<ll> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define m_p make_pair
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<=n;i++)
#define ford(i,p,n) for(int i=n-1;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))

/*=====================================================================*/

inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
/*======================================================================*/
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
/*======================================================================*/
int main()
{
  /*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  string n;
  cin>>n;
  if(n=="SUN")
    cout<<7<<endl;
  if(n=="MON")
    cout<<6<<endl;
  if(n=="TUE")
    cout<<5<<endl;
  if(n=="WED")
    cout<<4<<endl;
  if(n=="THU")
    cout<<3<<endl;
  if(n=="FRI")
    cout<<2<<endl;
  if(n=="SAT")
    cout<<1<<endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

k = int(input())

list = [a,b,c,d,e]

for i in range(len(list)):
    for j in range(i,len(list)):
        if list[j] - list[i] > k :
            print(':(')
            exit()

print('Yay!')


Measured memory_bytes: 3064
#include<cstdio>
using namespace std;
int n;
long long max1=0ll,min1=1000000001,t;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&t);
		if (max1<t) max1=t;
		if (min1>t) min1=t;
	}
	printf("%lld",max1-min1);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b + 1) / 2 << endl;
}

Measured memory_bytes: 256
s = input()

n = 4

mae = int(s[:2])
ato = int(s[2:])

if mae < 13 and mae > 0:
    if ato < 13 and ato > 0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if ato < 13 and ato > 0:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
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; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }







// https://juppy.hatenablog.com/entry/2019/02/17/ARC72_-D_Alice%26Brown-_Python_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0_Atcoder

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    
    ll x, y;
    cin >> x >> y;
    
    
    if (abs(x - y) > 1) cout << "Alice" << endl;
    else cout << "Brown" << endl;
}


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

#define ff first
#define ss second
// #define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}
signed main(void)
{
	IOS;
	string s,t;
	cin>>t>>s;
	cout<<s+t<<endl;
	
	time();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool matches(const string& ss, const string& t, int p) {
    const int tlen = t.size();
//    cerr << "on p=" << p << endl;
    for(int i=0; i<tlen; i++) {
        if(ss[p+i]!='?' && ss[p+i]!= t[i]) {
//            cerr << "  not match at ss[" << p+i << "]!=t[" << i << "]" << endl;
            return false;
        }
    }
    return true;
}

string create(const string& ss, const string& t, int p) {
    string res(ss);
    const int sslen = ss.size();
    const int tlen = t.size();
    for(int i=0; i<tlen; i++) res[p+i] = t[i];
    for(int i=0; i<sslen; i++) if(res[i]=='?') res[i] = 'a';
    return res;
}

int main() {
    string ss, t;
    cin >> ss >> t;
    int sslen = ss.size();
    int tlen = t.size();
    int shiftwidth = sslen - tlen;
    bool matched = false;
    string s;
    for(int p=0; p<=shiftwidth; p++) {
        if(matches(ss, t, p)) {
            string r = create(ss, t, p);
            if(!matched) {
                matched = true;
                s = r;
            } else if(r < s){
                s = r;
            }
        }
    }
    cout << (matched ? s : "UNRESTORABLE") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;int a, b,c;a = 0; b = 0;c = 1;
    vector<int> p(n), q(n),v(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i]; v[i] = i + 1;
    }
    for (int i = 0;i < n;i++)cin >> q[i];
    do {
        if (v == q) a = c;
        if (v == p) b = c;
        c++;
    } while (next_permutation(v.begin(),v.end()));
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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 () {
  int n;
  cin >> n;
  bool k4 = false;
  rep(i,n) {
    char s;
    cin >> s;
    if (s == 'Y') k4 = true;
  }
  if (k4) puts("Four");
  else puts("Three");
  return 0;
}

Measured memory_bytes: 256
h,w,a,b = map(int,input().split())
ans = [[] for _ in [0]*h]
for i in range(b):
  ans[i] = "0"*a + "1"*(w-a)
for i in range(b,h):
  ans[i] = "1"*a + "0"*(w-a)

for i in ans:
  print(i)

  


Measured memory_bytes: 5108
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

int main()
{
	char a[10];
	rep(i, 10) {
		cin >> a[i];
	}
	rep(i, 10) {
		cout << ((i == 3) ? '8' : a[i]);
	}
	cout << endl;
}



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

int main(){
    int n, x;
    int cnt = 0;
    cin >> n >> x;
    while(n!=0 | x!=0){
        for(int i = 1; i <= n; i++){
            for(int j = i+1; j <= n; j++){
                for(int k = j+1; k <= n; k++){
                    if(i+j+k == x){
                        cnt++;
                    }
                }
            }
        }
        cout << cnt << endl;
        int n_n, x_x;
        cin >> n_n >> x_x;
        n = n_n;
        x = x_x;
        cnt = 0;
    }
}


Measured memory_bytes: 3072
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

string s;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  cin >> s;
  if((int)s.size() == 2){
    if(s[0]!=s[1]){
      cout << "-1 -1" << endl;
    }else{
      cout << "1 2" << endl;
    }
    return 0;
  }
  for(int l=0, r=2;r < (int)s.size();l++, r++){
    if(s[l] == s[l+1] || s[l] == s[r] || s[l+1] == s[r]){
      cout << l+1 << " " << r+1 << endl;
      return 0;
    }
  }
  cout << "-1 -1" << endl;
	return 0;
}



Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x) {
    S[++top] = x;
}

int pop() {
    top--;
    return S[top + 1];
}

int main(){
    int a, b;
    top = 0;
    char s[100];
    
    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        } else if (s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }
    }
    
    printf("%d\n", pop());
    return 0;

}



Measured memory_bytes: 2064
def InS(): return input()


def InL(): return list(map(int, input().split()))


def InI(): return int(input())


S = input()

S_list = list(S)


if S_list[0] == S_list[1]:
    if S_list[1] == S_list[2]:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")

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

int main(void)
{
	int A,B,K;
	scanf("%d%d%d", &A, &B, &K);
	for (int i = 0; i < K; i++)
	{
		if (i % 2 == 0)
		{
			if (A % 2 == 1)
			{
				A = (A - 1) / 2;
				B = B + A;
			}
			else
			{
				A = A / 2;
				B = B + A;
			}
		}
		else
		{
			if (B % 2 == 1)
			{
				B = (B - 1) / 2;
				A = A + B;
			}
			else
			{
				B = B / 2;
				A = A + B;
			}
		}
	}
	printf("%d %d", A, B);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
   /* ll t;
    cin>>t;
    while(t--)
    {
       
    }*/
    ll n,w;
    cin>>n>>w;
    ll wt[n],v[n];
    for(ll i=0;i<n;i++)
    cin>>wt[i]>>v[i];
    ll dp[n][w+1];
    memset(dp,0,sizeof(dp));
    for(ll i=1;i<=w;i++)
    {
        if(wt[0]<=i)
        dp[0][i]=v[0];
    }
    for(ll i=1;i<n;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            if(j<wt[i])
            dp[i][j]=dp[i-1][j];
            else
            {
                dp[i][j]=max(v[i]+dp[i-1][j-wt[i]],dp[i-1][j]);
            }
        }
    }
    cout<<dp[n-1][w]<<endl;
}


Measured memory_bytes: 78336
import math
import heapq
from itertools import product, permutations,combinations

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

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(N):
	A[i] = -A[i]

heapq.heapify(A)


for i in range(M):
	x = heapq.heappop(A)
	x /= 2
	x = heapq.heappush(A, x)

total = 0
for i in range(N):
	total -= math.ceil(A[i])

print(total)

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

#define mod 1000000007

int main()
{
    
    int n,m;
    cin>>n>>m;
        
    char g[n][m];


    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>g[i][j];
        }
    }
    int dp[n][m];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            dp[i][j]=0;
        }
    }

    dp[0][0]=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(g[i][j]=='.')
            {
                if(i>=1)
                    dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
                if(j>=1)
                    dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
            }
        }   
    }
    // for(int i=0;i<n;i++)
    // {
    //     for(int j=0;j<m;j++)
    //     {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    cout<<dp[n-1][m-1]<<endl;


    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

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

    ll ans = 0;
    /*if(a[0] > x) {
         ans += a[0] - x;
         a[0] = x;
    }
    if(a[n-1] > x) {
        ans += a[n-1] - x;
        a[n-1] = x;
    }*/
    rep(i, n-1) {
        if(a[i] + a[i+1] > x) {
            ans += a[i+1] + a[i] - x;
            if(a[i] > x) {
                a[i] = x;
                a[i+1] = 0;
            }
            else {
                a[i+1] = x - a[i];
            }
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 1024
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 

long long dp[51][51][3000]={};

int main(){

	int a,b,c;
	cin>>a>>b>>c;

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

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "No" << endl;return 0
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N,K,A[114514];
    int S=0;
    cin >> N >> K;
    REP(i,N){
        cin >> A[i];
        S+=A[i];
    }
    vector<int> Y;
    for(int i=1;i*i<=S;i++){
        if(S%i==0){
            Y.push_back(i);
            if(i*i!=N){
                Y.push_back(S/i);
            }
        }
    }
    sort(Y.begin(),Y.end(),greater<>());
    
    REP(j,Y.size()){
        int Ans=0;
        int y=Y[j];
        int E=0,t;
        priority_queue<int> P;
        REP(i,N){
            E+=y*(A[i]/y);
            P.push(A[i]%y);
        }
        int f=(S-E)/y;
        REP(i,f){
            t=P.top();
            P.pop();
            t-=y;
            P.push(t);
        }
        while(!P.empty()){
            t=P.top();
            P.pop();
            if(t>0)Ans+=t;
        }
        if(Ans<=K){
            cout << y << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<cstring>

using namespace std;

set<int> SubData;
set<int>::iterator it,tmp;
int CntData[10000];

void solve(int n, int limit) {
	int result;

    //cout<<"result_before: "<<*it<<"-"<<*tmp<<"="<<result<<endl;
	result = *it - *tmp;
	while (result<0 || result>limit) {
		if (result < 0) {
			result += n;
		}
		else if (result > limit) {
			result = n - result;
		}
	}
	//cout<<"result_after:"<<result<<endl;
	CntData[result]++;
}

int main() {
	int n, limit;

	while (cin >> n, n) {
		SubData.clear();
		memset(CntData, 0, sizeof(CntData));
		limit = (n - 1) / 2;
		for (int i = 1; i < n; i++) {
			SubData.insert((i*i) % n);
		}
		for (it = SubData.begin(); it != SubData.end(); it++) {
			for (tmp = SubData.begin(); tmp != SubData.end(); tmp++) {
				if (*tmp == *it) {
					continue;
				}
				solve(n, limit);
			}
		}
		limit++;
		for (int i = 1; i < limit; i++) {
			if (CntData[i] != 0) {
				cout << CntData[i] << endl;
			}
		}

	}

	return 0;
}




Measured memory_bytes: 3288
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

int e[10010], m[10010];

int solve2(int E){
  int minimum = 1000000;
  for(int z = 0; z <= 100; ++z) //zとyからxを算出
    for(int y = 0; y <= 1000; ++y){
      int x = E - y*y - z*z*z;
      if(x >= 0)
        minimum = min(minimum, x + y + z);
    }
  return minimum;
}

int solve(int E)
{
  int minimum = 1000000;
  if (E == 1)
  {
    minimum = 1;
  }
  else
  {
    for (int x = 0; x <= E; ++x)
    {
      for (int y = 0; y <= E; ++y)
      {

        //y = y_solver(x, z, E);
        //int z = z_solver(x, y, E);
        if (int z = (int)round(pow(E - x - y * y, 1.0 / 3)))
        {
          if (int y1 = (int)round(pow(E - x - pow(z, 3), 1.0 / 2)))
          {
            //int x1 = (int)round(E - pow(z, 3) - y1 * y1);
            if (x + y1 * y1 + pow(z, 3) == E)
            {

              if (x + y1 + z < minimum)
              {
                minimum = x + y1 + z;
              }
            }
          }
        }
      }
      //for (int z = 0; z <= E; ++z)
      //{
      //int y = (int)round(pow(E - x - pow(z, 3), 1.0 / 2));
      //}

      //if (x + y * y + pow(z1, 3) == E)
      //{

      //}
    }
  }
  return minimum;
}

int main()
{
  int E;
  while(cin >> E && E > 0){
    cout << solve2(E) << endl;
  }
  //for (int i = 0; i < 1000000; ++i)
  //{
    //cin >> e[i];
    //if (e[i] != 0)
    //{
    //  cout << solve(e[i]) << endl;
    //}
    //else
    //{
    //  break;
    //}
  //}
}


Measured memory_bytes: 3092
#include <stdio.h>

int main(void){
    int n;
    long long ans=0;
    scanf("%d",&n);
    long long a[n],b[n];
    for (int i=0; i<n; i++){
        scanf("%lld%lld",&a[i],&b[i]);
    }
    for (int i=n-1; i>=0; i--){
        a[i]+=ans;
        if (a[i]%b[i]!=0){
            ans+=b[i]-(a[i]%b[i]);
        }
    }
    printf("%lld\n",ans);
	return 0 ;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>

    #define ll long long
    #define pb push_back
    #define mp make_pair
    #define f first
    #define s second
    #define sz(x) (int)x.size()
    #define all(x) x.begin(), x.end()

    using namespace std;
    using namespace __gnu_pbds;

    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
    template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
    template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
    template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
    template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
    template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
    template<class T1,class T2> ostream& operator<<(ostream& os, const gp_hash_table<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}

    int dp[100050];

    vector<int> a;
    int n, k;

    int nadji(int k)
    {
        //cout << "AAA " << k << endl;
        if(k < 0)
            return 1;
        if(dp[k]!=-1)
            return dp[k];




       //cout << "proveravam za k " << k << endl;


        for(int i =0; i<n; i++)
        {
             //cout << "proveravam za k-a " << k-a[i] << endl;

            if(nadji(k-a[i])==0)
            {
                //cout << "naso za " << k << endl;
                dp[k]=1;
                return 1;
            }
        }

        dp[k] = 0;
        return 0;


    }

    int main()
    {




        cin >> n>>k;
        int m=100050;
        for(int i=0; i <n; i++)
        {
            int pom;
            cin >> pom;
            a.push_back(pom);
            m=min(m, pom);
        }

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

        for(int i=0; i <m; i++)
        {
            dp[i]=0; //trenutni ne pobedjuje
        }

        int res = nadji(k);

        if(res==1)
            cout << "First" << endl;
        else
            cout << "Second" << endl;

        return 0;
    }


Measured memory_bytes: 3712
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Abhas Jain
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ICoins solver = new ICoins();
        solver.solve(1, in, out);
        out.close();
    }

    static class ICoins {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.ni();
            double[] ar = new double[n + 1];
            for (int i = 1; i <= n; ++i) ar[i] = in.nd();
            double[][] dp = new double[n + 1][n + 1]; // i -> taken i, j-> j heads
            dp[0][0] = 1D;
            for (int i = 1; i <= n; ++i) {
                for (int j = 0; j <= n; ++j) {
                    dp[i][j] += dp[i - 1][j] * (1 - ar[i]);
                    if (j != 0) dp[i][j] += dp[i - 1][j - 1] * ar[i];
                }
            }
            double ans = 0D;
            for (int j = (n + 1) / 2; j <= n; ++j) ans += dp[n][j];
            out.print(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}



Measured memory_bytes: 132556
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int H = sc.nextInt();
   int W = sc.nextInt();
   char[][] gr = new char[H][W];
   for(int i=0;i<H;i++)
   {
     gr[i] = sc.next().toCharArray();
   }
   char[][] gmap = new char[H+2][W+2];
   for(int i =0;i<H+2;i++) 
   {
     gmap[i][0]='.';
     gmap[i][W+1]='.';
   }
   for(int i =0;i<W+2;i++) 
   {
     gmap[0][i]='.';
     gmap[H+1][i]='.';
   }
   for(int i=0;i<H;i++)
   {
     for(int k =0;k<W;k++)
     {
       gmap[i+1][k+1]= gr[i][k];
     }
   }
   StringBuilder sb = new StringBuilder();
   int count=0;
   for(int i=1;i<H+1;i++)
   {
     for(int k=1;k<W+1;k++)
     { 
       count = 0;
       if(gmap[i][k]=='#')
       {
         sb.append('#');
         continue;
       }
       if(gmap[i-1][k-1]=='#')
       {
         count++;
       }
       if(gmap[i][k-1]=='#')
       {
         count++;
       }
       if(gmap[i+1][k-1]=='#')
       {
         count++;
       }
       if(gmap[i-1][k]=='#')
       {
         count++;
       }
       if(gmap[i+1][k]=='#')
       {
         count++;
       }
       if(gmap[i-1][k+1]=='#')
       {
         count++;
       }
       if(gmap[i][k+1]=='#')
       {
         count++;
       }
       if(gmap[i+1][k+1]=='#')
       {
         count++;
       }
       sb.append(count);
       
     }
     System.out.println(sb.toString());
     sb.setLength(0);
   }
 }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pi 2*acos(0.0)
#define MOD 1000000007
#define N 100001
#define SZ 100000
int fx[5]= {0,0,0,-1,1};
int fy[5]= {0,-1,1,0,0};
int main()
{
    int x,n,i,inp;
    cin>>x>>n;
    int ara[n];
    set<int>st;
    for(i=0; i<n; i++)
    {
        cin>>inp;
        st.insert(inp);
    }
    vector<int>vec;
    int ans,temp,t1=INT_MAX;
    for(i=-101; i<=101; i++)
    {
        if(st.count(i)==false)
        {
            temp=abs(i-x);
            if(temp<t1)
            {
                t1=temp;
                ans=i;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3584
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    W = [iss() for _ in range(N)]
    s = W[0]
    r1 = True
    for i in range(1, N):
        if s[-1:] != W[i][0:1]:
            r1 = False
        s = W[i]

    print('Yes' if r1 and all([W.count(w) == 1 for w in W]) else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
#include <iostream>
#include <queue>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  priority_queue< int > q;
  for (int i = 0; i < n; ++i) {
    int l;
    cin >> l;
    q.push(l);
  }
  int sum = 0;
  for (int i = 0; i < k; ++i) {
    sum += q.top();
    q.pop();
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
  string S, T;
  int a = 1;
  cin >> S >> T;
  for(int i = 0; i < S.size(); i++){
    if(S[i] != T[i]){
      a = 0;
      break;
    }
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3620
import java.lang.reflect.Array;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

public class Main implements Runnable {
	public static void main(String[] args) {
		// long t = System.currentTimeMillis();
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
		// System.err.println(System.currentTimeMillis() - t);
	}

	class State {
		protected double srct;
		protected double dstt;
		protected int a;
		protected double srcv;
		protected double dstv;

		public State(double srct_, double dstt_, int a_, double srcv_) {
			srct = srct_;
			dstt = dstt_;
			a = a_;
			srcv = srcv_;
			dstv = srcv + a * (dstt - srct);
		}
	}

	void solve(int n, double[] t, double[] dt, double[] v) {
		ArrayDeque<State> dq = new ArrayDeque<>();
		dq.add(new State(-1, 0, 0, 0));
		for (int i = 0; i < n; ++i) {
			while (i > 0 && true) {
				State s = dq.peekLast();
				if (s.srcv - (t[i - 1] - s.srct) <= v[i])
					break;
				else {
					dq.pollLast();
				}
			}
			State ps = dq.peekLast();
			if (ps.dstv > v[i]) {
				dq.pollLast();
				double T = t[i - 1] - ps.srct;
				double ddt = (v[i] + T - ps.srcv) / (1 + ps.a);
				ps.dstt = ps.srct + ddt;
				ps.dstv = ps.srcv + (ps.dstt - ps.srct) * ps.a;
				dq.addLast(ps);
				dq.add(new State(ps.dstt, t[i - 1], -1, ps.dstv));
			}
			ps = dq.peekLast();
			if (ps.dstv + dt[i] > v[i]) {
				dq.addLast(new State(ps.dstt, ps.dstt + v[i] - ps.dstv, 1, ps.dstv));
				dq.addLast(new State(ps.dstt + v[i] - ps.dstv, t[i], 0, v[i]));
			} else {
				dq.addLast(new State((i > 0 ? t[i - 1] : 0), t[i], 1, ps.dstv));
			}
		}

		double ans = 0;
		for (State state : dq) {
			double ddt = state.dstt - state.srct;
			ans += ddt * state.srcv + ddt * ddt * state.a * 0.5;
		}
		System.out.println(ans);
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] t = new double[n + 1];
		double[] dt = new double[n + 1];
		double[] v = new double[n + 1];
		for (int i = 0; i < n; ++i) {
			t[i] = sc.nextDouble();
			dt[i] = t[i];
			if (i > 0)
				t[i] = t[i - 1] + t[i];
		}
		for (int i = 0; i < n; ++i) {
			v[i] = sc.nextDouble();
		}
		++n;
		v[n - 1] = 0;
		t[n - 1] = t[n - 2];
		dt[n - 1] = 0;
		solve(n, t, dt, v);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

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

int main() {
  int n, m, s;
  int a[100][100] = {0};
  int b[100] = {0};
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }

  for (int i = 0; i < n; i++) {
    s = 0;
    for (int j = 0; j < m; j++) {
      s += a[i][j] * b[j];
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
template< typename T >
struct BIT {
  int N; int max_2beki;

  vector< T > data;
  // 初期化 1-indexedでデータを管理する 0で初期化
  BIT(int size){
      N = ++size;
      data.assign(N, 0);
      max_2beki = 1;
      while(max_2beki * 2 <= N) max_2beki *= 2;
  }

  // [0,k](閉区間)の総和 閉区間に注意！
  T sum(int k) {
    if(k < 0) return 0; // k<0のとき0を返す
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  // [l,r](閉区間)の総和
  inline T sum(int l,int r){
    return sum(r) - sum(l-1);
  }

  // 一点取得 更新はできないことに注意
  inline T operator[](int k){
    return sum(k) - sum(k-1);
  }

  // data[k] += x;
  void add(int k, T x) {
    for(++k; k < N; k += k & -k) data[k] += x;
  }

  // imos法 [l,r]にxを加算
  void imos(int l,int r,T x){
    add(l , x); add(r + 1 , -x);
  }

  // lower_bound sum(i)がval以上となる最小のi
  int lower_bound(T w){
    if(w <= 0) return 0;
    int x = 0;
    for(int k = max_2beki; k > 0; k /= 2){
      if(x+k <= N - 1 && data[x + k] < w){
        w -= data[x + k];
        x += k;
      }
    }
    return x;
  }

  // upper_bound sum(i)がvalより大きくなる最小のi
  int upper_bound(T w){
    if(w < 0) return 0;
    int x = 0;
    for(int k = max_2beki; k > 0; k /= 2){
      if(x+k <= N - 1 && data[x + k] <= w){
        w -= data[x + k];
        x += k;
      }
    }
    return x;
  }

};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d;cin >> d;
    vector<int> x(d);
    vector<pair<int,pair<int,int>>> p;
    rep(i,d){
        cin >> x[i];
        p.push_back({x[i],{0,i}});
    }
    int q;cin >> q;
    vector<int> l(q),r(q),e(q);
    rep(i,q){
        cin >> l[i] >> r[i] >> e[i];
        l[i]--,r[i]--;
        int a=min(x[l[i]],x[r[i]]),b=max(x[l[i]],x[r[i]]);
        p.push_back({a-e[i],{-1,i}});
        p.push_back({b+e[i],{1,i}});
    }
    sort(p.begin(),p.end());
    BIT<int> bit(d);
    vector<int> ans(q);
    for(auto x:p){
        int u=x.first,v=x.second.first,w=x.second.second;
        if(v==-1){
            ans[w]+=bit.sum(l[w],r[w]);
        }
        else if(v==0){
            bit.add(w,1);
        }
        else{
            ans[w]+=r[w]-l[w]+1-bit.sum(l[w],r[w]);
        }
    }
    for(int x:ans){
        cout << x << endl;
    }
}


Measured memory_bytes: 10472
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <complex>
using namespace std;

typedef long long ll;

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

int main(){
  string s;
  int a,b;

  while(cin>>s>>a>>b){
    cout<<s<<" "<<a+b<<" "<<a*200+b*300<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

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

    string s, t;
    cin >> s >> t;

    for(lint i=0; i<n; i++) {
        cout << s[i] << t[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
def main(): 
    
    N = int(input())
    h = list(map(int, input().split()))

    dp = [0 for _ in range(N)]

    for i in range(1,N):
        if i == 1:
            dp[i] = abs(h[i] - h[i-1])
        else:
            dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))

    print(dp[N-1])

    
if __name__ == "__main__":
    main() 

Measured memory_bytes: 13976
#include <utility>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <iostream>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;
int main() {
    int a,b,k;
    cin >> k >> a >> b;
    if (b/k-(a-1)/k > 0) {
        cout << "OK";
    }
    else {
        cout << "NG";
    }
    return 0;
}

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

int main(void){
  
   int A,B,C,D,R;
   cin >> A >> B >> C >> D;
   R = (A+B)-(C+D);
  
   if(R>0) cout << "Left";
   else if (R<0) cout << "Right";
   else cout << "Balanced";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
    int data;
    node* next;
};
node *root=NULL;
void appended(int data){
    if(root==NULL){
        root=new node;
        root->data=data;
        root->next=NULL;
    }
    else{
        node* currentNode=root;
        while(currentNode->next!=NULL)
            currentNode=currentNode->next;
        node* newNode=new node;
        newNode->data=data;
        newNode->next=NULL;
        currentNode->next=newNode;
    }
}
void print(){
    node* currentNode=root;
    while(currentNode!=NULL){
        cout<<currentNode->data<<" ";
        currentNode=currentNode->next;
    }
    cout<<endl;
}



int main(){
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}







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

using namespace std;
using ll = long long;

const int INF = 0x3f3f3f3f;
const int MAX_N = 3002;
double dp[MAX_N][MAX_N];
int N;
double prob[MAX_N];

void solve()
{
	dp[0][0]=1;
	for(int i=1; i<=N; ++i){
		for(int j=0; j<=i; ++j){ //
			if(j==0) dp[i][j] = dp[i-1][j] * (1-prob[i]);
			else dp[i][j] = dp[i-1][j-1] * prob[i] + dp[i-1][j] * (1-prob[i]);
		}
	}
	double ans = 0;
	for(int i=N/2+1; i<=N; ++i) ans += dp[N][i];
	cout << setprecision(15);
	cout << ans << endl;
}

int main()
{
	cin >> N;
	for(int i=1; i<=N; ++i) cin >> prob[i];
	solve();
	return 0;
}


Measured memory_bytes: 68992
#include<iostream>
#include<vector>
int main() {
	int n;
	std::vector<int>v;
	while (1) {
		std::cin >> n;
		if (n == 0) {
			break;
		}
		int a = 0;
		for (int i = 0; i < n / 4; ++i) {
			int b;
			std::cin >> b;
			a += b;
		}
		v.push_back(a);
}
	for (int i = 0; i < v.size(); ++i) {
		std::cout << v[i]<< std::endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
//define
typedef pair<int,int>pi;
#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb() push_back()
#define mod 100000007
#define elif else if
#define str string

signed main(){
  int N,M,O,P,count=0,Amax=0,imin=0,Amin=0;
  double d;
  char c;
  cin>>N>>M>>O;
  N+M+O>21?cout<<"bust"<<endl:cout<<"win"<<endl;
}


Measured memory_bytes: 256
N = int(input())
 
card = list(map(int, input().split()))
card.sort(reverse=True)
 
Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += card[i]
  else:
    Bob += card[i]
    
print(Alice - Bob)


Measured memory_bytes: 2940
#![allow(unused_macros, unused_imports, dead_code)]

use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
            assert!(_it.next().is_none());
        }
    };
}

fn main() {
    from_line!(r: u32, g: u32, b: u32);

    println!("{}",
             if (g * 10 + b) % 4 == 0 {
                 "YES"
             } else {
                 "NO"
             });
}

Measured memory_bytes: 4352
#include <cstdio>

int main(void)
{
	#if DEBUG
	freopen("_in","r",stdin);
	#endif

	int m1count=0,m2count=0,m4count=0;
	int i,N,x;
	scanf("%d",&N);
	while(N--)
	{
		scanf("%d",&x);
		if(x%4==0)
			m4count++;
		else if(x%2==0)
			m2count++;
		else
			m1count++;
	}

	if(m2count>0 && m1count<=m4count)
		printf("Yes\n");
	else if(m2count==0 && m1count<=m4count+1)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;



}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;
typedef long long ll;

int main() {

    int X, Y;
    cin >> X >> Y;
    for (int i = 0; i <= X; i++) {
        int j = X - i;
        if (i * 2 + j * 4 == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, k;
int x[100];

int main() {
	int i;
	
	cin >> n >> k;
	rep(i, n) cin >> x[i];
	
	int ans = 0;
	rep(i, n) {
		ans += 2 * min(abs(k - x[i]), x[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )

#define MOD 1000000007

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void print(int A[], int n)
{
	int i;
	for (i = 0; i < n; i++)
	{
		printf("%d", A[i]);
		if (i != n - 1)
			printf(" ");
	}
	printf("\n");
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main()
{
	int m, n;

	scanf("%d%d", &m, &n);

	printf("%d\n", modpow(m,n,MOD));
}


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

int main() {

int N;
string S;
  
  cin >> N;
  cin >> S;
  
  int count = 0;

for(int i = 0;i < N-2; i++){
  if(S.at(i) == 'A' & S.at(i+1) == 'B' & S.at(i+2) == 'C')
  count++;
}
    cout << count <<endl;
}


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();
		int T = sc.nextInt();
		int min = 0;
		for(int i = 0; i < N; i++) {
			int c = sc.nextInt();
			int t = sc.nextInt();
			if(t <= T) {
				if(min == 0) {
					min = c;
				}else{
					min = Math.min(min, c);
				}
			}
		}

		if(min == 0) {
			System.out.println("TLE");
		}else {
			System.out.println(min);
		}
	}
}


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

int main(){
	long long A[3];
	cin >> A[0] >> A[1] >> A[2];
	
	sort(A,A+3);
	if(A[2] % 2 == 0){
		cout << 0 ;
	}
	else cout << A[0]*A[1] ;
} 

Measured memory_bytes: 256
n = int(input())
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
dif = [a[i] - b[i] for i in range(n)]
dif_abs = [abs(dif[i]) for i in range(n)]
sorted_dif = sorted(dif)
dif_minus = [(dif_abs[i] - dif[i]) // 2 for i in range(n)]
total_minus = sum(dif_minus)
len_minus = sum(x>0 for x in dif_minus)

res = 0

if sum(a) < sum(b):
    print(-1)
else:
    if len_minus == 0:
        print(res)
    else:
        res += len_minus
        while True:
            if total_minus <= 0:
                break
            total_minus -= sorted_dif.pop()
            res += 1

        print(res)

Measured memory_bytes: 20532