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()
}

const mod = 1000000007

func mpow(a, b int) int {
	if b == 0 {
		return 1
	} else if b%2 == 0 {
		tmp := mpow(a, b/2)
		return tmp * tmp % mod
	}
	return mpow(a, b-1) * a % mod
}

var fracMemo = []int{1, 1}

func mfrac(n int) int {
	if len(fracMemo) > n {
		return fracMemo[n]
	}
	if len(fracMemo) == 0 {
		fracMemo = append(fracMemo, 1)
	}
	for len(fracMemo) <= n {
		size := len(fracMemo)
		fracMemo = append(fracMemo, fracMemo[size-1]*size%mod)
	}
	return fracMemo[n]
}

var ifracMemo = []int{1, 1}

func mifrac(n int) int {
	if len(ifracMemo) > n {
		return ifracMemo[n]
	}
	if len(ifracMemo) == 0 {
		fracMemo = append(ifracMemo, 1)
	}
	for len(ifracMemo) <= n {
		size := len(ifracMemo)
		ifracMemo = append(ifracMemo, ifracMemo[size-1]*mpow(size, mod-2)%mod)
	}
	return ifracMemo[n]
}

func nCr(n, r int) int {
	if n == r {
		return 1
	}
	if n < r || r < 0 {
		return 0
	}
	ret := 1
	ret *= mfrac(n)
	ret %= mod
	ret *= mifrac(r)
	ret %= mod
	ret *= mifrac(n - r)
	ret %= mod
	return (ret)
}

func main() {
	sc.Split(bufio.ScanWords)
	n := getInt()
	a := make([]int, n+1)
	p := make(map[int]int)
	var s, e int
	for i := 0; i <= n; i++ {
		a[i] = getInt()
		if p[a[i]] != 0 {
			s = p[a[i]]
			e = i + 1
		}
		p[a[i]] = i + 1
	}
	l := n - e + s
	//out(n, a, s, e, l)

	for i := 1; i <= n+1; i++ {
		val := (nCr(n+1, i) - nCr(l, i-1)) % mod
		if val < 0 {
			val += mod
		}
		out(val)
	}

}


Measured memory_bytes: 11008
n,x,y = map(int,input().split())
k = [0]*(n)
 
for i in range(1,n):
  for j in range(i+1,n+1):
    ind = min(j-i,abs(x-i) + abs(j-y) + 1)
    k[ind] += 1
      
for i in range(1,n):
  print(k[i])

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


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;

// #define  part ..
#define listi vector<int >
#define listll vector<long long >
#define pii pair<int ,int >
#define pll pair<long long ,long long >
#define heap priority_queue<long long >
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define mod 998244353
#define maxx 200006
#define ll long long
#define quick   ios_base::sync_with_stdio(NULL),cin.tie(0);
#define rep(i,a,b) for(int i=a;i<b;i++)
long long gcd(long long a, long long b) {
  while (b > 0) {
    long long t = a % b;
    a = b;
    b = t;
  }
  return a;
}
 
// #define test int t;cin>>t;while(t--)
// end of #define 

// define globals ...


long long ni() {
  int c = getchar();
  while (c < '0' || c > '9') c = getchar();
  long long ret = 0.0;
  while (c >= '0' && c <= '9') {
    ret = ret * 10 + c - '0';
    c = getchar();
  }
  return ret;
}





int Main ()
{

 
  long double a,b,c;
  cin>>a>>b>>c;
  (sqrt(a)+sqrt(b) +1e-14 < sqrt(c) ) ? cout<<"Yes":cout<<"No";

  return 0;
}























// main function..
int main ()
{
  quick;

#ifndef ONLINE_JUDGE
  freopen ("input.txt", "r", stdin);
  freopen ("outt.txt", "w", stdout);
#endif

  Main ();


}


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

int main() {
  int n,ans = 0;
  cin >> n;
  vector<int>data(n);
  for(int i = 0;i < n;i++){
    cin >> data.at(i);
  }
  for(int i = 1;i < n;i++){
    for(int j = 0;j < i;j++){
      if(data.at(j) > data.at(i)){
        break;
      }
      else if(j == i-1){
        ans++;
      }
    }
  }
  cout << ans+1 << endl;
}

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

using namespace std;

const int N = 3010; 

long double p[N];

long double f[N][N][3];

int main()
{
	 int n;
	 cin>>n;
	 for(int i=1;i<=n;i++)	cin>>p[i];
	f[1][0][0]=(1-p[1]);
	f[1][1][1]=p[1];
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<=(n>>1);j++)
		{
			if(j)
			f[i][j][1]=(f[i-1][j-1][1]+f[i-1][j-1][0])*p[i];
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])*(1-p[i]);
		}
	}
	double sum=0.0;
	for(int i=0;i<=n>>1;i++)
	{
		sum+=f[n][i][0]+f[n][i][1];
	}
	printf("%.10lf\n",1-sum);
	
	 
	 
	
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
    string s;
    cin >> s;

    bool ans = true;

    for(int i = 0; i < s.size(); i += 2){
        if(s[i]=='L') ans = false;
    } 

    for(int i = 1; i < s.size(); i += 2){
        if(s[i] == 'R') ans = false;
    } 

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 1005
#define MOD 1000000007
using namespace std;
int n,m,dp[M][M];
char in[M][M];
int main()
{
    while (~scanf("%d %d",&n,&m)) {
        REP(i,1,n) scanf("%s", in[i]+1);

        MSET(dp, 0);
        dp[1][1] = 1;
        REP(i,1,n) REP(j,1,m) if (i+j>2) {
            dp[i][j] = 0;
            if (in[i][j]=='#') continue;
            dp[i][j] += dp[i-1][j] + dp[i][j-1];
            if (dp[i][j] >= MOD) dp[i][j] -= MOD;
        }
        printf("%d\n",dp[n][m]);
    }
    
    return 0;
}




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

int main(){
    int A,B;
    cin >> A >> B;
    int count = 0;
    int tap = 1;
    while(tap < B){
        tap += A - 1;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b,c,i;
  int x=0;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++){
    if(c%i==0) x++;
  }
  printf("%d\n",x);
  return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;
using T = std::tuple<ll,ll,ll>;

constexpr ll INF = 1001001001001001001;
int N, M, S;
std::vector<T> G[60];
ll C[60], D[60];
std::priority_queue<T, std::vector<T>, std::greater<T>> pq;
ll dist[60][2600];

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

  std::cin >> N >> M >> S;

  for(int i=0;i<M;++i){
      int U, V, A, B;
      std::cin >> U >> V >> A >> B;

      G[U].emplace_back(V, A, B);
      G[V].emplace_back(U, A, B);
  }

  for(int i=1;i<=N;++i){
      std::cin >> C[i] >> D[i];
  }

  std::fill(&dist[0][0], &dist[0][0] + 60 * 2600, INF);
  
  S = std::min(S, 2500);

  pq.emplace(0, 1, S);
  dist[1][S] = 0;

  until(pq.empty()){
      auto [d, v, s] = pq.top();
      pq.pop();

      if(d > dist[v][s]){
          continue;
      }

      if(s < 2500){
          ll ns = std::min<ll>(s + C[v], 2500),
              nd = d + D[v];
          
          if(nd < dist[v][ns]){
              dist[v][ns] = nd;
              pq.emplace(nd, v, ns);
          }
      }

      for(auto [w, a, b] : G[v]){
          if(a > s){
              continue;
          }

          ll ns = s - a,
              nd = d + b;
          
          if(nd < dist[w][ns]){
              dist[w][ns] = nd;
              pq.emplace(nd, w, ns);
          }
      }
  }

  for(int i=2;i<=N;++i){
      std::cout << *std::min_element(&dist[i][0], &dist[i][0] + 2600) << std::endl;
  }
}


Measured memory_bytes: 7544
A = [i for i in input()]
B = [i for i in input()]
C = [i for i in input()]

ps = {'a':A,'b':B,'c':C}
turn = 'a'
while True:
    if len(ps[turn]) <= 0:
        break
    turn = ps[turn].pop(0)
print(turn.upper())


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

int main(){
    int n,a,b; cin>>n>>a>>b;
    int aika=0,aida=0,bkoe=0;
    for(int i=0; i<n; i++){
        int p; cin>>p;
        if(p<=a) aika++;
        else if(b+1<=p) bkoe++;
        else aida++;
    }
    cout << min(min(aika,aida),bkoe) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=3000+30;
char S[MAXN],T[MAXN];
int D[MAXN][MAXN];
int main() {
	scanf("%s %s",S+1,T+1);
	int n=0,m=0;
	while(S[n+1])n++;
	while(T[m+1])m++;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++) {
			if (S[i]==T[j]) D[i][j]=D[i-1][j-1]+1;
			else D[i][j]=max(D[i-1][j],D[i][j-1]);
		}
	int i=n,j=m;
	string r;
	while (i && j) {
		if (S[i]==T[j]) {
			r+=S[i];
			--i;
			--j;
		} else if(D[i-1][j]<D[i][j-1]) --j;
		else --i;
	}
	reverse(r.begin(),r.end());
	puts(r.c_str());
	return 0;
}

Measured memory_bytes: 35840
#include<iostream>
#include<algorithm>

using namespace std;


int main() {

	int N;
	cin >> N;


	int ans = 1;
	int maxi = 0;//割れる回数の最大

	for (int i = 1; i <= N; i++) {

		int count = 0;//割れる回数
		int num = i;
		while (num % 2 == 0) {
			num/=2;
			count++;
		}

		if (maxi < count) {
			ans = i;
			maxi = count;
		}
	}

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




Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
      int L = in.nextInt();
      int R = in.nextInt();
      int d = in.nextInt();
      int r = R / d;
      int l = L /d ;
      if(L%d == 0 ){
      System.out.print(r-l+1);
      }
      else{
      System.out.print(r-l);
      }
      }
}

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

#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    // int N, P; string S; cin >> N >> P >> S;
    string S;
    cin >> S;
    int N = S.length();
    int P = 2019;
    ll ans = 0;
    if (P == 2 || P == 5) {
        REP(i, 0, N)
            if ((S[N - i - 1] - '0') % P == 0)
                ans += N - i;
    }
    else {
        vector<ll> mods(P, 0);

        ll cur = 0, coef = 1;
        mods[cur]++;
        REP(i, 0, N) {
            cur = (cur + coef * (S[N - i - 1] - '0') % P) % P;
            coef = coef * 10 % P;
            mods[cur]++;
        }

        REP(i, 0, P) {
            ans += mods[i] * (mods[i] - 1) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3748
<?php
list($h, $n) = explode(" ", trim(fgets(STDIN)));
$h=intval($h);
$n=intval($n);
$a=[0];
$b=[0];
for($i=0;$i<$n;$i++){
  list($x, $y) = explode(" ", trim(fgets(STDIN)));
  $a[]=intval($x);
  $b[]=intval($y);
}

$ans=[];
$ans[0]=0;
for($i=1;$i<=20001;$i++){
  $ans[$i]=PHP_INT_MAX;
  for($j=1;$j<=$n;$j++){
    if($a[$j]==$i){
      if($ans[$i]==PHP_INT_MAX){
        $ans[$i]=$b[$j];
      }else{
        $ans[$i]=min($ans[$i], $b[$j]);
      }
    }else if($a[$j]<$i){
      if($ans[$i-$a[$j]]!=PHP_INT_MAX){
        $ans[$i]=min($ans[$i], $ans[$i-$a[$j]]+$b[$j]);
      }
    }
  }
}

$min=PHP_INT_MAX;
for($i=0;$i<=20001-$h;$i++){
  $min=min($min, $ans[$i+$h]);
}

echo $min;

Measured memory_bytes: 16824
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
	int n,x1,x2,y1,y2,p,q,a=0,b=0;
	vector<int> E,F,G,H;
	vector<long long int> S, T;
	vector<vector<long long int>> I,J;
	string s, t;
	vector<string> U, X, Y;
	vector<vector<string>> UU;

	cin >> n;
	for (int k = 0; k < n; k++) {
		cin >> s >> t;
		int f = 0;
			if (s.size() > 80 || t.size() > 80) {
				f = 1;
				F.push_back(f);
			}
			else F.push_back(0);
			x1 = s.size() % 10; y1 = (s.size() + 9) / 10; p = 8 - y1;
			for (int i = 0; i < p; i++)S.push_back(0);
			if (x1 == 0) for (int i = 0; i < y1; i++)S.push_back(stoll(s.substr(i * 10, 10)));
			else {
				S.push_back(stoll(s.substr(0, x1)));
				for (int i = 1; i < y1; i++)S.push_back(stoll(s.substr(x1 + (i - 1) * 10, 10)));
			}

			x2 = t.size() % 10; y2 = (t.size() + 9) / 10; q = 8 - y2;
			for (int i = 0; i < q; i++)T.push_back(0);
			if (x2 == 0) for (int i = 0; i < y2; i++)T.push_back(stoll(t.substr(i * 10, 10)));
			else {
				T.push_back(stoll(t.substr(0, x2)));
				for (int i = 1; i < y2; i++)T.push_back(stoll(t.substr(x2 + (i - 1) * 10, 10)));
			}
			I.push_back(S); S.clear();
			J.push_back(T); T.clear();
		}

	for (int k = 0; k < I.size(); k++) {
		for (int i = 0; i < 8; i++) U.push_back(to_string(I[k][i] + J[k][i]));
		UU.push_back(U); U.clear();
	}
	
	for (int k = 0; k < I.size(); k++) {
		for (int i = 7; i >= 0; i--) {
			UU[k][i] = to_string(stoll(UU[k][i]) + b);
			if (UU[k][i].size() == 11 && i == 0) {
				UU[k][i] = "a";
				b = 1;
			}
			else if (UU[k][i].size() == 11) {
				UU[k][i] = UU[k][i].substr(1, 10);
				b = 1;
			}
			else if (UU[k][i].size() < 10) {
				for (int j = 0; j < 10 - UU[k][i].size()+j; j++) UU[k][i] = "0" + UU[k][i];
				b = 0;
			}
			else b = 0;
		}
		b = 0;
	}

	for (int k = 0; k < UU.size(); k++) {
		int e = 0;
		for (int i = 0; i < UU[k].size(); i++) {
			if (UU[k][i] == "a") {
				e = 100;
				E.push_back(e);
				break;
			}
			else if (stoll(UU[k][i]) == 0 && i == 7)E.push_back(13);
			else if (stoll(UU[k][i]) == 0);
			else {
				e = i;
				E.push_back(e);
				break;
			}
		}
	}

	for (int k = 0; k < UU.size(); k++) {
		if (E[k] == 100)cout << "overflow";
		else if (F[k] == 1)cout << "overflow";
		else {
			if (E[k] == 13)cout << "0";
			else {
				cout << stoll(UU[k][E[k]]);
				for (int i = E[k] + 1; i < UU[k].size(); i++) cout << UU[k][i];
			}
		}
			cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
//Cancel in interactive questions
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define got(container,num) get<num-1>(container)
using namespace std;
const int INF=LLONG_MAX/2;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;
umap<int,int>h;
main()
{
    IOS
    cin>>n;
    fun(i)
    {
        int x;
        cin>>x;
        h[x]++;
        ans+=x;
    }
    cin>>m;
    fum(i)
    {
        int x,y;
        cin>>x>>y;
        int num=h[x]*x+h[y]*y;
        h[y]+=h[x];
        h[x]=0;
        ans+=(h[x]*x+h[y]*y-num);
        out(ans)
    }
    return 0;
}

Measured memory_bytes: 7084
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	string ss;
	cin >> ss;
	int64 ans = 0;
	for(int64 ii = 0;ii < ss.length();ii++)
	{
		ans += (ss[ii] - '0');
	}
	if(ans % 9 == 0)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll s,w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe";
    else cout<<"safe";
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(void){
	int w,h,x,y,r;
	scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
	if(0<=x-r&&x+r<=w){
		if(0<=y-r&&y+r<=h) printf("Yes\n");
		else printf("No\n");
	}
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 2100
def inint(): return int(input())
def inlint(): return list(map(int, input().split()))
def infloat(): return float(input())
def inlffloat(): return list(map(float, input().split()))
def inl(): return list(input())
def putlint(): return "".join(list(map(str, ans)))

a,o,b = list(input().split())
a=int(a)
b=int(b)
if o=="+":
    print(a+b)
else:
    print(a-b)

Measured memory_bytes: 3064
N = int(input())
g = [ [1] * N for _ in range(N) ]

if N % 2 == 1:
  for i in range(N//2):
    g[i][N-2-i] = 0
    g[N-2-i][i] = 0
else:
  for i in range(N//2):
    g[i][N-1-i] = 0
    g[N-1-i][i] = 0
    

M = 0
for b in range(N):
  for a in range(b):
    if g[a][b] == 1:
      M += 1
print(M)
for b in range(N):
  for a in range(b):
    if g[a][b] == 1:
      print(a+1, b+1)



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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 W, H, x, y, r; cin >> W >> H >> x >> y >> r;
        bool ans = x >= r && y >= r && x <= W - r && y <= H - r;
        cout << (ans ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    ll n,q;
    cin >> n >> q;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    vector<ll> x(q);
    rep(i,q){
        cin >> x[i];
    }
    rep(i,q){
        ll r = 0;
        ll sum = 0;
        ll ans = 0;
        for(ll l=0;l<n;l++)
        {
            while(r<n&&sum+a[r]<=x[i]){
                sum+=a[r];
                r++;
            }
            ans+=r-l;
            sum-=a[l];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    //cout<<n<<'\n';
    vector<int> a(m);
    map<int,int> num;
    num[1]=2,num[2]=5,num[3]=5,num[4]=4,num[5]=5,num[6]=6,num[7]=3,num[8]=7,num[9]=6;
    rep(i,m){
      cin>>a[i];
    }
    //cout_vec(a);
    sort(begin(a),end(a),greater<int>());
    int inf=-1e6;
    vector<int> dp(n+1,inf);
    dp[0]=0;
    FOR(i,1,n+1){
      rep(j,m){
        if(i-num[a[j]]>=0 && dp[i]<dp[i-num[a[j]]]+1){
          dp[i]=dp[i-num[a[j]]]+1;
        }
      }
    }
    //cout_vec(dp);
    int cnt=n;
    //cout<<cnt<<'\n';
    while(cnt!=0){
      //cout<<cnt<<'\n';
      rep(i,m){
        if(cnt-num[a[i]]>=0 && dp[cnt-num[a[i]]]==dp[cnt]-1){
          cout<<a[i];
          cnt-=num[a[i]];
          //cout<<cnt<<'\n';
          break;
        }
      }
    }
    cout<<endl;
}

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

#define mod 1000000007
#define LOCAL 0
#define pb push_back
#define ll long long

ll po(ll a,ll b){
	ll x = 1,y=a;
	while(b>0){
		if(b%2){
			x = x*y;
			x %= mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}

int main(){
	if(LOCAL){
    	freopen("C:/Users/gold/Desktop/sublime IO/input.txt","r",stdin);
    	freopen("C:/Users/gold/Desktop/sublime IO/output.txt","w",stdout);
	}
	int T = 1;
	//scanf("%d",&T);
	while(T--){
		int h,w,n;
		scanf("%d %d %d",&h,&w,&n);
		static int a[10000];
		for(int i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		int s = 0;
		static int mat[105][105];
		for(int i=0;i<w;i++){
			if(i%2 == 0){
				for(int j=0;j<h;j++){
					while(a[s] == 0){
						s++;
					}
					mat[j][i] = s+1;
					a[s]--;
				}
			} else {
				for(int j=h-1;j>=0;j--){
					while(a[s] == 0){
						s++;
					}
					mat[j][i] = s+1;
					a[s]--;
					//printf("%d\n",s);
				}
			}
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				printf("%d ",mat[i][j]);
			}
			puts("");
		}
	}
	return 0;	
}

Measured memory_bytes: 384
a, b = list(map(int, input().split()))
poker = [2,3,4,5,6,7,8,9,10,11,12,13,1]
if poker.index(a)<poker.index(b):
    print("Bob")
elif poker.index(a)>poker.index(b):
    print("Alice")
else:
    print("Draw")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  string s;
  cin >> s;
  ll n=s.size();

  ll c=0;
  for(ll i=0;i<n/2;i++)if(s[i]!=s[n-1-i])c++;

  cout << c <<endl;  

}

Measured memory_bytes: 3644
#include<iostream>
#include<stdio.h>
#include<ios>
#include<cmath>
#include<string>
#include<string.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<assert.h>
#include<bitset>
#include<tuple>
#include<climits>
#include<deque>
#include<utility>
#include<unordered_map>
#include<unordered_set>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<ext/pb_ds/assoc_container.hpp>
#include<chrono>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int64_t>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    int n,c=0;cin>>n;
    for(int i=1;i<=n;i++)
    {
    	if(i>=n-i) break;
    	else c++;
    }
    cout<<c;
    return 0;
}

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

int main(){
    int n;  cin >> n;
    vector<int>l(n);
    rep(i, n)   cin >> l[i];
    //solve
    int ans = 0;
    sort(l.begin(), l.end());
    rep(a, n-2){
        for(int b = a+1; b < n-1; b++){
            for(int c = b+1; c < n; c++){
                if(l[a]+l[b] > l[c])    ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int data[11]={0};
  int a,b,c,flag=0;
  cin >> a >> b >> c;
  data[a]++;
  data[b]++;
  data[c]++;
  if(data[5] == 2){
    if(data[7] == 1){
      cout << "YES" << endl;
      flag++;
    }
  }
  if(flag == 0){
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC169
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            int[] ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(ab[0] * ab[1]);
        }
    }
}


Measured memory_bytes: 28288
a,b=[int(i) for i in input().split()]

n=[[] for i in range(a)]

e=[]

for i in range(b):
    x0,y0=[int(i) for i in input().split()]
    x=x0-1
    y=y0-1
    e.append([x,y])
    n[x].append(y)
    n[y].append(x)


def loopn(j,x,y):
  s.append(j)
  for k in n[j]:
    if k not in s and not (j== x and k==y) and not(j== y and k==x):
      loopn(k,x,y)
x = 0

for i,j in e:
  s=[]

  loopn(j,i,j)
  if i not in s:
    x +=1 
print(x)

Measured memory_bytes: 3064
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    N = I()
    T = []
    S = []
    for i in range(N):
        s,t = input().split()
        S.append(s)
        T.append(int(t))
    X = input()

    ans = 0
    for i in range(N):
        if S[i] == X:
            for j in range(i+1,N):
                ans += T[j]
            print(ans)
            return

if __name__ == "__main__":
    main()


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

#define max 246913

int main(){
  int n;
  int count,limit;
  bool a[max];
  a[0]=a[1]=false;
  for(int i=2;i<max;i++) a[i]=true;
  limit=sqrt(max);
  /* cout<<limit<<endl;
     cout<<a[20]<<endl;*/
  for(int i=2;i<=limit;i++){
       if(a[i]==true){
           for(int k=2*i;k<max;k+=i){
	   a[k]=false;
           }
       }
   }
  /*cout<<a[20]<<endl;
    cout<<"ha?"<<endl;*/
  while(1){
    count=0;
    cin>>n;
    if(n==0) break;
    for(int i=n+1;i<2*n;i++){
      if(a[i]==true) count++;
    }
    if(n==1) cout<<"1"<<endl;
    else cout<<count<<endl;
  }
  return 0;
}



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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

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

void solve() {

}

int main() {
  int A,B,K;
  cin >> K >> A >> B;
  ll v = 0;
  while ( v <= B ) {
    v += K;
    if( A <= v && v <= B ) {
      puts("OK");
      return 0;
    }
  }
  puts("NG");
  return 0;
}


Measured memory_bytes: 3640
import scala.io.StdIn.{readInt,readLine}

object Main {
  val a = Array(
    Array('.',',','!','?',' '),
    Array('a','b','c'),
    Array('d','e','f'),
    Array('g','h','i'),
    Array('j','k','l'),
    Array('m','n','o'),
    Array('p','q','r','s'),
    Array('t','u','v'),
    Array('w','x','y','z')
  )

  def main(args:Array[String]) = {
    val n = readInt
    val r = for(i<-1 to n) yield {
      val s = readLine.split("0")
      s.map { btns =>
        if(btns.length>0) {
          val btn = btns(0).asDigit
          val len = if(List(2,3,4,5,6,8).contains(btn)) 3
                    else if(List(7,9).contains(btn)) 4
                    else if(List(1).contains(btn)) 5
                    else 1
          a(btn-1)((btns.length-1) % len)
        } else ""
      }.mkString
    }
    println(r.mkString("\n"))
  }

}

Measured memory_bytes: 48244
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

const int MAX_N = 5100;
const int MAX_P = MAX_N * MAX_N;
int grid[MAX_N][MAX_N] = {0};

void compress(vector<int> &v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}

int lb(vector<int> v, int num){
    return lower_bound(all(v), num) - v.begin();
}


//s[MAX_N + 1][MAX_N + 1]
void cumulativeSum(int h, int w){
    //?????????????´????(1,1)
    rep(i,h) rep(j,w) grid[i + 1][j + 1] += grid[i + 1][j] + grid[i][j + 1] - grid[i][j];
}

//(i,j)????????????(k,l)???????????¨??????????????¢
int sum(int i, int j, int k, int l){
    return grid[k][l] - grid[i][l] - grid[k][j] + grid[i][j];
}

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

    vector<int> x(n), y(n);
    pair<int, int> inp[MAX_N];
    rep(i,n){
        cin >> x[i] >> y[i];
        inp[i] = make_pair(x[i],y[i]);
    }

    compress(x);
    compress(y);

    rep(i,n){
        int fy = lb(y, inp[i].second);
        int fx = lb(x, inp[i].first);
        grid[fy + 1][fx + 1]++; //?´???????????????????+1??????
    }


    cumulativeSum(y.size(), x.size());
    //rep(i,y.size() + 1){ rep(j,x.size() + 1){ cout << grid[i][j] <<' '; } cout << endl; }
    //rep(i,x.size()){ show(x[i]) }

    rep(i,m){
        int lx, ly, rx, ry;
        cin >> lx >> ly >> rx >> ry;
        lx = lb(x, lx);
        ly = lb(y, ly);
        rx = lb(x, rx + 1);//?¢???????????????????
        ry = lb(y, ry + 1);
        cout << sum(ly, lx, ry, rx) << endl;
    }
}

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

using namespace std;

const int mod = 998244353;

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

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

  vector<long long> A(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }

  vector<vector<long long>> dp(N + 10, vector<long long>(S + 10, 0));
  dp[0][0] = 1;

  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= S; j++) {
      dp[i][j] += dp[i - 1][j];
      dp[i][j] %= mod;
      if (j - A[i] >= 0) {
        dp[i][j] += dp[i - 1][j - A[i]] * (mod + 1) / 2;
        dp[i][j] %= mod;
      }
    }
  }

  cout << (dp[N][S] * mod_pow(2, N, mod)) % mod << "\n";

  return 0;
}

Measured memory_bytes: 74168
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
using namespace std;

bool check (string s){
  int n = s.length();
  if (n%2==1){
    return false;
  }
  else {
    return (s.substr(0,n/2-1)==s.substr(n/2));
  }
}

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

  for (int i=0; i<=n; i++){
    for (int j=0; j<=n; j++){
      for (int k=0; k<=n; k++){
        if (10000*i+5000*j+1000*k==y && i+j+k==n){
          printf("%d %d %d\n",i,j,k);
          return 0;
        }
        if (10000*i+5000*j+1000*k>y || i+j+k>n){
          break;
        }
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
p = gets.chomp.split.map(&:to_i)

ans = 0
prev = false

N.times do |i|
  if p[i] == i + 1
    if prev
      prev = false
      next
    end

    ans += 1
    prev = true
  else
    prev = false
  end
end

p ans


Measured memory_bytes: 8708
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	int n,a,b;
	int ma,mi;
	scanf("%d %d %d",&n,&a,&b);
	ma=min(a,b);
	if(n-a-b<0)mi=abs(n-a-b);
	else mi=0;
	printf("%d %d\n",ma,mi);
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
// typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 1000000007;
const lli e3 = 1 << 13;
const lli INF = 1ll << 63;

lli n;
string s;
lli dp[e3];
lli dp_[e3];

lli powl(lli x,lli r,lli mod = mod){
  lli ret = 1;
  for(;r != 0;r >>= 1){
    if(r&1 != 0) ret *= x,ret %= mod;
    x *= x,x %= mod;
  }
  return ret;
}

lli inverse(lli x,lli mod = mod){
  return powl(x,mod-2,mod);
}

int main(){
  cin >> n;
  cin >> s;
  dp[0] = 1;
  for(lli i = 0;i < n;i++){
    for(lli j = 0;j <= n;j++){
      dp_[j+1] += dp[j];
      dp_[j+1] += dp[j];
      dp_[max(j-1, 0ll)] += dp[j];
    }

    for(lli j = 0;j <= n;j++){
      dp[j] = dp_[j]%mod;
      dp_[j] = 0;
    }
  }
  cout << (dp[s.size()]*inverse(powl(2,(lli)(s.size()))))%mod << endl;

}


Measured memory_bytes: 384
L,R = map(int,input().split())
k = 0
m = float("inf")
for i in range(L,R+1):
    k += 1
    if k >= 2019**2 + 1:
        break
    for j in range(i+1,R+1):
        m = min(m,(i*j)%2019)
        if m == 0:
            break
print(m)

Measured memory_bytes: 40684
N = int(input())
A = list(map(int, input().split()))
A.sort()
P = sum([1 for a in A if a >= 0])
Q = N - P
if P == 0:
    P = 1
    Q = N - 1
elif Q == 0:
    P = N - 1
    Q = 1

# print(P, Q)
ans = []
for y in range(Q, N - 1):
    ans.append((A[0], A[y]))
    A[0] = A[0] - A[y]

for y in range(Q):
    ans.append((A[N - 1], A[y]))
    A[N - 1] = A[N - 1] - A[y]

print(A[N - 1])
for x in ans:
    print(*x)


Measured memory_bytes: 19588
#include <math.h>

#include <algorithm>
#include <cassert>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  long long N, K;
  cin >> N >> K;

  long long a = N % K;

  long long b = abs(a - K);

  if (a > b)
    cout << b << endl;
  else
    cout << a << endl;
}


Measured memory_bytes: 3608
package main

import (
	"fmt"
)

func main() {


	var N int

	fmt.Scan(&N)

	A := make([]int,N)

	for i:=0;i<N;i++{

		fmt.Scan(&A[i])
	}


	for i:=0;i<N;i++{

		if A[i]%2==0{

			if A[i]%3 !=0 && A[i]%5 !=0{

				fmt.Println("DENIED")
				return
			}
		}
	}

	fmt.Println("APPROVED")

}

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

class Program {
    static void Main() {
        while (true) {
            var n = int.Parse(Console.ReadLine());
            if (n == 0)
                break;

            var sales = new long[4000];
            var ids = new List<int>();

            for (var i = 0; i < n; i++) {
                var l = Console.ReadLine().Split(' ');

                var id = int.Parse(l[0]);
                if (sales[id - 1] == 0) {
                    ids.Add(id);
                }
                long proceeds = long.Parse(l[1]) * int.Parse(l[2]);
                sales[id - 1] += proceeds;
            }

            var found = false;
            foreach (var id in ids) {
                if (sales[id - 1] >= 1000000) {
                    found = true;
                    Console.WriteLine(id);
                }
            }
            if (!found) {
                Console.WriteLine("NA");
            }
        }
    }
}

Measured memory_bytes: 9416
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


#隣接リスト 1-order
def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append([edge[1], edge[2]])
        res[edge[1]].append([edge[0], edge[2]])
    return res


def main():
    N = NI()
    edges = [NLI() for _ in range(N-1)]
    graph = make_adjlist_nond(N, edges)
    colors = [0]*(N+1)

    def dfs(node, prev):
        for goto, dist in graph[node]:
            if goto == prev:
                continue
            colors[goto] = 1 - colors[node] if dist % 2 else colors[node]
            dfs(goto, node)

    dfs(1, 0)
    print("\n".join(map(str, colors[1:])))


if __name__ == "__main__":
    main()

Measured memory_bytes: 108316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i,l,r) for(int i=l;i<=r;i++)
signed main()
{  // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    double p[n+1];
    for(int i=1;i<=n;i++)cin>>p[i];
    double pr[n+1][n+1];

    for(int i=1;i<=n;i++)
    {
      for(int j=0;j<=i;j++)
      {  if(i==1 || j==0){
        if(i==1){pr[1][0]=(1-p[1]);
                  pr[1][1]=p[1];}
        if(j==0 && i!=1)
          pr[i][j]=pr[i-1][j]*(1-p[i]);
        
      }
        else 
        pr[i][j]=pr[i-1][j-1]*p[i]+pr[i-1][j]*(1-p[i]);
      }

      
    }
   double sum=0;
    for(int i=n/2+1;i<=n;i++)sum+=pr[n][i];

      cout<<setprecision(11)<<sum<<endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,m;

int main(){
    while(cin >> n >> m && n){
        ll MAX[10001] = {};
        ll MIN[10001] = {};
        rep(i,m){
            ll s,k;
            cin >> s >> k;
            rep(j,k){
                ll num;
                cin >> num;
                num--;
                if(k == 1)MIN[num] += s;
                MAX[num] += s;
            }
        }
        ll ans = 0;
        rep(i,n){
            rep(j,n){
                if(i != j)ans = max(ans,MAX[i] - MIN[j]);
            }
        }
        cout << ans + 1 << endl;
    }
}


Measured memory_bytes: 3232
function main(input){
    lines = input;

    var count=0;
    var cou=0;
    var t = lines.length;
    for(var i=0;i<t;i++){
        var a=lines.charAt(i);
        if(a=="W"){
            count+=cou;
        }else{cou++;}
    }

    console.log(count);
}

main(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 7372
#include<stdio.h>

int n,A[2000];

int solve(int i, int m){
  if(m == 0)return 1;
  if(i >= n)return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main(){

  int i,q,m;

  scanf("%d", &n);  
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d", &q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if (solve(0,m))printf("yes\n");
    else printf("no\n");
  }

  return 0;
}








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

int isPrime(int n) {
    int i;
    if (n < 2) return 0;
    else if (n == 2) return 1;
    if (n%2 == 0) return 0;
    for (i = 3; i <= n/i; i+=2) {
        if (n%i == 0) return 0;
    }
    return 1;
}

int main() {
    int n, m, count = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> m;
        if (isPrime(m)) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1160
a, b = map(int, input().split())
c = [list(input()) for _ in range(a)]
d = [[0] * b for _ in range(a)]

for i in range(len(c)):
    for j in range(len(c[i])):
        if c[i][j] == "#":
            for k in range(max(0, i - 1), min(a, i + 2)):
                for l in range(max(0, j - 1), min(b, j + 2)):
                    if c[k][l] != "#":
                        d[k][l] += 1
for i in range(a):
    e = ""
    for j in range(b):
        if c[i][j] == "#":
            e += c[i][j]
        else:
            e += str(d[i][j])
    print(e)


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

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

	double v;
	while(cin >> v){

		double t = v / 9.8;	// 2.59...
		double y = t * t * 4.9; // 

		/*// y = n * 5 - 5
		int n = 0;
		if(int(y + 5) % 5 == 0) n = (y + 5) / 5;
		else n = (y + 5) / 5 + 1;
		*/

		int n = 1;
		while(n * 5 - 5 < y){
			++n;
		}
		cout << n << endl;
	}

	return 0;
}

Measured memory_bytes: 1232
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i;
        for(i=1;;i++){
            int x = sc.nextInt();
            if(x == 0) break;
            System.out.printf("Case %d: %d\n",i,x);
        }
    }
}



Measured memory_bytes: 74252
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=m/10000;i>=0;i--){
    for(int j=(m-i*10000)/5000;j>=0;j--){
      int k=n-i-j;
      if(i*10000+j*5000+k*1000==m){
        cout<<i<<" "<<j<<" "<<k;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1";
}

Measured memory_bytes: 256
n, m = map(int, input().split())

if m == 0:
  if n == 1:
    print(0)
  elif n == 2:
    print(10)
  else:
    print(100)
else:
    sc = [list(map(int, input().split())) for i in range(m)]

    k = 0

    ans = [-5] * n

    for i in range(m):
        if ans[sc[i][0] - 1] == -5:
            ans[sc[i][0] - 1] = sc[i][1]
        elif ans[sc[i][0] - 1] != sc[i][1]:
            k = 1

    if k == 1:
        print(-1)
    elif ans[0] == 0:
        if n == 1:
            print(0)
        else:
            print(-1)
    else:
        for i in range(n):
            if ans[i] == -5:
                ans[i] = 0
        if ans[0] == 0:
            ans[0] = 1
        ans = [str(i) for i in ans]
        ans = "".join(ans)
        print(int(ans))



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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	string s[100], t[100];
  ll j, n, m, result = 0;
  cin >> n;
  rep(i, n) cin >> s[i];
  cin >> m;
  rep(i, m) cin >> t[i];

  rep(i, n) {
    ll sum = 0;
    for(j = 0; j < n; j++) {
      if (s[i] == s[j]) sum++;
    }
    rep(k, m) {
      if (s[i] == t[k]) sum--;
    }
    if (result < sum) result = sum;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,mx(0);
  string ans;
  cin >> n;
  
  vector<string> a(n),b(n);
  for(int i = 0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  b = a;
  b.erase(unique(b.begin(),b.end()),b.end());
  vector<int>cnt(b.size());
  int j(0);
  for(int i = 0;i<b.size();i++){
    while(j<n && b.at(i) == a.at(j)){
      cnt.at(i)++;
      j++;
      mx = max(mx,cnt.at(i));
    }
  }
  for(int i = 0;i<b.size();i++){
    if(cnt.at(i) == mx){
      cout << b.at(i) << endl;
    }
  }
}

Measured memory_bytes: 16640
n = int(input())
a=[]

b = list(map(int, input().split()))
for i in range(n):
    a+=[[i+1, b[i]] ]
    
    
import operator as op
a.sort(key = op.itemgetter(1))

x=""
for i in range(n):
    x+=str(a[i][0])
    if i!=n-1:
        x+=" "

print(x)


Measured memory_bytes: 22628
#include <bits/stdc++.h>
#define MAX (ll)(1e5 + 4)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int n;
ld min_rad (ld x, ld y, pair<ld, ld> aa[]) {
	ld ma = 0;
	for (int i = 0; i < n; i++) {
		ld xx = aa[i].first - x, yy = aa[i].second - y;
		ma = max (xx * xx + yy * yy, ma);
	}
	return ma;
}

ld fy (ld x, pair<ld, ld> aa[]) {
	ld l = 0, h = 1000, mu = 1e9;
	while (h - l > 1e-8) {
		ld d = (h - l)  / 3;
		ld m1 = l + d, m2 = h - d;
		ld f1 = min_rad (x, m1, aa), f2 = min_rad (x, m2, aa);
		if (f1 > f2) {
			l = m1;
		}
		else if (f1 < f2) {
			h  = m2;
		}
		else {
			l = m1, h = m2;
		}
		mu = min (f1, f2);
	}
	return min_rad (x, l, aa);
}
		
	
int main () {
	cin >> n;
	pair<ld, ld> ar[n];
	for (int i = 0; i < n; i++) {
		cin >> ar[i].first >>  ar[i].second ;
	}
	ld rr = 1e9, lx = 0, hx = 1000;
	while (hx - lx > 1e-8) {
		ld dx = (hx - lx) / 3;
		ld m1 = lx + dx, m2 = hx - dx;
		ld f1 = fy (m1, ar), f2 = fy (m2, ar);
		if (f1 > f2) {
			lx = m1;
		}
		else if (f2 > f1) {
			hx = m2;
		}
		else {
			lx = m1;
			hx = m2;
		}
	}
	cout << fixed << setprecision (9) << sqrt (fy (lx, ar))<< "\n";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
  int count=0,len,i;
  char a[300000],b[300000];

scanf("%s",a);
scanf("%s",b);
len = strlen(a);
for(i=0;i<len;i++)
{
  if(a[i] != b[i])
  {
    count++;
  }
}
printf("%d",count);
return 0;
}

Measured memory_bytes: 2132
from collections import deque
N,M=map(int,input().split())
table=[[] for i in range(N)]
Lin=[0]*N
for i in range(N-1+M):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    Lin[b]+=1
    table[a].append(b)
M=[0]*N
H=deque()
s=-1
for i in range(N):
    if Lin[i]==0:
        s=i
        break
H.append(s)
while H:
    x=H.popleft()
    for y in table[x]:
        Lin[y]-=1
        if Lin[y]==0:
            M[y]=x+1
            H.append(y)
print('\n'.join(map(str,M)))



Measured memory_bytes: 73760