akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
//#include <numeric> //iota
//#include <sstream>
#include <cstring>
//#include <tuple>
//#include <random>
//#include <string>
//#include <unordered_set>
//#include <bitset>
//#include <unordered_map>
//#include <stack>
#include <cmath>
//#include <deque>
#include <queue>
//#include <list>
#include <array>
using namespace std;
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define vec vector
#define pb push_back
#define pp pop_back
#define fi first
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define se second
#define un_map unordered_map
#define rep(i,a,n) for (int i = a; i < n; ++i) 
#define inc_rep(i,a,n,inc) for (int i = a; i < n; i += inc) 
#define couts(x) cout << x << "\n" 
#define watch(x) cout << #x << " : " << x << endl;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long, long long>  PLII;
template<typename T>
void print(vector<T>& v) {rep(i, 0, (int)v.size()) cout << v[i] << " ";cout << endl;}
int nxt() {int x;cin >> x;return x;}
ll nxtl() {ll x;cin >> x;return x;}
string nxts() {string x;cin >> x;return x;}
double nxtd() {double x; cin >> x; return x;}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main() {
	IOS;
	int n;
	cin >> n;
	vector<int> v(n);
	for (auto &x : v) cin >> x;
	string a = "pairwise coprime";
	string b = "setwise coprime";
	string c = "not coprime";
	int z = 1e6 + 1;
	vector<int> prime(z + 1);
	vector<int> val(z + 1);
	for (int i = 2; i <= z; ++i) {
		if (!val[i]) {
			prime[i] = 1;
			for (int j = i; j <= z; j += i) {
				val[j] = i;
			}
		}
	}
	int g = 0;
	for (int i = 0; i < n; ++i) {
		g = __gcd(g, v[i]);
	}
	map<int,int> m;
	for (int i = 0; i < n; ++i) {
		map<int,int> w;
		int x = v[i];
		while (x > 1) {
			w[val[x]] = 1;
			x = x / val[x];
		}
		for (auto y : w) {
			m[y.first]++;
		}
	}
	bool ans = 1;
	for (auto x : m) {
		if (x.second > 1) {
			ans = 0;
		}
	}
	if(ans) {
		cout << a;
	}else if (g == 1) {
		cout << b;
	}else {
		cout << c;
	}
}















	



Measured memory_bytes: 18232
#include<iostream>

using namespace std;


int main(){
	int n,k;
	int *x;
	int min;
	int index0,ista,iend;
	int i,j;
	int temp;
	bool flag;
	
	cin >> n >> k ;
	x = new int[n];
	
	index0=n;
	flag = true;
	for(i=0;i<n;i++){
		cin>>temp;
		x[i]=temp;
		if(temp>0 && flag){
			index0=i;
			flag=false;
		}
	}
	// cout << "index0 "<<index0<<endl;
	ista=index0-k;
	if(ista<0)ista=0;
	iend=n-k;
	if(iend>index0)iend=index0;
	if(iend>n-1)iend=n-1;
	min=1000000000;
	
	for(i=ista;i<=iend;i++){
		j = i+k-1;
		if(i<index0 && index0<=j){
			temp=-2*x[i]+x[j];
			if(temp<min)min=temp;
			temp=-x[i]+2*x[j];
			if(temp<min)min=temp;
		}else if(j<index0){
			temp=-x[i];
			if(temp<min)min=temp;
		}else if(i>=index0){
			temp=x[j];
			if(temp<min)min=temp;
		}else{
			cout << "ERROR" <<endl;
			return 1;
		}
		// cout << temp <<" "<<min<<" "<<i<<" "<<j<< endl;
	}
	
	cout << min << endl;
	
	return 0;
}

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

namespace Test01
{    
    class Program
    {       
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int n = N / 2;
            if (N % 2 == 1) n++;

            
            Console.WriteLine((decimal)n / N);

        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int i = 0, x;
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			x = scan.nextInt();
			if (x == 0) break;
			i++;
			System.out.println("Case " + i + ": " + x);
		}
	}
}



Measured memory_bytes: 41292
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;


static class P
{
    static void Main()
    {
        var Nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = Nx[0];
        var x = Nx[1];
        var a = Enumerable.Repeat(0, 1).Concat(Console.ReadLine().Split().Select(int.Parse)).ToArray();
        long res = 0;
        for (int i = 1; i < a.Length; i++)
        {
            var op = Max(0, a[i - 1] + a[i] - x);
            a[i] -= op;
            res += op;
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 30300
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    string s;
    cin >> s;
    int sum = 0;
    REP(i,s.size()){
        sum += s[i] - '0';
    }
    if(sum % 9 == 0){
        Yes();
    }else No();
    return 0;
}

Measured memory_bytes: 3760
#include <iostream>

using namespace std;

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

  const int l = a + b;
  const int r = c + d;
  if (l > r)
    cout << "Left" << endl;
  else if (l < r)
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  rep(i,N) cin >> A[i];
  rep(i,N+1) A[i+1] += A[i];
  map<long long, int> cnt;
  cnt[0] = 1;
  long long ans = 0;
  rep(i,N){
    ans += cnt[A[i]];
    cnt[A[i]]++;
  }
  cout << ans  << endl;
  return 0;
}


Measured memory_bytes: 14336
#include <cstdio>
#include <map>
using namespace std;

int main() {  
  int n, m; scanf("%d %d", &n, &m);
  
  multimap<int, int> demands;
  for (int i = 0; i < m; i++) {
    int a, b; scanf("%d %d", &a, &b);
    demands.emplace(b, a);
  }
  
  int ans = 0;
  int line = 0;
  
  for (auto it = demands.cbegin(); it != demands.cend(); it++) {
    if ((*it).second <= line) continue;
    line = (*it).first - 1;
    ans++;
  }
    
  printf("%d\n", ans);
}

Measured memory_bytes: 4864
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, readline().split()))
    r, s, p = list(map(int, readline().split()))
    t = str(readline().rstrip().decode('utf-8'))
    ans = []
    score = 0
    for i, v in enumerate(t):
        if v == "r":
            ans.append("p")
        elif v == "s":
            ans.append("r")
        else:
            ans.append("s")
    for i, v in enumerate(ans):
        if i >= k:
            if ans[i-k] == ans[i]:
                ans[i] = "x"
    cnt = 0
    for v in ans:
        if v == "r":
            cnt += r
        elif v == "s":
            cnt += s
        elif v == "p":
            cnt += p
    print(cnt)


if __name__ == '__main__':
    solve()


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

int main(){

  double w, h;
  ll x, y;
  cin >> w >> h >> x >> y;
  
  if(x+x == w && y+y == h){
    printf("%9.9lf 1\n", h*w/2);
  }else{
    printf("%9.9lf 0\n", h*w/2);
  }
  
}


Measured memory_bytes: 256
import math
A,B,N=map(int,input().split())
han=0
kot=0
i=0
if B==1:
    print(0)
    exit()
if B-1>=N:
    print(math.floor(A*N/B)-A*math.floor(N/B))
    i=1
else:
    for a in range(B-1,N,B):
        if han<(math.floor(A*a/B)-A*math.floor(a/B)):
            han=(math.floor(A*a/B)-A*math.floor(a/B))
            kot=a

if i==0:
    print(han)

Measured memory_bytes: 61960
a, b = map(int, input().split())

if a == 1:
  if b == 1:
    print('Draw')
  else:
    print('Alice')
else:
  if b == 1:
    print('Bob')
  elif a > b:
    print('Alice')
  elif a == b:
    print('Draw')
  else:
    print('Bob')


Measured memory_bytes: 2940
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin - 1; 0 <= end; i--)		// repeat reverse

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl << msec << " msec " << endl;
}

#endif

class ABC125D
{
public:
	ABC125D()
	{
		cin >> n;

		a.resize(n);
		rep(i, 0, n)
			cin >> a[i];
	}
	void Run(void)
	{
		ll negative = 0;
		for (auto& e : a)
		{
			if (e < 0)
			{
				e = -e;
				negative++;
			}
		}

		sort(all(a));
		if (a[0] == 0 || negative % 2 == 0)
			cout << accumulate(all(a), 0LL);
		else
			cout << accumulate(all(a), 0LL) - a[0] * 2;

		return;
	}
private:
	ll n;
	vector<ll> a;
};

int main(void)
{
	ABC125D abc125d;
	abc125d.Run();

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#define N 100
void push(int);
  int pop(void);
int isEmpty(void);
int isFull(void);
int atoi(char c[]);
void print (void);
int box[N],key=0;

int main(){
  int a,b,result;
  char c[100];
  while(1){
    if((scanf("%s ",c))==EOF)break;
    if(c[0] >= '0' && c[0] <= '9' )push(atoi(c));
    if(c[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
 if(c[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }
  if(c[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
  }
  result=pop();
  printf("%d\n",result);






  
  return 0;
}
  void push(int a){
    int c;
    box[key]=a;
    key++;
  }
    
  int pop(void){
    int c;
    key--;
    return box[key];
  }
int isEmpty(void){
  if(key==-1)return 0;
  else return 1;
}
int isFull(void){
  if(key>=N)return 0;
  else return 1;
}
int atoi(char a[]){
  int b,i,j,z;
  for(i=0;a[i]!='\0';i++){
  }
  for(j=i-1;j>=0;j--){
    z=a[j]-'0';
    b+=z*pow(10,i-j-1);
  }
  return b;
}
void print(void){
  int i;
  for(i=0;i<key;i++){
    printf("%d ",box[i]);
  }
  printf("\n");
}



Measured memory_bytes: 2916
import collections

n,m=map(int,input().split())
arr=list(map(int,input().split()))
cnt=collections.Counter(arr)
cnt1=collections.defaultdict(int)
cnt2=collections.defaultdict(int)
for key in cnt.keys():
  tmp=key%m
  val=cnt[key]
  if val%2==0:
    cnt2[tmp]+=val
  else:
    cnt1[tmp]+=1
    cnt2[tmp]+=val-1
ans=0
for i in range(m):
  l=i
  r=(m-i)%m
  if l>r:
    break
  elif l==r:
    ans+=(cnt1[l]+cnt2[l])//2
  else:
    ans+=min(cnt1[l],cnt1[r])
    if cnt1[l]==cnt1[r]:
      ans+=(cnt2[l]+cnt2[r])//2
    elif cnt1[l]<cnt1[r]:
      cnt1[r]-=cnt1[l]
      ans+=min(cnt2[l],cnt1[r])
      cnt2[l]=max(0,cnt2[l]-cnt1[r])
      ans+=(cnt2[l]+cnt2[r])//2
    else:
      cnt1[l]-=cnt1[r]
      ans+=min(cnt1[l],cnt2[r])
      cnt2[r]=max(0,cnt2[r]-cnt1[l])
      ans+=(cnt2[l]+cnt2[r])//2
print(ans)

Measured memory_bytes: 35932
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

string sa,sb;

bool check(int a){
	if(a+sb.size()>sa.size())return false;
	for(int i=0;i<sb.size();i++){
		if(sa[a+i]=='?')continue;
		if(sa[a+i]!=sb[i])return false;
	}
	return true;
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>sa>>sb;
	for(i=sa.size();i>=0;i--){
		if(check(i)){
			for(j=0;j<sb.size();j++){
				if(sa[i+j]=='?')sa[i+j]=sb[j];
			}
			for(j=0;j<sa.size();j++){
				if(sa[j]=='?')sa[j]='a';
			}
			cout<<sa<<endl;
			return 0;
		}
	}
	cout<<"UNRESTORABLE"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		int ans = 0;
		for(int i = 0; i < count; i++) {

			int min = sc.nextInt();
			int max = sc.nextInt();
			ans += max - min + 1;

		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 24276
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int length;
    string S;
    cin >> length >> S;

    int answer = 0;
    for(int i = 1; i < length - 1; i++)
    {
        const int NO_OF_ALPHABETS = 26;

        vector <int> X_has(NO_OF_ALPHABETS, false);
        for(int j = 0; j <= i; j++)
            X_has[S[j] - 'a'] = true;

        vector <int> Y_has(NO_OF_ALPHABETS, false);
        for(int j = i + 1; j < length; j++)
            Y_has[S[j] - 'a'] = true;

        int current_answer = 0;

        for(int alphabet = 0; alphabet < NO_OF_ALPHABETS; alphabet++)
            current_answer += (X_has[alphabet] && Y_has[alphabet]);

        answer = max(answer, current_answer); //cout << i << " " << current_answer << endl;
    }

    cout << answer;
    return 0;
}


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

int main()
{
    int t,c=0,c1=0,c2=0,c3=0;
    cin>>t;
    string s;
    for(int i=0;i<t;i++){
        cin>>s;
    if(s=="AC"){
        c++;
    }
    else if(s=="WA"){
        c1++;
    }
    else if(s=="TLE"){
        c2++;
    }
    else{
        c3++;
    }
    }
    cout<<"AC x "<<c<<endl;
    cout<<"WA x "<<c1<<endl;
    cout<<"TLE x "<<c2<<endl;
    cout<<"RE x "<<c3<<endl;

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
#define maxn 1005
#define mo 1000000007
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,k,a[maxn],dp[25][maxn];
int jc[maxn],inv[maxn];
inline void Add(int &x,int y){x+=y;x-=(x>=mo?mo:0);}
inline int C(int x,int y){return 1ll*jc[x]*inv[y]%mo*inv[x-y]%mo;}
int main()
{
    n=read(),k=read();reg int i,j,add;
    for(i=1;i<=k;++i)a[i]=read();
    jc[0]=inv[0]=inv[1]=1;
    for(i=1;i<=n;++i)jc[i]=1ll*jc[i-1]*i%mo;
    for(i=2;i<=n;++i)inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
    for(i=2;i<=n;++i)inv[i]=1ll*inv[i-1]*inv[i]%mo;
    dp[0][0]=1;
    for(i=1;i<=k;++i)for(j=0;j<=n;++j)
        for(add=0;add+j<=n&&add<=a[i];++add)
            Add(dp[i][j+add],1ll*dp[i-1][j]*C(n-add,a[i]-add)%mo*inv[add]%mo);
    printf("%lld\n",1ll*jc[n]*dp[k][n]%mo);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
int N, M;
int s = 0;
cin >> N >> M;
vector<int> vec(M);
for (int i = 0; i < M; i++) {
  cin >> vec.at(i);
}
for (int i = 0; i < M; i++) {
  s = s + vec.at(i);
};

if(N - s >= 0){
    cout << N - s << endl;
}else{
    cout << -1 << endl;
};

}

Measured memory_bytes: 3656
// Anve$hi $hukla
#include <bits/stdc++.h>
using namespace std;
struct ${$(){ios_base::sync_with_stdio(false);cin.tie(NULL);}}$;

typedef long long LL;
const long long Mod = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector <int> v(n + 1);
    for(int i = 0; i < n; i++) {
        cin >> v[i + 1];
    }

    set <int> s;
    s.insert(1);
    int cur = 1;

    while(cur != 2) {
        cur = v[cur];
        if(s.find(cur) != s.end()) {
            cout << -1 << endl;
            return 0;
        }
        s.insert(cur);
    }
    cout << (int)s.size() - 1 << endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++)
    cin >> d[i];

  sort(d.begin(), d.end());
  int m = n / 2;
  cout << d[m] - d[m - 1] << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
using namespace std;
 
int main(){
    float x;
    float y;
    float area;
    float per;
    
   scanf("%f %f",&x,&y);
   area = x * y;
   per = (x+y)*2;
   
   printf("%.0f %.0f\n",area ,per);

    
    return 0;
}


Measured memory_bytes: 2612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>A(N);
    rep(i,N)cin>>A[i];

    sort(all(A));
    reverse(all(A));
    ll ans=0;
    rep(i,N){
        if(i%2==0){
            ans+=A[i];
        }else{
            ans-=A[i];
        }
    }

    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3632
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,g,m,i,j,k,s[20],nx;
  while(scanf("%d %d %d",&n,&g,&m),n){
    double a=0,d[60][6500]={1};
    int e[3][60]={0};
    for(i=0;i<n;i++)scanf("%d",&s[i]);
    while(m--){
      scanf("%d %d %d",&i,&j,&k);
      e[j-1][i]=k;
    }
    for(i=0;i<g;i++){
      for(j=0;j<6000;j++){//printf("%lf ",d[i][j]);
	for(k=0;k<n;k++){
	  nx=MIN(g,i+s[k]);
	  d[MIN(nx+e[0][nx],g)][MAX(0,j+e[1][nx]-e[2][nx])]+=d[i][j]/n;
	}
      }//printf("\n");
    }
    for(i=0;i<6000;i++)a+=i*d[g][i];
    printf("%d\n",(int)a);
  }
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

struct mint{
    static const long long MOD = 998244353;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}

int main(){
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> lr(k);

    REP(i, k){
        cin >> lr.at(i).first;
        cin >> lr.at(i).second;
    }

    vector<mint> num(n, 0);
    num.at(0) = 1;
    vector<mint> x(n, 0);
    for(ll i = 0; i < n; ++i){
        if(i > 0){
            x.at(i) += x.at(i - 1);
            num.at(i) = x.at(i);
        }
        REP(j, k){
            const ll li = lr.at(j).first;
            const ll ri = lr.at(j).second;
            if(i + li < n){
                x.at(i + li) += num.at(i);
            }
            if(i + ri + 1 < n){
                x.at(i + ri + 1) -= num.at(i);
            }
        }
    }

    cout << num.at(n - 1) << endl;
    return 0;
}


Measured memory_bytes: 6420
n = int(input())
a = list(map(int,input().split()))
m = int(input())
t = [0] * (10 ** 5 + 1)
ans = sum(a)
for i in a:
    t[i] += 1
for i in range(m):
               b, c = map(int,input().split())
               #ans = sum([int(i) for i in a])
               ans -= b * t[b]
               ans += c * t[b]
               t[c] += t[b]
               t[b] = 0
               #ans = ans - a.count("b")(int("c")-int("b"))
               print(ans)
               

        
    


Measured memory_bytes: 21196
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int num = scn.next().replaceAll("[^AZ]", "").replaceAll("AZ", ".").replaceAll("[^.]", "").length();
            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < num; i++) {
                sb.append("AZ");
            }
            System.out.println(sb.length() > 0 ? sb : "-1");
        }
    }
}

Measured memory_bytes: 26116
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

map<long, int> memo;

ll m(ll h) {
	if (h == 1)
		return 1;

	ll a = m(h / 2);
	return 1LL + a + a;
}

void solve() {
	cinll(h);
	ll ans = m(h);
	cout << ans << endl;
}

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



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

const int maxn = 105;

int n, m;
int sum;
int pos, val;
int a[maxn];

inline int read(void)
{
	int s = 0, w = 1;
	char ch = getchar();
	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') w = -1;
	for(; ch <= '9' && ch >= '0'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

int main()
{
	n = read();
	for(register int i = 1; i <= n; i++) {a[i] = read(); sum += a[i];}
	m = read();
	for(register int i = 1; i <= m; i++)
	{
		pos = read(); val = read();
		cout << sum - (a[pos] - val) << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
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
  
N = int(input())  
ans = 0
for i in range(7, N+1, 2):
  cnt = len(make_divisors(i))
  if cnt == 8:
    ans += 1
    
print(ans)  
  

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

using namespace std;

int main()
{
    int N, a, b;
    while (cin >> N, N) {
        int p1 = 0, p2 = 0;
        for (int i = 0; i < N; i++) {
            cin >> a >> b;
            if (a > b) {
                p1 += a + b;
            } else if (a < b) {
                p2 += a + b;
            } else {
                p1 += a;
                p2 += b;
            }
        }
        cout << p1 << " " << p2 << endl;
    }
    return 0;
}

Measured memory_bytes: 2988
#include <iostream>

using namespace std;

int main()
{

  int C[3][3];

  for (int ii=0; ii<3; ++ii)
    cin >> C[ii][0] >> C[ii][1] >> C[ii][2];

  
  bool a = ((C[1][0] - C[0][0]) ==  (C[1][1] - C[0][1]) &&
	    (C[1][0] - C[0][0]) ==  (C[1][2] - C[0][2]) &&

	    (C[2][0] - C[0][0]) ==  (C[2][1] - C[0][1]) &&
	    (C[2][0] - C[0][0]) ==  (C[2][2] - C[0][2]) &&


	    (C[0][1] - C[0][0]) ==  (C[1][1] - C[1][0]) &&
	    (C[0][1] - C[0][0]) ==  (C[2][1] - C[2][0]) &&
	    
	    (C[0][2] - C[0][0]) ==  (C[1][2] - C[1][0]) &&
	    (C[0][2] - C[0][0]) ==  (C[2][2] - C[2][0])

	    );
  
    std::cout << (a ? "Yes" : "No")<< std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>

 
using namespace std;

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

	long long ans;
	ans=k;
	for (int i = 0; i < n-1; ++i)
	{
		ans=ans*(k-1);
	}

	cout<<ans<<endl;

	return 0;
	}

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<string> &s, string a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


int main() {

    int n;
    cin >> n;
    vector<int> numbers(n);
    rep(i, n) cin >> numbers[i];

    int mi = *min_element(numbers.begin(), numbers.end());
    int ma = *max_element(numbers.begin(), numbers.end());

    ll ans = INF;
    for (int i = mi; i <= ma; i++) {

        ll sum = 0;
        for (int num : numbers) {
            int c = (num - i);
            int cc = c * c;
            sum += cc;
        }
        cmin(ans, sum);
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int H,W,i,j;
  while(1){
  scanf("%d %d",&H,&W);
  if(H==0&&W==0){
    break;
  }
  else{
    for(i=1;i<=H;i++){
      for(j=1;j<=W;j++){
        if(i%2==j%2){
          printf("#");
        }
        else{
          printf(".");
        }
      }
      printf("\n");
    }
  }
  printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    string s;
    cin>>s;
    int n = s.size();
    int f = 0;
    for(int i=0;i<n;i++)
    {
        if( s[i] == 'U' || s[i] == 'D' ) continue;
        if( i%2 == 0 )
        {
            if( s[i] == 'L' )
            {
                f = 1;
                break;
            }
        }
        else
        {
            if( s[i] == 'R' )
            {
                f = 1;
                break;
            }
        }
    }
    if( f )
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD1        1000000007
#define MOD2        998244353
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;


void solve()
{
    ll x;
    cin >> x;

    ll ans = (x/500) * 1000 + ((x%500)/5) * 5;
    cout << ans;
}


int main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif

    ll t = 1;
    //cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
struct Coordinate
{
    private double x;
    private double y;
    public double X { get { return x; } }
    public double Y { get { return y; } }
    public Coordinate(double x, double y)
    {
        this.x = x;
        this.y = y;
    }
    public static Coordinate Sub(Coordinate p, Coordinate q)
    {
        return new Coordinate(p.X - q.X, p.Y - q.Y);
    }
}
class P
{
    static void Main()
    {
        List<Coordinate> ps = new List<Coordinate>();
        for (; ; )
        {
            try
            {
                string[] s = Console.ReadLine().Split(',');
                double x = double.Parse(s[0]);
                double y = double.Parse(s[1]);
                ps.Add(new Coordinate(x, y));
            }
            catch { break; }
        }
        int n = ps.Count;
        double ans = 0.0;
        for (int i = 1; i < n - 1; i++)
        {
            Coordinate p = Coordinate.Sub(ps[i], ps[0]);
            Coordinate q = Coordinate.Sub(ps[i + 1], ps[0]);
            ans += CalcArea(p, q);
        }
        Console.WriteLine(ans);
    }
    static double CalcArea(Coordinate p, Coordinate q){
        return Math.Abs(p.X * q.Y - p.Y * q.X) / 2;
    }
}    


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

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, a;
	ll sum = 0, ans = 0, s;
	cin >> num;
	vector<ll> d(num + 1, 0);
	for (i = 1; i <= num; i++) {
		scanf("%d", &a);
		sum += a;
		d[i] = sum;
	}
	sort(d.begin(), d.end());
	for (i = 0; i < num; i++) {
		s = 1;
		while (i < num && d[i] == d[i + 1]) {
			s++;
			i++;
		}
		s *= s - 1;
		ans += s >> 1;
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n);
    for (auto &e : a) cin >> e;

    int sum = 0;
    for (auto e : a) sum += e;

    int count = 0;
    for (auto e : a) {
        if (e * 4 * m < sum) continue;
        ++count;
    }

    cout << (m <= count ? "Yes" : "No") << endl;
}



Measured memory_bytes: 3580
import java.util.Scanner;

/**
 * A : ???????????°?????? / Finger Counting
 */
public class Main {

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

		long n = sc.nextLong();
		int count = 0;

		if (n > 0) {
			while (n >= 2) {
				n /= 2;
				count++;
			}
			count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 26184
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n;
	cin>>n;
 	vector<double> dp(n+1,0);
 	vector<double> ndp(n+1,0);
 	vector<double> a(n);
 	dp[0]=1;
 	for(i=0;i<n;i++)
 	cin>>a[i];
 	for(i=0;i<n;i++)
 	{
 	  	int j;
 	  	for(j=0;j<=i+1;j++)
 	  	{
 	  		ndp[j]=(j!=0?dp[j-1]*a[i]:0)+dp[j]*(1-a[i]);
		}
		dp=ndp;
	}
	double ans;
	ans=0;
	for(i=0;i<=n;i++)
	{
		int j=n-i;
		//cout<<dp[i]<<endl;
		if(i>j)
		{
			ans+=dp[i];
		}
	}
 std::cout << std::setprecision(12) << ans << '\n';
 return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
	int a,b,i,j,k,n,ans=0;
	scanf("%d%d",&a,&b);
	for(i=1;i<=9;i++){
		for(j=0;j<=9;j++){
			for(k=0;k<=9;k++){
				n=10001*i+1010*j+100*k;
				if(n>=a && n<=b)
					ans++;
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
 
#define N 600000
#define NIL -1
 
//array
int key[N];
int parent[N];
int leftc[N];
int rightc[N];
//root
int root=NIL;
//function insert
void insert(int z){
  int x,y;
   
  y=NIL;
  x=root;
 
  while(x!=NIL){
    y=x;
    if(key[z]<key[x]) x=leftc[x];
    else x=rightc[x];
  }  
   
  parent[z]=y;
 
  if(y==NIL) root=z;
     
  else if(key[z]<key[y]) leftc[y]=z;
 
  else rightc[y]=z;
   
   
}
 
//function search
int find(int now,int data){
  if(now==NIL||data==key[now]) return now;
  if(data<key[now]) return find(leftc[now],data);
  else return find(rightc[now],data);
}
 
//print
void inorderprint(int now){
  if(now!=NIL){
    inorderprint(leftc[now]);
    printf(" %d",key[now]);
    inorderprint(rightc[now]);
  }
}
 
void preorderprint(int now){
  if(now!=NIL){
    printf(" %d",key[now]);
    preorderprint(leftc[now]);
    preorderprint(rightc[now]);
  }
}
 
 
 
int main(){
 
  int n,i,j,data;
  int z=0;
  char str[10];
  //initialize array
  for(i=0;i<N;i++){
    parent[i]=NIL;
    key[i]=NIL;
    rightc[i]=NIL;
    leftc[i]=NIL;
  }
  //load n
  scanf("%d",&n);
  //load commnad and key
  for(i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp(str,"insert")==0) {
      scanf("%d",&data);
      key[z]=data;
      insert(z);
      z++;
    }
    else if(strcmp(str,"find")==0){
      scanf("%d",&data);
      if(find(root,data)!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(str,"print")==0){
      inorderprint(root);
      cout <<endl;
      preorderprint(root);
      cout <<endl;
    }
  }
 
  return 0;
}

Measured memory_bytes: 10604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

int main() {
	string s;
	vector<int> a(27);
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < 27; j++) {
			if (s[i] == 'a' + j) {
				a[j]++;
			}
		}
	}
	for (int i = 0; i < 27; i++) {
		if (a[i] % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int read() {
	int f = 1, x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -f;
		ch = getchar();
	} while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return f * x;
}
map <int, int> app; 
int main() {
	int n, m;
	cin >> n >> m;
	if (n % 2 == 1) {
		int l = 1, r = n-1; 
		for (int i = 1; i <= m; ++i) cout << (l++) << " " << (r--) << endl;
		return 0; 
	} else {
		int l = 1, r = n;
		for (int i = 1; i <= m; ++i) {
			while (true) {
				app[r - l]++;
				if (app[r - l] >= 2) {
					++l;
				app[r - l]--;
					continue;
				}
				app[l - r + n]++;
				if (app[l - r + n] >= 2) {
					++l;
					app[l - r + n]--;
					continue;
				}
				break;
			} 
			cout << l <<  " " << r << '\n'; 
			++l, --r; 
		}
	}
	return 0;
}






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

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
//    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        double[] p = new double[n];
        double dp[][] = new double[n+1][n+1];
        for (int i = 0; i < p.length; i++) {
			p[i]=sc.nextDouble();
		}
        dp[0][0]=1;
        
        for (int i = 1; i <= n; i++) {
			for (int t = 0; t <= i ; t++) {
				if(t>0)dp[i][t] = dp[i-1][t-1]*p[i-1];
				dp[i][t] +=	dp[i-1][t]*(1-p[i-1]);
			}
		}
        double ans=0;
        for (int i = n/2+1; i <= n ; i++) {
			ans += dp[n][i];
		}

        out.println(ans	);
        out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }


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

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//    public int compareTo(P p){
//        return d-p.d; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 131020
n, m = map(int, input().split())
k_s = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for i in range(2 ** n):
    cnt = 0
    for j in range(m):
        on = 0
        for k in range(n):
            if i >> k & 1:
                if k + 1 in k_s[j][1:]:
                    on += 1
        if on % 2 == p[j]:
            cnt += 1
    if cnt == m:
        ans += 1
print(ans)

Measured memory_bytes: 3064
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

static constexpr ull anti_divisions(ull X, ull C, ull D) {
  const ull Y = X - (X / C) - (X / D);
  return Y + X / lcm(C, D);
}

int main() {
  ull A, B, C, D;
  cin >> A >> B >> C >> D;
  const ull B_ = anti_divisions(B, C, D);
  const ull A_ = anti_divisions(A - 1, C, D);
  cout << B_ - A_ << endl;
  return 0;
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int x,y;
  cin>>x>>y;
  int now=x*2;
  if(y==now){
    cout<<"Yes"<<endl;
    return 0;
  }
  rep(i,x){
    
    now+=2;
    if(y==now){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main()
{
    char a[50][50];
    int h, w;
    while(cin >> h >> w)
    {
        for(int i = 0; i < h; i++)
        {
            for(int j=0; j<w; j++)
            {
                cin >> a[i][j];
            }
        }

        for(int i = 0; i < h; i++)
        {
            for(int j=0; j<w; j++)
            {
                if(a[i][j]=='#')
                    continue;
                if(i == 0 && j==0)
                {
                    a[i][j]=((a[i+1][j]=='#')+(a[i][j+1]=='#')+(a[i+1][j+1]=='#'))+'0';
                    continue;
                }
                if(i == 0 && j==w-1)
                {
                    a[i][j]=((a[i][j-1]=='#')+(a[i+1][j]=='#')+(a[i+1][j-1]=='#'))+'0';
                    continue;
                }
                if(i == h-1 && j==0)
                {
                    a[i][j]=((a[i-1][j]=='#')+(a[i][j+1]=='#')+(a[i-1][j+1]=='#'))+'0';
                    continue;
                }
                if(i == h-1 && j==w-1)
                {
                    a[i][j]=((a[i][j-1]=='#')+(a[i-1][j]=='#')+(a[i-1][j-1]=='#'))+'0';
                    continue;
                }
                if(i==0)
                {
                    a[i][j]=((a[i][j-1]=='#')+(a[i+1][j-1]=='#')
                             +(a[i+1][j]=='#')+(a[i+1][j+1]=='#')
                             +(a[i][j+1]=='#'))+'0';
                             continue;
                }
                if(j==0)
                {
                    a[i][j]=((a[i-1][j]=='#')+(a[i-1][j+1]=='#')
                             +(a[i][j+1]=='#')+(a[i+1][j+1]=='#')
                             +(a[i+1][j]=='#'))+'0';
                             continue;
                }
                if(i==h-1)
                {
                     a[i][j]=((a[i][j-1]=='#')+(a[i-1][j-1]=='#')
                             +(a[i-1][j]=='#')+(a[i-1][j+1]=='#')
                             +(a[i][j+1]=='#'))+'0';
                             continue;
                }
                if(j==w-1)
                {
                     a[i][j]=((a[i-1][j]=='#')+(a[i-1][j-1]=='#')
                             +(a[i][j-1]=='#')+(a[i+1][j-1]=='#')
                             +(a[i+1][j]=='#'))+'0';
                             continue;
                }
                a[i][j]=((a[i-1][j]=='#')+(a[i-1][j-1]=='#')
                             +(a[i][j-1]=='#')+(a[i+1][j-1]=='#')
                             +(a[i+1][j]=='#')+(a[i+1][j+1]=='#')
                             +(a[i][j+1]=='#')+(a[i-1][j+1]=='#'))+'0';
                             continue;

            }


        }
        for(int i = 0; i <h; i++)
            {
                for(int j=0; j<w; j++)
                {
                    cout << a[i][j];
                }
                cout << endl;
            }

    }
    return 0;
}


Measured memory_bytes: 256