akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define A 1
#define C 2
#define G 3
#define T 4
int N;
char str[100001];
ll dp[101][5][5][5];
int main() {
	scanf("%d", &N);
	dp[0][0][0][0] = 1;
	rep(i, 0, N) {
		rep(i2, 0, 5) {
			rep(i3, 0, 5){
				rep(i4, 0, 5) {
					rep(i5, 1, 5) {
						if (i3 == A && i4 == G && i5 == C)continue;
						if (i3 == A && i4 == C && i5 == G)continue;
						if (i3 == G && i4 == A && i5 == C)continue;
						if (i2 == A && i3 == G && i5 == C)continue;
						if (i2 == A && i4 == G && i5 == C)continue;
						dp[i + 1][i3][i4][i5] += dp[i][i2][i3][i4];
						dp[i + 1][i3][i4][i5] %= 1000000007;
					}
				}
			}
		}
	}
	ll ans = 0;
	rep(i2, 0, 5) {
		rep(i3, 0, 5) {
			rep(i4, 0, 5) {
				ans += dp[N][i2][i3][i4];
				ans %= 1000000007;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main () {
    ios_base::sync_with_stdio(false);
    int N,ans = 0;
    string S;
    cin>>N;
    for(int i=0;i<N;i++) {
        cin>>S;
        auto it = mp.find(S);
        if(it == mp.end()) {
            mp.insert({S,1});
            ans++;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 19204
#include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
int a,b,c,d;
cin>>a>>b>>c>>d;
if(a>b){
    cout<<(b*c)+((a-b)*d)<<endl;
}
else cout<<a*c<<endl;
    return 0;
    
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
a = LIST()

ans = 0
for i in range(1, N):
	if a[i] == a[i-1]:
		ans += 1
		a[i] = 0

print(ans)



Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS

    int A, V;
    cin >> A >> V;
    int B, W;
    cin >> B >> W;
    int T; cin >> T;
    int d = abs(A-B);
    ll d2 = V-W;
    if (d2 <= 0) OUT("NO")
    else {
        if (d <= d2 * T) OUT("YES")
        else OUT("NO")
    }

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = a; i < b; ++i)
#define ll long long
#define M 100000007
#define fr first
#define sc second
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll, ll>
#define psi pair<string, ll>
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define PI 3.14159265
#define r0 return 0

/* typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
*/
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
using namespace std;
int findi(int arr[], int len, int seek)
{
    for (int i = 0; i < len; ++i)
    {
        if (arr[i] == seek) return i;
    }
    return -1;
}

int main() {
    int n;
    cin>>n;
    int a[n],flag=0,flag1=0;
    rep(i,0,n) cin>>a[i];
    rep(i,0,n){
        if(a[i]==i+1 );
        else if(flag<1 && a[i]!=i+1){
           int x=findi(a,n,i+1);
        //    cout<<x<<endl;
           swap(a[x],a[i]);
           flag++;
        }
        else if(flag==1 && a[i]!=i+1) {
            cout<<"NO"<<endl;
            flag1++;
            break;
        }
    }
    if(flag1==0) cout<<"YES"<<endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};
use std::collections::HashMap;

pub struct Comb {
    max: usize,
    m: i64,
    fac: Vec<i64>,
    finv: Vec<i64>,
}
impl Comb {
    /// initialize table
    /// max: maximum that n as nCk takes
    /// m: MOD, a prime number
    /// O(n)
    pub fn new(max: usize, m: i64) -> Comb {
        let n = max;
        let mut fac = Vec::with_capacity(n);
        fac.push(1);
        fac.push(1);
        let mut finv = Vec::with_capacity(n);
        finv.push(1);
        finv.push(1);
        let mut inv = Vec::with_capacity(n);
        inv.push(1);
        inv.push(1);
        for i in 2..n {
            let i = i as i64;
            let tmp = fac.last().unwrap() * i % m;
            fac.push(tmp);
            let tmp = m - inv[(m % i) as usize] * (m / i) % m;
            inv.push(tmp);
            let tmp = finv.last().unwrap() * inv.last().unwrap() % m;
            finv.push(tmp);
        }
        Comb {
            max: max,
            m: m,
            fac: fac,
            finv: finv,
        }
    }
    /// nCr
    pub fn ncr(&self, n: usize, k: usize) -> i64 {
        // since n, k are usize, do not need to check `n < 0 || k < 0`
        if n < k || n > self.max {
            panic!("Invalid query (n, k) = ({}, {})", n, k);
        } else {
            self.fac[n] * (self.finv[k] * self.finv[n - k] % self.m) % self.m
        }
    }
}

struct Edge {
    to: i32,
    id: i32,
}
const MOD: i64 = 1_000_000_007;

fn main() {
    let x: i64 = read();
    let y: i64 = read();
    if (x + y) % 3 != 0 {
        println!("{}", 0);
        return;
    }

    let n: i64 = (2 * y - x) / 3;
    if n < 0 {
        println!("{}", 0);
        return;
    }
    let m: i64 = (2 * x - y) / 3;
    if m < 0 {
        println!("{}", 0);
        return;
    }
    let c: Comb = Comb::new((n + m + 1) as usize, MOD);
    let c: Comb = Comb::new((n + m + 1) as usize, MOD);
    let mut ans = c.ncr((n + m) as usize, n as usize);

    println!("{}", ans % MOD);
}


Measured memory_bytes: 35068
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

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

	int n; cin >> n;

	for (int x = sqrt(n);; x--) {
		if (n%x == 0) {
			int y = n / x;
			dump(x, y);
			dump(log10(x), log10(y));
			int ans = max(1+(int)log10(x), 1+(int)log10(y));
			cout << ans << endl;
			break;
		}
	}

	return 0;
}

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

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

int main(){
  int l,r,d;
  cin >> l >> r >> d;

  cout << r/d - int((l-0.1)/d);
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll n; cin >> n;
    ll a[n+1]; f(i,1,n) cin >> a[i];
    ll rot[n]; f(i,0,n-1) rot[i] = 0;
    f(i,1,n) {
        if(a[i] < 1 || a[i] >= n) continue;
        if(i - a[i] < 0 || i - a[i] >= n) continue;
        rot[i - a[i]]++;
    }
    ll ans = 0;
    f(i,1,n) {
        if(a[i] < 1 || a[i] >= n) continue;
        ll reqrot = i + a[i];
        if(reqrot < 0 || reqrot >= n) continue;
        ans += rot[reqrot];
        if(i - a[i] < 0 || i - a[i] >= n) continue;
        rot[i-a[i]]--;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 6760
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
int solution(vector<int> A, int k) 
{ 
 
    int N = A.size(); 
 
    vector<int> v1(N, 0); 
    vector<int> v2(N, 0); 
    vector<int> v3(100, 0); 
  

    v2[N - 1] = 1; 
    v3[A[N - 1] - 1] = 1; 
  

    for (int i = N - 2; i >= 0; i--) { 
  
        v2[i] = v2[i + 1]; 
  
        if (v3[A[i] - 1] == 0) { 
            v2[i]++; 
            v3[A[i] - 1] = 1; 
        } 
    } 
  
    for (int j = 1; j < k; j++) { 
  
     
        fill(v3.begin(), v3.end(), 0); 
  
        v1[N - 1] = 0; 
  
        for (int i = N - 2; i >= 0; i--) { 
  
            v1[i] = v1[i + 1]; 
  
           
            v1[i] = v1[i] + v2[i + 1]; 
  
            v1[i] = v1[i] - v3[A[i] - 1]; 
  
            v3[A[i] - 1] = v2[i + 1]; 
        } 
  
        v2 = v1; 
    } 
    return v1[0]; 
}  
signed main()
{
    fast;
    
    int n,i,ans=0,j,k;
    cin>>n;
    string s;
    cin>>s;
    for(i=0;i<10;i++)
    {
    	for(j=0;j<10;j++)
    	{
    		for(k=0;k<10;k++)
    		{
    			int z=0;
    			for(z=0;z<n;z++)
    			{
    				if((s[z]-'0')==i) break;
    			}
    			for(z++;z<n;z++)
    			{
    				if((s[z]-'0')==j) break;
    			}
    			for(z++;z<n;z++)
    			{
    				if((s[z]-'0')==k) break;
    			}
    			if(z<n) ans++;
    		}
    	}
    }

    cout<<ans;
}

Measured memory_bytes: 384
import math
def combination(n, r):
    return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))
N, M = list(map(int, input().split(' ')))
sum_num = 0
if N >= 2:
    sum_num += combination(N, 2)
if M >= 2:
    sum_num += combination(M, 2)
print(int(sum_num))


Measured memory_bytes: 3060
//#include<cstdio>
//#include<cstdlib>
#include <iostream>
#include <vector>
#include <queue>
//#include<bitset>
//#include<string>
//#include<stack>
//#include<set>
//#include<unordered_set>
//#include<map>
//#include<unordered_map>
//#include<cstring>
//#include<complex>
//#include<cmath>
//#include<iomanip>
//#include<numeric>
#include <algorithm>
#include <stdio.h>
//#include<list>
//#include<functional>
//#include<cassert>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define m 1000000007
void pv(vector<ll> arr, ll size)
{

    for (ll i = 0; i < size; i++)
    {
        cout << arr[i] << ' ';
    }
}
void gv(vector<ll> &arr)
{
    ll size = arr.size();
    for (ll i = 0; i < size; i++)
    {
        cin >> arr[i];
    }
}
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    gv(a);
    ll arr[n + 1][k + 1] = {0};
    for (ll i = n; i > 0; i--)
    {
        ll cum[k + 1] = {0};
        if (i != n)
        {
            cum[0] = arr[i + 1][0];
            for (ll w = 1; w <= k; w++)
            {
                cum[w] = (cum[w - 1] + arr[i + 1][w]) % m;
            }
            // for (ll w = 0; w < k; w++)
            //     cout << cum[w] << " ";
            // cout << '\n';
        }
        ll cc = 0;
        for (ll j = 0; j <= k; j++)
        {
            if (i == n)
            {
                if (j > a[i - 1])
                    arr[i][j] = 0;
                else
                    arr[i][j] = 1;
            }
            else
            {
                // ll cum[k + 1];
                if (j == 0)
                {
                    arr[i][j] = 1;
                }
                else if (j > a[i - 1])
                {
                    arr[i][j] = cum[j] - cum[cc];
                    cc++;
                }
                else
                {
                    arr[i][j] = cum[j];
                }
            }
            // cout << arr[i][j] << " ";
        }
        // cout << '\n';
    }
    cout << (arr[1][k] % m + m) % m;
    return 0;
}

Measured memory_bytes: 79232
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
k = gets.to_i

if (b-a <= k) && (c-a <= k) && (d-a <= k) && (e-a <= k) && (c-b <= k) && (d-b <= k) && (e-b <= k) && (d-c <= k) && (e-c <= k) && (e-d <= k)
  puts "Yay!"
else
  puts ":("
end

Measured memory_bytes: 14316
#include<stdio.h>
int main(void){
	int t,n,a[]={6000,4000,3000,2000},i,x[10];
	for(i=0;i<4;i++){
		scanf("%d%d",&t,&n);
		x[i]=a[t-1]*n;
	}
	for(i=0;i<4;i++) printf("%d\n",x[i]);
	return 0;
}

Measured memory_bytes: 2732
from collections import Counter,defaultdict,deque
import sys
import copy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

def find(x): # 木の根を求める
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
        
def unite(x,y): # xとyの属する集合を併合
    x=find(x)
    y=find(y)
    if x==y:
        ans.append(0)
        return
    ans.append(num[x]*num[y])
    z=num[x]+num[y]
    num[x]=z
    num[y]=z
    if rank[x]<rank[y]:
        par[x]=y
    else:
        par[y]=x
        if rank[x]==rank[y]:
            rank[x]+=1

def same(x,y): # xとyが同じ集合に属するか判定
    return find(x)==find(y)

def main():
    n,m = map(int,input().split()) 

    global par,rank,num,ans
    par=[i for i in range(n)]  # 親
    rank=[0 for _ in range(n)] # 木の深さ
    num=[1 for _ in range(n)] # 木の大きさ
    ans=[]
    ab=[]
    for _ in range(m):
        a,b = map(int,input().split())
        ab.append((a-1,b-1))
    for i in range(m-1,-1,-1):
        unite(ab[i][0],ab[i][1])
    p=(n*(n-1))//2
    x=[]
    for i in range(m):
        x.append(p)
        p-=ans[i]
        if p<0:
            p=0
    x.reverse()
    for i in range(m):
        print(x[i])
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 95520
#include<bits/stdc++.h>
using namespace std;
#define  ll  long long
#define  sf  scanf
#define  pf  printf
int main()
{
    int t,z,i,n,m;
    sf("%d %d",&n,&m);
    if(n>8 || m>8)
    {
        pf(":(\n");
    }
    else
    {
        pf("Yay!\n");
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  double p[N]; rep(i,N) cin >> p[i];
  double dp[N+1][N+1] = {}; dp[0][0] = 1;
  rep(i,N) rep(j,i+2) {
    if (j==0) dp[i+1][j] = dp[i][j]*(1-p[i]);
    else dp[i+1][j] = dp[i][j]*(1-p[i]) + dp[i][j-1]*p[i];
  }
  // debug(dp[N],dp[N]+(N+1));
  double result = 0; repr(i,(N+1)/2,N+1) result += dp[N][i];
  cout << setprecision(10) << result << endl;
  return 0;
}

Measured memory_bytes: 70528
#include <iostream>
#include <stdlib.h>
#define llint long long

using namespace std;

llint n;
llint x[1005], y[1005];
bool upos[35], vpos[35];

void calc(llint u, llint v)
{
	llint t = (u + (1LL<<31) - 1) / 2;
	for(int j = 0; j < 31; j++){
		if(t%2) upos[j] = true;
		else upos[j] = false;
		t /= 2;
	}
	t = (v + (1LL<<31) - 1) / 2;
	for(int j = 0; j < 31; j++){
		if(t%2) vpos[j] = true;
		else vpos[j] = false;
		t /= 2;
	}
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
	
	for(int i = 1; i <= n; i++){
		if(abs(x[i]+y[i])%2 != abs(x[1]+y[1])%2){
			cout << -1 << endl;
			return 0;
		}
	}
	
	bool odd = (abs(x[1]+y[1])%2==1);
	int m = 31; if(!odd) m++;
	
	if(odd){
		cout << 31 << endl;
		for(int i = 0; i < 31; i++) cout << (1<<i) << " "; cout << endl;
	}
	else{
		cout << 32 << endl;
		for(int i = 0; i < 31; i++) cout << (1<<i) << " "; 
		cout << 1 << endl;
	}
	
	const llint C = (1LL<<31)-1;
	for(int i = 1; i <= n; i++){
		llint u = x[i]+y[i], v = x[i]-y[i];
		if(odd) calc(u, v);
		else{
			if(u-1 > -C) upos[31] = true, u--;
			else upos[31] = false, u++;
			if(v-1 > -C) vpos[31] = true, v--;
			else vpos[31] = false, v++;
			calc(u, v);
		}
		
		for(int j = 0; j < m; j++){
			if(upos[j]){
				if(vpos[j]) cout << 'R';
				else cout << 'U';
			}else{
				if(vpos[j]) cout << 'D';
				else cout << 'L';
			}
		}
		cout << endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q; cin>>q;
    for(int i=0; i<q; i++){
        string x,y;
        cin>>x>>y;
        int nx=(int)x.size();
        int ny= (int)y.size();
        vector<vector<Int>> dp(nx+1,vector<Int>(ny+1,0));
        for(int i=0; i<(int)x.size(); i++){
            for(int j=0; j<(int)y.size(); j++){
                if(x[i]==y[j]){
                    dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
                }
                dp[i+1][j+1]=max({dp[i+1][j+1],dp[i][j+1],dp[i+1][j]});
            }
        }
        cout<<dp[nx][ny]<<endl;
    }
    return 0;
}


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

int main()
{
    int N,M,Input = 0;
    vector<int> student;
    cin >> N >> M;
    
    for(int i = 0;i < N;i++){
        cin >> Input;
        student.push_back(Input);
    }
    
    for(int k = 1;k <= M;k++){
        for(int i = 0;i < N-1;i++){
            if(student[i] % k > student[i+1] % k){
                swap(student[i],student[i+1]);
            }
        }
    }
    
    for(int i = 0;i < student.size();i++){
        cout << student[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3140
#include <iostream>

using namespace std;

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

    int dif = b - a;
    int sum = 0;
    for (int i = 1; i <= dif; i++)
    {
        sum += i;
    }

    // cout << sum << endl;
    cout << sum - b << endl;
    return 0;
}

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

using namespace std;

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

int main(){
    int n;
    cin >> n;
    string s[n];
    rep(i, n) cin >> s[i];
    int m;
    cin >> m;
    string t[m];
    rep(i, m) cin >> t[i];
    int ans = 0;
    rep(i, n){
        int num = 0;
        string S = s[i];
        rep(j, n){
            if (s[j] == S){
                num++;
            }
        }
        rep(j, m){
            if (t[j] == S){
                num--;
            }
        }
        ans = max(ans, num);
    }
    cout << ans << 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 a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());

		if (a == 1){
			a = 14;
		}
		if (b == 1){
			b = 14;
		}

		if (a > b){
			System.out.println("Alice");
		}else if (a < b){
			System.out.println("Bob");
		}else{
			System.out.println("Draw");
		}
	}
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string T;
	cin >> T;
	int64 res = 0;
	REP(i, T.size()) {
	  if (T[i] == '?') T[i] = 'D';
	}
	cout << T << endl;
}


Measured memory_bytes: 3744
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename T>
class hashmap64 {
	std::vector<std::pair<uint64, T>> map;
	uint64 mask, count, temp;
	uint64 hash64(uint64 key) {
		//key = ~key;
		key ^= key << 13;
		key ^= key >> 19;
		return key ^ (key << 17);
	}
public:
	hashmap64() :map(8192, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = 8191; count = 0;
	}
	hashmap64(size_t s) {
		s |= s << 1;
		s |= s >> 2;
		s |= s >> 4;
		s |= s >> 8;
		s |= s >> 16;
		s |= s >> 32;
		mask = s;
		count = 0;
		map.resize(s + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
	}
	T &operator[](uint64 suf) {
		temp = mask&hash64(suf);
		while (map[temp].first != suf) {
			temp = mask&(temp + 1);
		}
		return map[temp].second;
	}
	void insert(uint64 key, const T &value) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<uint64, T> mkey;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
			for (uint64 t = 0;t <= mask >> 1;++t) {
				if (!~map[t].first) {
					mkey = map[t];
					map[t].first = ~0;
					temp = mask&hash64(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(uint64 key) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	hashmap64<uint32> map(16000);
	uint32 n;
	std::cin >> n;
	int64 a, sum = 1e15;
	uint32 ans = 0;
	map.insert(sum, 0);
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)) {
			ans = std::max(ans, i + 1 - map[sum]);
		}
		else {
			map.insert(sum, i + 1);
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 15252
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
	string s;
	cin >> s;
	int n=s.size();
	bool ok=1;
	rep(i,(n+1)/2){
		if(s[i]!=s[n-i-1])ok=0;
	}
	rep(i,(n-1)/2){
		if(s[i]!=s[(n-1)/2-i-1])ok=0;
	}
	rep(i,n-(n+3)/2+1){
		if(s[i+(n+3)/2-1]!=s[n-i-1])ok=0;
	}
	if(ok){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
    return 0;
}



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

// ------ graph ------ //
using Weight = long long;
using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) { }
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // pqが降順のため
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
using Edges = vector<Edge>;
struct Graph {
    vector<Edges> adj;
    Graph(int n) : adj(n) { }
    int size() { return adj.size(); }
    Edges operator [] (int v) { return adj[v]; }
    void add_edge(int a, int b, Weight w = 1) { // graph
        adj[a].emplace_back(a, b, w);
        adj[b].emplace_back(b, a, w);
    }
    void add_arc(int a, int b, Weight w = 1) {  // digraph
        adj[a].emplace_back(a, b, w);
    }
};
using Array = vector<Weight>;
using Matrix = vector<Array>;
using UnweightedGraph = vector<vector<int>>;

// ------ StronglyConnectedComponents ------ //
struct StronglyConnectedComponents {
    const UnweightedGraph &g;
    UnweightedGraph rg;
    vector<int> comp, order, seen;
    StronglyConnectedComponents(const UnweightedGraph &g)
    : g(g), rg(g.size()), comp(g.size(), -1), seen(g.size()) {
        for (int u = 0; u < g.size(); ++u) {
            for (int v: g[u]) {
                rg[v].emplace_back(u);
            }
        }
    }
    int operator[](int k) { return comp[k]; }
    void dfs(int u) {
        seen[u] = true;
        for (int v: g[u]) if (!seen[v]) dfs(v);
        order.emplace_back(u);
    }
    void rdfs(int u, int id) {
        comp[u] = id;
        for (int v: rg[u]) if (comp[v] == -1) rdfs(v, id);
    }
    UnweightedGraph build() {
        for (int u = 0; u < g.size(); ++u) if (!seen[u]) dfs(u);
        reverse(begin(order), end(order));
        int id = 0;
        for (int u: order) if (comp[u] == -1) rdfs(u, id++);
        UnweightedGraph g_comp(id);
        for (int u = 0; u < g.size(); ++u) for (int v: g[u]) {
            int x = comp[u], y = comp[v];
            if (x != y) g_comp[x].push_back(y);
        }
        return g_comp;
    }
};

int main() {
    int V, E; cin >> V >> E;
    UnweightedGraph g(V);
    while (E--) {
        int s, t; cin >> s >> t;
        g[s].emplace_back(t);
    }
    StronglyConnectedComponents scc(g);
    UnweightedGraph g_comp = scc.build();
    cout << (g_comp.size() != V) << endl;
    return 0;
}


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

vector<ll>v[200001];
ll vis[200001]={0};
ll g;

void dfs(ll n,ll k)
{
    vis[n]=1;
    
    g++;
    for(ll i=0;i<v[n].size();i++)
    {
        if(vis[v[n][i]]==0)
        {
            
            dfs(v[n][i],k+1);
           
        }
    }
 
}

int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
	
	ll n,m;
	cin>>n>>m;
	
	
	for(ll i=0;i<m;i++)
	{
	    ll x,y;
	    cin>>x>>y;
	    v[x].push_back(y);
	    v[y].push_back(x);
	    
	}
	ll ans=0;
	ll k=0;
	ll q;
	for(ll i=1;i<=n;i++)
    {
        k=0;
        if(vis[i]==0)
        {
            g=0;
            dfs(i,k);
         ans=max(ans,g);
        }
        
    }
    cout<<ans<<endl;
	
	
	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  int first = 0, second = 0;
  for (int i=0; i<N; i++) {
    if (A[i] >= first) {
      second = first;
      first = A[i];
    } else if (A[i] >= second) {
      second = A[i];
    }
  }
  for (int i=0; i<N; i++) {
    if (A[i] == first) cout << second << endl;
    else cout << first << endl;
  }
}

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

map<string, int> M;
int main(){
  int n;
  cin >> n;
  string s;
  for(int i = 0; i < n; i++){
    cin >> s;
    M[string(s)]++;
  }
  int max  = 0;
  for(auto x : M){
    if(max < x.second){
      max = x.second;
    }
  }

  for(map<string, int>::iterator it = M.begin(); it != M.end(); it++){
    if(it->second == max){
      cout << it->first << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 25216
N, M = map(int, input().split())
# また答えが見つかってなければTrue
flag = True
for i in range(N, M//10 + 1):
    if M%i == 0:
        print(M//i)
        flag = False
        break
for i in range(9):
    if flag and M%(10 - i) == 0 and M//(10 - i) >= N:
        print(10 - i)
        flag = False
if flag:
    print(1)

Measured memory_bytes: 40044
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define repd(z, x, y) for(int z=x;z>=y;--z)
#define com bool operator<(const node &b)const
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;
int hang[maxn], lie[maxn];
map<pii, bool> mp;

void solve() {
    int h, w, m;
    cin >> h >> w >> m;
    while (m--) {
        int x, y;
        cin >> x >> y;
        mp[pii{x, y}] = true;
        hang[x]++;
        lie[y]++;
    }
    int maxxlie = 0, maxxhang = 0;
    rep(i, 1, w)maxxlie = max(maxxlie, lie[i]);
    rep(i, 1, h)maxxhang = max(maxxhang, hang[i]);
    vector<int> l, ht;
    rep(i, 1, w) {
        if (lie[i] == maxxlie)l.push_back(i);
    }
    rep(i, 1, h) {
        if (hang[i] == maxxhang)ht.push_back(i);
    }
    for (auto &i:l) {
        for (auto &j:ht) {
            if (!mp[pii{j, i}]) {
                cout << maxxlie + maxxhang;
                return;
            }
        }
    }
    cout << maxxlie + maxxhang - 1;
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 35012
import sys
N,M = map(int,input().split())
intact = [True for _ in range(N)]
dp = [0 for _ in range(N+1)]
MOD = 1000000007
for i in range(M):
  a = int(input())
  intact[a] = False
if N == 1:
  print(1)
  sys.exit(0)
dp[0] = 1
if (intact[1]):
  dp[1] = 1
for i in range(2,N+1):
  if intact[i-2]:
    dp[i] += dp[i-2]
  if intact[i-1]:
    dp[i] += dp[i-1]
  dp[i] %= MOD
print(dp[N])

Measured memory_bytes: 7828
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
map< ll , ll > mp;
int main()
{
	int n;
	cin >> n;
	int k;
	cin >> k;
	int ans = 0;
	for(int i = 0 ; i < n ;i++){
		int x;
		cin >> x;
		ans += (2*min(abs(k-x),x));
	}
	cout << ans << endl;
	return 0;
} 




Measured memory_bytes: 256
S = list(input())

count = 0

for i in range(len(S)):
    try:
        if S[i] == S[i+1]:
            if S[i] == '1':
                S[i+1] = '0'
            else:
                S[i+1] = '1'
            count += 1
    except IndexError:
        pass
print(count)

Measured memory_bytes: 3956
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    A,B,C,D=pin()
    turn=0
    while(1):
        if turn%2 ==0:#takahashiatacck
            C-=B
        else:
            A-=D
        if C<1 or A<1:
            
            print((["No","Yes"][turn%2==0]))
            break
        turn+=1
        
#%%submit!
resolve()



Measured memory_bytes: 9224
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Contexts;
class Simple {
    private string a, b;
    void Solve() {
        //input
        a = io.String;
        b = io.String;
        //cal
        Func <string, bool> isHonest = (str) => str == "H";
        var ans = !(isHonest(a) ^ isHonest(b));
        //ret
        Console.WriteLine(ans?"H":"D");            
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //System.Console.SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO {
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if(_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = Console.ReadLine();
        while(st == "") st = Console.ReadLine();
        if(st != null) _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() { Console.Out.Flush(); }
}
static class NumericEx {
    public static string pad0 <T>(this T v, int n) { return v.ToString().PadLeft(n, '0'); }
    public static double RoundOff(this double v, int n) { return Math.Round(v, n - 1, MidpointRounding.AwayFromZero); }
    public static bool Odd(this int v) { return v % 2 != 0; }
    public static bool Odd(this long v) { return v % 2 != 0; }
    public static void REP(this int v, Action <int> act) {
        for(int i = 0; i < v; ++i) act(i);
    }
    public static void REPR(this int v, Action <int> act) {
        for(int i = v - 1; i >= 0; --i) act(i);
    }
}


Measured memory_bytes: 11092
from sys import stdin

N = int(input())
XY = [[] for _ in range(N)]
max_honest = 0

for i in range(N):
    A = int(input())
    for j in range(A):
        xy = list(map(int,stdin.readline().rstrip().split()))
        XY[i].append(xy)

for i in range(2**N):
    honest = True
    bin_list = list(format(i,'015b'))
    bin_list.reverse()
    for j in range(N):
        if bin_list[j] == '1':
            for p in XY[j]:
                if int(bin_list[p[0]-1]) != p[1]:
                    honest = False
    if honest:
        max_honest = max(max_honest,bin_list.count('1'))

print(max_honest)

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define sint int32_t
#define int long long int
#define all(v) v.begin() , v.end()
#define vii vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main()
{
    int n;
    cin>>n;
    int arr[n];
    int brr[n];
    for(int i=0; i<n; i++) {
        cin>>arr[i];
        brr[i] = arr[i];
    }
    for(int i=n-2; i >= 0; i--) {
        brr[i] += brr[i+1];
    }
    int MOD = 1e9+7;
    int ans = 0;
    for(int i = 0; i<n-1; i++) {
        ans += (arr[i]%MOD * (brr[i+1]%MOD) )%MOD;
        ans %= MOD;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 6692
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		System.out.println((a == b)? c : (b == c)? a : b);
	}
}

Measured memory_bytes: 21844
# -*- coding: utf-8 -*-
def main():
    inNumber = input()
    inStr = input()

    try:
        wk_inNumber = int(inNumber)
    except Exception as e:
        print('No')
        return 0
    if wk_inNumber > 100 or wk_inNumber <= 0:
        print('No')
        return 0

    if inStr.islower() == False:
        print('No')
        return 0

    charInstr = list(inStr)

    if wk_inNumber % 2 == 1:
        print('No')
        return 0

    if wk_inNumber != len(charInstr):
       print('No')
       return 0

    i = 0
    while i < wk_inNumber / 2 :
        j = int(wk_inNumber / 2 + i)
        if charInstr[i] != charInstr[j]:
            print('No')
            return 0
        i += 1

    print('Yes')


main()


Measured memory_bytes: 3064
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	alp := strings.Split("abcdefghijklmnopqrstuvwxyz", "")
	queue := make([]string, 0)
	queue = append(queue, "a")
	mem := make(map[string]bool)
	for i := 0; i < (n - 1); i++ {
		m := len(queue)
		for j := 0; j < m; j++ {
			q := queue[0]
			queue = queue[1:]
			for _, s := range alp[0:i+2] {
				v := q + s
				pattern := toPattern(v)
				if _, ok := mem[pattern]; !ok {
					queue = append(queue, v)
					mem[pattern] = true
				}
			}
		}
	}
	for _, s := range queue {
		fmt.Println(s)
	}
}

func toPattern(str string) string {
	arr := strings.Split(str, "")
	mem := make(map[string]string)
	set := make(map[string]bool)
	for _, s := range arr {
		if _, ok := mem[s]; !ok {
			set[s] = true
			mem[s] = strconv.Itoa(len(set) - 1)
		}
	}
	res := ""
	for _, s := range arr {
		res += mem[s]
	}
	return res
}

Measured memory_bytes: 26624
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 1000001;
const int mod = 1e9 + 7;


#define FILENAME ""

int f (int a, int b) {
 	re min(a, b)*1000 + max(a, b);
}

vector <vector <int> > g;
vector <int> temp;

int main() {
    //  freopen(FILENAME ".in", "r", stdin);
    //  freopen(FILENAME ".out", "w", stdout);
 	int n;
 	cin >> n;
 	g.resize(MAXN);
 	temp.resize(MAXN);
 	for (int i = 0; i < n; i++) {
 		int x;
 		cin >> x;
 		--x;
 	 	int previ = x;
 	 	for (int j = 0; j < n - 2; j++) {
 	 	 	int y;
 	 	 	cin >> y;
 	 	 	--y;
 	 	 	int v = f(i, previ);
 	 	 	int to = f(i, y);
 	 	 	g[v].pb(to);
 	 	 	g[to].pb(v);
 	 	 	temp[to]++;
 	 	 	previ = y;
 	 	}
    }
    vector <int> a;
    for (int i = 0; i < MAXN; i++) {
    	if (temp[i] == 0) {
    	 	a.pb(i);
     	}
    }
    int days = 0;
    int sum = 0;
    while (sz(a) != 0) {
     	++days;
     	sum += sz(a);
     	vector <int> b;
     	for (int j = 0; j < sz(a); j++) {
     	 	for (int k = 0; k < g[a[j]].size(); k++) {
     	 	 	int to = g[a[j]][k]; 	
     	 	 	temp[to]--;
     	 	 	if (temp[to] == 0) {
     	 	 	 	b.pb(to);
     	 	 	}
     		}
     	}
     	a = b;
    }
    if (sum != MAXN) {
     	re cout << -1, 0;
    }
    cout << days;
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    deque<int> deq;
    rep(i,n){
        if(i%2==0)deq.push_front(v[i]);
        else deq.push_back(v[i]);
    }
    if(n%2==0)reverse(all(deq));
    
    rep(i,deq.size()){
        if(i)cout<<" ";
        cout<<deq[i];
    }
    cout<<endl;
}

Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <sstream>
using namespace std;

const int MAX_N = 100000;
const int MAX_M = 100000;
int N, M;
vector<pair<int, int>> a[MAX_N + 10];
vector<pair<int, string>> b;

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; ++i){
    	int p, y;
    	cin >> p >> y;
    	a[p].push_back(make_pair(y,i));
    }
	
	for (int i = 1; i <= N; ++i){
    	sort(a[i].begin(), a[i].end());
    }

    ios::fmtflags curret_flag = cout.flags();

	for (int i = 1; i <= N; ++i){
		int index = 1;
		for (auto ite = a[i].begin(); ite != a[i].end(); ++ite){
		    ostringstream p, q;
    		p << std::setw(6) << std::setfill('0') << i;
    		q << std::setw(6) << std::setfill('0') << index;
    		string s = p.str() + q.str();
    		pair<int,int> tmp = *ite;
    		b.push_back(make_pair(tmp.second, s));
    		++index;
		}
    }

    cout.flags(curret_flag);

    sort(b.begin(), b.end());
	for (auto ite = b.begin(); ite != b.end(); ++ite){
    	pair<int,string> tmp = *ite;
    	cout << tmp.second << endl;
	}
}

Measured memory_bytes: 13168
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
const LL mod=1e9+7;
#define x first
#define y second
#define mp make_pair 

LL ans;
int n,a[maxn];
int l,r;
int fil[maxn];
LL pw[maxn],ny[maxn];

pair<LL,LL> exgcd(LL a,LL b)
{
	if (a==1ll && b==0ll) return mp(1ll,0ll);
	else
	{
		pair<LL,LL> tmp=exgcd(b,a%b);
		return mp(tmp.y,tmp.x-a/b*tmp.y);
	}
}

LL getny(LL p)
{
	return (exgcd(p,mod).x%mod+mod)%mod;
}

LL c(LL tot,LL q)
{
	return ((pw[tot]*ny[q])%mod*ny[tot-q])%mod;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n+1;i++)
	{
		scanf("%d",&a[i]);
		if (!fil[a[i]]) fil[a[i]]=i;
		else
		{
			l=fil[a[i]];
			r=i;
		}
	}
	
	pw[0]=1ll;ny[0]=1ll;
	for(int i=1;i<=n+1;i++)
	{
		pw[i]=(pw[i-1]*i)%mod;
		ny[i]=getny(pw[i]);
	}
	
	int rem=n+1-(r-l+1);
	for(int i=1;i<=n+1;i++)
	{
		ans=c((LL)n+1,(LL)i);
		if (i-1<=rem) ans=(ans-c((LL)rem,i-1)+mod)%mod;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3456