akhauriyash/Code-Regression huggingface dataset:
use std::collections::HashMap;

fn readone() -> String {
    let reader = std::io::stdin();
    let mut line = String::new();
    let _l = reader.read_line(&mut line);
    while line.ends_with('\n') || line.ends_with('\r') {
    line.pop();
    }
    return line;
}

fn main() {
    let mut rights = HashMap::new();
    rights.insert('y', true);
    rights.insert('u', true);
    rights.insert('i', true);
    rights.insert('o', true);
    rights.insert('p', true);
    rights.insert('h', true);
    rights.insert('j', true);
    rights.insert('k', true);
    rights.insert('l', true);
    rights.insert('n', true);
    rights.insert('m', true);
    loop {
        let a = readone();
        if a == "#" {
            break;
        }
        let mut cnt = 0;
        let mut first : bool = true;
        let mut isright : bool = true;
        for char in a.chars(){
            // println!("{}", char);
            if first {
                first = false;
                isright = rights.contains_key(&char);
            } else {
                let nxt : bool = rights.contains_key(&char);
                if nxt != isright {
                    cnt = cnt + 1;
                }
                isright = nxt;
            }
        }
        println!("{}", cnt);
    }
}



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

const ll mod = 998244353;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll res = 1;
	for (int i = 0; i < N; i++) {
		res = (res * __gcd(a[i], i)) % mod;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
const int INF=1e9;

int main(){
    string s;cin>>s;
    ll k;cin>>k;
    ll ans=0;
    int c=1;
    int n=s.size();
  bool flag=true;
  for(int i=0;i<n-1;i++)if(s[i]!=s[i+1]){
    flag=false;break;
  }
  if(flag){
    cout<<n*k/2<<endl;
    return 0;
  }
    vector<int> cnt;
    for(int i=0;i<n;i++){
        if(i+1<n&&s[i]==s[i+1]) c++;
        else{
            ans+=c/2;
            cnt.push_back(c);
            c=1;
        }
    }
    ans*=k;
    if(s[0]==s[n-1]){
        ans=ans-(cnt.front()/2+cnt.back()/2-(cnt.front()+cnt.back())/2)*(k-1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a,mx;
    cin>>n>>k;
    vector<int>v;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());

    for(int i=0;i<n-k+1;i++)
    {int dif;
    dif=abs(v[i]-v[i+k-1]);

if(i==0)
{
   mx=dif;
}
else if(mx>dif){mx=dif;}
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 892
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n;
    cin>>n;
    vector<int> type(n+2);
    vector<int> height(n+2);
    
    type[0] = 1;
    height[0] = INF/2;
    type[1] = 0;
    height[1] = INF;
    
    rep(i,n){
        char ch;
        int h;
        cin>>ch>>h;
        type[i+2] = (ch=='y'?1:0);
        height[i+2] = h;
    }
    
    vector<int> v;
    
    int ntype = -1;
    int nh = -1;
    rep(i,type.size()){
        if(ntype==-1){
            ntype = type[i];
            nh = height[i];
        }else if(type[i]==ntype){ //same type
            if(ntype==1)    nh = min(nh,height[i]);
            else            nh = max(nh,height[i]);
        }else{  //different type
            v.pb(nh);
            
            ntype = type[i];
            nh = height[i];
        }
    }
    v.pb(nh);
    
    int ans = 0;
    vector<bool> used(v.size(),0);
    int less = (v.size()+1)/2;
    while(less){
        int mini = INF;
        int pos = -1;
        for(int i=0;i<v.size();i+=2){
            if(mini>v[i] && used[i]==false){
                mini = v[i];
                pos = i;
            }
        }
        assert(pos!=-1);
        
        ans++;
        used[pos] = true;
        less--;
        
        int l = pos, r=pos;
        while(l-2>=0 && v[l-1]<v[pos]){
            l-=2;
            if(v[l]>=v[pos] && !used[l]){
                less--;
                used[l] = true;
            }
        }
        while(r+2<v.size() && v[r+1]<v[pos]){
            r+=2;
            if(v[r]>=v[pos] && !used[r]){
                less--;
                used[r] = true;
            }
        }
        //        cout<<pos<<" "<<l<<" "<<r<<endl;
        
    }
    cout<<ans-1<<endl;
    
}



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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll n;
	cin >> n;

	vector<ll> a, b, c;
	rep(i,n) {
		ll t;
		cin >> t;
		a.push_back(t);
	}
	rep(i,n) {
		ll t;
		cin >> t;
		b.push_back(t);
	}
	rep(i,n) {
		ll t;
		cin >> t;
		c.push_back(t);
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	ll t[n+1], u[n+1], v[n+1];

	t[n] = 0;
	u[n] = 0;
	v[n] = 0;
	rep(i,n) v[i] = 1;
	rrep(i,n-1) v[i] = v[i] + v[i+1];

	rep(i,n){
		ll x = b[i];
		auto y = upper_bound(c.begin(), c.end(), x);
		u[i] = v[distance(c.begin(), y)];
	}
	rrep(i,n-1) u[i] = u[i] + u[i+1];

	rep(i,n){
		ll x = a[i];
		auto y = upper_bound(b.begin(), b.end(), x);
		t[i] = u[distance(b.begin(), y)];
	}
	rrep(i,n-1) t[i] = t[i] + t[i+1];

	cout << t[0] << endl;	
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  int A, B;
  A = 0;
  B = 0;
  
  for ( int i = 0; i < b; i++ ) {
    A = A * 10 + a;
  }
  
  for ( int i = 0; i < a; i++ ) {
    B = B * 10 + b;
  }
  
  if ( a < b ) {
    cout << A << endl;
  }
  
  else {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
from sys import stdin
import math

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])

    return arr


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    X = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    X_fac = make_divisors(X)
    flag = False
    for fac in X_fac:
        A = math.ceil(fac/2)
        while True:
            B = A-fac
            if X == A**5-B**5:
                s = f'{A} {B}'
                flag == True
                break
            else:
                if A**5-B**5>X:
                    break
            A += 1
        if flag:
            break
    if flag==False:
        for fac in X_fac:
            A = math.ceil(fac/2)
            while True:
                B = A-fac
                if X == A**5-B**5:
                    s = f'{A} {B}'
                    flag == True
                    break
                else:
                    if A**5-B**5>X:
                        break
                A -= 1
            if flag:
                break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(s)


Measured memory_bytes: 64848
/*
AtCoderBeginnerContest168
Problem D - .. (Double Dots) / Double Dots
Time Limit: 2 sec / Memory Limit: 1024 MB
Score: 400 points
*/

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

std::vector< std::vector<int> > conns;
std::vector<int> signs;
std::queue<int> q;

int main()
{
    int N, M;
    std::cin >> N >> M;
    for (int i=0; i<=N; i++) { conns.push_back(std::vector<int>()); }
//std::cerr << "size of conns: " << conns.size() << "\n";

    int A, B;
    for (int i=0; i<M; i++)
    {
        std::cin >> A >> B;
        conns[A].push_back(B);
        conns[B].push_back(A);
    }

    for (int i=0; i<=N; i++) { signs.push_back(-1); }

    q.push(1);
    while(!q.empty())
    {
        int curr = q.front();
        q.pop();
//not needed, but gives exact match to sample output and shouldn't kill the timing
std::sort(conns[curr].begin(), conns[curr].end());
        for (int i=0; i<conns[curr].size(); i++)
        {
            int next = conns[curr][i];
            if (signs[next]==-1)
            {
                q.push(next);
                signs[next] = curr;
            }
        }
    }
    std::cout << "Yes\n";
    for (int i=2; i<=N; i++)
    {
        std::cout << signs[i] << "\n";
    }
}


Measured memory_bytes: 10368
K = int(input())

import queue

q = queue.Queue()
initial_number = [1,2,3,4,5,6,7,8,9]
for i in initial_number:
    q.put(i)

count = 0
while True:
    x = q.get()
    count += 1
    if count == K:
        print(x)
        break
    if x % 10 != 0:
        q.put(10 * x + (x % 10) - 1)
    q.put(10 * x + (x % 10))
    if x % 10 != 9:
        q.put(10 * x + (x % 10) + 1)

Measured memory_bytes: 12452
const M: usize = 1000_000_007;

fn main() {
    proconio::input! {
        s: usize,
    }

    if s >= 3 {
        if s >= 6 {
            let mut dp = vec![0; s + 1];
            dp[3] = 1;
            dp[4] = 1;
            dp[5] = 1;
            for i in 6..=s {
                dp[i] = (dp[i - 1] + dp[i - 3]) % M;
            }
            println!("{}", dp[s]);
        } else {
            println!("1");
        }
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2160
#include <iostream>
using namespace std;
int main() {
    int d;
    cin >> d;
    cout << "Christmas";
    if(d == 25){
        cout << endl;
    }else if(d == 24){
        cout << " Eve" << endl;
    }else if(d == 23){
        cout << " Eve Eve" << endl;
    }else if(d == 22){  
        cout << " Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 256
w,h,n=map(int,input().split())
X=Y=0
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1 and X<x:
    X=x
  if a==2 and w>x:
    w=x
  if a==3 and Y<y:
    Y=y
  if a==4 and h>y:
    h=y

print(max(w-X,0)*max(h-Y,0))

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

int main(){
  int n,t,a; cin >> n>>t>>a;
  vector<int> h(n);
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  double min_sub =abs( a - (t - h[0]*0.006) );
  int ans = 1;
  for( int i=0; i<n; i++){
    if( abs( a - (t - h[i]*0.006) ) < min_sub){
      min_sub = abs( a- (t - h[i]*0.006) );
      ans = i+1;
    }
  }
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

int main() {
  int n, lim;
  std::cin >> n >> lim;
  std::vector<int> v(n);
  for(int i = 0; i < n; i++)
    std::cin >> v[i];
  std::sort(v.begin(), v.end());
  int result = 0;
  for(int i = 0;i < n; i++) {
    if(v[i] <= lim) {
      lim -= v[i];
      result++;
    }
  }
  if(result < n || 0 == lim)
    std::cout << result;
  else
    std::cout << n - 1;
}


Measured memory_bytes: 3536
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    a,b,c=input().split()
    YESNO(a[-1]==b[0] and b[-1]==c[0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N, Q = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = [int(i) - 1 for i in input().split()]
        G[a].append(b)
        G[b].append(a)
    A = [0] * N  # 頂点数分だけ準備する
    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        A[p] += x
    que = deque([[-1, 0]])
    while que:
        par, vi = que.popleft()
        for vj in G[vi]:
            if vj == par:  # 探索が親の時はスルー
                continue
            A[vj] += A[vi]  # 数値を追加する
            que.append([vi, vj])  # queに(親，子)を追加する
    print(*A)


if __name__ == '__main__':
    main()

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

int main()
{
    int N;
    bool flag = false;
    string S;

    cin >> N;

    for (int count = 0; count < N; count++)
    {
        cin >> S;
        if (S == "Y")
        {
            flag = true;
            break;
        }
    }

    if (flag)
    {
        cout << "Four" << endl;
    }
    else
    {
        cout << "Three" << endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  int guest_num = 0;
  for (int i = 0; i < n; i++) {
    int start, end;
    cin >> start >> end;
    guest_num += (end - start + 1);
  }
  
  cout << guest_num << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n, f[310][310], ans;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> f[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ll res = 11000000000;
            if (i == j) continue;
            for (int k = 0; k < n; k++) {
                if (i == k || j == k) continue;
                res = min(res, f[i][k] + f[j][k]);
            }
            if (res < f[i][j]) {
                    cout << -1 << endl;
                    return 0;
            } if (res > f[i][j]) {
                ans += f[i][j];
            }
        }
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 1024
import numpy as np
n,w=map(int,input().split())
wv=[]
for _ in range(n):
    wv.append(list(map(int,input().split())))
dp=np.full(100001,w+1) # dp[j]:価値総和jをちょうど実現できる最小の重さ総和
dp[0]=0
for i in range(n):# i番目までの商品について全ての重さについて調べる
    w_=wv[i][0]
    v_=wv[i][1]
    dp[v_:]=np.minimum(dp[v_:],dp[:-v_]+w_)

print(np.where(dp<=w)[0][-1])


Measured memory_bytes: 14944
#include <stdio.h>
int main()
{
    int n;  scanf("%d", &n);
    int flag = -1;
    for(int i=1; i<=9; i++)
    {
        if(n%i==0 && ((n/i)/10)==0)
            flag = 1;
    }
    if(flag==1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

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

int main(void) {
    long long int n;
    long long int count=0;
    long long int point=0;

    cin>>n;
    vector<long long int> a(n+2),b(n+1);

    FOR(i,1,n+1){
        cin>>a[i];
    }
    FOR(i,1,n){
        cin>>b[i];
    }

    FOR(i,1,n){
        if(b[i]<a[i]){
            count+=b[i];
        }else{
            count+=a[i];
            b[i]-=a[i];
            if(b[i]<a[i+1]){
                count+=b[i];
                a[i+1]-=b[i];
            }else{
                count+=a[i+1];
                a[i+1]=0;
            }
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int a[n], b[n], c[n];
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n - 1) cin >> c[i];

  int ans = b[a[0] - 1];
  for (int i = 1; i < n; i++) {
    ans += b[a[i] - 1];
    if (a[i] == (a[i - 1] + 1))
      ans += c[a[i] - 2];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

food = [int(input()) for i in range(5)]

minr = 10
minf = 0
for f in food:
    if f % 10 != 0 :
        if f % 10 < minr :
            minr = f % 10
            minf = f
if minf == 0:
    minf = food[0]
        

food.remove(minf)
food.append(minf)

sumf = 0
i = 0
for f in food:
    if i == 4:
        sumf += f
    elif f % 10 != 0:
        sumf += int(f/10) * 10 + 10
    else:
        sumf += f
    i+=1
print(sumf)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n, k;
	cin >> n >> k;
	rep(i, k) {
		int a;
		cin >> a;
		n -= a;
	}
	int ans = (n < 0) ? -1 : n;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
s = raw_input().split(' ')
st = []
for i in s:
    if i.isdigit():
        st.append(int(i))
    elif i == '+':
        tmp1 = st.pop()
        tmp2 = st.pop()
        st.append(int(tmp1 + tmp2))
    elif i == '-':
        tmp1 = st.pop()
        tmp2 = st.pop()
        st.append(int(tmp2 - tmp1))
    elif i=='*':
        tmp1 = st.pop()
        tmp2 = st.pop()
        st.append(int(tmp1 * tmp2))
print st[0]

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

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

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

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

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

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	double c;
	cin>>a>>c;
	b=round(c*100);
	puta(a*b/100);
}


Measured memory_bytes: 3752
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Arrays;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
           int ans[][][]=new int[4][3][10];
           for(int k=0;k<4;k++){
           for(int i=0;i<3;i++){
               for(int j=0;j<10;j++){
                ans[k][i][j]=0;
               }
           }
        }
           int n=sc.nextInt();
           for(int i=0;i<n;i++){
            int b,f,r,v;
            b=sc.nextInt();
            f=sc.nextInt();
            r=sc.nextInt();
            v=sc.nextInt();
            --b;--f;--r;
            ans[b][f][r]+=v;
           }
           
           for(int k=0;k<4;k++){
            for(int i=0;i<3;i++){
                for(int j=0;j<10;j++){
                 if(j!=9)System.out.print(" "+ans[k][i][j]); 
                else System.out.println(" "+ans[k][i][j]); 
                }
            }
          if(k!=3)  System.out.println("####################");
        }
          
}
}



Measured memory_bytes: 29268
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int to,costa,costb;};

signed main() {
 int n;
 cin>>n;
 int x[n+1]={},a;
 for(int i=0;i<n;i++){
     cin>>a;
     x[a]++;
 }
priority_queue<int> v;
for(int i=1;i<=n;i++)if(x[i]!=0)v.push(x[i]);

int m=n,j=0;
for(int i=1;i<=n;i++){
    while(!v.empty()&&m/(i-j)<v.top()){
        m-=v.top();
        v.pop();
        j++;
    }
    cout<<m/(i-j)<<endl;
}


return 0;
}


Measured memory_bytes: 8688
// 5/28
// 2-5-4 ベルマンフォード
// 類題
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;

struct Edge {
    int from;
    int to;
    int cost;
    Edge(int f, int t, int c) : from(f), to(t), cost(c) { }
    bool operator<(const Edge& o) const {
        return cost < o.cost;
    }
};
using Graph = vector<Edge>;

vector<int> bellman_ford(int N, Graph& es, int s) {
    // 初期化
    vector<int> d(N, INF);
    d[s] = 0;
    bool have_negative_loop = false;

    // 辺の緩和を反復
    rep(i, N) {
        for (auto e : es) {
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (i == N - 1) {
                    have_negative_loop = true;
                    break;
                }
            }
        }
    }

    // ネガティブループが存在する場合は全ての値を-1にする。
    // スタート地点の値でチェックする。
    if (have_negative_loop) d.assign(N, -1);
    return d;
}

int main() {
    int N;  // 与えられた有向グラフの頂点の数
    int M;  // 同辺の数（辺の重みは負の場合がある）
    int s;  // 最短経路の始点
    cin >> N >> M >> s;

    vector<Edge> es;
    rep(i, M) {
        int from;  // 辺の始点の番号（0始まり）
        int to;  // 辺の終点の番号（0始まり）
        int d;  // 重み
        cin >> from >> to >> d;
        es.push_back(Edge(from, to, d));
    }

    vector<int> d;  // 始点sからの最短経路の距離を格納
    d = bellman_ford(N, es, s);

    // negative cycleがある場合（＝収束しない）は-1を出力する。
    if (d[s] == -1) cout << "NEGATIVE CYCLE" << endl;

    // 各頂点の最短距離を出力する。経路が存在しない場合はINFと出力する。
    else {
        rep(i, N) {
            if (d[i] == INF) cout << "INF" << endl;
            else cout << d[i] << endl;
        }
    }
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<vector<vector<char> >,int> P;
const long long int MOD = 1000000007;
const int INF = 1000000000;

int n;
map<P, int> m;
int dx[8] = {1,0,-1,1,-1,1,0,-1};
int dy[8] = {1,1,1,0,0,-1,-1,-1};

bool check(vector<vector<char> > hoge){
    int cnt = 0;
    rep(i,hoge.size()){
        rep(j,hoge[i].size()){
            if(hoge[i][j] == '#'){
                cnt++;
            }
        }
    }
    if(cnt == 0) return true;
    else return false;
}

P simulate(vector<vector<char> > bo, int x, int y){
    rep(i,bo.size()){
        rep(j,bo[i].size()){
            if(bo[i][j] == '@'){
                bo[i][j] = '.';
            }
        }
    }
    bo[x][y] = '@';
    P ret;
    ret.second = x*n+y;
    ret.first = bo;
    rep(i,bo.size()){
        rep(j,bo[i].size()){
            if(i == x && j == y) continue;
            int sur = 0;
            if(bo[i][j] == '.'){
                rep(k,8){
                    if(0>i+dx[k]||i+dx[k]>=n||0>j+dy[k]||j+dy[k]>=n) continue;
                    if(bo[i+dx[k]][j+dy[k]] != '.'){
                        sur++;
                    }
                }
                if(sur == 3) ret.first[i][j] = '#';
            } else{
                rep(k,8){
                    if(0>i+dx[k]||i+dx[k]>=n||0>j+dy[k]||j+dy[k]>=n) continue;
                    if(bo[i+dx[k]][j+dy[k]] != '.'){
                        sur++;
                    }
                }
                if(sur != 2 && sur != 3) ret.first[i][j] = '.';
            }
        }
    }
    return ret;
}

void solve(){
    vector<vector<char> > b;
    int now = 0;
    rep(i,n){
        vector<char> hoge;
        rep(j,n){
            char tmp;
            cin >> tmp;
            if(tmp == '@') now = i*n+j;
            hoge.push_back(tmp);
        }
        b.push_back(hoge);
    }
    m.clear();
    m[P(b,now)] = 0; 
    queue<P> que;
    que.push(P(b,now));
    while(!que.empty()){
        P p = que.front();
        vector<vector<char> > bo = p.first;
        if(check(bo)){
            cout << m[p] << endl;
            return;
        }
        que.pop();
        int nx = p.second/n, ny = p.second%n;
        rep(i,8){
            if(0>nx+dx[i]||nx+dx[i]>=n||0>ny+dy[i]||ny+dy[i]>=n) continue;
            if(bo[nx+dx[i]][ny+dy[i]] != '.') continue;
            P neb = simulate(bo,nx+dx[i],ny+dy[i]);
            if(m.count(neb)) continue;
            m[neb] = m[p]+1;
            que.push(neb);
        }
    }
    cout << -1 << endl;
}

int main(){
    while(cin >> n){
        if(n == 0) break;
        solve();
    }
}

Measured memory_bytes: 16828
using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            int inputCount = 0;

            var residents = new List<String>();

            while (true)
            {
                String s = Console.ReadLine();
                inputCount++;
                residents.Add(s);

                if (inputCount == num)
                {
                    break;
                }
            }

            int[,,] address = new int[4, 3, 10];

            for (int i = 0; i < residents.Count; i++)
            {
                String s = residents[i];
                String[] array = s.Split();
                int building = (int.Parse(array[0])) - 1;
                int floor = (int.Parse(array[1])) - 1;
                int room = (int.Parse(array[2])) - 1;
                int human = int.Parse(array[3]);

                int oldCountHuman = (int)address.GetValue(building, floor, room);

                int newCountHuman = human + oldCountHuman;

                address[building, floor, room] = newCountHuman;
            }

            int count = 0;

            foreach (int value in address)
            {
                Console.Write(" " + value);
                count++;
                if (count % 10 == 0) 
                {
                    Console.WriteLine("");
                    if (count % 30 == 0 && count <= 90)
                    {
                        Console.WriteLine("####################");
                    }
                }
            }
        }
    }
}


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

using namespace std;

struct Edge {
    int src, dst, len;
    Edge(int src, int dst, int len) : src(src), dst(dst), len(len) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

class TravelingByStagecoach {
public:
    TravelingByStagecoach(int n, int m, int p, int a, int b) :
        n(n), m(m), p(p), a(a - 1), b(b - 1), t(n), g(m) { }
    void Input();
    double Solve();

private:
    int n, m, p, a, b;
    vector<int> t;
    Graph g;
};

void TravelingByStagecoach::Input() {
    for (int i = 0; i < n; ++i) cin >> t[i];

    int x, y, z;
    for (int i = 0; i < p; ++i) {
        cin >> x >> y >> z;
        g[x - 1].emplace_back(Edge(x - 1, y - 1, z));
        g[y - 1].emplace_back(Edge(y - 1, x - 1, z));
    }
}

double TravelingByStagecoach::Solve() {
    const int size = 1 << n;
    vector<vector<double>> dp(m, vector<double>(size, -1.0));
    queue<pair<int, int>> que;

    dp[a][0] = 0.0;
    que.push(make_pair(0, a));
    while (!que.empty()) {
        auto cur = que.front();
        que.pop();
        int src = cur.second, visited = cur.first;

        for (auto e : g[src]) {
            int dst = e.dst;
            double len = e.len;

            // src ?????? dst ??? ??¬??????i????????£????§??????????
            for (int i = 0; i < n; ++i) {
                if (visited >> i & 1) continue;

                if (dp[dst][visited | 1 << i] == -1 || dp[src][visited] + (len / t[i]) < dp[dst][visited | 1 << i]) {
                    dp[dst][visited | 1 << i] = dp[src][visited] + (len / t[i]);
                    que.push(make_pair(visited | 1 << i, dst));
                }
            }
        }
    }

    double min_len = 100 * 31;;
    for (int s = 0; s < size; ++s)
        if (0 < dp[b][s]) min_len = min(min_len, dp[b][s]);

    // for (int v = 0; v < m; ++v) {
    //     for (int s = 0; s < size; ++s) {
    //         cout << "dp[" << v << "][" << s << "] = " << dp[v][s] << endl;
    //     }
    // }

    return (min_len == 100 * 31 ? -1 : min_len);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
     cout << setprecision(4) << setiosflags(ios::fixed); // printf("%.4f", x);

     int n, m, p, a, h;
     while (cin >> n >> m >> p >> a >> h, n) {
         TravelingByStagecoach tbs(n, m, p, a, h);
         tbs.Input();
         double len = tbs.Solve();
         if (len == -1) cout << "Impossible\n";
         else cout << len << "\n";
     }

    return 0;
}

Measured memory_bytes: 3408
use proconio::{input, fastout};
use proconio::marker::{Chars};
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        _s: Chars,
    }

    let mut dp: Vec<i64> = Vec::new();
    for i in 0.._s.len()-2 {
        let s: String = _s.iter().collect();
        let s1 = &s[i..i+3];
        let num: i64 = s1.parse().unwrap();
        debug!(num);
        dp.push((num-753).abs());
    }
    dp.sort();
    println!("{}", dp[0]);
}


Measured memory_bytes: 2200
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int h,w;
string a[128];

int main(){
    cin >> h >> w;
    rep(i,h) cin >> a[i];
    string t(w+2,'#');
    cout << t << endl;
    rep(i,h){
        cout << "#" << a[i] << "#" << endl;
    }
    cout << t << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
     int a,b,c,d,y,z;
     scanf("%d %d %d %d",&a,&b,&c,&d);
     y=a+b;
     z=c+d;
     if(y>z)
                printf("Left\n");
     else if(y<z)
                printf("Right\n");

     else if(y==z)
                printf("Balanced\n");

    return 0;
}


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

int main(){
        int i,x,idx,m;
        cin >> x;
        vector<int> v(1000000);
        for(i=2;i<1000;++i){
                if(v.at(i)==0){
                        idx = i;
                        m = 2;
                        while(idx*m<1000000){
                                v.at(idx*m) = 1;
                                ++m;
                        }
                }
        }
        for(i=x;i<1000000;++i){
                if(v.at(i)==0){
                        cout << i << endl;
                        break;
                }
        }
        return 0;
}

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

int main(int argc, char *argv[]) {
  int N;
  cin >> N;
  if(N == 0) {
    cout << '0' << endl;
    return 0;
  }
  string S;
  while(N != 0) {
    if(N % 2 == 0) {
      S = '0' + S;
    } else {
      N--;
      S = '1' + S;
    }
    N /= -2;
  }
  cout << S << endl;
  return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> cards(n);
    rep(i, n) {
        int x;
        cin >> x;
        cards[x - 1]++;
    }

    sort(cards.begin(), cards.end());
    vector<int> somes(n + 1);
    rep(i, n) somes[i + 1] = somes[i] + cards[i];
    for (int k = 1; k <= n; k++) {
        int floor = 0, ceil = n / k + 1;
        while (floor + 1 < ceil) {
            int center = (floor + ceil) / 2;
            bool ok = [&](int center) {
                int i = lower_bound(cards.begin(), cards.end(), center) - cards.begin();
                int sum_i_over = (n - i) * center;
                int sum_i_under = somes[i];
                int sum = sum_i_over + sum_i_under;

                return sum >= center * k;
            }(center);
            if (ok) floor = center; else ceil = center;
        }

        printf("%d\n", floor);
    }


}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n, a;
    cin >> n >> a;
    ll ans = n;

    srep(i,2,60){
        ll f[i];
        ll x = 1;
        rep(j,i){
            f[j] = 2;
            x *= 2;
        }
        int flag = 0;
        if(x >= n) flag = 1;
        while(flag == 0){
            rep(j,i){
                x /= f[j];
                f[j]++;
                x *= f[j];
                if(x >= n){
                    flag = 1;
                    break;
                }
            }
        }
        ll sum = 0;
        rep(j,i)sum += f[j];
        sum += a * (i - 1);
        ans = min(ans, sum);
    }

    cout << ans << endl;
}




Measured memory_bytes: 384
q,h,s,d = map(int, input().split())
n = int(input())

if n % 2 == 1:
    qua = 4 * q * n
    hal = 2 * h * n
    one = s * n
    two_1 = d * (n//2) + s
    two_2 = d * (n//2) + 2*h
    two_3 = d * (n//2) + 4*q
    
    print(min(qua, hal, one, two_1, two_2, two_3))
    
else:
    qua = 4 * q * n
    hal = 2 * h * n
    one = s * n
    two = d * (n//2)
    
    print(min(qua, hal, one, two))

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>

using namespace std;

int main(void)
{
    int h,n;
    cin >>h >>n;

    int sum = 0;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >>tmp;
        sum += tmp;
    }

    if(h > sum){
        printf("No\n");
    }else{
        printf("Yes\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;

typedef map<string, int> msi;

typedef pair<int, int> pii;
typedef pair <ll, ll> pll; // note 'single' ls

#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++)

#define pb \
push_back

#define ff \
first

#define ss \
second

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

	vi P = { -1 };

	REP(i, 1, n)
	{
		int p;
		cin >> p;
		P.pb(p);
	}

	//vvi components;
	//vi component(n+1, -1);
	//int no_components = 0;

	//REP(i, 1, m)
	//{
	//	int x, y;
	//	cin >> x >> y;

	//	// either neither are in a component

	//	if (component[x] == component[y] && component[x] == -1)
	//	{
	//		components.pb({ x, y });
	//		component[x] = no_components;
	//		component[y] = no_components;
	//		no_components += 1;

	//		continue;
	//	}

	//	// one is in a component

	//	if (component[x] == -1 || component[y] == -1)
	//	{
	//		if (component[x] == -1)
	//		{
	//			component[x] = component[y];
	//			components[component[y]].pb(x);
	//		}

	//		if (component[y] == -1)
	//		{
	//			component[y] = component[x];
	//			components[component[x]].pb(y);
	//		}

	//		continue;
	//	}

	//	// or both are in a component

	//	if (component[x] != component[y])
	//	{
	//		//component[y] = component[x];

	//		for (auto z : components[component[y]])
	//		{
	//			components[component[x]].pb(z);
	//			component[z] = component[x];
	//		}

	//		component[y] = component[x];
	//	}

	//	// if both in same component, no need to take action
	//}

	vvi adjacents(n+1);

	REP(i, 1, m)
	{
		int x, y;
		cin >> x >> y;

		adjacents[x].pb(y);
		adjacents[y].pb(x);
	}

	vb processed(n + 1);
	vi component(n + 1);
	int no_components = 0;

	REP(i, 1, n)
	{
		if (processed[i]) continue;
		processed[i] = true;

		component[i] = no_components;
		no_components += 1;

		vi bfs = { i };

		while (!bfs.empty())
		{
			vi new_bfs;

			for (auto v : bfs)
			{
				for (auto w : adjacents[v])
				{
					if (processed[w]) continue;
					processed[w] = true;

					new_bfs.pb(w);
					component[w] = component[i];
				}
			}

			bfs = new_bfs;
		}
	}

	int id_max = 0;

	REP(i, 1, n)
	{
		//cout << "i, component[i]: " << i << " " << component[i] << endl;

		if (P[i] == i || (component[i] == component[P[i]] && component[i] != -1))
		{
			id_max += 1;
		}
	}

	cout << id_max << endl;

	//cin >> n;
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int total = 700;
  total += s.at(0) == 'o' ? 100 : 0;
  total += s.at(1) == 'o' ? 100 : 0;
  total += s.at(2) == 'o' ? 100 : 0;
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 256
w,h,n=map(int,input().split())
p=0
q=w
r=0
s=h
for k in range(n):
    x,y,a=map(int,input().split())
    if a==1 and x>p:
        p=x
    if a==2 and x<q:
        q=x
    if a==3 and y>r:
        r=y
    if a==4 and y<s:
        s=y
if q-p>0 and s-r>0:
    print((q-p)*(s-r))
else:
    print(0)
    
    

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int sheep = sc.nextInt();
        int wolf  = sc.nextInt();
        String ans = "";
      
        if(wolf < sheep){
          ans = "safe";
        }else{
          ans = "unsafe";
        }
        
      	System.out.println(ans);
 
    }
}

Measured memory_bytes: 35892
s = list(str(input()))

for _ in range(len(s)//2-1):
    del s[-2:]
    cnt = 0

    for i in range(len(s)//2):
        if s[i]==s[len(s)//2+i]:
            cnt += 1

    if cnt==len(s)//2:
        break

print(len(s))

Measured memory_bytes: 3060
import sys
h,w=map(int,input().split())
l1=[]
l2=[]
a=[]
for i in range(h):
    l1.append(list(map(str,input())))
for i in range(len(l1)):
    if set(l1[i])!={'.'}:
        l2.append(l1[i])
for k in range(len(l2[0])):
    c=0
    for i in range(len(l2)):
        if l2[i][k]=='.':
            c+=1
            continue
        else:
            break
    if c!=len(l2):
        a.append(k)
for i in range(len(l2)):
    b=''
    for k in a:
        b+=l2[i][k]
    print(b)



Measured memory_bytes: 3188
/*
    quid-pro-quo: LOGIC for AC
    written by: codercell07
    LANG: C++ 11
    Problem: random
*/
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL)
#define testcases freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define ui unsigned int
#define ll long long
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sz(x) (int)x.size()
#define pq priority_queue /*maxim at top(max-heap)*/
#define pqmax priority_queue<int, vector<int>, greater<int>> /*minim at top(min-heap)*/
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define asc(x) sort(all(x))
#define desc(x) sort(all(x), greater<int>())
#define time_el (double)time/CLOCKS_PER_SEC
using namespace std;
const int MAX=2e6; //dummy, make sure change as per constraints
const ll M=1e9+7, inf=1e18;
const char nl='\n';
 
ll apbmc(ll a, ll b, ll c){ a%=c; ll res=1; while(b){ if(b&1) res=res*a%c; a=a*a%c; b>>=1; } return res;}
ll apb(ll x, ll y){ ll temp; if(y==0) return 1;  temp=apb(x, y/2); if(y%2==0) return temp*temp;  else return temp*temp*x;}
 



void solve(){   
    //clock_t time;
    int n; cin>>n;
    vector<double> p(n);
    for(double &i: p) cin>>i;
    vector<vector<double>> dp(n+1, vector<double>(n+1));
    dp[0][0]=1;
    for(int i=0; i<n; i++){
        for(int j=0; j<=i; j++){
            dp[i+1][j+1]+=dp[i][j]*p[i];
            dp[i+1][j]+=dp[i][j]*(1-p[i]);
        }
    }
    // for(int i=0; i<=n; i++){
    //     for(int j=0; j<=n; j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<nl;
    // }
    double ans = 0.0;
    for(int i=n/2+1; i<=n; i++){
        ans+=dp[n][i];
    }
    cout<<ans;

}
int main(){
    fastio;
    // #ifndef ONLINE_JUDGE
    //     testcases;
    // #endif // !DEBUG
    cout<<fixed<<setprecision(10);
    
    //int t; cin>>t; while(t--) solve();    
    solve();

    return 0;
}
//points to check:
//  * check for constraints, mainly array!
//  * EDGE CASES
//  * check for integer overflow, use long long!
//  * learn, do, solve, share something, NOW!

Measured memory_bytes: 73728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
 
int main(){
  int n;
  cin >> n;
  vector<vector<P>> g(n);
  rep(i,n-1) {
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    g[u].emplace_back(make_pair(v, w));
    g[v].emplace_back(make_pair(u, w));
  }
  vector<int> res(n,-1);
  auto dfs = [&](auto& f, int p, int u, int c)->void{
    res[u] = c;
    for (auto v : g[u]) {
      if (p == v.first) continue;
      if (res[v.first] != -1) continue;
      if (v.second & 1) f(f, u, v.first, 1-c);
      else f(f, u, v.first, c);
    }
  };
  dfs(dfs, -1, 0, 0);
  for (auto e : res) cout << e << endl;
  return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll inv[1000000];
ll FactorialInv[1000000];
ll Factorial[1000000];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    inv[1] = 1;
    FactorialInv[1] = 1;
    Factorial[1] = 1;
    for(int i = 2; i < 1000000; i++){
        inv[i] = beki(i, mod - 2);
        Factorial[i] = Factorial[i - 1] * i % mod;
        FactorialInv[i] = FactorialInv[i - 1] * inv[i] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

int main() {
    //cout.precision(10);
    //init_combination();
    ll N;
    cin >> N;
    ll a[200050];
    for(int i = 1; i <= N; i++) cin >> a[i];
    vector<ll> sum;
    sum.push_back(a[1]);
    map<ll, ll> mp;
    for(int i = 2; i <= N; i++) {
        sum.push_back(sum.back() + a[i]);
    }
    sum.push_back(0);
    for(int i = 0; i < sum.size(); i++) mp[sum[i]]++;
    ll ans = 0;
    for(int i = 0; i < sum.size(); i++) {
        ans += mp[sum[i]] * (mp[sum[i]] - 1) / 2;
        mp[sum[i]] = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15856
#include<stdio.h>

int main (void){

  int N , M , C;
  int B[20];
  int A[100][100];

  scanf("%d %d %d", &N , &M , &C);
  for(int i = 0 ; i < M ; i++){
    scanf("%d", &B[i]);

  }

  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < M ; j++){

      scanf("%d", &A[i][j]);

    }
  }

  int count = 0;
  int sum;

  for(int i = 0 ; i < N ; i++){
    sum = C;

    for(int j = 0 ; j < M ; j++){

      sum += A[i][j] * B[j];

    }

    if(sum > 0){
      count++;
    }

  }

  printf("%d", count);

return 0;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D) {
    cout << "Left" << endl;
  }
  if (A+B == C+D) {
    cout << "Balanced" << endl;
  }
  if (A+B < C+D) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    long long int n,m;
    cin>>n>>m;
    long long int a=1;
    REP(i,m){
        a*=2;
    }
    long long int b;
    b=(m*1900+(n-m)*100)*a;
    cout<<b;
    return 0;
}


Measured memory_bytes: 256