akhauriyash/Code-Regression huggingface dataset:
#import <Foundation/Foundation.h>

bool isvowel(NSString *c){
    return [c isEqualToString:@"a"] || [c isEqualToString:@"e"] || [c isEqualToString:@"i"] || [c isEqualToString:@"o"] || [c isEqualToString:@"u"];
}

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSData *stdinData = [[NSFileHandle fileHandleWithStandardInput] availableData];
        NSString *s = [[NSString alloc] initWithData:stdinData encoding:NSUTF8StringEncoding];
        NSString *raw = [s substringWithRange:NSMakeRange(0,1)];
        
        NSString *answer = @"consonant";
        if(isvowel(raw)){
            answer = @"vowel";
        }
        
        NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
        [fileHandle writeData:[answer dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle writeData:[@"\n" dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle closeFile];
    }
    
    return 0;
}


Measured memory_bytes: 2404
#include <stdio.h>
 
int main(){
    int j,s_length = 0;
    char s[101],p[101];
    scanf("%s",s);
    scanf("%s",p);
 
    for(int i = 0; s[i] != '\0';i++) s_length++;
 
    for(int left = 0;s[left] != '\0';left++){
        for(j = 0;p[j] != '\0' && p[j] == s[(left+j)%s_length];j++);
        if(p[j] == '\0'){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


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

vector<int> vr,vg,vb;

int main(){
	string s;
	int n;
	long long ans=0;
	cin>>n>>s;
	
	for(int i=0;i<n;i++){
		if(s[i]=='R') vr.push_back(i);
		else if(s[i]=='G') vg.push_back(i);
		else vb.push_back(i);
	}
	
	int a=vr.size(),b=vg.size(),c=vb.size();
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			ans+=c;
			
			int d=abs(vr[i]-vg[j]);
			int mi=min(vr[i],vg[j]),ma=max(vr[i],vg[j]);
			
			if(mi-d>=0&&s[mi-d]=='B') ans--;
			if(ma+d<n&&s[ma+d]=='B') ans--;
			if((vr[i]+vg[j])%2==0&&s[mi+d/2]=='B') ans--;
		}
	}
	
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int H, W;
string s[110];
map<char, int> alp;

string solve() { 
  if (H % 2 == 0 && W % 2 == 0) {
    fore(x, alp) {
      if (x.second % 4) return "No";
    }
    return "Yes";
  }

  if (H % 2 && W % 2) {
    int m[4] = {0};
    fore(p, alp) m[p.second % 4]++;
    if (m[3]) return "No";
    if (m[1] != 1) return "No";
    if (m[2] > (H - 1) / 2 + (W - 1) / 2) return "No";
    return "Yes";
  }

  if (W % 2) swap(H, W);

  int m[4] = {0};
  fore(p, alp) m[p.second% 4]++;
  if (m[1] || m[3]) return "No";
  if (m[2] > W / 2) return "No";
  return "Yes";
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> H >> W;
    rep(i, 0, H) {
      cin >> s[i];
      rep(j, 0, W) {
        alp[s[i][j] - 'a']++;
      }
    }
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

long n, m;
vector<long> a;

#if 0
long p[10005];

void dfs( long curr )
{
    if(curr==2*n) {
        long i;
        long valmax=0;
        for(i=0; i<2*n; i++) {
            long val=(a[i]+a[p[i]])%m;
            printf("%ld(%ld-%ld) ", val, a[i], a[p[i]]);
            valmax = MAX(valmax, val);
        }
        printf("    %ld\n", valmax);
        return;
    }

    long i;
    for(i=0; i<2*n; i++) {
        if(i==curr || p[i]>=0) continue;
        
        p[curr]=i;
        p[i]=curr;
        
        long next=curr;
        while(next<2*n && p[next]>=0) {
            next++;
        }
        dfs(next);

        p[curr]=-1;
        p[i]=-1;
    }

    return;
}

int main(int argc, char* argv[])
{
    scanf("%ld%ld", &n, &m);

    a.resize(2*n);
    long i;
    for(i=0; i<2*n; i++) {
        scanf("%ld", &a[i]);
    }

    for(i=0; i<2*n; i++) {
        p[i]=-1;
    }

    dfs( 0 );

    return 0;
}
#endif

bool check( long k )
{
    long i;
    for(i=2*k; i<n+k; i++) {
        long val=(a[i]+a[2*(k+n)-1-i]);
        if(val<m) {
            return false;
        }
    }
    return true;
}

int main(int argc, char* argv[])
{
    scanf("%ld%ld", &n, &m);

    a.resize(2*n);
    long i;
    for(i=0; i<2*n; i++) {
        scanf("%ld", &a[i]);
    }
    sort(a.begin(), a.end());

    long k;
    if( check( 0 ) ) {
        k = 0;
    }
    else if( !check(n-1) ) {
        k = 0;
    }
    else {
        long l=0, r=n-1;
        while( r-l>1 ) {
            long mm=(l+r)/2;
            if( check(mm) ) {
                r = mm;
            }
            else {
                l = mm;
            }
        }
        k = r;
    }

    long valmax=0;
    for(i=0; i<k; i++) {
        long val=(a[i]+a[2*k-1-i])%m;
        valmax = MAX(valmax, val);            
    }
    for(i=2*k; i<n+k; i++) {
        long val=(a[i]+a[2*(k+n)-1-i])%m;
        valmax = MAX(valmax, val);
    }
    printf("%ld\n", valmax);

    return 0;
}


Measured memory_bytes: 1792
using System;

namespace AtCoder_Beginner_Contest_143
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] AB = Console.ReadLine().Split(' ');
            int A = Convert.ToInt32(AB[0]);
            int B = Convert.ToInt32(AB[1]);
            int diff = A - B * 2;
            if (diff >= 0)
            {
                Console.WriteLine(diff);
            } else
            {
                Console.WriteLine(0);
            }
        }
    }
}

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

int main(void){
  string s;
  cin >> s;
  int ans = 753; 
  for(int i = 0; i < s.size()-2; i++){
    int S;
    int min;
    S = stoi(s.substr(i, 3));
    min = 753 - S;
    if(min < 0){
      min *= -1;
    }
    if(min < ans) ans = min;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
l_list = list(map(int, input().split()))
l_list.sort()
count = [0 for i in range(2000)]
cum = [0 for i in range(2000)]
for l in l_list:
  count[l] += 1
for i in range(1, 2000):
  cum[i] = cum[i - 1] + count[i]

ans = 0
cnt = 0
for i in range(n - 2):
  for j in range(i + 1, n - 1):
    ans += cum[l_list[i] + l_list[j] - 1] - j - 1
print(ans)
      

Measured memory_bytes: 41580
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int n, m;
string s;
int nxt[100005];

int main()
{
    cin >> n >> m >> s;
    int p = -1;
    for (int i = n; i >= 0; --i)
    {
        if (s[i] == '0')
            p = i;
        nxt[i] = p;
    }
    vector<int> sol;
    int x = n;
    while (x >= m)
    {
        sol.push_back(x - nxt[x - m]);
        if (x == nxt[x - m])
            return cout << -1, 0;
        x = nxt[x - m];
    }
    if (x > 0)
        sol.push_back(x);
    reverse(all(sol));
    for (int x : sol)
        cout << x << ' ';
}


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

int main(){
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    long long s = 0;
    if(k <= a) cout << a - (a - k);
    else{
        k -= a;
        s += a;
        if(k <= b) cout << s;
        else {
            k -= b;
            s += 0;
            cout << s - k;
        }
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void read(int &x){
	register char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar());
	for(;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar());
}
void write(ll x){
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
int n,m,lst,x,m_=1;
ll lzy[263144];
int cnt[263144];
void upd(int l,int r,int id,int a,int b,int x){
	if(r<a||b<l)return;
	if(a<=l&&r<=b){
		lzy[id]+=x;return;
	}
	upd(l,(l+r)/2,id*2+1,a,b,x),upd((l+r)/2+1,r,id*2+2,a,b,x);
}
void add(int l,int r,int id,int a,int b,int x){
	if(r<a||b<l)return;
	if(a<=l&&r<=b){
		lzy[id]+=x;cnt[id]++;return;
	}
	add(l,(l+r)/2,id*2+1,a,b,x),add((l+r)/2+1,r,id*2+2,a,b,x);
}
ll minans(int l,int r,int id,ll a,int num){
	if(l>m)return 1e18;
	if(l==r){
		num+=cnt[id];
		return a+lzy[id]-1ll*num*l;
	}
	return min(minans(l,(l+r)/2,id*2+1,a+lzy[id],num+cnt[id]),minans((l+r)/2+1,r,id*2+2,a+lzy[id],num+cnt[id]));
}
int main(){
	read(n),read(m),read(lst);
	while(m_<m)m_<<=1;
	for(int i=1;i<n;i++){
		read(x);
		if(lst<x){
			upd(1,m_,0,1,lst,x-lst);
			add(1,m_,0,lst+1,x,x+1);
			if(x<m)upd(1,m_,0,x+1,m,x-lst);
		}else{
			add(1,m_,0,1,x,x+1);
			upd(1,m_,0,x+1,lst,x+m-lst);
			if(lst<m)add(1,m_,0,lst+1,m,x+m+1);
		}
		lst=x;
	}
	write(minans(1,m_,0,0,0));
}

Measured memory_bytes: 5976
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

ll lcm(ll a, ll b)
{
   return a / gcd(a, b) * b;
}

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

    if(a > b) cout << 0 << endl;
    else if(a == b) cout << 1 << endl;
    else if(n == 2) cout << 1 << endl;
    else if(n == 1) cout << 0 << endl;
    else cout << (n-2) * (b-a) + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]
dicter = dict()
for i in range(1, n + 1):
    dicter[i] = []

for i in range(k):
    di = int(input())
    lister = [int(j) for j in input().split()]
    for j in lister:
        dicter[j].append(di)

sumer = 0
for i in range(1, n + 1):
    if dicter[i] == []:
        sumer += 1

print(sumer)

Measured memory_bytes: 67736
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(), x.end()

int main() {
  ll n, m, ans = 0;
  cin >> n >> m;
  priority_queue<ll> que;
  for (ll i = 0; i < n; i++) {
    ll tmp;
    cin >> tmp;
    que.push(tmp);
  }
  for (ll i = 0; i < m; i++) {
    ll x = que.top();
    que.pop();
    que.push(x / 2);
  }
  for (ll i = 0; i < n; i++) {
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string a, b; cin >> a >> b;
  int an = a.size(), bn = b.size();
  string ans = "EQUAL";
  if (an > bn) {
    ans = "GREATER";
  } else if (an < bn) {
    ans = "LESS";
  } else if (an == bn) {
    rep(i,an) {
      if (a[i] > b[i]) {
        ans = "GREATER"; break;
      } else if (a[i] < b[i]) {
        ans = "LESS"; break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 123;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int a[N], cnt[N];

ll ans;

void add(int i){
    ans += cnt[i];
    cnt[i]++;
}

void dec(int i){
    cnt[i]--;
    ans -= cnt[i];
}

void solve(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        add(a[i]);
    }
    for (int i = 1; i <= n;i++){
        dec(a[i]);
        cout << ans << ndl;
        add(a[i]);
    }
}

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3712
/* compatible with http://kk.kake.info.waseda.ac.jp/~kakehi/lp12/wl/ */
#include <stdio.h>
enum{M=99};
bigint_init(int a[], int x){
	int z;
	z=0;
	while(z<=M){a[z]=0;z=z+1;}
	a[M]=0;
	while(x/10){a[a[M]]=x%10;a[M]=a[M]+1;x=x/10;}
	a[a[M]]=x%10;
	a[M]=a[M]+1;
}
bigint_print(int a[]){
	int i;
	i=a[M]-1;
	while(i>-1){fputc(a[i]+'0',stdout);i=i-1;}
}
bigint_add(int a[], int x[]){
	int i,c;
	i=0;
	c=0;
	while(i<M){
		a[i]=a[i]+x[i]+c;
		c=a[i]/10;
		a[i]=a[i]%10;
		if(a[i])a[M]=i+1;
		i=i+1;
	}
}
bigint_mul(int A[], int x[]){
	int i,j,c;
	int a[M];
	i=A[M]-1;c=0;
	while(c<M){a[c]=0;c=c+1;}
	c=0;
	while(i>-1){
		j=0;
		while(j<x[M]){
			a[i+j]=a[i+j]+A[i]*x[j];
			j=j+1;
		}
		i=i-1;
	}
	i=0;
	while(i<M){
		a[i]=a[i]+c;
		c=a[i]/10;a[i]=a[i]%10;
		if(a[i])A[M]=i+1;
		i=i+1;
	}
	i=0;while(i<M){A[i]=a[i];i=i+1;}
}
int main(){
	int i,n,c;
	int ten[M+1],d1[M+1];
	bigint_init(ten,10);
	n=0;
	c=fgetc(stdin);
	while('0'<=c&&c<='9'){
		n=n*10;n=n+c-'0';
		c=fgetc(stdin);
	}
	while(n>0){
		int f1[M+1],f2[M+1];
		bigint_init(f1,0);
		c=fgetc(stdin);
		while('0'<=c&&c<='9'){
			bigint_mul(f1,ten);
			bigint_init(d1,c-'0');
			bigint_add(f1,d1);
			c=fgetc(stdin);
		}
		bigint_init(f2,0);
		c=fgetc(stdin);
		while('0'<=c&&c<='9'){
			bigint_mul(f2,ten);
			bigint_init(d1,c-'0');
			bigint_add(f2,d1);
			c=fgetc(stdin);
		}
		bigint_add(f1,f2);
		if(f1[M]>80)puts("overflow");
		else{
			bigint_print(f1);
			fputc('\n',stdout);
		}
		n=n-1;
	}
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;

int main(){
	int n = 0, m = 0;
	while(cin >> n >> m && (n != 0 || m != 0)){
		vector<pair<string, int> > win;
		for(int i = 0; i < n; i++){
			pair<string, int> tmp;
			cin >> tmp.first >> tmp.second;
			win.push_back(tmp);
		}
		vector<string> mylot;
		for(int i = 0; i < m; i++){
			string tmp;
			cin >> tmp;
			mylot.push_back(tmp);
		}

		int sum = 0;
		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				int ast = 0;
				int match = 0;
				for(int k = 0; k < 8; k++){
					if(win[j].first[k] == '*'){
						ast++;
						continue;
					}
					if(win[j].first[k] == mylot[i][k]) match++;
				}
				if(8-ast == match) sum += win[j].second;
			}
		}
		cout << sum << endl;
	}
	return 0;
}

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int sum = 0;
    string S, T;
    cin >> S;
    cin >> T;
    
    for(int i=0; i<3; i++) {
        if(S[i] == T[i]) {
            sum++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import kotlin.math.pow

fun main() {
    readLine()
    val list = readLine()!!.split(" ").map(String::toInt).sorted()
    list.indices.flatMap { i ->
        (i + 1 until list.size).flatMap { j ->
            (j + 1 until list.size).map { k ->
                Triple(list[i], list[j], list[k])
            }
        }
    }.filter {
        it.toList().distinct().size == 3
    }.filter {
        it.first + it.second > it.third
    }.count().let {
        println(it)
    }
}


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

int main(){
    double l;
    long double res = 0;
    cin >> l;

    /*
    for(long double i = 0; i <= l; i += 0.000001){
        for(long double j = 0; j + i <= l; j += 0.000001){
            long double k = l - i - j;
            res = max(res, i * j * k);
        }
    }*/

    res = (l/3.0) * (l/3.0) * (l/3.0);

    printf("%.100Lf\n",res);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  for(int i = s.size()-1; i >= 2; i--){
    if(s[i] == s[i-1] || s[i] == s[i-2]){
      printf("%d %d\n", i-1, i+1);
      return 0;
    }
  }
  printf("%s\n", s[0] == s[1] ? "1 2" : "-1 -1");
}


Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
H = LIST()
# print(H)
ans = []
for i in range(len(H)):
	if max(H[0:i+1]) == H[i]:
		ans.append(i)
print(len(ans))

Measured memory_bytes: 4144
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=1e6+5,M=2e6+5,mo=1e9+7;
ll f[3005][3005][2];
int n,m,i,j,k,ans;
int main()
{
	scanf("%d %d",&n,&m);
	fo(i,0,n) f[0][i][i==0]=1;
	fo(i,0,m-1)
		fo(j,0,n)
			fo(k,0,1)
			{
				if (j) (f[i+1][j-1][k|(j==1)]+=f[i][j][k])%=mo;
				if (j) (f[i+1][j][k|(j==1)]+=f[i][j][k])%=mo;
				if (n-j) (f[i+1][j+1][k]+=f[i][j][k])%=mo;
				if (n-j) (f[i+1][j][k]+=f[i][j][k])%=mo;
			}
	fo(i,0,n) ans=(ans+f[m][i][1])%mo;
	printf("%d\n",ans%mo);
}

Measured memory_bytes: 141056
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        solve();
    }

    private static void solve() {
        Scanner input = new Scanner(System.in);

        int n = input.nextInt();
        int d = input.nextInt();

        int ans = 0;

        while(n > 0) {
        	ans++;
        	n = n - 1 - 2*d;
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 21844
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	a,b = map(int,input().split())
	print((a-1)*(b-1))

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 68076
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;
  cout << max(a+b, max(a-b, a*b)) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
        public static void main(String[] args){

                Scanner sn = new Scanner(System.in);
                int n, r;

                while( (n = sn.nextInt())!=0 && (r = sn.nextInt()) != 0 ){
                        int[] array = rangeArray(n);
                        for(int i = 0; i < r; i++){
                                shuffle(array, sn.nextInt(), sn.nextInt());
                        }
                        System.out.println(topOf(array));
                }

        }

        static void shuffle(int[] a, int _p, int  c){
        		int p =_p-1;
                int[] p2c = new int[c];
                for(int i = 0; i < c; i++) p2c[i] = a[p+i];
                for(int i = 0; p != i; i++) a[(p+c-1)-i] = a[(p-1)-i];
                for(int i = 0; i < c; i++) a[i] = p2c[i];
        }

        static void printArray(int[] a){
                for(int i = 0; i < a.length; i++) System.out.print(a[i]+" ");
                System.out.println();
        }

        static int[] rangeArray(int n){
                int[] a = new int[n];
                for(int i = 0; i < a.length; i++) a[i] = n-i;
                return a;
        }
        
        static int topOf(int[] a){ return a[0];}
}

Measured memory_bytes: 28272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int n;
    cin >> n;
    vi p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }

    int cnt = 0;
    int prev = p[0];
    int curr = p[1];
    for (int i = 2; i < n; i++)
    {
        int next = p[i];
        if ((prev < curr && curr <= next) || (next < curr && curr <= prev))
        {
            cnt++;
        }
        prev = curr;
        curr = next;
    }

    cout << cnt << endl;
    return 0;
}


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

struct Node
{
	int parent;
	int child_left;
	int child_right;
};

void print_preorder(int id, const vector<Node> node)
{
	if (id == -1) return;
	cout << " " << id;
	print_preorder(node[id].child_left, node);
	print_preorder(node[id].child_right, node);
}

void print_inorder(int id, const vector<Node> node)
{
	if (node[id].child_left != -1) print_inorder(node[id].child_left, node);
	cout << " " << id;
	if (node[id].child_right != -1) print_inorder(node[id].child_right, node);
}

void print_postorder(int id, const vector<Node> node)
{
	if (node[id].child_left != -1) print_postorder(node[id].child_left, node);
	if (node[id].child_right != -1) print_postorder(node[id].child_right, node);
	cout << " " << id;
}

int main()
{
	int n;
	cin >> n;
	vector<Node> node(n);
	for (int i = 0; i < n; i++) {
		node[i].parent = -1;
		node[i].child_left = -1;
		node[i].child_right = -1;
	}

	for (int i = 0; i < n; i++) {
		int id, left, right;
		cin >> id >> left >> right;
		node[id].child_left = left;
		node[id].child_right = right;
		if (left != -1) node[left].parent = id;
		if (right != -1) node[right].parent = id;
	}

	int root = 0;
	for (int i = 0; i < n; i++) {
		if (node[i].parent == -1) root = i;
	}

	cout << "Preorder" << endl;
	print_preorder(root, node);
	cout << endl;

	cout << "Inorder" << endl;
	print_inorder(root, node);
	cout << endl;

	cout << "Postorder" << endl;
	print_postorder(root, node);
	cout << endl;
}


Measured memory_bytes: 3152
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
string ans[] = {"not coprime", "setwise coprime", "pairwise coprime"};
int a[1010101], b[1010101], c[1010101];
set<int> divisors[1010101];

int main() {
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%d", &a[i]);
    
    // 2. 素因数を取得.
    repx(i, 2, 1010101){
        if(b[i]) continue;
        repex(j, i, 1010101, i){
            b[j]++;
            if(j % i == 0) divisors[j].insert(i);
        }
    }
    // rep(i, 15){
    //     if(divisors[i].size() == 0) continue;
    //     for(auto &p : divisors[i]) printf("%d ", p);
    //     puts("");
    // }
    
    // 3. "pairwise coprime" であるかの判定.
    int idx = 2;
    rep(i, N){
        bool ok = false;
        for(auto &p : divisors[a[i]]){
            // 前回以前に出てきた素因数が見つかったら, 
            // "pairwise coprime" でないことが分かるので, 終了.
            if(!c[p]){
                c[p]++;
            }else{
                idx--;
                ok = !ok;
                break;
            }
        }
        if(ok) break;
    }
    
    // 4. GCD(A[1], ..., A[N]) の 計算.
    // -> gcd = 1 の 場合は, 少なくとも, "setwise coprime" になる.
    int gcd = a[0];
    repx(i, 1, N) gcd = __gcd(gcd, a[i]);
    if(gcd != 1) idx--;
    
    // 5. 出力.
    printf("%s\n", ans[idx].c_str());
    return 0;
    
}

Measured memory_bytes: 194344
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main() {

    fast

    string s;
    cin>>s;
    int n=s.size();
    int cnt=0;

    for(int i=0;i<n;i++){

        if(i%2==0)
        {
            if(s[i]=='R' || s[i]=='U' || s[i]=='D')
                cnt++;
        }
        else{
                if(s[i]=='L' || s[i]=='U' || s[i]=='D')
                cnt++;

        }
    }
    if(cnt==n)
        cout<<"Yes";
    else
        cout<<"No";


	return 0;
}


/*
ll  modularExponentiation(ll x,ll n,ll M)
{

    ll result=1;

    while(n>0)
    {

	if(n%2==1)

 result=(result*x)%M;

  x=(x*x)%M;

  n=n/2;

}

  return result;
}



*/


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

#define ll long long
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define repr(i,n) for(int (i)=(n); (i)>=0; (i)--)

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : 3番目にのみビットを立てることを意味する "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

// 過去問第3問ABC113Bまでdone

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

    vector<int> dp(N,0);
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2; i<N; i++){
        int jump1 = dp[i-1] + abs(h[i-1]-h[i]);
        int jump2 = dp[i-2] + abs(h[i-2]-h[i]);
        dp[i] = min(jump1, jump2);
    }
    cout << dp[N-1] << endl;

    return 0;
}

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

int main(){
    int ans=0;
    int x1,x2,y1,y2;
    int a;
    cin >> x1>>y1>>x2>>y2;

    int vx = x2 - x1;
    int vy = y1 - y2;

    cout << x2 + vy <<" "<< y2 + vx <<" "<< x1 + vy <<" "<< y1 + vx << endl;
    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
using namespace std;
unordered_map<int,int>mp;
int main()
{
    int n,m;
    cin >> n >> m;
    bool ok = false;
    for(int i = 0;i<m;++i)
    {
        int s,e;
        cin >> s >> e;
        if(!ok) {
            if (s == 1 || s == n)++mp[e];
            else if (e == 1 || e == n)++mp[s];
            if (mp[s] > 1 || mp[e] > 1) {
                ok = true;
            }
        }
    }
    if(ok) {
        cout << "POSSIBLE" << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef queue<int> qi;

int main(){
    ll n;
    cin >> n;
    vl a(n);
    lrp(i,n){
        cin >> a.at(i);
    }
    ll ans=0;
    lrp(i,n){
        if(i<n-1&&a.at(i)<a.at(i+1)){
            while(i<n-1&&a.at(i)<=a.at(i+1)){
                i++;
            }
            ans++;
        }elif(i<n-1&&a.at(i)>a.at(i+1)){
            while(i<n-1&&a.at(i)>=a.at(i+1)){
                i++;
            }
            ans++;
        }elif(i<n-1&&a.at(i)==a.at(i+1)){
            continue;
        }elif(i==n-1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
set< char >st;
int main()
{
    string s;
    cin>>s;
    for(char c:s)
        st.insert(c);
    if(s=="zyxwvutsrqponmlkjihgfedcba")
        cout<<-1;
    else if(s.size()==26)
    {
        string nxt = s;
        next_permutation(nxt.begin(),nxt.end());
        string ans;
        for(int i=0;i<s.size();i++)
        {
            ans.push_back(nxt[i]);
            if(nxt[i]!=s[i])
                break;
        }
        cout<<ans;
    }
    else
    {
        int i;
        char c;
        for(i=0;i<26;i++)
        {
            c =i+'a';
            if(st.find(c)==st.end())
                break;
        }
        cout<<s+c<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

antenna = [int(input()) for i in range(0,5)]
k=int(input())

distance = [[0,0,0,0,0] for i in range(len(antenna)) ]

flag = 0
for jj in range(len(antenna)):
    for kk in range(len(antenna)):
        distance[jj][kk]=abs(antenna[jj]-antenna[kk])
        if distance[jj][kk] > k:
            flag = 1

if flag == 0:
    print("Yay!")
elif flag == 1:
    print(":(")
else:
    print("error")


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
//#include <boost/graph/adjacency_list.hpp>
using namespace std;

#define ll long long
#define IN(type, name) type name; cin >> name
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x

int main()
{
	cout << fixed << setprecision(6);
	IN(int, n);
	IN_V(int, hls, n);

	vector<int> hdiff(n - 1);

	for (int i = 0; i < n - 1; ++i) { hdiff[i] = hls[i + 1] - hls[i]; }

	bool isAble = true;
	int diff = 0;
	for (int i = 0; i < n - 1; ++i) {
		if (hdiff[i] < 0) {
			if (hdiff[i] < -1) { isAble = false; break; }
			if (diff == -1) { isAble = false; break; }
			diff = -1;
		}
		if (hdiff[i] > 0)diff = 0;
	}

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

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++) cin >> p[i];
  int count = 0;
  for(int i = 1; i < n - 1; i++) {
    if((p[i + 1] - p[i])*(p[i] - p[i - 1]) > 0) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
from sys import stdin
import numpy as np
# import math
# import random
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]
N, M = [int(x) for x in stdin.readline().rstrip().split()]

L_max = 0
R_min = N
for i in range(M):
  L, R = [int(x) for x in stdin.readline().rstrip().split()]
  if L > L_max:
    L_max = L
  if R < R_min:
    R_min = R

print(max(0,R_min-L_max+1))

Measured memory_bytes: 21160
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<27;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
//const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll mod;

vvl mul(vvl A,vvl B){
	vvl C(A.size(),vl(B[0].size()));
	for(int i=0;i<A.size();i++) for(int k=0;k<B.size();k++) for(int j=0;j<B[0].size();j++) (C[i][j]+=A[i][k]*B[k][j])%=mod;
	return C;
}

// 行列の最小二乗法
vvl pow(vvl A,ll n){
	vvl B(A.size(),vl(A.size()));
	for(int i=0;i<A.size();i++) B[i][i]=1;
	while(n>0){
		if(n&1) B=mul(B,A);
		A=mul(A,A);
		n>>=1;
	}
	return B;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int n,m;
		cin>>n>>m;
		vd a(n),b(n),c(n);
		for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
		double res=0;
		vd dp(1<<n);
		for(int i=1;i<1<<n;i++){
			for(int j=0;j<n;j++) if(i&1<<j){
				dp[i]=dp[i-(1<<j)];
				for(int k=j+1;k<n;k++) if(i&1<<k){
					dp[i]+=(a[j]-a[k])*(a[j]-a[k])+(b[j]-b[k])*(b[j]-b[k])+(c[j]-c[k])*(c[j]-c[k]);
				}
				break;
			}
		}
		for(int i=0;i<1<<n;i++){
			int t=0;
			for(int j=0;j<n;j++) if(i&1<<j) t++;
			if(t==m) res=max(res,dp[i]);
		}
		cout<<syosu(9)<<res<<endl;
		break;
	}
}


Measured memory_bytes: 11152
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

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

	cout<<setprecision(12)<<fixed;

	int n;
	cin>>n;
	long double p[n];
	for(int i=0;i<n;i++){
		cin>>p[i];
	}

	long double dp[n+1][n+1];
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		dp[0][i] = 0;
		dp[i][0] = dp[i-1][0]*(1-p[i-1]);
	}

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			dp[i][j] = (dp[i-1][j]*(1-p[i-1])) + (dp[i-1][j-1]*p[i-1]);
		}
	}

	long double ans = 0;
	for(int i=(n/2)+1;i<=n;i++){
		ans += dp[n][i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 140928
import java.io.*
import java.util.*

fun solve(N: Int){
    val lucasNumbers = LongArray(90)
    lucasNumbers[0] = 2
    lucasNumbers[1] = 1

    for (i in 2 until 90){
        lucasNumbers[i] = lucasNumbers[i-1] + lucasNumbers[i-2]
    }
    println(lucasNumbers[N])
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    solve(N)
}



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

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define ull unsigned long long
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define mst(ss,b) memset(ss,b,sizeof(ss));
#define dbg(x) cout << #x << "= " << x << endl;
typedef pair <int, int> pii;
const int inf = 0x3f3f3f3f;
const ll INF = (1LL<<63)-1;
const ll mod = 1e9+7;
const int N = 1e5+5;

int n, m, q;
vector<int>E[N];
tuple<int, int, int>op[N];
int col[N][15];

//void dfs(int u, int d, int c){ //这种写法不对，不是vis=1就返回
//    if(vis[u])return ;
//    vis[u] = 1;
//    if(!col[u])col[u] = c;
//    for(auto v : E[u]){
//        if(d)dfs(v, d-1, c);
//    }
//}

//void dfs(int u, int d, int c, int fa){ //暴力写法TLE
//    col[u] = c;
//    if(!d)return ;
//    for(auto v : E[u]){
//        if(v == fa)continue;
//        dfs(v, d-1, c, u);
//    }
//}

void dfs(int u, int d, int c){
    if(d == -1)return ;
    if(col[u][d])return ;
    col[u][d] = c;
    for(auto v : E[u]){
        dfs(v, d-1, c);
    }
}

int  main(){
    scanf("%d%d", &n, &m);
    for(int i=1; i<=m; i++){
        int u, v;
        scanf("%d%d", &u, &v);
        E[u].pb(v);
        E[v].pb(u);
    }
    scanf("%d", &q);
    int v, d, c;
    for(int i=1; i<=q; i++){
        scanf("%d%d%d", &v, &d, &c);
        op[i] = make_tuple(v, d, c);
    }
    for(int i=1; i<=n; i++)E[i].pb(i); //自己指向自己， 才能够自己跑到color[i][0]

    for(int i=q; i>=1; i--){
        tie(v, d, c) = op[i];
        dfs(v, d, c);
    }
    for(int i=1; i<=n; i++)printf("%d\n", col[i][0]);
    return 0;
}


//    lower_bound()
//    __builtin_popcount()
//    ios::sync_with_stdio(false);
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    const double eps=1e-12;
//    #pragma comment(linker,"/STACK:102400000,102400000")



Measured memory_bytes: 13560
#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 MOD=1000000007;

int main() {
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n) {
    int x;
    cin >> x;
    mp[x]++;
  }
  vector<int> a;
  set<int> se;
  for(auto p: mp) {
    if(p.second==1) a.push_back(p.first);
    else {
      if(se.count(p.first)) continue;
      int j=1;
      while(p.first*j<=1001001) {
        se.insert(p.first*j);
        j++;
      }
    }
  }
  int ans=0;
  int sz=a.size();
  rep(i,sz) {
    if(!se.count(a[i])) {
      ans++;
      int j=1;
      while(a[i]*j<=1001001) {
        se.insert(a[i]*j);
        j++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 60248
#include <iostream>
#define N 5000+1

using namespace std;

void input();
void pro();

bool ok = false;
char c[N][N];

int x[N];
int ans[N];
int n, m;
int v = 0;
int at = 0;
int a, b;
int i, j, l;

int main() {

	input();
	pro();

	for (i = 0; i < n; i++) cout << ans[i] + 1 << endl;

	if (ok == true)cout << "1" << endl;
	else cout << "0" << endl;

	//	cin >> n;

	return 0;

}

void input() {

	cin >> n >> m;
	for (i = 0; i < m; ++i) {

		cin >> a >> b;

		--a; --b;

		c[a][b] = 1;
		c[b][a] = 2;
		++x[b];

	}
}

void pro() {

	for (i = 0; i<n; ++i) {

		v = 0;

		for (j = 0; j<n; ++j) {

			if (x[j] == 0) {
				at = j;
				++v;

			}
		}

		//		printf("%d\n", v);

		if (v >= 2)ok = true;
		x[at] = 99999999;
		ans[i] = at;
		for (j = 0; j<n; ++j)if (c[j][at] == 2) --x[j];

	}
}




Measured memory_bytes: 27516
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N,X;cin>>N>>X;
  vector<int>L(N+1);
  L[0]=0;
  for (int i=0;i<N;++i){
    int x;cin>>x;
    L[i+1]=L[i]+x;
  }
  int ans=0;    
  for (int i=0;i<=N;++i){
    if (L[i]<=X){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define N 400005
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

vi fac(N);
void fact()
{
    fac[0] = 1;
    for(int i = 1; i< N; i++)
        fac[i] = 1LL*fac[i-1]*i%mod;
}


ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}


ll ncr(int n, int r)
{
    ll res = (fac[n] * bigmod(1LL*fac[r] * fac[n-r]%mod, mod - 2))%mod;
    return res;
}



//=============================================ASIFAZAD==============================================//

int32_t main()
{
    io;
    fact();
    int n, k;
    cin>>n>>k;
    int res = 0, lim = min(k, n-1);
    for(int i = 0; i<= lim; i++)
        res = (res + ncr(n, i)*ncr(n-1, i))%mod;
    cout<<res;
    return 0;
}

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

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

int main(){
  int   n,height;
  int Height;
  int ans=0;

  cin >> n;
  cin >> height;
  
  rep(i,n){
    cin >> Height;
    if(height<=Height) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def calc():
  n=int(input())
  table=[i for i in range(n+1)]
  for i in range(2,n+1):
    if table[i]<i:
      continue
    for j in range(i,n+1,i):
      table[j]=i
  ans=0
  for i in range(1,n+1):
    cnt={}
    ret=i
    while i!=1:
      prime=table[i]
      if prime in cnt:
        cnt[prime]+=1
      else:
        cnt[prime]=1
      i//=prime
    for val in cnt.values():
      ret*=val+1
    ans+=ret
  print(ans)
calc()

Measured memory_bytes: 225456
n,m = map(int, input().split())
ma = []
for i in range(n):
  ma.append(input())

t = []
for i in range(m):
  t.append(input())

ans = False
for i in range(n - m + 1):
  for j in range(n - m + 1):
    for k in range(m):
      ll = ma[i + k][j : j + m]
      if ll != t[k]:
        break
    else:
      ans = True

if ans:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9040
#WA

#桁DP

N=str(input())
K=int(input())
L=len(N)

#DP[i][smaller][j]=上からi桁(1<=i<=L)で0でない数字がj個(0<=j<=3)
DP=[[[0]*5 for index1 in range(2)] for index2 in range(L+1)]
#適当に初期設定
DP[0][0][0]=1



for i in range(1,L+1):
    #smaller=1->smaller=1
    DP[i][1][4]+=DP[i-1][1][4]*10+DP[i-1][1][3]*9
    DP[i][1][3]+=DP[i-1][1][3]+DP[i-1][1][2]*9
    DP[i][1][2]+=DP[i-1][1][2]+DP[i-1][1][1]*9
    DP[i][1][1]+=DP[i-1][1][1]+DP[i-1][1][0]*9
    DP[i][1][0]+=DP[i-1][1][0]

    n=int(N[i-1])

    #smaller=0->smaller=1
    #n=0だとsmaller=0->smaller=1がない
    #n=1だとsmaller=0->smaller=1のとき必ずjは変化しない
    if n==1:
        DP[i][1][4]+=DP[i-1][0][4]
        DP[i][1][3]+=DP[i-1][0][3]
        DP[i][1][2]+=DP[i-1][0][2]
        DP[i][1][1]+=DP[i-1][0][1]
        DP[i][1][0]+=DP[i-1][0][0]
    elif n>=2:
        DP[i][1][4]+=DP[i-1][0][4]*n+DP[i-1][0][3]*(n-1)
        DP[i][1][3]+=DP[i-1][0][3]+DP[i-1][0][2]*(n-1)
        DP[i][1][2]+=DP[i-1][0][2]+DP[i-1][0][1]*(n-1)
        DP[i][1][1]+=DP[i-1][0][1]+DP[i-1][0][0]*(n-1)
        DP[i][1][0]+=DP[i-1][0][0]

    #smaller=0->smaller=0
    #n=0だと必ずjは変化しない
    if n==0:
        DP[i][0][4]+=DP[i-1][0][4]
        DP[i][0][3]+=DP[i-1][0][3]
        DP[i][0][2]+=DP[i-1][0][2]
        DP[i][0][1]+=DP[i-1][0][1]
        DP[i][0][0]+=DP[i-1][0][0]
    else:
        DP[i][0][4]+=DP[i-1][0][4]+DP[i-1][0][3]
        DP[i][0][3]+=DP[i-1][0][2]
        DP[i][0][2]+=DP[i-1][0][1]
        DP[i][0][1]+=DP[i-1][0][0]

print(DP[L][0][K]+DP[L][1][K])



Measured memory_bytes: 3268