akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
	int a,b,x=0,i;
	scanf("%d %d",&a,&b);
	for(i=0;i<2;i++){
		if(a<b){
			x=x+b;
			b--;
		}
		else if(a>b){
			x=x+a;
			a--;
		}
		else{
			x=x+b;
		}
	}
	printf("%d\n",x);
}


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

public class Program {
    public static void Main() {
        var n = int.Parse(Console.ReadLine());
        var arrs = Console
            .ReadLine()
            .Split(' ')
            .Select(s => int.Parse(s))
            .GroupBy(k => k)
            .ToDictionary(kv => kv.Key, kv => kv.Count());
        var max = 0;

        foreach (var a in arrs) {
            max = Math.Max(max, GetOrZero(arrs, a.Key - 1) + GetOrZero(arrs, a.Key + 1) + a.Value);
        }

        Console.WriteLine(max);
    }

    static int GetOrZero(Dictionary<int, int> arr, int index) {
        int value;
        if (arr.TryGetValue(index, out value)) {
            return value;
        }
        return 0;
    }
}


Measured memory_bytes: 32656
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll modncr(ll n,ll r){
  if(r*2>n)return modncr(n,n-r);
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,N,K,a,ans=0;
  cin>>N>>K;
  vec v(N,0);
  rep(i,N){
    cin>>a;
    v[a-1]++;
  }
  vsort(v);
  rep(i,N-K){
    ans+=v[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
package main
import(
  "fmt"
)
func main(){
  a:=make([]int, 3)
  x:=0
  y:=0
  for i:=0;i<3;i++{
    fmt.Scan(&a[i])
    if a[i]==5{
      x++
    }else if a[i]==7{
      y++
    }
  }
  if x==2&&y==1{
    fmt.Println("YES")
  }else{
    fmt.Println("NO")
  }
}


Measured memory_bytes: 512
k = int(input())

n = 7 % k
ans = -1
cnt = 1
checked = {n}
while n > 0:
    n = (n * 10 + 7) % k
    cnt += 1
    if n in checked:
        break
    checked.add(n)

if n == 0:
    print(cnt)
else:
    print(-1)


Measured memory_bytes: 77948
#include <stdio.h>

int main(){
	int a,b,c,t;
	scanf("%d %d %d",&a,&b,&c);
	t = a;
	a = b;
	b = t;
	t = a;
	a = c;
	c = t;
	printf("%d %d %d",a,b,c);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stack>
using namespace std;
int main(void){
    // Here your code !
    stack<int> s;
   for(int d;cin>>d;){
    
       if(d==0){
           cout<<s.top()<<endl;
           s.pop();}
       else{
           s.push(d);
       }
}
}

Measured memory_bytes: 1200
fun Int.bit(i: Int) = 1 shl i and this > 0

fun main(A: Array<String>) {
    val n = readLine()!!.toInt()
    if (n > 24) {
        println(0)
        return
    }

    val a = readLine()!!.split(" ").map { it.toInt() }
    val b = java.util.BitSet(25)
    b[0] = true
    b[24] = true

    (0 until (1 shl n)).asSequence().map { bit ->
        b.clear(1, 24)
        for (i in a.indices) {
            val j = if (bit.bit(i)) 24 - a[i] else a[i]
            if (b[j])
                return@map 0
            b[j] = true
        }

        (1..24).asSequence().filter { b.get(it) }
                .map { it - b.previousSetBit(it - 1) }
                .min() ?: 0
    }.max().let(::println)
}


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

const int MOD = 1e9 + 7;
string s;
long long ans;
int no2, no3;
long long powe(long long a, long long b) {
	long long res = 1;
	for (b; b; b /= 2) {
		if (b % 2)
			res *= a, res %= MOD;
		a *= a, a %= MOD;
	}
	return res;
}

int main() {
	cin >> s;
	for (int i = 0; i < s.size(); i++)
		no3 += (s[i] == '1');
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') {
			ans += powe(2, no2) * powe(3, (int)s.size() - i - 1);
			ans %= MOD;
		}
		if (s[i] == '1')
			no2++, no3--;
	}
	ans += powe(2, no2);
	ans %= MOD;
	cout << ans;
}

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

int dp[1010][1010];

int main() {
	int q;
	cin >> q;
	vector<string> x(q), y(q);
	for (int i = 0;i < q;i++) {
		cin >> x[i] >> y[i];
	}

	for (int i = 0;i <= 1000;i++) {
		dp[i][0] = 0;
		dp[0][i] = 0;
	}
	for (int i = 0;i < q;i++) {
		for (int j = 1;j <= x[i].size();j++) {
			for (int k = 1;k <= y[i].size();k++) {
				dp[j][k] = 0;
			}
		}
		for (int j = 1;j <= x[i].size();j++) {
			for (int k = 1;k <= y[i].size();k++) {
				dp[j][k] = max(dp[j - 1][k], dp[j][k - 1]);
				if (x[i][j-1] == y[i][k-1]) {
					dp[j][k] = max(dp[j][k], dp[j - 1][k - 1] + 1);
				}
			}
		}
		cout << dp[x[i].size()][y[i].size()] << endl;
	}

	return 0;
}


Measured memory_bytes: 7096
import java.util.Scanner;

public class Main{
	static int a[][] = new int[3][101];
	static int dp[][] = new int[3][101];
	static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		for (int i = 1; i <= 2; i++) {
				for (int j = 1; j <= n; j++) {
					a[i][j] = sc.nextInt();
				}
			}
			solve();
      
			System.out.println(dp[2][n]);
		}

	

	private static void solve() {
		dp[1][1] = a[1][1];
		for (int i = 1; i <= 2; ++i) {
			for (int j = 1; j <= n; ++j) {
				if (i == 1)
					dp[i][j] = dp[i][j - 1] + a[i][j];// 说明第一步往下走
				else
					dp[i][j] = Math.max(dp[i - 1][j]+a[i][j], dp[i][j - 1] + a[i][j]);

			}
		}

	}
}

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

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

    sort(S.begin(), S.end());
    if ((S.at(0) == S.at(1) && S.at(2) == S.at(3)) &&
        (S.at(1) != S.at(2)))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ull unsigned long long
#define size(v) int((v).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < int(n); i++)
template<typename T>
inline void read(T &a) {
	register int b=1,c=getchar();a=0;
	for(;!isdigit(c);c=getchar())if(c==45)b*=-1;
	for(;isdigit(c);c=getchar())a=(a<<3)+(a<<1)+(c^48);
	a*=b;
}
// Template end

const int maxn = 4005;
const int INF = 1000000007;
char c[maxn];
int n, a[maxn], tp[maxn], pos[maxn][2], dp[maxn][maxn];

struct BIT {
	int arr[maxn];
	void init() {
		rep(i, maxn) arr[i] = 0;
	}
	void add(int x, int v) {
		while (x <= n * 2) {
			arr[x] += v;
			x += x & -x;
		}
	}
	int sum(int x) {
		int ans = 0;
		while (x) {
			ans += arr[x];
			x -= x & -x;
		}
		return ans;
	}
};
BIT bit;

inline void chkmin(int &a, int b) {
	if (a > b) a = b;
}

int main() {
	// Work start
	read(n);
	memset(pos, 0, sizeof pos);
	for (int i = 1; i <= n * 2; i++) {
		scanf("%s", c);
		tp[i] = (c[0] == 'B');
		read(a[i]);
		pos[a[i]][tp[i]] = i;
	}
	rep(i, n + 1) rep(j, n + 1) dp[i][j] = INF;
	dp[0][0] = 0;
	rep(i, n + 1) {
		bit.init();
		for (int j = 1; j <= i; j++) bit.add(pos[j][0], 1);
		rep(j, n + 1) {
			if (j) bit.add(pos[j][1], 1);
			if (i < n) {
				chkmin(dp[i + 1][j], dp[i][j] + pos[i + 1][0] - 1 - bit.sum(pos[i + 1][0]));
			}
			if (j < n) {
				chkmin(dp[i][j + 1], dp[i][j] + pos[j + 1][1] - 1 - bit.sum(pos[j + 1][1]));
			}
		}
	}
	printf("%d\n", dp[n][n]);
#ifdef DEBUG
	printf("\nRunning Time : %ldms", clock());
#endif
	return 0;
}


Measured memory_bytes: 32512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string c;
	cin>>c;
	int a= count(c.begin(), c.end(), 'R');
	if(a==0)
		cout<<0;
	else{
		int count=a;
		for(int i=0; i<count; i++){
			if(c[i]=='R')
				a--;
		}
		cout<<a;
	}
	return 0;
}

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

import sys
from math import ceil

for line in sys.stdin.readlines():
    List = map(int, line.strip().split())
    
    n = List[0]
    yen = 100000
    for i in xrange(n):
        yen *= 1.05
        yen = int(ceil(yen/1000)) * 1000
    print yen

Measured memory_bytes: 4360
#include <iostream>
#define SWAP(a,b) do{int t; t=a, a=b, b=t;}while(0)
using namespace std;

int main()
{
   ios::sync_with_stdio(false), cin.tie(0);
   int N;
   int a[102];

   cin >> N;
   for(int i=0; i<N; ++i)cin >> a[i];

   int cnt = 0;
   bool flag = true;

   for(int i=0; flag; ++i){
      flag = false;
      for(int j = N-1; j > i; --j){
         if(a[j-1] > a[j]){
            SWAP(a[j-1], a[j]);
            ++cnt;
            ++flag;
         }
      }
   }
   for(int i=0; i<N; ++i)
      cout << a[i] << (i+1 < N ? ' ' : '\n');
   cout << cnt << endl;
}



Measured memory_bytes: 3160
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    System.out.print((char)(sc.next().charAt(0)-32));
    System.out.print((char)(sc.next().charAt(0)-32));
    System.out.println((char)(sc.next().charAt(0)-32));
  }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

int main(void) {
  ll i, j, k;
  
  ll N, K;
  cin >> N >> K;
  ll p[MAX*2];
  
  for(i=0; i<N; i++) {
    ll a;
    cin >> a;
    a--;
    
    p[i]=a;
  }
  
  ll s=0;
  ll cnt[MAX*2]={};
  ll po=0;
  cnt[0]=1;
  while(1) {
    po=p[po];
    cnt[po]++;
    
    if(cnt[po]>2) {
      s=po;
      break;
    }
  }
  
  
  ll siz=0;
  ll t=K;
  for(i=0; i<N; i++) if(cnt[i]==1) K--;
  
  if(K<0) {
    po=0;
    for(i=0; i<t; i++) {
      po=p[po];
    }
    
    pt(po+1);
    return 0;
  }
  
  for(i=0; i<N; i++) if(cnt[i]==3||cnt[i]==2) siz++;
  K%=siz;
  po=s;
  for(i=0; i<K; i++) {
    po=p[po];
  }
  
  pt(po+1);
  
}
 
 


Measured memory_bytes: 6752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;

int  main()
{
	string s[3];
	rep(i, 3)
		cin >> s[i];
	cout << s[0][0] << s[1][1] << s[2][2] << endl;
	return (0);
}


Measured memory_bytes: 256
//
//  main.cpp
//  E - Knapsack 2
//
//  Created by Nishant Dhankhar on 16/01/19.
//  Copyright © 2019 Nishant Dhankhar. All rights reserved.
//
#include <bits/stdc++.h> //REMEMBER TO REMOVE '/'
#include <iostream>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define int ll
#define double long double
#define ff first
#define ss second
#define RE(i,n) for(int i=1;i<=n;i++)
#define RED(i,n) for(int i=n;i>0;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 remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define wl(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define OUT(a) cout<<a<<endl;
int n,W;
const int INF = 1000000000000;
int dp[105][100005];
signed main(){
    
    cin>>n>>W;
    //dp on the value;
    // if the value can be achieved , we
    int w[n],v[n];
    RE(i,n){
        cin>>w[i]>>v[i];
    }
    
    rep(i,104){
        rep(j,100004){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    RE(i,n){
        rep(j,100001){
            dp[i][j]=dp[i-1][j];
            if(j>=v[i]&&dp[i-1][j-v[i]]<INF) remin( dp[i][j] , dp[i-1][j-v[i]] + w[i] ) ;
        }
    }
    int ans=0;
    rep(i,100001){
        if(dp[n][i]<=W) ans=i;
    }
    OUT(ans);
    
    
}









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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1000005
#define mod 1000000007

ll n;

int main()
{
    _FastIO;

    cin >> n;
    if(n == 1){
        cout << "0" << endl;
        return 0;
    }
    if(n == 2){
        cout << "2" << endl;
        return 0;
    }
    ll ans = 1;
    for(ll i = 0; i < n; i++){
        ans *= 10;
        ans %= mod;
    }
    ans += mod;
    ans += mod;
    ll k = 2;
    for(ll i = 0; i < n; i++){
        k *= 9;
        k %= mod;
    }
    k += mod;
    ll p = 1;
    for(ll i = 0; i < n; i++){
       p *= 8;
       p %= mod;
    }
    ans = (ans - (k - p)) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3688
from time import time
import random


def main():
    random.seed(0)

    now = time()

    MAX = 26

    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(d)]

    t = []
    prev = [0] * MAX
    for day, row in enumerate(s, 1):
        mxi = 1
        mx = 0
        for i, (es, ec) in enumerate(zip(row, c), 1):
            point = es + ec * (day - prev[i - 1])
            if point > mx:
                mx = point
                mxi = i

        prev[mxi - 1] = day
        t.append(mxi)

    last = [0] * MAX

    score = 0
    for day, e in enumerate(t, 1):
        score += s[day-1][e-1]
        last[e-1] = day

        for ec, elast in zip(c, last):
            score -= ec * (day - elast)

    d_li = []
    for i in range(1, d + 1):
        ln = max(1, (-(i - d // 2) ** 2 + d ** 2 // 4) // 500)
        d_li += [i] * ln

    di_max = len(d_li) - 1

    #c_sum = sum(c)
    #c_li = []
    #for i, e in enumerate(c, 1):
    #    c_li += [i] * e

    sc = []
    for row in s:
        app = []
        for i, (es, ec) in enumerate(zip(row, c), 1):
            app += [i] * max(1, (es + ec * d) // 20)

        sc.append(app)

    while time() - now <= 1.85:
        prev_score = score

        di = random.randint(0, di_max)
        ed = d_li[di]
        qi = random.randint(0, len(sc[ed-1]) - 1)
        eq = sc[ed-1][qi]

        q_old = t[ed-1]
        d_prev = {q_old: 0, eq: 0}

        c_old = c[q_old-1]
        c_new = c[eq-1]

        for day, e in enumerate(t, 1):
            if e in d_prev.keys():
                d_prev[e] = day

            score += c_old * (day - d_prev[q_old])
            score += c_new * (day - d_prev[eq])

        score -= s[ed-1][q_old-1]
        score += s[ed-1][eq-1]

        t[ed-1] = eq

        d_prev = {q_old: 0, eq: 0}

        for day, e in enumerate(t, 1):
            if e in d_prev.keys():
                d_prev[e] = day

            score -= c_old * (day - d_prev[q_old])
            score -= c_new * (day - d_prev[eq])

        if prev_score > score:
            t[ed-1] = q_old
            score = prev_score

    print(*t, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 262048
N = int(input())
H = list(map(int, input().split()))
list = []
a = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    a += 1
  else:
    list.append(a)
    a = 0
list.append(a)
list = sorted(list)
print(list[-1])
  

Measured memory_bytes: 20524
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let (a, b) = (it.next().unwrap(), it.next().unwrap());
    println!("{}", a * b - a - b + 1);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 5e2+7, M = 8;
int p[N], d[N];
int find(int x)
{
	return x == p[x] ? x : p[x] = find(p[x]);
}
int main()
{
	for(int i = 1; i <= 4; i++)
	{
		p[i] = i;
	}
	for(int i = 2; i <= 4; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		d[u]++;
		d[v]++;
		if(find(u)==find(v))
		{
			puts("NO");
			return 0;
		}
		p[find(u)] = find(v);
	}
	for(int i = 1; i <= 4; i++)
	{
		if(d[i]>2)
		{
			puts("NO");
			return 0;
		}
	}
	puts("YES");
    return 0;
}

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

using namespace std;

int count2(int a) {
  int ret = 0;
  while (!(a & 1)) {
    ret++;
    a >>= 1;
  }
  return ret;
}

int solve(const std::array<int, 3>& as) {
  if (as[0] == as[2]) {
    return -1;
  }
  int aa = count2(as[1] - as[0]);
  int bb = count2(as[2] - as[1]);
  if (!aa) {
    return bb;
  }
  if (!bb) {
    return aa;
  }
  return std::min(aa, bb);
}

int main() {
  std::array<int, 3> as;
  bool anyOdd = false;
  for (auto& a : as) {
    std::cin >> a;
    anyOdd = anyOdd || (a % 2 == 1);
  }
  if (anyOdd) {
    std::cout << 0 << std::endl;
    return 0;
  }
  std::sort(as.begin(), as.end());
  std::cout << solve(as) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#define N 105
using namespace std;
typedef long long ll;
string s;
int main() {
	cin>>s;
	int cnt[26];
	memset(cnt, 0, sizeof(cnt));
	int i = 0;
	for (i = 0; i < s.size(); ++i) {
		if (cnt[s[i]-'a'] > 0) break;
		cnt[s[i]-'a']++;
	}
	if (i < s.size()) {
		cout<<"no"<<endl;
	} else {
		cout<<"yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
  int k;cin>>k;
  int ans = 0,gcd;
	for(int i=1;i<=k;i++){
     for(int j=1;j<=k;j++){
     	for(int l=1;l<=k;l++){
        	gcd = __gcd(i,j);
          	gcd = __gcd(gcd,l);
          	ans = ans + gcd;
        }
     }
    }
  cout<<ans;
	return 0;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

const int MOD = 1000000007;
struct mi {
    ll v; explicit operator ll() const { return v; }
    mi() { v = 0; }
    mi(ll _v) { 
        v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
        if (v < 0) v += MOD;
    }
    friend bool operator==(const mi& a, const mi& b) { 
        return a.v == b.v; }
    friend bool operator!=(const mi& a, const mi& b) { 
        return !(a == b); }
    friend bool operator<(const mi& a, const mi& b) { 
        return a.v < b.v; }
   
    mi& operator+=(const mi& m) { 
        if ((v += m.v) >= MOD) v -= MOD; 
        return *this; }
    mi& operator-=(const mi& m) { 
        if ((v -= m.v) < 0) v += MOD; 
        return *this; }
    mi& operator*=(const mi& m) { 
        v = v*m.v%MOD; return *this; }
    mi& operator/=(const mi& m) { return (*this) *= inv(m); }
    friend mi pow(mi a, ll p) {
        mi ans = 1; assert(p >= 0);
        for (; p; p /= 2, a *= a) if (p&1) ans *= a;
        return ans;
    }
    friend mi inv(const mi& a) { assert(a.v != 0); 
        return pow(a,MOD-2); }
        
    mi operator-() const { return mi(-v); }
    mi& operator++() { return *this += 1; }
    mi& operator--() { return *this -= 1; }
    mi operator++(int) { mi temp; temp.v = v++; return temp; }
    mi operator--(int) { mi temp; temp.v = v--; return temp; }
    friend mi operator+(mi a, const mi& b) { return a += b; }
    friend mi operator-(mi a, const mi& b) { return a -= b; }
    friend mi operator*(mi a, const mi& b) { return a *= b; }
    friend mi operator/(mi a, const mi& b) { return a /= b; }
    friend ostream& operator<<(ostream& os, const mi& m) {
        os << m.v; return os;
    }
    friend istream& operator>>(istream& is, mi& m) {
        ll x; is >> x;
        m.v = x;
        return is;
    }
};

void doit(){
    ll n, i, j;
    mi s = 0, ans = 0;
    cin >> n;
    vector< mi >v(n);
    for(i = 0; i < n; i++)cin>>v[i], s += v[i];
    rep(i,0,n){
        s -= v[i];
        ans += (v[i] * s);  
    }
    cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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

int main()
{
	int N, K, X, Y;
	int S;

	cin >> N >> K >> X >> Y;
	if (N <= K)
		S = N*X;
	else
		S = K*X + (N - K)*Y;
	cout << S << endl;

	return 0;
}

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

using namespace std;

vector<int> complete { 1,1,1,1,1,1,1,1,1,2,2,2,4,4,4,6,6,6,5,5,5,3,3,3,3,3,3,3,3,3 };

int minv;

void cube_swap(vector<int>& cube, int mode) {
    if (mode == 0) {
        swap(cube[0], cube[27]);
        swap(cube[1], cube[28]);
        swap(cube[2], cube[29]);
        swap(cube[14], cube[15]);
        swap(cube[18], cube[20]);
    }
    else if (mode == 1) {
        swap(cube[0], cube[23]);
        swap(cube[3], cube[26]);
        swap(cube[6], cube[29]);
        swap(cube[9], cube[20]);
        swap(cube[15], cube[17]);
    }
    else if (mode == 2) {
        swap(cube[2], cube[21]);
        swap(cube[5], cube[24]);
        swap(cube[8], cube[27]);
        swap(cube[11], cube[18]);
        swap(cube[12], cube[14]);
    }
    else if (mode == 3) {
        swap(cube[6], cube[21]);
        swap(cube[7], cube[22]);
        swap(cube[8], cube[23]);
        swap(cube[9], cube[11]);
        swap(cube[12], cube[17]);
    }
}

void dfs(vector<int>& cube, int d) {
    if (d >= minv) {
        return;
    }
    if (cube == complete) {
        minv = min(minv, d);
        return;
    }
    for (int i = 0; i < 4; i++) {
        cube_swap(cube, i);
        dfs(cube, d + 1);
        cube_swap(cube, i);
    }
}

int main() {
    int n;
    cin >> n;
    while (n--) {
        vector<int> cube(30);
        for (int i = 0; i < 30; i++) {
            cin >> cube[i];
        }
        minv = 8;
        dfs(cube, 0);
        cout << minv << endl;
    }

    return 0;
}

Measured memory_bytes: 3136
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

//指定された頭文字からはじまる文字列とそれの出現回数を
//扱う、クラス。sort用に比較も用意。
class Moji implements Comparable<Moji>{
	String str="";
	int count=0;
	Moji(String a,int b){
		str=a;
		count=b;
	}
	@Override
	public int compareTo(Moji o) {
		// TODO 自動生成されたメソッド・スタブ
		if(this.count<o.count){
			return 1;
		}
		else if (this.count>o.count) {
			return -1;
		}
		return this.str.compareTo(o.str);
	}
	
}

/*出現回数順をどうするかわからなかった。
 * 試したこと
 * map
 * set
 * 
 * 結局hashmapとMojiクラスで解決
*/
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		new Main().run();
	}
	void run(){
		Scanner sc=new Scanner(System.in);
		String str[][];
		char ch;
		int n,count;
		HashMap<String, Integer> hm=new HashMap<String, Integer>();
		Moji m[]=new Moji[200];
		
		while(true){
			n=sc.nextInt();
			if(n==0) break;
			hm.clear();
			count=0;
			str=new String[n][];
			sc.nextLine();
			for(int i=0;i<n;i++){
				str[i]=sc.nextLine().split(" ");
			}
			ch=sc.next().charAt(0);
			for(int i=0;i<n;i++){
				for(int j=0;j<str[i].length;j++){
//					System.out.println(str[i][j]);
					if(ch==str[i][j].charAt(0)){
						if(hm.containsKey(str[i][j])){
							int t=hm.get(str[i][j]);
							m[t].count++;
						}
						else{
							hm.put(str[i][j], count);
							m[count]=new Moji(str[i][j], 1);
							count++;
						}
					}
				}
			}
			
			Arrays.sort(m,0,count);
			if(hm.isEmpty()){
				System.out.print("NA");
			}
			
			else{
				System.out.print(m[0].str);
				for(int i=1;i<5;i++){
					if(i>=count) break;
					System.out.print(" "+m[i].str);
				}
			}
			System.out.println();
		}

	}//run

}

Measured memory_bytes: 35940
from collections import defaultdict
d = defaultdict(int)
s = input()
for i in range(len(s)):
  d[s[i]] += 1
d = dict(d)
values = set(list(d.values()))
if len(d) == 2 and len(values) == 1 and list(values)[0] == 2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int digit (long long a)
{
	int d;

	for(d=0; a; d++){
		a /= 10;
	}

	return d;
}
int main()
{
	long long n;
	cin >> n;
    
    int dig = 0, ans = 12;
	for(long long i=1; i<=sqrt(n)+1; i++){
		if(n % i == 0){
			dig = max(digit(i), digit(n/i));
			ans = min(ans, dig);
		}
	}

	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    n,m = map(int, input().split())
    aabb = [[0 for _ in range(2)] for _ in range(n)]
    for i in range(n):
        aabb[i][0], aabb[i][1] = map(int, input().split())
    aabb.sort(key=lambda x: x[0])
    count = 0
    for a,b in aabb:
        k = min([m,b])
        count += k*a
        m -= b
        if m <= 0:
            break
    print(count)


Measured memory_bytes: 22820
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#include <random>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

string reverse_str(string s) {
	reverse(all(s));
	return s;
}

int n, m;
string a[55];
string b[55];

bool ok() {
	rep(i, n - m + 1) {
		rep(j, n - m + 1) {
			rep(dy, m) {
				rep(dx, m) {
					if (a[i + dy][j + dx] != b[dy][dx]) {
						goto end;
					}
				}
			}
			return true;
		end:;
		}
	}
	return false;
}

void solve() {
	cin >> n >> m;
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];
	cout << (ok() ? "Yes" : "No") << endl;
}

signed main() {
	srand(time(NULL));
	int T = 100;
	cout << fixed << setprecision(15);
	rep(i, T) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

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

int main()
{
	string s;
	bool flag = true, cCheck = false;
	cin >> s;
	
	if (s[0] != 'A') flag = false;
	
	for (int i = 2; i < (int)s.length() - 1; i++)
	{
		if (s[i] == 'C')
		{
			if (!cCheck) cCheck = true;
			else flag = false;
		}
	}

	int count = 0;
	rep(i, (int)s.length()) if (isupper(s[i])) count++;
	if (count != 2) flag = false;

	if(flag && cCheck) cout << "AC";
	else     cout << "WA";
	
	return 0;
}

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

struct Point {
    int x;
    int y;
};

int main(){
    int n;
    std::cin >> n;
    std::vector<Point> p, q;
    p.resize(n); q.resize(n);

    int a, b;
    for(int i = 0; i < n; i++){
        std::cin >> a >> b;
        p[i] = Point {a,b};
    }
    for(int i = 0; i < n; i++){
        std::cin >> a >> b;
        q[i] = Point {a,b};
    }

    std::stable_sort(p.begin(), p.end(), [](auto&& a, auto&& b){ return a.y > b.y; });
    std::stable_sort(q.begin(), q.end(), [](auto&& a, auto&& b){ return a.x < b.x; });

    int ret = 0;
    for(auto&& blue : q){
        for(auto&& red : p){
            if(red.x < blue.x && red.y < blue.y){
                ret++;
                red.x = 200; red.y = 200;
                break;
            }
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<double> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  sort(p.begin(), p.end());
reverse(p.begin(), p.end());
  int64_t a=2;
  double Z=0;
  for(int i=0;i<N;i++){
    Z+=p.at(i)/a;
    a*=2;
    if(i==N-2){
      a/=2;
    }
  }
  cout << fixed << setprecision(10);

  cout<<Z<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
long long digitNumber[100005];
int needMatch[10] = {0,2,5,5,4,5,6,3,7,6};
void getDigitNumber(long long matchNumber,long long kindNumber,long long canUseKind[10]){
	for(long long i=0;i<kindNumber;i++){
		digitNumber[needMatch[canUseKind[i]]] = 1;
	}
	for(long long i=1;i<=matchNumber;i++){
		for(long long j=0;j<kindNumber;j++){
			if(i-needMatch[canUseKind[j]]>=0){
				digitNumber[i] = std::max(digitNumber[i-needMatch[canUseKind[j]]]+1,digitNumber[i]);
			}
		}
	}
}

void answerDisplay(long long matchNumber,long long kindNumber,long long canUseKind[10]){
	long long answer = 0;
	long long nowMatchNumber = matchNumber,useNumber=0;
	long long count=0;
    bool flag=false;
	for(long long i=0;i<digitNumber[matchNumber];i++){
		answer = 0;
		if(count == digitNumber[matchNumber]-1){
			for(long long j=0;j<kindNumber;j++){
				if(nowMatchNumber-needMatch[canUseKind[j]]==0){
					//cout<<"nowMatchNumber:"<<nowMatchNumber<<" nn:"<<nn[a[j]]<<endl;
					answer = std::max(answer,canUseKind[j]);
				}
			}
			std::cout<<answer<<std::endl;
            break;
		}else {
			for(long long j=0;j<kindNumber;j++){
				if(digitNumber[nowMatchNumber-needMatch[canUseKind[j]]]==digitNumber[nowMatchNumber]-1){
					if(answer<canUseKind[j]){
						answer = canUseKind[j];
						useNumber = needMatch[canUseKind[j]];
					}
				}
			}
			nowMatchNumber-=useNumber;
			std::cout<<answer;
			count++;
		}
	}
}

int main(){
	long long matchNumber,kindNumber;
	std::cin>>matchNumber>>kindNumber;
	long long canUseKind[kindNumber];
	for(long long i=0;i<kindNumber;i++)std::cin>>canUseKind[i];
	memset(digitNumber,-1,sizeof(digitNumber));
	digitNumber[0]=0;

    getDigitNumber(matchNumber,kindNumber,canUseKind);
    answerDisplay(matchNumber,kindNumber,canUseKind);
}


Measured memory_bytes: 1024
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  string N;
  cin >> N;
  ll sum = 0;
  for (ll i = 0; i < N.size(); i++) {
    sum += N[i] - '0';
  }
  if (sum % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
  int N;
  ll ans = 0;
  cin >> N;
  vector<ll> A(N);
  vector< vector<ll> > B(60, vector<ll>(N+1));
  ll all_a = 0;
  REP(i, N) {
    ll ain;
    cin >> A[i];
    all_a ^= A[i];
  }
  // 全部XORを取った値で、1 になったbitはどのような分け方をしても、片方は偶数、もう片方は奇数になるので、
  // そのbitは考慮しなくてOK。
  // 最終的に和を求める際に、そのbitは 0+1 か 1+0 にしかならないので、和は 1 になる。
  // つまり、この all_a そのものを足せばいい。
  // 0 になった bit は 偶数と偶数、奇数と奇数 のどちらかになる。
  // 当然、奇数＋奇数になったほうが和は大きいので、それを目指す。

  // 考慮しないbitの情報を消す
  REP(i,N) A[i] &= ~all_a;

  // 考慮しない桁の和は 1 になるので、先に足しておく
  ans = all_a;
  
  // 掃き出し法が使えるように
  //  B[0] = [ A[0].bit59, A[1].bit59,,, A[N-1].bit59, 1 ] 
  //  B[1] = [ A[0].bit58, A[1].bit58,,, A[N-1].bit58, 1 ] 
  // という2次元配列に格納
  REP(i,60) {
    REP(j,N) {
      B[59-i][j] = (A[j] >> i) & 1;
    }
    B[59-i][N] = 1;
  }
  
  // 掃き出し法
  //  ただし、できるだけ上位Bitが1になる解がいいので、上位側から優先して判定する
  //  上記で考慮しないbitにした桁は、対応する行の値が全て 0 になっている。
  //  そのため、pivotに選ばれることはないし、0 なので xor 演算の対象になることもない。
  //  なので、最後まで同じ形 (0 0 0...0 | 1) をしているはず
  vector<bool> use(60,false);
  REP(col,N) {
    int pivot = -1;
    // Pivot探す
    REP(row,60) {
      if (use[row]) continue;
      if (B[row][col] == 1) {
        pivot = row;
        break;
      }
    }
    if (pivot == -1) continue;
    
    // 見つかったpivot以外の行の、現在の列の値を 0 にしていく
    REP(row,60) {
      if ((row != pivot) && (B[row][col] == 1)) {
        REP(i,N+1) {
          B[row][i] ^= B[pivot][i];
        }
      }
    }
    use[pivot] = true;
  }

  
  // (0 0 0 0 | 1) となっている桁は無視
  REP(row,60) {
    bool ok = false;
    if ( (B[row][N] == 0) ) ok = true;
    REP(col,N)
      if ( B[row][col] == 1 ) ok = true;
    // 2グループのどちらも 1 になるので、合計値はその桁が 2 になったものになる
    if (ok) 
      ans += (2LL << (59-row));
  }

  cout << ans << endl;
}


Measured memory_bytes: 48896
#include<bits/stdc++.h>
//#pragma GCC optimize("trapv")
#define I inline void 
#define S struct 
#define vi vector<int> 

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

const int N = 5e3 + 7 , mod = 1e9 + 7 ; 


// How interesting!

ll n , k ; 

ll ans ; 

ll a[N] , b[N] ;

vector<bool> vis(N , 0) ; 

int main(){
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ;
	//freopen("in.in" , "r" , stdin) ;

	cin >> n >> k ; 
	ll mx = -1e18 ; 
	for(int i = 0 ;i < n;i++){
		cin >> a[i] ; 
		a[i] -- ; 
	}

	for(int i = 0;i < n;i ++){
		cin >> b[i] ; 
		mx = max(mx , b[i]) ; 
	}
	if(mx <= 0)
		return cout<< mx , 0 ; 
	ll out  = -1e18 ; 
	for(int i = 0 ;i < n;i ++){
		ll cur = a[i] ; 
		ll cyc = 0 ; 
		for(int j = 0 ;j < N ;j++){
			vis[j] = 0 ; 
		}
		vector<ll> vec ; 
		while(!vis[cur]){
			vec.push_back(b[cur]) ; 
			cyc += b[cur] ; 
			vis[cur] = 1; 
			cur = a[cur] ; 
		}
		ans = 0 ; 

		ll buckets = k / (int) vec.size() ; 

		if(cyc > 0){
			ans = buckets * cyc ;
		}

		ll rem = k % (vec.size()) ; 

		ll add = 0 , best = 0 ;
		for(int j = 0 ;j < rem ;j ++){	
			add+= vec[j] ; 
			best = max(best , add) ; 
		}
		ans+=best ; 

		if(buckets){
			ll add2 = 0 , best2 = 0 ; 
			ll rem = k % (vec.size()) + (int) vec.size() ; 
			for(int j = 0 ;j < rem ;j ++){
				add2+=vec[j%(int) vec.size()] ; 
				best2 = max(best2 , add2) ; 
			}
			ans = max(ans , max(0ll , (buckets -1 ) * cyc )  + best2  ) ; 
		}
		out = max(out , ans) ; 

	}

	cout<< out; 
	return 0 ; 
}


Measured memory_bytes: 3840
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

import math
# isprime, prime_division

def isprime(x):
    q = int(math.sqrt(x))  # int() rounds to zero
    for i in range(2,q+1):   # upto q
        if x%i == 0:
            return False
    return True

def prime_division(x):
    q = int(math.sqrt(x))
    a = []
    for i in range(2,q+1):
        ex = 0
        while x%i == 0:
            ex += 1
            x //= i
        if ex>0:
            a.append([i,ex])
    if x>q:
        a.append([x,1])
    return a

def prime_division2(x):
    q = int(math.sqrt(x))
    h = {}
    for i in range(2,q+1):
        ex = 0
        while x%i == 0:
            ex += 1
            x //= i
        if ex>0:
            h[i] = ex
    if x>q:
        h[x] = 1
    return h

def divisorlist(z): # z : output of prime_division
    if len(z)==1:
        return [z[0][0]**i for i in range(z[0][1]+1)]
    y = divisorlist(z[1:])
    s = []
    for i in range(z[0][1]+1):
        for j in y:
            s.append((z[0][0]**i)*j)
    return s

n,m = inm()
if m==1:
    print(1)
    exit()
#ls = prime_division(m)
#ddprint(ls)
ps = divisorlist(prime_division(m))
#ddprint(ps)
ps2 = [x for x in ps if x<=m//n]
print(max(ps2))


Measured memory_bytes: 3188
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int N;
double p[3001];
double dp[3001][3001];

void solve()
{
    dp[0][0] = 1.;
    FOR (i, 1, N+1) {
        REP (j, i+1) {
            dp[i][j] += dp[i-1][j] * (1. - p[i]);
            dp[i][j] += (j - 1 >= 0 ? dp[i-1][j-1] : 0.) * p[i];
        }
    }
    double ans = 0.;
    FOR (i, N/2+1, N+1) ans += dp[N][i];
    cout << fixed << setprecision(9) << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP (i, N) cin >> p[i+1];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

int N,M;
int L[200010],R[200010];
pair<int,int> A[100010];

int main(){
    cin >> N >> M;
    int x,y;
    for(int i=1;i<=M;i++){
        cin >> x >> y;
        A[i] = {x,y};
    }
    sort(A+1,A+M+1);
    for(int i=1;i<=N;i++) {L[i] = i; R[i] = i;}
    for(int i=1;i<=M;i++){
        int a = A[i].second;
        R[a] = R[a+1];
        L[a+1] = L[a];
    }
    for(int i=1;i<=N;i++) cout << R[i]-L[i]+1 << (i!=N? " ":"\n");
}


Measured memory_bytes: 5432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7

//first, secondで昇順ソート
bool compare(P a, P b){
    if(a.first == b.first){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

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

    int n;
    cin >> n;
    int d[n];
    rep(i,n) cin >> d[i];
    
    sort(d, d+n);
    
    int diff = d[n/2] - d[n/2 - 1];
    
    cout << diff << endl;

    return 0;
}

Measured memory_bytes: 640
main = do
    l <- getLine
    let (a:b:[]) = map read $ words l :: [Int]
    putStrLn $ a `compare'` b
compare' :: Int -> Int -> String
compare' a b
    | ordering == LT = "a < b"
    | ordering == EQ = "a == b"
    | ordering == GT = "a > b"
    where ordering = a `compare` b

Measured memory_bytes: 3484
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  
  int n=s.size();
  bool a=true;
  
  for(int i=0;i<n;i++){
    if(i%2==0){
      if(s.at(i)=='L') a=false;
    }else{
      if(s.at(i)=='R') a=false;
    }
  }
  
  if(a==true) cout << "Yes" << endl;
  if(a==false) cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    double a,b;
    int c,d;
    cin >> a >> b;
    c=a;d=b;
    cout << c/d << " ";
    cout << c%d << " ";
    cout << fixed << setprecision(5) << a/b << "\n";
    return 0;
}


Measured memory_bytes: 3248
import heapq

n, m, q = map(int, input().split())
abcds_list = [list(map(int, input().split())) for _ in range(q)]

res = []
def dfs(current, n, m):
    if len(current) == n:
        res.append(current)
        return
    last = current[-1]
    for i in range(last, m+1):
        nex = current[::1]
        nex.append(i)
        dfs(nex, n, m)
for i in range(1, m+1):
    dfs([i], n, m)

max_p = 0
for r in res:
    p = 0
    for query in abcds_list:
        a, b, c, d = query
        if r[b-1] - r[a-1] == c:
            p += d
    if p > max_p:
        max_p = p
print(max_p)


Measured memory_bytes: 28784
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
using namespace std;
int main(){
	long long N,K,X,Y; cin >> N >> K >> X >> Y;
	long long sum = 0;
	if ( N < K ) cout << N*X << endl;
	else cout << K*X + (N-K)*Y << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007

int main(){
  ll a,b,x,s;
  ll ans = 0;

  scanf("%lld %lld %lld", &a, &b, &x);

  ans += b/x + 1;

  if(a != 0) ans -= (a - 1)/x + 1;

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
N, P = map(int, input().split())
A = list(map(int, input().split()))
even = 0
for a in A:
	if a % 2 == 0:
		even += 1
if even == N:
	if P == 0:
		print(2 ** N)
	else:
		print(0)
else:
	print(2 ** (N-1))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,p;
	cin>>a>>p;
	p+=3*a;
	cout<<p/2<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

long gcd(long a,long b){
	long n;
	if(b>=a){
	n=a;
	a=b;
	b=n;
	}
	
	long k;
	while(b > 0){
		k = a%b;
		a = b;
		b = k;
	}
	return a;
}

	
int main(void){
	long a,b;
	while(scanf("%ld %ld",&a,&b) != EOF){
	
	printf("%ld %ld\n",gcd(a,b),(a*b)/gcd(a,b));
	}
	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define N 100005
#define pb push_back
using namespace std;
inline void in(int &x)
{
	x=0;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
}
int dep[N],low[N],n,m,ans;
vector<int> v[N];
inline void chmin(int &x,int y){x=x<y?x:y;}
void tarjan(int from,int f)
{
	dep[from]=dep[f]+1;
	low[from]=dep[from];
	for(int i=0;i<v[from].size();++i)
	{
		int to=v[from][i];
		if(to==f)continue;
		if(!dep[to])
		{
			tarjan(to,from);
			chmin(low[from],low[to]);
		}
		else chmin(low[from],dep[to]);
	}
	if(from!=1&&low[from]==dep[from])++ans;
}
int main()
{
	in(n);in(m);
	while(m--)
	{
		int x,y;
		in(x);in(y);
		v[x].pb(y);
		v[y].pb(x);
	}
	tarjan(1,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5992
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=2e6+10;
const ll MOD=1e9+7;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
ll factor[MAXN];
void cal_factor(){factor[0]=1;for(int u=1;u<MAXN;u++){factor[u]=(factor[u-1]*u)%MOD;}}
ll C(ll n,ll k){return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;}
void solve()
{
    cal_factor();
    ll K,N;
    string s;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>K>>s;
    N=K+s.size();
    ll ans=qpow(26,N);
    for(ll k=0;k<s.size();k++){
        ans=(ans-C(N,k)*qpow(25,N-k)%MOD+MOD)%MOD;
    }
    cout<<ans;
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 19844
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF=10000000;
const int mod=1e9+7;
int srh(int a[],int n,int k)
{
    int q=0;
    a[n]=k;
    while(a[q]!=k)
        q++;
    return q!=n;
}
int main()
{
    int n,a[10005],q,key,sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++)
    {
        scanf("%d",&key);
        if(srh(a,n,key))
            sum++;
    }
    printf("%d\n",sum);
    return 0;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
long long k,a,b,re,res;
int main()
{
	cin>>k>>a>>b;
	if (b-a<=2)
	{
		printf("%lld\n",1+k);
		return 0;
	}
	re=k-(a-1);
	if (re<=0)
	{
		printf("%lld\n",1+k);
		return 0;
	}
	res=a+(b-a)*(re/2);
	if (re&1ll) res++;
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 256