akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e15;
ll mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
    //freopen("telecow.in", "r", stdin), freopen("telecow.out", "w", stdout);
    fast_io;
    ll n, i, k, s1, s2, ans = 0;
    cin >> n >> k;
    for (i = k; i <= n + 1; i++)
    {
        s1 = i * (i + 1) / 2;
        s2 = (n + 1) * (n + 2) / 2 - (n + 1 - i) * (n + 2 - i) / 2;
        ans += s2 - s1 + 1;
        ans %= mod1;
    }
    cout << ans;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
	set<string> k;
	int N;
	cin >> N;
	for (int i = 0; i<N; i++){
		string ts;
		cin >> ts;
		k.insert(ts);
	}
	cout << k.size() << endl;
}


Measured memory_bytes: 19184
#include <cstdio>
int n,d[103][3];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d%d",&d[i][1],&d[i][2]);
    for(int i=3;i<=n;i++) if(d[i][1]==d[i][2]&&d[i-1][1]==d[i-1][2]&&d[i-2][1]==d[i-2][2]) return puts("Yes"),0;
    return puts("No"),0;
}

Measured memory_bytes: 1660
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, a: "List[int]"):

    dp = [False] * (K + 1)
    for i in range(0, K + 1):
        for j in a:
            if i - j >= 0:
                dp[i] = not dp[i - j] or dp[i]

    print("First" if dp[K] else "Second")

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> vec(n, 0);
  reps(i, 1, n+1) {
    vector<int> seen(n+1, 0);
    vector<int> dist(n+1, 0);
    seen.at(i) = 1;
    dist.at(i) = 0;
    queue<int> que;
    que.push(i);
    while(!que.empty()) {
      int cv = que.front();
      que.pop();
      if (cv == x) {
        if (!seen.at(y)) {
          seen.at(y) = 1;
          dist.at(y) = dist.at(cv)+1;
          que.push(y);
        }
      }
      if (cv == y) {
        if (!seen.at(x)) {
          seen.at(x) = 1;
          dist.at(x) = dist.at(cv)+1;
          que.push(x);
        }        
      }
      if (cv - 1 > 0) {
        if (!seen.at(cv-1)) {
          seen.at(cv-1) = 1;
          dist.at(cv-1) = dist.at(cv)+1;
          que.push(cv-1);
        }
      }
      if (cv + 1 < n+1) {
        if (!seen.at(cv+1)) {
          seen.at(cv+1) = 1;
          dist.at(cv+1) = dist.at(cv)+1;
          que.push(cv+1);
        }        
      }
    }
    reps(j, 1, n+1) vec.at(dist.at(j))++;
  }
  
  reps(i, 1, n) {
    cout << vec.at(i)/2 << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
import numpy as np
N=int(input())
six=[1]
nine=[]
for i in range(1,N):
  six.append(6**i)
  nine.append(9**i)
  if 6**i>N:
    break
six=np.array(six)
nine=np.array(nine)
L=np.concatenate([six,nine])    
now=N
count=0
dp=np.ones(N+L.max()+1)*np.inf
dp[1]=1
dp[0]=0
#dp[i+1]　iをちょうど引き出すのに必要な最小回数
for i in range(1,N):
  dp[i+1]=(dp[i-L+1]+1).min()

  
print(int(dp[N]))
#print(len(L))

Measured memory_bytes: 88680
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    double T, X;
    cin >> T >> X;
    double ans = T/X;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

ans = 0

for i in range(10):
  a = S.find(str(i))
  if a == -1:
    continue
  for j in range(10):
    b = S.find(str(j), a+1)
    if b == -1:
      continue
    for k in range(10):
      c = S.find(str(k), b+1)
      if c != -1:
        ans += 1

print(ans)

Measured memory_bytes: 9220
n=int(input())
H=[int(i) for i in input().split()]


for i in range(n-2,-1,-1):
  if H[i]-H[i+1]>0:
    H[i]-=1

cnt=0
for i in range(n-1):
  if H[i]-H[i+1]<=0:
    cnt+=1

if cnt==n-1:
  print('Yes')
else:
  print('No')
          

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

vector<int> top2(map<int,int> m){
    vector<pair<int,int>> v;
    for(const auto &p:m) v.pb({p.se,p.fi});

    sort(all(v));
    reverse(all(v));
    return vector<int>({v[0].se, v[1].se});
}

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

    map<int,int> m[2];
    rep(i,n){
        int v;
        cin >>v;
        ++m[i%2][v];
    }
    rep(i,2) m[i][-1] = 0;

    int ans = n;
    for(int i:top2(m[0]))for(int j:top2(m[1]))if(i!=j){
        ans = min(ans, n-m[0][i]-m[1][j]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8180
n = int(input())
count = set([n,n-1])

for i in range(2,int((n)**0.5)+5):
    if (n-1)%i == 0:
        count.add(i)
        count.add((n-1)//i)
    if n%i == 0:
        a = n
        while a % i == 0:
            a //= i
        if a%i == 1:
            count.add(i)
    
if 1 in count:
    print(len(count)-1)
else:
    print(len(count))

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
  int a ,n ,i ,j ,total=0 ,high=-100001 ,nam[5000];
  while( 1 ){
    scanf( "%d" ,&n );
    if( n == 0 ){
      break;
    }

    for( j=0 ; j<n ; j++ ){
      scanf( "%d" ,&nam[j] );
    }
    high = nam[0];
    for( i=0 ; i<n ; i++ ){
      total = 0;
      for( j=i ; j<n ; j++ ){
	total += nam[j];
	if( total > high ){
	  high = total;
	}
      }
    }

    printf( "%d\n" ,high );
    high = 0;
    total = 0;
  }
  return 0;
}

Measured memory_bytes: 616
//#include <ext/pb_ds/assoc_container.hpp> 
 //#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
int fre[100001];
int co[11];
int n,k;
int f[100001];
int maxi;
int dp[501][5001];
int solve(int i,int rem)
{
	if(rem==0)
		return 0;
	if(i==maxi)
		return 0;
	int &res=dp[i][rem];
	if(res!=-1)
		return res;
	res=0;
	for(int j=1;j<=min(rem,k);j++)
	{
		res=max(res,co[j]+solve(i+1,rem-j));
	}
	return res;
}
int32_t main()
{
    IOS
    
    int n;
    cin>>n;
    int a[n+1];
    int xori=0;
    for(int i=1;i<=n;i++)
    	cin>>a[i],xori^=a[i];
    for(int i=1;i<=n;i++)
    	cout<<(xori^a[i])<<" ";

}       

Measured memory_bytes: 5176
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in= new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int arr [] = new int[n];
		int dp[] = new int[k+1];
		for( int i=0;i<n;i++) {
			arr[i] = in.nextInt();
		}
		int mod= (int)1e9 + 7;
		dp[0] =1;
		int dpPrev[] = new int[k+1];
		int sum=0;
		for(int i=1;i<=n;i++) {
			 sum+= arr[i-1];
			 Arrays.fill(dpPrev,0);
			 dpPrev[0]=1;
			 for(int j=1;j<=k;j++)
				 dpPrev[j]=(dpPrev[j-1]%mod + (int)dp[j]%mod)% mod;
			for(int j=1;j<=k; j++) {
			           if(arr[i-1]-j>=0)	
			             dp[j]= dpPrev[j]%mod;
			           else {
			        	   dp[j]=(dpPrev[j] - dpPrev[j-arr[i-1]-1] + mod)%mod;
			           }
			           
			           
			   }
		}
		
		System.out.println(dp[k]);
	}

}


Measured memory_bytes: 29160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_N 2000
#define MOD 1000000007

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, M;
int S[MAX_N], T[MAX_N];
llong dp[MAX_N + 1][MAX_N + 1];

llong solve() {
    for(int i = 0; i <= N; ++i)
        dp[i][0] = 1;
    for(int j = 0; j <= M; ++j)
        dp[0][j] = 1;

    for(int i = 0; i < N; ++i)
        for(int j = 0; j < M; ++j) {
            if(S[i] == T[j]) {
                dp[i + 1][j + 1] = modulo(dp[i][j + 1] + dp[i + 1][j], MOD);
            } else {
                dp[i + 1][j + 1] = modulo(dp[i][j + 1] + dp[i + 1][j] - dp[i][j], MOD);
            }
        }

    return dp[N][M];
}

int main(int argc, char **argv) {
    cin >> N >> M;
    for(int i = 0; i < N; ++i)
        cin >> S[i];
    for(int i = 0; i < M; ++i)
        cin >> T[i];
    
    cout << solve() << endl;
}

Measured memory_bytes: 31488
// ---------- begin scannner ----------
#[allow(dead_code)]
mod scanner {
    use std::str::FromStr;
    use std::str::SplitWhitespace;
    use std::io::Read;
    use std;
    pub struct Scanner<'a> {
        it: SplitWhitespace<'a>
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a String) -> Scanner<'a> {
            Scanner {
                it: s.split_whitespace()
            }
        }
        pub fn next<T: FromStr>(&mut self) -> T {
            match self.it.next().unwrap().parse::<T>() {
                Ok(v) => v,
                _ => panic!("Scanner error")
            }
        }
        pub fn next_chars(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }
    }
    pub fn read_string() -> String {
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}
// ---------- end scannner ----------
use std::io::Write;
use std::cmp::*;
fn main() {
    let sc = scanner::read_string();
    let mut sc = scanner::Scanner::new(&sc);
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    // run(&mut sc, &mut out);
    // solvea(&mut sc,&mut out);
    // solveb(&mut sc,&mut out);
    // solvec(&mut sc,&mut out);
    solved(&mut sc,&mut out);
}

#[allow(dead_code)]
fn solvea(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<std::io::StdoutLock>){
    let t = sc.next::<usize>();
    for _ in 0..t{
        let n = sc.next::<i32>();
        for i in 2..=32{
            let cnt = 2i64.pow(i);
            if (n as i64)%(cnt-1) == 0{
                writeln!(out,"{}",(n as i64)/(cnt-1)).ok();
                break;
            }
        }
    }
}


#[allow(dead_code)]
fn solved(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<std::io::StdoutLock>){
    let n = sc.next::<usize>();
    let k = sc.next::<usize>();
    let mut res = 0i64;
    const MOD:i64 = (1e9+7.0) as i64;
    for i in k..=(n+1){
        let l = (i as i64)*((i-1) as i64)/2i64;
        let r = (i as i64)*((2*n-i+1) as i64)/2i64;
        res = (res+r-l+1)%MOD;
    }
    writeln!(out,"{}",res).ok();
}

Measured memory_bytes: 2160
N = int(input())
lis = list(map(int, input().split()))

half = sum(lis)
left, right, dif = 0, half, half

for i in range(N):
    dif_before = dif
    left += lis[i]
    right = half - left
    dif = abs(right - left)
    if dif >= dif_before:
        break

print(dif_before)

Measured memory_bytes: 31412
N = int(input())
x, y, h = [], [], []
x2, y2, h2 = [], [], []
for i in range(N):
    xi, yi, hi = map(int, input().split())
    if hi == 0:
        x2.append(xi)
        y2.append(yi)
        h2.append(hi)
    else:
        x.append(xi)
        y.append(yi)
        h.append(hi)


def fn(H, X, Y, Cx, Cy):
    return H + abs(Cx - X) + abs(Cy - Y)

heights = []
for Cx in range(101):
    for Cy in range(101):
        H = fn(h[0], x[0], y[0], Cx, Cy)
        heights.append([H, Cx, Cy])
        if len(h) == 1:
            continue
        flag = True
        for i in range(1, len(h)):
            if H != fn(h[i], x[i], y[i], Cx, Cy):
                flag = False
                break
        if flag:
            print(Cx, Cy, H)
            exit()

print(x[0], y[0], h[0])

Measured memory_bytes: 4324
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[1000007]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
*/
using namespace std;
signed main(){
  fast;
  //usefile;
  //test
  {
    int n;
    cin>>n;
    cout<<ceil((n*1.0)/2);
    
  }
  //time("");
  return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
def input():
    return sys.stdin.readline()[:-1]

S = deque(map(int, list(input())))
num = 0
dict = {}
dict[0] = 1
ans = 0

for i in range(len(S)):
    num += S.pop() * pow(10,i,2019)
    cand = num % 2019
    if cand in dict.keys():
        dict[cand] += 1
    else:
        dict[cand] = 1

for key in dict.keys():
    ans += dict[key] * (dict[key] - 1) // 2
print(ans)


Measured memory_bytes: 80876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

bool flag[3001][3001];
ll dp[3001][3001];
vector<ll> a;

// rec(l, r) は a_l ~ a_r でターンが回ってきた人の、(自分の点数)-(相手の点数)の最大値
ll rec(int l, int r){
    if(flag[l][r]) return dp[l][r];
    if(l==r){
        flag[l][r] = true;
        return dp[l][r] = a[l];
    }
    else{
        flag[l][r] = true;
        return dp[l][r] = max(a[l]-rec(l+1, r), a[r]-rec(l, r-1));
    }
}

int main(void){
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        ll tmp_a;
        cin >> tmp_a;
        a.push_back(tmp_a);
    }
    cout << rec(0, n-1) << endl;
    return 0;
}

Measured memory_bytes: 79616
use std::io;

fn main() {
	let mut s:Vec<Vec<char>> = Vec::new();
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut si = buf.trim().chars().collect::<Vec<char>>();
	let mut sj = si.clone();
	let iter = sj.iter().rev();
	let mut sa:Vec<char> = Vec::new();
	for c in iter {
		sa.push(*c);
	}
	s.push(sa);
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut si = buf.trim().chars().collect::<Vec<char>>();
	let mut sj = si.clone();
	let iter = sj.iter().rev();
	let mut sb:Vec<char> = Vec::new();
	for c in iter {
		sb.push(*c);
	}
	s.push(sb);
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut si = buf.trim().chars().collect::<Vec<char>>();
	let mut sj = si.clone();
	let iter = sj.iter().rev();
	let mut sc:Vec<char> = Vec::new();
	for c in iter {
		sc.push(*c);
	}
	s.push(sc);
	let mut n = 0;
	let mut winner = 0;
	loop {
		match s[n].pop() {
			Some(c) => {
				if c == 'a' {
					n = 0;
				}else if c == 'b' {
					n = 1;
				}else{
					n = 2;
				};
			},
			None => {
				winner = n;
				break;
			},
		}
	}
	if winner == 0 {
		println!("A");
	}else if winner == 1 {
		println!("B");
	}else{
		println!("C");
	}
}

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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+100000000
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}



void solve() {
            
           string s;
           cin >> s;
           if(s[s.size() - 1] == 's') {
                cout << s << "es" << endl;
           } else {
                cout << s << "s" << endl;
           }
            
            
}


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

    int t=1;
   // cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 3588
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <deque>

int main(){
  std::string S;
  long long K;
  std::cin >> S;
  scanf("%lld", &K);
  std::vector<int > a(S.length());
  for (int i=0; i<S.length(); i++){
    a[i] = int(S[i])-int('0');
  }
  int index = 0;
  while(K>1 && a[index]==1){
    K--;
    index++;
  }
  printf("%d\n", a[index]);
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
	val s = scala.io.StdIn.readLine.toList.toSet


	if(s.size == 4){
		println("Yes")
	}else if(s.size == 1 || s.size == 3){
		println("No")
	}else{
		if(s.contains('W') && s.contains('E')){
			println("Yes")
		}else if(s.contains('S') && s.contains('N')){
			println("Yes")
		}else{
			println("No")
		}
	}

}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------
int N, turn;
int d[111], f[111];
vector<vector<int>> G;

void dfs(int from) {
   d[from] = ++turn;
   for (int to : G[from]) {
      if (!d[to]) dfs(to);
   }
   f[from] = ++turn;
}

int main() {
   // 入力
   cin >> N;
   G = vector<vector<int>>(N);
   rep (i, N) {
      int u, k;
      cin >> u >> k;
      u--;
      rep (j, k) {
         int a;
         cin >> a;
         a--;
         G[u].push_back(a);
      }
   }

   rep (i, N) {
      if (!d[i]) dfs(i);
   }

   rep (i, N) {
      printf("%d %d %d\n", i+1, d[i], f[i]);
   }

   return 0;
}


Measured memory_bytes: 3288
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <numeric>
#include <array>

using namespace std;

typedef long long ll;


int main(int argc, const char * argv[]) {
    string N;
    cin >> N;
    
    int digit = N.size();
    int total = 0;
    for (int i = 0; i < digit; i++) {
        if (i % 2 == 0) {
            total += (int)(min(stod(N) + 1, pow(10, i + 1)) - pow(10, i));
        }
    }
    cout << total << endl;
    
    return 0;
}


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

using namespace std;

struct edge{
  int to;
  char c;
  edge(){}
  edge(int a, char b){
    to = a, c = b;
  }
};

int n, m, s, g;
vector<edge> G[2505];
vector<int> revG[2505];
string ans;
bool valid[2505], nvalid[2505];
bool reach[2505];

void dfs(int v)
{
  reach[v] = true;
  for(int i = 0; i < revG[v].size(); i++){
    if(reach[revG[v][i]]) continue;
    dfs(revG[v][i]);
  }
}

int main(void)
{
  while(1){
    cin >> n >> m >> s >> g;
    if(n == 0 && m == 0 && s == 0 && g == 0) break;
    s++, g++;
    for(int i = 1; i < 2505; i++) G[i].clear();

    int V = n, u, v; string lab;
    for(int i = 1; i <= m; i++){
      cin >> u >> v >> lab;
      u++, v++;
      int pre = u;
      for(int j = 0; j < (int)lab.size()-1; j++){
        V++;
        G[pre].push_back(edge(V, lab[j]));
        pre = V;
      }
      G[pre].push_back(edge(v, lab[(int)lab.size()-1]));
    }
    for(int i = 1; i <= V; i++) revG[i].clear();
    for(int i = 1; i <= V; i++){
      for(int j = 0; j < G[i].size(); j++){
        revG[G[i][j].to].push_back(i);
      }
    }
    for(int i = 1; i <= V; i++) reach[i] = false;
    dfs(g);

    ans = "";
    for(int i = 1; i <= V; i++) valid[i] = false;
    valid[s] = true;
    for(int i = 0; i < 305; i++){

      if(valid[g]){
        cout << ans << endl;
        goto end;
      }
      bool found = false;
      for(int j = 0; j < 26; j++){
        bool flag = false;
        for(int k = 1; k <= V; k++){
          if(!valid[k]) continue;
          for(int l = 0; l < G[k].size(); l++){
            if(G[k][l].c == j+'a' && reach[G[k][l].to]){
                flag = true;
                goto pass;
            }
          }
        }
        pass:;
        if(!flag) continue;
        for(int k = 1; k <= V; k++) nvalid[k] = false;
        for(int k = 1; k <= V; k++){
          if(!valid[k]) continue;
          for(int l = 0; l < G[k].size(); l++){
            if(G[k][l].c == j+'a' && reach[G[k][l].to]) nvalid[G[k][l].to] = true;
          }
        }
        for(int k = 1; k <= V; k++) valid[k] = nvalid[k];
        found = true;
        ans += j+'a';
        break;
      }
      if(!found){
        cout << "NO" << endl;
        goto end;
      }
    }
    cout << "NO" << endl;
    end:;
  }
  return 0;
}



Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    vector<int64_t> a(n);
    int64_t min_a = INT_MAX, sum = 0;
    bool flg = false;
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
        min_a = min(min_a, abs(a[i]));
        sum += abs(a[i]);
        if(a[i] < 0) flg = not(flg);
    }

    if(flg) sum -= min_a * 2;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;    
int main()
{
    long long n;
    cin>>n;
    long long a[n],c[n];
       for(long long i=0;i<n;i++)
    {
        cin>>a[i];
        c[i]=a[i]-(i+1);
           }
    
    sort(c,c+n);
    long long k=n/2;
    long long b=c[k];
    
    long long sum=0;
    for(long long i=1;i<=n;i++)
        {
          sum+=labs(a[i-1]-(b+i));
        }
    
    
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3328
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.util.Calendar.Builder;



public class Main {
	static int INF = 2 << 27;
	static int N;
	static int M;
	static int A;
	static int B;
	static int C;
	static int T;
	static long[][] dp;
	public static void main(String[] args) {	
		//FastScanner sc = new FastScanner();
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		while(true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int d = sc.nextInt();
			if(a == 0 && b == 0 && d == 0) break;
			int minWeight = INF;
			int minNumber = INF;
			int ansX = -1;
			int ansY = -1;
			for(int i = 0; i <= 50000; i++) {
				for(int j = 0; j < 50000; j++) {
					if(i + j > minNumber) break;
					if(a * i + b * j > minWeight) continue;
					if(Math.abs(a * i - b * j) == d || (a * i + b * j) == d) {
						minWeight = a * i + b * j;
						minNumber = i + j;
						ansX = i;
						ansY = j;
					}
				}
			}
			System.out.println(ansX + " " + ansY);
		}
	}
}

Measured memory_bytes: 27572
import math
import numpy
list = list(map(int, input().split()))
jikaku = (30 * (list[2])) + (30 * (list[3]) / 60)
ax = list[0] * math.cos(math.radians(jikaku))
ay = list[0] * math.sin(math.radians(jikaku))

hunkaku = 6 * (list[3])
bx = list[1] * math.cos(math.radians(hunkaku))
by = list[1] * math.sin(math.radians(hunkaku))
print(numpy.linalg.norm(numpy.array([ax, ay]) - numpy.array([bx, by])))

Measured memory_bytes: 27264
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    vector<int> n(N);
    rep(i, 0, N) {
        n[i] = i + 1; 
    }
    rep(i, 0, N) {
        cin >> P[i];
    }
    rep(i, 0, N) {
        cin >> Q[i];
    }
    sort(n.begin(), n.end());

    int count = 0;
    string s = "";
    string t = "";
    string u = "";
    int a = 0;
    int b = 0;
    do{
        ++count;
        for(int i=0; i<N; i++){
            s += to_string(n[i]);
            t += to_string(P[i]);
            u += to_string(Q[i]);
        }
        if (s == t) {
            a = count;
        }
        if (s == u) {
            b = count;
        }
        s = "";
        t = "";
        u = "";
    }while(next_permutation(n.begin(),n.end()));
    cout << abs(a-b) << endl;
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    int a[2][100];
    inc(i, 0, 2){
        inc(j, 0, n){
            cin >> a[i][j];
        }
    }
    int ans = 0;
    inc(i, 0, n){
        int cnt = 0;
        inc(j, 0, i){
            cnt += a[0][j];
        }
        cnt += a[0][i] + a[1][i];
        inc(j, i+1, n){
            cnt += a[1][j];
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = [int(a) - 1 for a in input().split()]

if K <= N:
    p = 0
    for i in range(K):
        p = A[p]
    print(p + 1)
    exit()

p = 0
t = [-1] * N
t[0] = 0
for i in range(1, N):
    p = A[p]
    if t[p] != -1:
        break
    t[p] = i

d = i - t[p]
K -= i
K %= d

for i in range(K):
    p = A[p]
print(p + 1)


Measured memory_bytes: 92372
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#define INF (int)1e9
#define pb push_back
using namespace std;

int keta(long long int n){
  int i=1;
  while(n>9){
    i++;
    n/=10;
  }
  return i;
}

int main(void){
  long long int n,nn;
  cin>>n;
  long long int i,a,b;
  long long int maxn=sqrt(n)+1;

  int tmp,res;
  res=keta(n);
  for(i=2;i<=maxn;i++){
    if(n%i==0){
      a=i;
      b=n/i;
      tmp=max(keta(a),keta(b));
      if(tmp<res) res=tmp;
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  int n,i,c[4]={0};
  char s[3];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s);
    if(s[0]=='A'){
      c[0]++;
    } else if(s[0]=='W'){
      c[1]++;
    } else if(s[0]=='T'){
      c[2]++;
    } else if(s[0]=='R'){
      c[3]++;
    }
  }
  
  printf("AC x %d\n",c[0]);
  printf("WA x %d\n",c[1]);
  printf("TLE x %d\n",c[2]);
  printf("RE x %d\n",c[3]);

}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VL xs(N);
  cin >> xs;

  LL ans = 0;
  for(auto x: xs){
	while(x % 2 == 0){
	  ++ans;
	  x /= 2;
	}
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int a,i,A[100],flag,c,j,count=0;
  scanf("%d",&a);
  for(i=0;i<a;i++)scanf("%d",&A[i]);
  flag = 1;
    while (flag == 1){
      flag = 0;
      for (j=a-1;j>=1;j--){
	if (A[j] < A[j-1]){
	  c=A[j];
	A[j]=A[j-1];
	A[j-1]=c;
        flag = 1;
	count++;
	}
      }
    }

  

    for(i=0;i<a;i++){
      if(i!=a-1)printf("%d ",A[i]);
      else printf("%d",A[i]);
    }
  printf("\n%d\n",count);


}



Measured memory_bytes: 2756
#関数リスト
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n = I()
mylist = LI()
buy = [0] * n

katamuki = 0
for i in range(n-1):
    if katamuki == 0:
        if mylist[i+1] > mylist[i]:
            buy[i] = "buy"
            katamuki = 1
        elif mylist[i+1] < mylist[i]:
            katamuki = -1
    elif katamuki == -1 and mylist[i+1] > mylist[i]:
        buy[i] = "buy"
        katamuki = 1
    elif katamuki == 1 and mylist[i+1] < mylist[i]:
        buy[i] = "sell"
    elif katamuki == 1 and mylist[i+1] > mylist[i]:
        buy[i] = "buysell"

        
result = 1000
stock = 0
price = 0    
for i in range(n):
    if buy[i] == "buy":
        stock = result // mylist[i]
        result -= mylist[i] * stock
    elif buy[i] == "sell":
        result += mylist[i] * stock
        stock = 0
    elif buy[i] == "buysell":
        result += mylist[i] * stock
        stock = result // mylist[i]
        result -= mylist[i] * stock
    elif i == n-1:
        result += mylist[i] * stock
print(result)

Measured memory_bytes: 62124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>

#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#include <utility>
#include <list>

#include <cmath>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <complex>
#include <climits>
#include <functional>
#include <unordered_set>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back

#define debug(x) cerr << #x << " = " << x << " "

int main()
{
  string s; cin >> s;
  string nxt;
  while (!s.empty())
    {
      if (s.back() == 'A') 
	{
	  s.pop_back();
	  nxt.pb('a');
	}
      else if (s.size() >= 2 && s.substr(s.length()-2) == "BC")
	{
	  s.pop_back();
	  s.pop_back();
	  nxt.pb('b');
	}
      else 
	{
	  nxt.pb(s.back());
	  s.pop_back();
	}
    }
  reverse(nxt.begin(), nxt.end());
  ll ans = 0;
  ll cnt = 0;
  for (int i = int(nxt.size())-1; i >= 0; --i)
    if (nxt[i] == 'a') ans += cnt;
    else if (nxt[i] == 'b') ++cnt;
    else cnt = 0;

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


Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	cout << max({ A + B, A - B, A * B }) << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n ;
    cin >> n ;
    int lim = (int)(sqrt(lim));
    long long ans = 0 ;
    lim++;
    bool d = true;
    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ;; j++){
            if(i*j>n){
                break;
            }
            if(i*j<n){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

int main(){
	int N; std::cin >> N;
	std::vector<int> H(N);
	for (auto& r : H) std::cin >> r;
	int count = 0;
	int i = 1;
	for (auto& r : H) {
		if (i == r) {
			++count;
			++i;
		}
	}

	std::sort(H.begin(), H.end());
	if (H[0] != 1) {
		std::cout << -1 << std::endl;
		return 0;
	}
	std::cout << N - count << std::endl;

	return 0;
}

Measured memory_bytes: 4040
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<math.h>
using namespace std;

class point{
public:
	int p,q;// p/q
};

int a,n;

int count;
int r(point,int,int,int);
point pp(point,int);
int gcd(int,int);
int main(){
	point p;
	while(cin>>p.p>>p.q>>a>>n){
		if(p.p==0 && p.q==0 && a==0 && n==0) break;
		count=0;
		r(p,1,0,1);
		cout<<count<<endl;
	}
	return 0;
}

int r(point src,int q,int c,int k){
	//cout<<"   "<<src.p<<"/"<<src.q<<endl;
	int ret;
	if((double)src.p*q>(double)(n-c)*src.q) return 2;
	if(k>a) return 0;
	if(c>n) return 0;
	if(src.p==0){
		count++;
		return 1;
	}
	if(src.p<0) return 1;
	while(1){
		ret=r(pp(src,q),q,c+1,k*q);
		if(ret!=1) break;
		q++;
	}
	return 1;
}

point pp(point src,int q){
	src.p=src.p*q-src.q;
	src.q=src.q*q;
	int g=gcd((abs(src.p)<src.q)?abs(src.p):src.q,(abs(src.p)<src.q)?src.q:abs(src.p));
	src.p/=g;
	src.q/=g;
	return src;
}

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

Measured memory_bytes: 864
def call(a):
    if a % 3 == 0:
        return True

    while a != 0:
        if a % 10 == 3:
            return True

        a //= 10

    return False

def main():
    n = int(input())

    for i in range(1, n + 1):
        if call(i):
            print(" {0}".format(i), end="")

    print("")

if __name__ == "__main__":
    main()

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

int main()
{
	int n;
	cin>>n;
	vector<double> P(n+1);
	for(int i=0;i<n;i++) cin>>P[i+1];
	vector<vector<double>> dp(n+1,vector<double>(n+1,0.0));
	dp[1][1]=P[1];
	dp[1][0]=1.0-P[1];
	for(int i=1;i<n;i++)
	{
		dp[i+1][0]=dp[i][0]*(1.0-P[i+1]);
		for(int j=1;j<=i+1;j++)
		{
			dp[i+1][j]=dp[i][j]*(1.0-P[i+1])+dp[i][j-1]*P[i+1];
		}
	}
	double sum=0;
	for(int i=(n+1)/2;i<=n;i++) sum+=dp[n][i];
	printf("%.10lf\n",sum);
}

Measured memory_bytes: 70656
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AAbcOfABC {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string s;
	    in >> s;
	    map<char, int> mp;
	    bool res = true;
	    for(int i=0; i<3; i++){
            if(mp[s[i]]){
                res = false;
            }
            mp[s[i]]++;
	    }

	    ans(res, out);
	}
};


int main() {
	AAbcOfABC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    vector<int> a(n);

    for (auto &&i : a)
    {
        cin >> i;
    }

    ll ans = 0;

    for (int i = 0; i < n; i++)
    {
        ans ^= a[i];
    }

    for (int i = 0; i < n; i++)
    {
        cout << (ans ^ a[i]) << endl;
    }
}


Measured memory_bytes: 3972
#include<iostream>
#include<algorithm>

using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B>> C;

  if(A>B){
   if(A>C && C>B)
   cout << "Yes"<<endl;
   else
   cout << "No"<<endl;
  }
  else if(A<B)
  {
    if(A<C && C<B)
   cout << "Yes"<<endl;
   else
   cout << "No"<<endl;
  }


  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<char> dchar;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
ll infi=1e18+100;

//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい


int n;
string s[55];
string ans;
string alpha="abcdefghijklmnopqrstuvwxyz";

int main(){
	cin>>n;
	Rep(i,n) cin>>s[i];
	Rep(i,26){
		Rep(j,50){
			int c=0;
			Rep(k,n){
				Rep(l,s[k].size()){
					if(alpha[i]==s[k][l]){
						s[k][l]='#';
						c++;
						break;
					}
					}
				}
			if(c==n){
				ans+=alpha[i];
			}
		}
	}
	cout<<ans<<endl;
	
	

  return 0;
  }



Measured memory_bytes: 256
N, = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
for i in range(N):
    a = A[i]
    c = 0
    while a:
        a, m = divmod(a, 2)
        if m:
            break
        c += 1
    B[i] = c
print(sum(B))


Measured memory_bytes: 41836
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

ll N;
int c[10][10] = {};
int main () {
    cin >> N;
	for (int i = 1; i <= N; ++i) {
		int n = log10(i);
		int first = i / pow(10,n); 
		int last = i%10;
		c[first][last]++;
	}
	ll ans = 0;
	rep(i,10)
		rep(j,10) {
			ans+=c[i][j] * c[j][i];
		}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
result = list()
for i in range(H):
    for j in range(W):
        if a[i][j]%2 == 1 and j+1 < W:
            a[i][j] -= 1
            a[i][j+1] += 1
            result.append((i+1, j+1, i+1, j+2))
        if a[i][j]%2 == 1 and j == W-1 and i+1<H:
            a[i][j] -= 1
            a[i+1][j] += 1
            result.append((i+1,j+1,i+2,j+1))
print(len(result))
for y, x, y_, x_ in result:
    print('{} {} {} {}'.format(y, x, y_, x_))


Measured memory_bytes: 26280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  string S;
  cin>>S;
  int ans=0,ans2=0;
  rep(i,S.size()){
    if(i%2&&S[i]=='1') ans++;
    else if(i%2==0&&S[i]=='0') ans++;
  }
  rep(i,S.size()){
    if(i%2&&S[i]=='0') ans2++;
    else if(i%2==0&&S[i]=='1') ans2++;
  }
  cout<<min(ans,ans2)<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n;
    cin >> n;
    vector<ll> p(n);
    vector<bool> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    ll t = p[0];
    ll s = p[0];
    a[0] = true;
    for (ll i = 1; i < n; i++)
    {
        t = max(t, p[i]);
        s = min(s, p[i]);
        if (t != p[i]&&s==p[i])
        {
            a[i] = true;
        }
        else{
            a[i] = false;
        }
    }
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        //cout << a[i] << endl;
        if (a[i])
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int y = sc.nextInt();
		int y500 = y/500;
		y =y - y500*500;
		int y5 = y/5;
		System.out.println(y500*1000+y5*5);
		
		
	}
}


Measured memory_bytes: 21844
a,b=input().split()
a=int(a)
b=int(b)
if a==b:
  print("Draw")
else:
  if a==1:
    print("Alice")
  else:
    if b==1:
      print("Bob")
    else:
      if a-b>0:
        print("Alice")
      else:
        print("Bob")

Measured memory_bytes: 9140