akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input! {n:usize, d:[i64;n]};

    let set:HashSet<_> = d.iter().collect();
    //debug!(set);

    println!("{}", set.len());

}

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

int main()
{
  i64 n;
  cin >> n;
  vector<i64> a(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i];
  vector<i64> in(n + 1), tmp(n + 1);
  vector<i64> ans, cnt(n + 1);
  for (i64 i = n; 0 < i; i--)
  {
    for (i64 j = i * 2; j <= n; j += i)
      a[i - 1] ^= a[j - 1];
    if (a[i - 1] == 1)
      ans.push_back(i);
  }
  i64 size = ans.size();
  cout << size << endl;
  for (i64 i = 0; i < size; i++)
    cout << ans[i] << (i + 1 == size ? "\n" : " ");
  return 0;
}


Measured memory_bytes: 8052
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int ans[202]={};
	ans[105]=1;
	ans[135]=1;
	ans[165]=1;
	ans[189]=1;
	ans[195]=1;
	int n,c=0;
	cin>>n;
	FOR(i,0,n+1)c+=ans[i];
	cout<<c;
    return 0;
}


Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, K = map(int, rl().split())
    A = list(map(int, rl().split()))
    
    for _ in range(min(K, 100)):
        imos = [0] * N
        for i in range(N):
            left = max(0, i - A[i])
            right = min(N - 1, i + A[i])
            imos[left] += 1
            if right < N - 1:
                imos[right + 1] -= 1
        for i in range(1, N):
            imos[i] += imos[i - 1]
        A = imos[:]
    print(*A)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 174996
#include<bits/stdc++.h>
using namespace std;
long long int inf=1e18+5;
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,i;
	cin>>n;
	long long int a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	long long int dp[n][n];
	memset(dp,0,sizeof(dp));
	int j,l,k;
	for(i=0;i<n;i++)
		dp[i][i]=a[i];
	long long int sum[n];
	sum[0]=a[0];
	for(i=1;i<n;i++)
		sum[i]=sum[i-1]+a[i];
	for(l=2;l<=n;l++)
	{
		for(i=0;i<n-l+1;i++)
		{
			j=i+l-1;
			dp[i][j]=inf;
			for(k=i;k<j;k++)
			{
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]);
			}
			dp[i][j]+=sum[j];
			if(i)
				dp[i][j]-=sum[i-1];
		}
	}
	cout<<dp[0][n-1]-sum[n-1]<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int i = 0;
    long long int h, ans = 0;
    cin >> h;

    while (h > 0){
        ans += pow(2,i);
        h = h / 2;
        i += 1;
    }

    cout << ans << endl;




    return 0;
}

//Sum accumulate(v.begin(),v.end(),0);
//Sort sort(v.begin(),v.end())
//Power pow(base, e)


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

"""
Nが偶数
f(2) = 2 * f(0) = 2 * 1
f(4) = 4 * f(2) = 4 * 2 * 1
f(6) = 6 * f(4) = 6 * 4 * 2 * 1
となる。
どれも2の倍数なので、2*5**xで割り切れる個数が答え


Nが奇数
f(3) = 3 * f(1) = 3 * 1
f(5) = 5 * 3 * 1
f(7) = 7 * 5 * 3 * 1
なので、偶数が出てくることがないので0
"""

if N in [0,1]:
    print(0)

elif N % 2 == 1:
    print(0)
else:
    ans = 0
    num = 1
    while 5**num <= N:
        cnt = N // (2*5**num)
        ans += cnt
        num += 1

    print(ans)



Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#include <fstream>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  int A,B,K;
  cin>>A>>B>>K;
  set<int> S;
  FOR(i,A,min(B,A+K-1)+1){
    S.insert(i);
  }
  FOR(i,max(A,B-K+1),B+1){
    S.insert(i);
  }
  for(set<int>::iterator it=S.begin();it!=S.end();it++){
    cout<<*it<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC50(void);
void ABC51(void);
void ABC52(void);
void ABC53(void);
void ABC54(void);
void ABC55(void);
void ABC56(void);
void ABC57(void);
void ABC58(void);
void ABC59(void);

int main(void){
    ABC50();
}

void ABC50(){
    int k,s,i,j,a,ans=0;
    cin>>k>>s;
    for(i=0;i<=s;i++){
        for(j=0;j<=s-i;j++){
            if(i<=k&&j<=k&&(s-i-j)<=k){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int cnt = 0;
		if (N >= 100000) {
			cnt = 90909;
		} else if (N >= 10000) {
			cnt = N - 9999 + 909;
		} else if (N >= 1000) {
			cnt = 909;
		} else if (N >= 100) {
			cnt = N - 99 + 9;
		} else if (N >= 10) {
			cnt = 9;
		} else if (N >= 0) {
			cnt = N;
		}
		System.out.println(cnt);

	}
}

Measured memory_bytes: 21204
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner cs = new Scanner(System.in);
        while (true) {
            int a = cs.nextInt();
            if(a==0) break;
            int[] p = new int[a];
            int big = 0;
            int small = 100000;
            int sum = 0;
            for (int i = 0; i < a; i++) {
                p[i] = cs.nextInt();
                if (big < p[i]) {
                    big = p[i];
                }
                if (small > p[i]) {
                    small = p[i];
                }
                sum = sum + p[i];
            }
            sum = sum - big - small;
            sum = sum / (a - 2);

            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 29024
#include <stdio.h>
#include <stdlib.h>
int binarysearch(int*,int,int);
int main(){

  int n,q,*data1,*data2,i,r,count=0;

  scanf("%d",&n);

  data1=(int *)malloc(sizeof(int)*n);
  for(i=0;i<n;i++){
    scanf("%d",&data1[i]);
  }

  scanf("%d",&q);

  data2=(int *)malloc(sizeof(int)*q);
  for(i=0;i<q;i++){
    scanf("%d",&data2[i]);
  }
  
  for(i=0;i<q;i++){
    r=binarysearch(data1,data2[i],n);
      if(r==1) count++;
        }

  printf("%d\n",count);

  free(data1);
  free(data2);
  return 0;
}


int binarysearch(int *data1,int data2,int length){

  int left,right,mid;

  left=0;
  right=length;
  while(left<right){
    mid=(left+right)/2;
    if(data2==data1[mid]) return 1;
    if(data2>data1[mid]) left=mid+1;
    else if(data2<data1[mid]) right=mid;
      }
  return -1;

}

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

#define ll long long

using namespace std;

int n, a[200'004];
int main() {
    deque<int> s;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = n; i >= 1; --i) {
        int count = 0;
        for (int j = 2; i * j <= n; j++) {
            if (a[i * j])
                count = 1 - count;
        }
        a[i] = a[i] ^ count;
        if (a[i])
            s.push_front(i);
    }
    cout << s.size() << endl;
    for (int i = 0; i < s.size(); ++i)
        cout << s[i] << " ";

    return 0;
}


Measured memory_bytes: 2304
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;
int s[105][105];

int main()
{
    int n;
    while (scanf ("%d",&n) != EOF)
    {
        for (int i = 0;i < n;i++)
            scanf ("%d",&s[0][i]);//读入
        for (int i = 0;i < n;i++)
        {
            if (i != n-1)
                printf ("%d ",s[0][i]);
            else
                printf ("%d\n",s[0][n-1]);
        }//输出第一行
        int r = 1;//当前处理的是第r行
        for (int i = 1;i < n;i++)//此次取得是数s[0][i]
        {
            r++;
            for (int j = 0;j < n;j++)
                s[r-1][j] = s[r-2][j];
            //将第r行的上面一行拷贝下来
            int key = s[r-1][i];
            //此次循环新加入有序数列的数
            //前方有i个数
            for (int j = i-1;j >= 0 ;j--)
            {
                if (key < s[r-1][j])
                {
                    swap(s[r-1][j],s[r-1][j+1]);
                }

            }
            for (int j = 0;j < n;j++)
            {
                if (j != n-1)
                    printf ("%d ",s[r-1][j]);
                else
                    printf ("%d\n",s[r-1][n-1]);
            }//输出后排
        }//逐渐增加有序数列中的个数，从2开始到n
    }
    return 0;
}








Measured memory_bytes: 3220
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
ll in(){ ll x; cin >> x; return x; }
vector<ll> in(size_t n){ vector<ll> v(n); each(x, v) cin >> x; return v; }
/* ]]] */

int main(){
  ll n = in();
  auto a = in(n);
  a.push_back(0);
  ll s = 0, t = 0;
  each(x, a){
    if (x > 0) s += x;
    else t += s / 2, s = 0;
  }
  cout << t << endl;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	zip(i, 0, n)
	{
		cout << s[i] << t[i];
	}
	cout << en;


	return 0;
}



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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	int ret=0, out=1;
	while(out<b)
		out--, out+=a, ret++;
	cout<<ret<<"\n";
	return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	int a,b;cin >> a >> b;
	cout << ((a % b)?1:0) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 1e5 + 5;
 
int n;
int a[N], b[N], c[N];
int ans = 0;
 
int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= n; i++)
	{
		cin >> b[i];
		ans += b[i];
	}
	for(int i = 1; i <= n; i++)
		cin >> c[i];
	for(int i = 2; i <= n; i++)
	{
		if(a[i] - a[i - 1] == 1)
			ans += c[a[i - 1]];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3636
N = int(input())
A = list(map(int, input().split()))

ans = 0

count = 0
existZero = False
for i in range(N):
    if A[i] == 0:
        existZero = True
    elif A[i] < 0:
        count += 1

    A[i] = abs(A[i])

if existZero:
    ans = sum(A)
else:
    if count % 2 == 0:
        ans = sum(A)
    else:
        ans = sum(A) - 2 * min(A)

print(ans)

Measured memory_bytes: 14332
from itertools import permutations
n = int(input())
a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))
cnta = 0
cntb = 0
for x in permutations(range(1,n+1)):
  if a == x:
    aa = cnta
  if b == x:
    bb = cntb
  cnta += 1
  cntb += 1
print(abs(aa-bb)) 

Measured memory_bytes: 3064
n,m = map(int,input().split())

K = []
A = []
for i in range(n):
    k,*a = input().split()
    K.append(k)
    A.append(a)

ans = 0

for i in range(m):
    sum = 0
    for j in range(n):
        sum += str(i+1) in A[j]
    if sum == n:
        ans+=1

print(ans)

Measured memory_bytes: 3064
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for (int i = 1; i < 10; i++)
	{
		for (int j = i; j < 10; j++)
		{
			if (i * j == n)
			{
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int n, k;
    string s;
    cin >> n >> s >> k;
    rep(i, n)
    {
        if (s[i] != s[k - 1])
        {
            s[i] = '*';
        }
    }
    cout << s << endl;
    return 0;
}


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

int main()
{
  int N, K;
  cin >> N >> K;
  set<int> S;
  for (int i = 0; i < K; i++)
  {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++)
    {
      int a;
      cin >> a;
      S.insert(a);
    }
  }
  cout << N - S.size() << endl;
}

Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T = int>
void print(vec<T> v){ cout << "["; for (T item: v) { cout << item << ", "; } cout << "]" << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__
#define next next__
#define prev prev__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

void Main() {
    //code here
    int n = gi;
    vec<int> nums = gim(n);
    int q = gi;
    vec<int> asks = gim(q);

    set<int> sums;
    for (int bit = 0; bit < (1<<n); bit++) {
        int sum = 0;
        REP(i, n) {
            if (bit & (1 << i)) {
                sum += nums[i];
            }
        }
        sums.insert(sum);
    }

    for (int ask: asks) {
        if (sums.find(ask) != sums.end()) {
            print("yes");
        } else {
            print("no");
        }
    }
}

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


Measured memory_bytes: 3168
function Main(input) {
	input = input.split("\n");
	const N = parseInt(input[0])
	const Hs = input[1].split(" ").map(x => parseInt(x))
	var now = 0
	var max = 0
	for(i=1; i < N; i++){
		if(Hs[i-1] >= Hs[i]){
			now++
		}else{
			if(now > max) max = now
			now = 0
		}
	}
  	if(now > max) max = now
	console.log(max)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17804
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	a,v = readline() |> split |> parseMap
	b,w = readline() |> split |> parseMap
	t = readline() |> parseInt
	println(a-t*v<=b-t*w&&a+t*v>=b+t*w ? "YES" : "NO")
end

main()

Measured memory_bytes: 161416
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    X = int(input())
    ans = 0
    t = 100
    while t < X:
        t = int(t * 1.01)
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i = 0;; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(x == 0 && y == 0) {
				break;
			} else if(x > y) {
				System.out.println(y + " " + x);
			} else {
				System.out.println(x + " " + y);
			}
		}
	}
}

Measured memory_bytes: 35956
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N;
    string S;
    cin >> N;
    cin >> S;
    
    if(N%2 == 0){
        for (int i = 0; i < N/2; i++) {
            if(S[i] != S[N/2+i]){
                cout << "No" << endl;
                return 0;
            }
            
        }
        cout << "Yes" << endl;
    }else{
    
        cout << "No" << endl;
        return 0;
        
        
    }
    
    
    return 0;
}



Measured memory_bytes: 256
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Long,Long> map = new TreeMap<>();
        for(int i = 0; i < n; i++) {
            long val = sc.nextLong();
            long key = sc.nextLong();
            if(map.containsKey(key)) {
                map.put(key, map.get(key) + val);
            }else {
                map.put(key, val);
            }
        }
        long sum = 0;
        for(Entry<Long, Long> entry : map.entrySet()) {
            long time = entry.getKey();
            sum += entry.getValue();
            if(time < sum) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 76192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;

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

int main() {
  int N, X;
  cin >> N >> X;

  int ans;
  cin >> ans;
  ans = abs(X - ans);
  rep(i, N - 1) {
    int y;
    cin >> y;
    ans = gcd(X - y, ans);
  }

  cout << ans << endl;
  return 0;
}


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

int main() {
  int n;cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  for(int i=0;i<n;i++) {
    cin>>a.at(i);
  }
  for(int i=0;i<n;i++) {
    cin>>b.at(i);
  }
  vector<int> sa(n);
  vector<int> sb(n);
  for(int i=0;i<n;i++) {
    if(i==0) {
      sa.at(i)=a.at(i);
    }
    else {
      sa.at(i)=sa.at(i-1) + a.at(i);
    }
  }
  for(int i=0;i<n;i++) {
    if(i==0) {
      sb.at(n-1-i)=b.at(n-1-i);
    }
    else {
      sb.at(n-1-i)=sb.at(n-i) + b.at(n-1-i);
    }
  }
  int ans=0;
  for(int i=0;i<n;i++) {
    ans=max(ans,sa.at(i)+sb.at(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
#include <atcoder/all>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
using namespace atcoder;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

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;
    }
}

lli gcd2(lli x, lli y)
{
    lli t;
    while (y != 0)
        t = x % y, x = y, y = t;
    return (x);
}

lli lcm2(lli x, lli y)
{
    lli xy = x * y;
    if (xy < 0)
        xy = -xy;
    return (xy / gcd2(x, y));
}

int main(void)
{
    int T;
    cin >> T;
    long long n, m, a, b;
    for (int i = 0; i < T; i++)
    {
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }
    return 0;
}


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

int main(){
    int N,H1;
    cin >> N;
    vector<int> H(N);
    cin >> H1;
    H[0] = H1 - 1;
    bool flag = true;
    for(int i = 1;i < N;i++){
        int Hi;
        cin >> Hi;
        if(Hi > H[i-1]){
            H[i] = Hi-1;
        }else if(Hi == H[i-1]){
            H[i] = Hi;
        }else{
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "Yes" <<  endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int count = 1;
    int min;
    cin >> min;

    for (int i = 0; i < N - 1; i++) {
        int H;
        cin >> H;
        if (H >= min) {
            count++;
            min = H;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, K; cin >> n >> K;
    deque<ll> deq;
    rep(i, n){
        ll v; cin >> v;
        deq.push_back(v);
    }

    ll ans = 0;

    for(ll i = 0; i <= K; i++){
        for(ll j = 0; j <= K - i; j++){
            deque<ll> que = deq;
            priority_queue<int, vector<int>, greater<int>> pq;

            for(ll k = 0; k < i; k++){
                if(!que.empty()){
                    pq.push(que.front());
                    que.pop_front();
                }else{
                    break;
                }
            }
            for(ll k = 0; k < j; k++){
                if(!que.empty()){
                    pq.push(que.back());
                    que.pop_back();
                }else{
                    break;
                }
            }

            //discard
            for(ll k = 0; k < K - i - j; k++){
                if(!pq.empty()){
                    ll now = pq.top();
                    if(now < 0){
                        pq.pop();
                    }else{
                        break;
                    }
                }
            }

            //calc
            ll tmp = 0;
            while(!pq.empty()){
                tmp += pq.top();
                pq.pop();
            }
            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;

}

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

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var w = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

            var minVal = int.MaxValue;
            for(var i = 1; i < n; i++){
                var front = w.Take(i).Sum();
                var back = w.Skip(i).Sum();
                var abs = Math.Abs(front - back);
                minVal = Math.Min(minVal, abs);
            }

            Console.WriteLine(minVal);
        }
    }
}


Measured memory_bytes: 13396
#define _USE_MATH_DEFINES
#include <math.h>
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 5002;
vector < int > g[N];
int x[N], b[N], dp[N][N];
void dfs(int v){
    vector < pair < int, int > > a;
    for (auto u: g[v]){
        dfs(u);
        a.pb({x[u], b[u]});
    }
    if (a.size() == 0){
        b[v] = 0;
    } else{
    for (int i = 0; i <= x[v]; i++)
    for (int j = 0; j <= a.size(); j++) dp[j][i] = 1e9;
    for (int j = 0; j <= x[v]; j++) dp[0][j] = 0;
    for (int i = 1; i <= a.size(); i++){
        int y = a[i - 1].F;
        int z = a[i - 1].S;
        for (int j = 0; j <= x[v]; j++){
            if (j >= y) dp[i][j] = dp[i - 1][j - y] + z;
            if (j >= z) dp[i][j] = min(dp[i][j], dp[i - 1][j - z] + y);
        }
    }
    b[v] = 5e8;
    for (int i = 0; i <= x[v]; i++) b[v] = min(b[v], dp[a.size()][i]);
    if (b[v] == 5e8){
        cout << "IMPOSSIBLE";
        exit(0);
        }
    }
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    for (int i = 2; i <= n; i++){
        int x;
        cin >> x;
        g[x].pb(i);
    }
    for (int i = 1; i <= n; i++) cin >> x[i];
    dfs(1);
    cout << "POSSIBLE";
}


Measured memory_bytes: 39552
#include<cstdio>

int main(){
	int f[104730] = {1,1};
	int a[10001] = {};
	int n = 0,t = 1;
	for(int i = 2; i < 52365; i++){
		f[i * 2] = 1;
	}
	for(int i = 3; i <= 324; i += 2){
		for(int j = 3; j * i < 104730; j += 2){
			f[i*j] = 1;
		}
	}

	for(int i = 1; i < 10001; i++){
		while(t){
			n++;
			t = f[n];
		}
		a[i] = a[i-1] + n;
		t = 1;
	}
	
	scanf("%d", &n);
	while(n){
		printf("%d\n", a[n]);
		scanf("%d", &n);
	}	
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int>a(1,1),dp(n+5,inf);
  rep(i, 0, 6)a.push_back(pow(6,(i+1)));
  rep(i, 0, 5)a.push_back(pow(9,(i+1)));
  int m = a.size();
  dp[0]=0;
  rep(i, 0, n+1){
      rep(j, 0, m){
          if(i-a[j]<0)continue;
          chmin(dp[i],dp[i-a[j]]+1);
      }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  
  vector<int> l(Q),r(Q);
  
  for(int i=0;i<Q;i++){
    cin >> l.at(i) >> r.at(i);
  }
  
  vector<int> ans(N);
  
  for(int j=0;j<N-1;j++){
    if(S.at(j)=='A'&&S.at(j+1)=='C'){
      ans.at(j+1)=ans.at(j)+1;
      }else{
      ans.at(j+1)=ans.at(j);
    }
  }
  
  for(int k=0;k<Q;k++){
    cout << ans.at(r.at(k)-1)- ans.at(l.at(k)-1)<< endl;
  }
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



ll N,M;
ll A[100005];

//最大公約数
ll gcd(ll x,ll y){

	x = abs(x);
	y = abs(y);

	if(x < y){
		swap(x,y);
	}
	if(y == 0){
		return x;
	}else{
		return gcd(y,x%y);
	}
}

//最小公倍数
ll lcm(ll x,ll y){

	return (x*y)/gcd(x,y);
}

int main(){

	scanf("%lld %lld",&N,&M);

	for(ll i = 0; i < N; i++){

		scanf("%lld",&A[i]);
		A[i] /= 2;
	}


	int count = 0;

	while(A[0]%2 == 0){

		A[0] /= 2;
		count++;
	}

	for(int i = 1; i < N; i++){

		int tmp = 0;

		while(A[i]%2 == 0){
			A[i] /= 2;
			tmp++;
		}

		if(tmp != count){

			printf("0\n");
			return 0;
		}
	}

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

		M /= 2;
	}

	ll LCM = 1;
	for(int i = 0; i < N; i++){

		LCM = lcm(A[i],LCM);
	}

	ll ans = (M/LCM+1)/2;

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

	return 0;
}


Measured memory_bytes: 1024
import math
n=int(input())
nums=[int(input()) for i in range(n)]

count=0
for num in nums:
    flag=0
    # check 2
    if num == 2:
        count+=1
        continue

    #skip
    if num%2==0:
        continue
    
    for p in range(3, int(math.sqrt(num))+1, 2):
        if num%p==0:
            flag=1
            break
        
    if flag==0:
        count+=1
        
print(count)


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

int main() {
  string s;
  cin >> s;
  char A,T,G,C;
  
  int n = s.size(), sum = 0, a = 0;
  
  rep(i,n){
    if (s.at(i)=='A' || s.at(i)=='T' || s.at(i)=='G' || s.at(i)=='C'){
      sum ++;
      a=max(a,sum);
    }
    else {
      a=max(a,sum);
      sum = 0;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

int stone[50];

int main(){

  while(true){
    int n,p;
    cin >> n >> p;
    if(n==0 && p==0) break;

    rep(i,n) stone[i]=0;
    int bowl=p;
    int idx=0;
    while(true){
      if(stone[idx]+1==p) break;
     //??????????????????
      while(bowl>0){
	stone[idx]++;
	bowl--;
	idx = (idx+1)%n;
      }

      //?¬???????????????£????????????
      while(stone[idx]==0) idx=(idx+1)%n;

      //????????\??????
      bowl=stone[idx];
      stone[idx]=0;
      idx= (idx+1)%n;
    }

    cout << idx << endl;

  }
}

Measured memory_bytes: 1160
list = input()
#print(list[2])
#print(len(list))
cnt = 0
if list[0] == list[1] == list[2] and list[1] == "R":
  print(3)
elif list[0] == list[1] and list[1] == "R":
  print(2)
elif list[1] == list[2] and list[2] == "R":
  print(2)
elif list[1] == "R" or list[0] == "R" or list[2] == "R":
  print(1)
else:
    print(0)


Measured memory_bytes: 8940
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
//#include <boost/math/common_factor_rt.hpp>

#define ll long long
#define max 100000
using namespace std;
ll l = 1000000007;

ll n[3] = {};
int main()
{
	ll a = 0;
	ll b = 0;
	ll c = 0;
	ll d = 0;


	for (int i = 0; i < 4; i++)
	{
		cin >> n[i];
	}
	
	for (int i = 0; i < 4; i++)
	{
		if (n[i] == 1) {
			a++;
		}
		else if (n[i] == 9) {
			b++;
		}
		else if (n[i] == 7) {
			c++;
		}
		else if (n[i] == 4) {
			d++;
		}
	}

	if (a == 1 && b == 1 && c == 1 && d == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;

	}
}



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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    int n,k; cin >> n >> k;
    int ans = k;
    for(int i=0;i<n-1;i++){
        ans *= k-1;
    }
    cout << ans;
 
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int n;
vector<ld> p;
vector<vector<ld>> dp;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    p.assign(n, 0);
    dp.assign(n, vector<ld>(n + 1, 0));
    F0R(i, n) cin >> p[i];
    dp[0][0] = 1 - p[0];
    dp[0][1] = p[0];
    FOR(i, 1, n)
    {
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);
        FOR(j, 1, n + 1)
        {
            dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * (p[i]);
        }
    }
    ld res = 0;
    F0R(i, n + 1) if(i > n/2) res += dp[n - 1][i];
    cout << setprecision(10) << fixed;
    cout << res;
    return 0;
}

Measured memory_bytes: 141056
#include<iostream>
#include<vector>
using namespace std;
const int SIZE = 50000;
bool isprime[SIZE + 1];
vector<int> prime;
void make_prime(){
    for(int i = 2; i <= SIZE; i++){
        isprime[i] = true;
    }
    isprime[0] = false;
    isprime[1] = false;
    for(int i = 2; i <= SIZE; i++){
        if(isprime[i] == false) continue;
        for(int j = i * 2; j <= SIZE; j += i){
            isprime[j] = false;
        }
        prime.push_back(i);
    }
}

int main(){
    make_prime();
    int n;
    while(cin >>n){
        if(n == 0) break;
        int cnt = 0;
        for(int i = 0; i < prime.size(); i++){
            if(prime[i] > (n / 2)) break;
            if(isprime[n - prime[i]]){
                cnt++;
            }
        }
        cout <<cnt <<endl;
    }
    return 0;
}

Measured memory_bytes: 1008
//Link : https://codeforces.com/contest/1253

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200005
#define mod 1000000007
/*
#include <limits.h>
INT_MAX
LLONG_MAX
*/
int add(int x,int y) {
  return ((x+y)%mod+mod)%mod;
}
int mul(int x,int y) {
  return (ll)x*y%mod;
}
int mypow(int x,int c) {
  int ret = 1;
  while(c>0) {
    if(c&1) {
      ret = mul(ret,x);
    }
    x = mul(x,x);
    c/=2;
  }
  return ret;
}

int fac[N],invFac[N];

vector<int> adj[N];
int dp[N],subSize[N],out[N];

void dfs(int node,int par) {
  subSize[node] = 1;
  dp[node] = 1;
  for(int ch : adj[node]) {
    if(ch == par) {
      continue;
    }
    dfs(ch,node);
    subSize[node] += subSize[ch];

    dp[node] = mul(dp[node],mul(dp[ch], invFac[subSize[ch]]));
  }
  dp[node] = mul(dp[node], fac[subSize[node]-1]);
}

void dfs2(int node,int par,int n,int tmpDp) {
  int r = mul(dp[node],invFac[subSize[node]-1]);
  r = mul(r, mul(fac[n-1], mul(invFac[n-subSize[node]], tmpDp)));
  out[node] = r;
  for(int ch : adj[node]) {
    if(ch == par) {
      continue;
    }
    int nextDp = mul(out[node], invFac[n-1]);
    nextDp = mul(nextDp, fac[n-subSize[ch]-1]);
    nextDp = mul(nextDp, fac[subSize[ch]]);
    nextDp = mul(nextDp, mypow(dp[ch],mod-2));
    dfs2(ch,node,n,nextDp);
  }
}

void solve() {
  int n;
  scanf("%d ", &n);
  fac[0] = invFac[0] = 1;
  for(int i=1;i<=n;++i) {
    fac[i] = mul(fac[i-1],i);
    invFac[i] = mypow(fac[i],mod-2);
  }
  for(int i=0;i<n-1;++i) {
    int a,b;
    scanf("%d %d ", &a,&b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1,0);
  dfs2(1,0,n,1);
  for(int i=1;i<=n;++i) {
    printf("%d\n", out[i]);
  }
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


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

using namespace std;

int main() {
    long long cap = 100LL;
    long long x;
    cin >> x;
    int t = 0;
    while (x > cap) {
        ++t;
        cap += cap / 100;
    }
    cout << t << "\n";
    return 0;
}


Measured memory_bytes: 3636
#include<cmath>    
#include<queue>    
#include<vector>    
#include<cstdio>    
#include<ctime>   
#include<cstring>    
#include<iostream>    
#include<algorithm>    
#define INF 0x3f3f3f3f
#define MAXN 100000
using namespace std;
int read()
{
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
int a[4],flag,v[4]={0,500,100,50},ans;
void DFS(int x,int sum){
	if(x!=4&&sum>flag) return ;
	if(x==4)
	{
		if(sum==flag)
			ans++;
		return ;	
	}
	for(int i=0;i<=a[x];i++)
		DFS(x+1,sum+i*v[x]);
	return ;
}
int main() 
{
	a[1]=read(),a[2]=read(),a[3]=read();
	flag=read();
	DFS(1,0);
	printf("%d\n",ans);
    return 0; 
} 


Measured memory_bytes: 256
def dfs(A,B):
    if len("".join(A))>10:
        return
    if int(A[-1]) == 0:
        for i in [0,1]:
            A.append(str(i))
            B.append("".join(A))
            dfs(A, B)
            A.pop()
    elif int(A[-1]) == 9:
        for i in [8,9]:
            A.append(str(i))
            B.append("".join(A))
            dfs(A, B)
            A.pop()
    else:
        for i in range(int(A[-1])-1,int(A[-1])+2):
            A.append(str(i))
            B.append("".join(A))
            dfs(A,B)
            A.pop()

if __name__ == "__main__":
    k=int(input())
    ans_list=[]
    num_list=[]
    for i in range(1,10):
        ans_list.append(str(i))
        num_list.append(str(i))
        dfs(num_list,ans_list)
        num_list.clear()
    ans_list=sorted(ans_list,key=int)
    print(ans_list[k-1])



Measured memory_bytes: 73948
a, b = map(int, input().split())
ans1 = a + b
ans2 = a - b
ans3 = a * b
if ans1 >= ans2 and ans1 >= ans3:
  print(ans1)
  exit()
if ans2 >= ans1 and ans2 >= ans3:
  print(ans2)
  exit()
if ans3 >= ans1 and ans3 >= ans2:
  print(ans3)
  exit()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int dp[100005][3];
int solve(){
    cin>>n;
    int a[n+1],b[n+1],c[n+1];
    rep(i,1,n) cin>>a[i]>>b[i]>>c[i];
    dp[1][0]=a[1]; dp[1][1]=b[1]; dp[1][2]=c[1];
    rep(i,2,n){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]});
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define pb       push_back
#define mp       make_pair
#define mod      1000000007
#define first    ff
#define second   ss
#define pi       acos(-1.0)
#define bg       begin()
#define end       end()
#define test     int t;cin>>t;while(t--)
typedef long long ll;
using namespace std;
vector<int>v;
int main()
{      


     ios::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
     int n;
     
     cin>>n;
     string s;
     cin>>s;
     if(n%2)
     {
        cout<<"No"<<endl;
        return 0;
     }
     for(int i=0,j=n/2;i<n/2,j<n;i++,j++)
     {
        if(s[i]!=s[j])
        {
            cout<<"No"<<endl;
            return 0;
        }
     }
     cout<<"Yes"<<endl;
      
     
     
    

      return 0;
    
 }   

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const int MAX_XY = 100;
const int MAX_N = 100;

int main() {
  int N;
  ll x[MAX_N], y[MAX_N], h[MAX_N];
  std::cin >> N;
  ll x_default, y_default, h_default;
  rep(i, N) {
    std::cin >> x[i] >> y[i] >> h[i];
    if(h[i] > 0) {
      x_default = x[i];
      y_default = y[i];
      h_default = h[i];
    }
  }

  rep(Cx, MAX_XY + 1) {
    rep(Cy, MAX_XY + 1) {
      ll H = h_default + std::abs(x_default - Cx) + std::abs(y_default - Cy);
      bool is_ok = true;
      rep(i, N) {
        if(h[i] != std::max(0LL, H - std::abs(x[i] - Cx) - std::abs(y[i] - Cy))) {
          is_ok = false;
          break;
        }
      }
      if(is_ok) {
        std::cout << Cx << ' ' << Cy << ' ' << H << '\n';
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256