akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    for(i=0;i<500;i++){
        if(i%2==0){
            c-=b;
            if(c<=0){
                cout << "Yes" << endl;
                return 0;
            }
        }else{
            a-=d;
            if(a<=0){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main() {
  int A1, A2, A3;
  scanf("%d %d %d", &A1,&A2,&A3);
  if (A1+A2+A3 >= 22) {
    printf("bust\n");
  } else {
    printf("win\n");
  }
  return 0;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, A, B;
    cin >> N >> A >> B;
    int a, b, c;
    a = b = c = 0;
    for (int i = 0; i < N; i++) {
        int P;
        cin >> P;
        if (P <= A) {
            a++;
        }
        else if (P <= B) {
            b++;
        }
        else {
            c++;
        }
    }
    cout << min({a, b, c}) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
signed main() {
	int n, a, sum = 1000000000000000, ans = -1000000000000000; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> a;
		ans = max(ans, a - sum);
		sum = min(sum, a);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3132
package main

import (
	"fmt"
)

func main() {
	var n string
	fmt.Scan(&n)

	a := ""
	for _, r := range n {
		t := string(r)
		if t == "1" {
			t = "9"
		} else if t == "9" {
			t = "1"
		}
		a += t
	}
	fmt.Println(a)
}


Measured memory_bytes: 512
def main():
    N, M = map(int, input().split())
    food_list = [set(map(int, input().split()[1:])) for _ in range(N)]

    ans = food_list[0]
    for idx in range(len(food_list) - 1):
        ans = ans & food_list[idx + 1]
    print(len(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
int N,M;
void func()
{
    string S;
    cin>>S;
    if(S[2]==S[3]&&S[4]==S[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
int main()
{
func();
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	static int n;
	static int[] x, y;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		x = new int[n];
		y = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		sc.close();

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

	static double ternarySearch() {
		double gosa = 1e-8;
		double l = 0;
		double r = 1000;
		while (r - l > gosa) {
			double m1 = (l * 2 + r) / 3;
			double m2 = (l + r * 2) / 3;
			double v1 = ternarySearch(m1);
			double v2 = ternarySearch(m2);
			if (v1 <= v2) {
				r = m2;
			} else {
				l = m1;
			}
		}
		return ternarySearch(r);
	}

	static double ternarySearch(double cx) {
		double gosa = 1e-8;
		double l = 0;
		double r = 1000;
		while (r - l > gosa) {
			double m1 = (l * 2 + r) / 3;
			double m2 = (l + r * 2) / 3;
			double v1 = calc(cx, m1);
			double v2 = calc(cx, m2);
			if (v1 <= v2) {
				r = m2;
			} else {
				l = m1;
			}
		}
		return calc(cx, r);
	}

	static double calc(double cx, double cy) {
		double ret = 0;
		for (int i = 0; i < n; i++) {
			double r = Math.hypot(x[i] - cx, y[i] - cy);
			ret = Math.max(ret, r);
		}
		return ret;
	}
}


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

using namespace std;


int main(){
    long long x;
    cin >> x;
    long long base = 100;
    int count = 0;
    while (base < x){
        count++;
        base += base /100;
    }
    cout << count << endl;
}




Measured memory_bytes: 3608
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    ans = 0
    nf = int(str(n)[0])
    ne = int(str(n)[-1])
    lenn = len(str(n))
    dp = [[0] * 10 for i in range(10)]
    for i in range(1, n + 1):
        f = int(str(i)[0])
        e = int(str(i)[-1])
        dp[f][e] += 1
    ans = 0
    for i in range(1, n + 1):
        f = int(str(i)[0])
        e = int(str(i)[-1])
        ans += dp[e][f]

    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 41068
import java.util.*;

import java.lang.Object;





public class Main{	

	public static void main(String[] args) {

		int i,flag,temp;

		char c;

		Deque<Integer> stack = new ArrayDeque<Integer>();

		Scanner sc = new Scanner(System.in);

		String str = sc.nextLine();



		flag = 0; temp = 0;

		for(i=0;i<str.length();i++){

			c = str.charAt(i);

			if(c>='0'&&c<='9'){

				if(flag==0){

					stack.push(c-'0');

				}else{

					stack.push(10*stack.pop()+c-'0');

				}

				flag = 1;

			}

			else if(c=='+'){

				stack.push(stack.pop()+stack.pop());

			}

			else if(c=='-'){

				stack.push(-stack.pop()+stack.pop());

			}

			else if(c=='*'){

				stack.push(stack.pop()*stack.pop());

			}

			else{

				flag = 0;

			}

		}

		System.out.println(stack.pop());

	}

}

Measured memory_bytes: 26200
#include <bits/stdc++.h>
#define ll long long int
#define c(a) ll a; cin>>a;
#define cs(a) string a; cin>>a;
#define ci(a) cin>>a;
#define co(a) cout<<a;
#define nl cout<<endl;
#define ca(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
#define f0(i,a,n) for(ll i=a;i>=n;i--)
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,a,n) for(ll i=a;i<n;i++)
#define T ll t=1; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main()
{
    fast;
    c(n) c(a) c(b)
    ll arr[n];
    ca(arr,n)
    ll a1=0,b2=0,c3=0;
    f(i,n)
    {
        if(arr[i]<=a) a1++;
        if(arr[i]>=(a+1) && arr[i]<=b) b2++;
        if(arr[i]>=(b+1)) c3++;
    }
    cout<<min(min(a1,b2),min(b2,c3))<<endl;
    return 0;
}

/*It's not who I am underneath, but what I do that defines me

MMMMMMMMMMMMMMMMMMMMM.                             MMMMMMMMMMMMMMMMMMMMM
 `MMMMMMMMMMMMMMMMMMMM           M\  /M           MMMMMMMMMMMMMMMMMMMM'
   `MMMMMMMMMMMMMMMMMMM          MMMMMM          MMMMMMMMMMMMMMMMMMM'
     MMMMMMMMMMMMMMMMMMM-_______MMMMMMMM_______-MMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
     .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
                   `MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'
                          `MMMMMMMMMMMMMMMMMM'
                              `MMMMMMMMMM'
                                 MMMMMM 
                                  MMMM
                                   MM
*/


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

signed main(){
    int N;cin>>N;
    vint A(N);
    rep(i,N)cin>>A[i];
    sort(all(A));
    reverse(all(A));

    int ans=0;
    rep(i,N){
        if(i&1)ans-=A[i];
        else ans+=A[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let t: String = read(&mut stdin_lock, &mut buf, b'\n');
    let sc: Vec<char> = s.chars().collect();
    let tc: Vec<char> = t.chars().collect();
    let mut tbl = vec![vec![0; tc.len() + 1]; sc.len() + 1];
    for i in 0..sc.len() {
        for j in 0..tc.len() {
            tbl[i + 1][j + 1] = max(
                tbl[i][j + 1],
                max(
                    tbl[i + 1][j],
                    tbl[i][j] + if sc[i] == tc[j] { 1 } else { 0 },
                ),
            );
        }
    }
    let mut ac: Vec<char> = Vec::new();
    let mut i: usize = sc.len();
    let mut j: usize = tc.len();
    while i > 0 && j > 0 {
        if tbl[i][j] == tbl[i - 1][j] {
            i -= 1;
        } else if tbl[i][j] == tbl[i][j - 1] {
            j -= 1;
        } else {
            ac.push(sc[i - 1]);
            i -= 1;
            j -= 1;
        }
    }
    println!("{}", ac.into_iter().rev().collect::<String>());
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
    ll A,B,N;
    cin>>A>>B>>N;
    ll x;
    if(N<B) x=N;
    else x=B-1;
    ll ans=(A*(x%B)-(A*x)%B)/B;
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 3504
import math

N = int(input())
A = list(map(int, input().split()))

# num is numerator
# den is denominator
num, den = A[0], 0

for i in A:
    num = (num * i) // math.gcd(num, i)

for i in A:
    den += num // i

ans = num / den
print(ans)


Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n, ans=0, cnt=0;
  char cmd;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> cmd;
        if(cmd=='I') cnt += 1;
        else if(cmd=='D') cnt -= 1;
        ans = max(cnt, ans);
    }
    cout << ans << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int64_t> H(N);
  for(int i=0;i<N;i++)
    cin >> H.at(i);
  sort(H.begin(),H.end());
  int64_t s=0;
  for(int i=0;i<N-K;i++)
    s += H.at(i);
  cout << s << endl;
}

Measured memory_bytes: 1792
A,B,K=map(int,input().split())
if B==A:
    print(A)
    exit()
K=min(K,B-A)
ans=set()
for i in range(K):
    ans.add(A+i)
    ans.add(B-i)
ans=list(ans)
ans=sorted(ans)
for i in ans:
    print(i)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
const int MAX=20;
char maze[MAX][MAX];
typedef pair<int,int> P;
int d[MAX][MAX];
int H,W;
int sx,sy;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ans=0;

void bfs(int sx,int sy){
    int ret=0;
    if(maze[sx][sy]=='#')return;
    queue<P>q;
    REP(i,H)REP(j,W)d[i][j]=INF;
    d[sx][sy]=0;
    q.push(P(sx,sy));
    while(!q.empty()){
        P p=q.front();q.pop();
        REP(i,4){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(nx>=0&&nx<H&&ny>=0&&ny<W&&maze[nx][ny]!='#'&&d[nx][ny]==INF){
                q.push(P(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
    REP(i,H){
        REP(j,W)if(d[i][j]!=INF)ans=max(ans,d[i][j]);
    }
}

signed main(){
    cin>>H>>W;
    REP(i,H)REP(j,W)cin>>maze[i][j];
    REP(i,H)REP(j,W)bfs(i,j);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - (h - 1)) * (n - (w - 1)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
int check[100010];
std::vector<int> V[100010];
void func(int k, int C)
{
	check[k] = C;
	for(int i=0;i<V[k].size();i++) if(check[V[k][i]]==0) func(V[k][i],C);
}
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=b;i++)
	{
		int c,d;
		scanf("%d%d",&c,&d);
		V[c].push_back(d);
		V[d].push_back(c);
	}
	
	int C = 1;
	for(int i=1;i<=a;i++)
	{
		if(check[i]==0)
		{
			func(i,C++);
		}
	}
	printf("%d\n",C-2);
}

Measured memory_bytes: 10012
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
    int n, k; cin >> n >> k;
    int cnt = 0;
    rep(i, n){
        int a; cin >> a;
        if(a>=k)cnt++;
    }
    cout << cnt << ln;
}


Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  ll X;
  cin >> X;
  ll P = 100, ans = 0;
  while(P < X){
    P += P / 100;
    ans++;
  }
  cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define LL long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define MOD(x) ((x)%mod)
#define mod 1000000007
#define pb push_back
#define STREAM_FAST ios::sync_with_stdio(false)

using namespace std;

int main()
{
    LL h,w;scanf("%lld%lld",&h,&w);
    LL ans=1e18;
    LL s1,s2,s3;
    LL tmp=h/3;if (h%3==2) tmp++;ans=min(ans,abs(3*tmp-h)*w);

    s1=tmp*w;s2=(h-tmp)*(w/2);s3=(h-tmp)*(w-w/2);
    ans=min(ans,max(s1,max(s2,s3))-min(s1,min(s2,s3)));

    tmp=w/3;if (w%3==2) tmp++;ans=min(ans,h*abs(3*tmp-w));


    s1=tmp*h;s2=(w-tmp)*(h/2);s3=(w-tmp)*(h-h/2);
    ans=min(ans,max(s1,max(s2,s3))-min(s1,min(s2,s3)));
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define BUFLEN 1000

void ord_print(char *str, int start, int end) {
    int i;

    for (i = start; i <= end; i++) {
        printf("%c", *(str + i));
    }
    printf("\n");
}

void ord_reverse(char *str, int start, int end) {
    int i;
    char tmp[BUFLEN];

    for (i = 0; i < end - start + 1; i++) tmp[i] = *(str + end - i);
    for (i = 0; i < end - start + 1; i++) *(str + start + i) = tmp[i];

}

void ord_replace(char *str, int start, int end, char *p) {
    int i;

    for (i = 0; i < end - start + 1; i++) *(str + start + i) = *(p + i);
}

int main(void) {
    int q, i, start, end;
    char str[BUFLEN], ord[BUFLEN], p[BUFLEN];

    scanf("%s", str);
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%s", ord);
        if (strcmp(ord, "print") == 0) {
            scanf("%d %d", &start, &end);
            ord_print(str, start, end);
        } else if (strcmp(ord, "reverse") == 0) {
            scanf("%d %d", &start, &end);
            ord_reverse(str, start, end);
        } else if (strcmp(ord, "replace") == 0) {
            scanf("%d %d %s", &start, &end, p);
            ord_replace(str, start, end, p);
        }
    }

    return 0;
}

Measured memory_bytes: 576
/*Its-Rashid*/
#include <bits/stdc++.h>
using namespace std;

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()
{
    ll n , b , m ;
    cin >> n >> b ;
    m = max(n , b) ;
    if (16 / m >= 2)
        cout << "Yay!";
    else
        cout << ":(" ;

}


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

int main() {
  int N;
  cin >> N;
  
  if(N==100000){
    cout << 90909 << endl;
  }
  else if(N>=10000 && N<100000){
    cout << 909 + N-9999 << endl;
  }
  else if(N>=1000 && N<10000){
    cout << 909 << endl;
  }
  else if(N>=100 && N<1000){
    cout << 9 + N-99 << endl;
  }
  else if(N>=10 && N<100){
    cout << 9 << endl;
  }
  else{
    cout << N << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll calc(ll x, ll y, ll z){
    ll res1 = 0, res2 = 0;
    res1 = x/2*2 + y/2*2 + z/2*2;
    if (x > 0 && y > 0 && z > 0){
        res2 = 3;
        x--;
        y--;
        z--;
    }
    res2 += x/2*2 + y/2*2 + z/2*2;
    return max(res1, res2);
}

int main() {
    int n = 7;
    VL a(n);
    REP(i,n) cin >> a[i];
    ll ans = a[1];
    ans += calc(a[0], a[3], a[4]);
    cout << ans << endl;

    return 0;
}

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

int main() {
	int a[31] = { 0 };
	for (int i = 1; i <= 30; i++) {
		int n;
		cin >> n;
		a[n] = 1;
	}
	for (int i = 1; i <= 30; i++) {
		if (a[i] == 0) cout << i << endl;
	}
	return 0;
}

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

inp = list(map(int, input().split()))
D = int(inp[0])
X = int(inp[1])

A = []
for i in range(N):
  A.append(int(input()))

ans = X

for i in range(D):
  j = 0
  while (j <= N - 1):
    # 1日目
    if i == 0:
      ans += 1
    else:
      # 2日目以降
      if i * A[j] + 1 <= D:
        ans += 1
        
    j += 1

print (ans)








Measured memory_bytes: 3064
#include <iostream>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>

using namespace std;

int main(void)
{

    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    long long max = -9999999999;
    int n,i;
    int f[101][11];
    long long p[101][11];
    cin >> n;
    for (i = 1; i <= n;i++)
    {
        int j;
        for (j = 1; j <= 10; j++)
        cin >> f[i][j];
    }
    for (i = 1; i <= n;i++)
    {
        int j;
        for (j = 0; j <= 10; j++)
        cin >> p[i][j];
    }
    for (int i1 = 0; i1 <= 1; i1 ++)
    for (int i2 = 0; i2 <= 1; i2 ++)
    for (int i3 = 0; i3 <= 1; i3 ++)
    for (int i4 = 0; i4 <= 1; i4 ++)
    for (int i5 = 0; i5 <= 1; i5 ++)
    for (int i6 = 0; i6 <= 1; i6 ++)
    for (int i7 = 0; i7 <= 1; i7 ++)
    for (int i8 = 0; i8 <= 1; i8 ++)
    for (int i9 = 0; i9 <= 1; i9 ++)
    for (int i10 = 0; i10 <= 1; i10 ++)
    if ((i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 + i10) != 0)
    {
        int j;
        long long date[101];
        long long answ = 0;
        memset(date,0,sizeof date);
        for (j = 1; j <= n; j++)
        {
            if ((f[j][1] == i1) && (i1 == 1))
            date[j]++;
        }
        for (j = 1; j <= n; j++)
        {
            if ((f[j][2] == i2) && (i2 == 1))
            date[j]++;
        }
        for (j = 1; j <= n; j++)
        {
            if ((f[j][3] == i3) && (i3 == 1))
            date[j]++;
        }
        for (j = 1; j <= n; j++)
        {
            if ((f[j][4] == i4) && (i4 == 1))
            date[j]++;
        }
        for (j = 1; j <= n; j++)
        {
            if ((f[j][5] == i5) && (i5 == 1))
            date[j]++;
        }
        for (j = 1; j <= n; j++)
        {
            if ((f[j][6] == i6) && (i6 == 1))
            date[j]++;
        }for (j = 1; j <= n; j++)
        {
            if ((f[j][7] == i7) && (i7 == 1))
            date[j]++;
        }
        for (j = 1; j <= n; j++)
        {
            if ((f[j][8] == i8) && (i8 == 1))
            date[j]++;
        }
        for (j = 1; j <= n; j++)
        {
            if ((f[j][9] == i9) && (i9 == 1))
            date[j]++;
        }
        for (j = 1; j <= n; j++)
        {
            if ((f[j][10] == i10) && (i10 == 1))
            date[j]++;
        }
        for (j = 1; j <= n; j++)
        {
            answ = answ + p[j][date[j]];
        }
        if (answ > max)
        max = answ;
    }
    cout << max;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b) cout<<c<<endl;
    else if(b==c) cout<<a<<endl;
    else cout<<b<<endl;
}


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

using namespace std;

#define INF 210000000
#define int long long

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

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

bool cmp(int a,int b){
		return a > b;
}

signed main() {
		float n,t,a;
		cin >> n >> t >> a;
		vector<float> h;
		for(int i=0;i<n;i++){
				float tmp;
				cin >> tmp;
				h.push_back(abs(a - (t - tmp * 0.006)));
		}
		float x = INF;
		float ans;
		for(int i=0;i<n;i++){
				if(h[i] < x){
						ans = i + 1;
						x = h[i];
				}
		}
		cout << ans;
}


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

int main(){
  int N;
  cin >> N;
  vector<tuple<string, int, int>> a(N);
  string c;
  int p;
  
  for (int i=0; i<N; i++){
    cin >> c >> p;
    a.at(i) = make_tuple(c, -p, i+1);
  }
  sort(a.begin(), a.end());
  
  for (int i=0; i<N; i++){
    cout << get<2>(a.at(i)) << endl;
  }
}

Measured memory_bytes: 3572
N = int(input())
aa = list(map(int, input().split()))
bb = map(int, input().split())
cc = list(map(int, input().split()))

s = sum(bb)
for i in range(N-1):
  if aa[i+1] - aa[i] == 1:
    s += cc[aa[i]-1]
print(s)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <string>
#include <map>
#include <set>
#include <tuple>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<double> A(N);
  for (auto& ai: A) scanf("%lf", &ai);

  double res = 0;
  for (auto ai: A) res += 1.0 / ai;
  res = 1.0 / res;
  printf("%.12f\n", res);
}


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 T = sc.nextInt();
		int A = sc.nextInt();
		int[] H = new int[N];
		for(int i = 0;i < N;++i)
			H[i] = sc.nextInt();
		sc.close();
		
		int ans = 0;
		double ansDiff = Math.abs(A - (T - 0.006 * H[0]));
		for(int i = 1;i < N;++i) {
			double cap = Math.abs(A - (T - 0.006 * H[i]));
			if(cap < ansDiff) {
				ansDiff = cap;
				ans = i;
			}
		}
		
		System.out.println((ans+1));
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <fstream>
#include <map>
#include <cstring>

using namespace std;


char ap[1000001];

int main(){

	int x,y;
	while(cin>>x>>y&&(x|y)){
		memset(ap,-1,sizeof(ap));
		int a,b;
		a=0;
		b=0;
		x*=10;
		int sz=0;
		ap[x/10]=sz++;
		while(1){
			if(x<y)x*=10;
			else{
				x=x%y;
				x*=10;
			}
			if(x==0){
				cout<<sz<<" "<<0<<endl;
				break;
			}
			if(ap[x/10]==-1)ap[x/10]=sz++;
			else{
				int i=ap[x/10];
				int band=sz-i;
				a=i;
				b=band;
				cout<<a<<" "<<b<<endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#define int long long
using namespace std;
int s,c;
signed main()
{
	scanf("%lld%lld",&s,&c);
	if(c<=s*2)
		printf("%lld\n",min(c/2,s));
	else
		printf("%lld\n",s+(c-s*2)/4);
	return 0;
}

Measured memory_bytes: 256
#import numpy as np
N = int(input())
S = input()

left, right = ([0] * 2)

for kakko in S:
    if kakko is "(":
        left += 1
    elif kakko is ")":
        if left is not 0:
            left -= 1
        else:
            right += 1

print("("*right+S+")"*left)


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x >= y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x <= y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  string s;
  cin >> s;
  if (s.size() < 4) no();
  if (s.substr(0, 4) == "YAKI") yes(); no();
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
    char w[128], n[26] = {0};
    int i;
    fgets(w, sizeof(w), stdin);

    for ( i = 0; w[i] != '\n'; i++ ){
        n[ w[i] - 'a' ]++;
    }
    for ( i = 0; i < 26; i++ ){
        if ( n[i]%2 != 0 ){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

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

int main(){
    bool check[5]={};
    char ch;
    int num;
    cin >> num;
    for(int i=0;i<num;i++){
        cin >> ch;
        if(ch=='P')check[0]=true;
        else if(ch=='W')check[1]=true;
        else if(ch=='G')check[2]=true;
        else if(ch=='Y')check[3]=true;
    }

    int ans=0;
    for(int i=0;i<4;i++){
        if(check[i]==true)ans++;
    }
    if(ans==3)cout << "Three" << endl;
    else if(ans==4)cout << "Four" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void)
{
	int n, m, c;
	int b[210];
	int a;

	cin >> n >> m >> c;

	for (int i = 1; i <= m; i++) {
		cin >> b[i];
	}

	int row_sum = 0;
	int count = 0;
	for (int i = 1; i <= n; i++) {
		row_sum = 0;
		for (int j = 1; j <= m; j++) {
			cin >> a;
			row_sum += b[j] * a;
		}
		if ((row_sum + c) > 0) {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a<=b*2){
      System.out.println(0);
    }else{
      System.out.println(a-b*2);
    }
  }
}


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

int main(){
	while(true){
	int h,w;
	cin>>h>>w;
		
	if(h==0&&w==0)
		break;

	int d=h*h+w*w;
	
	int H=150;
	int W=150;
	int D=150*150+150*150;

	for(int y=1;y<=150;y++){
		for(int x=y+1;x<=150;x++){
			int z=y*y+x*x;
			if(z<=d){
				continue;
			}else{
				if(z<D){
					H=y;
					W=x;
					D=z;
				}
				break;
			}
		}
	}

	for(int y=h+1;y<=150;y++){
		bool flg = false;
		for(int x=y+1;x<=150;x++){
			int z=y*y+x*x;
			if(z==d){
				H=y;
				W=x;
				D=z;
				flg=true;
			}
			if(z>=d)
				break;
		}
		if(flg)
			break;
	}
	cout<<H<<' '<<W<<endl;
}
return 0;
}



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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000007LL
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(i=a;i<=b;i++)

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

ll mypow(ll a, ll b) { if(b == 0) return 1; ll temp=mypow(a,b/2); temp=(temp*temp)%INF; if(b%2 == 1) temp=(a*temp)%INF; return temp; }
int mygcd(int a, int b) { if(b==0) return a; return mygcd(b,a%b); }
int cntBits(ll a) { int ret=0; while(a>0) { ret++; a/=2; } return ret; }

ll w[102],v[102];
ll ans[102][100010];


int main()
{
	ios::sync_with_stdio(0);
	int tt=1,tcase; 
	//cin >> tt;
	rep(tcase,1,tt)
	{
		ll n,W,a=0; cin >> n >> W;
		for(int i=1;i<=n;i++) cin >> w[i] >> v[i];
		for(int i=0;i<=n;i++) for(int j=1;j<100010;j++) ans[i][j]=1e18;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<100010;j++)
			{
				if(v[i]<=j) ans[i][j]=min(ans[i-1][j], ans[i-1][j-v[i]]+w[i]);
				else ans[i][j]=ans[i-1][j];
				if(ans[i][j]<=W) a=max(a,(ll)(j));
			}
		}
		cout << a << "\n";
	}
	return 0;
}


Measured memory_bytes: 79232
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<unordered_set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include <cstring>
#include <climits>
using namespace std;
#define rep(i,n) for(int (i)=0;(i) < (n); (i)++)
#define FIND(v, k) find((v).begin(), (v).end(), k)
#define MAX 101
#define MAX_V 15
#define mset(a,x) memset(a,x,sizeof(a))

int main() {
	int x;
	cin >> x;
	if (x < 1200) {
		cout << "ABC";
	}
	else {
		cout << "ARC";


	}
	cout << endl;
	return 0;
}

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

int main() {
  string s;
  cin >> s;

  int count = 0;
  for (int i = 0; i < 4; i ++) {
    if (s.at(i) == '+') {
      count ++;
    } else {
      count --;
    }
  }

  cout << count << endl;
}


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

int q(int a){
  if(a==2){
    return 3;
  }
  if(a<8 && a%2==1){
    return 1;
  }
  if(a>7 && a%2==0){
    return 1;
  }
  return 2;
}

int main() {
  int a,b;
  cin>>a>>b;
  if(a+b<10){
    cout<<a+b<<endl;
  }
  else{
    cout<<"error"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main( void ) {
	int n;

	scanf( "%d ", &n );
	while ( n-- ) {
		char str[ 1001 ], *ptr = str;

		gets( str );
		while ( ( ptr = strstr( ptr, "Hoshino" ) ) != NULL )
			memcpy( ptr, "Hoshina", 7 );

		puts( str );
	}

	return 0;
}

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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    string s; cin>>s;
    if(regex_match(s, regex("A?KIHA?BA?RA?")))puts("YES");
    else puts("NO");

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
lacks = []
%w(S H C D).each do |suite|
    (1..13).each do |num|
        lacks << [suite,num]
    end
end

n.times do
    suite,num = gets.split(' ')
    lacks.delete([suite,num.to_i])
end

lacks.each do |ary|
    puts ary.join(' ')
end
 


Measured memory_bytes: 6872
#include<iostream>
using namespace std;
  
int main() {
  int n, k ,r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  
  // total score
  int score = 0;
  
  for(int i=0; i<k; i++){
    char hand = t.at(i);
    char bef = 'o'; //other
    for(int j=0; i+j*k<n; j++){
      char hand = t.at(i+j*k);
      // 筐体がグーでk個前の手がパーでない
      if(hand=='r' && bef!='p'){
        score += p;
        bef = 'p';
      }
      // 筐体がチョキでk個前がグーでない
      else if(hand=='s' && bef!='r'){
        score += r;
        bef = 'r';
      }
      // 筐体がパーでk個前がチョキでない
      else if(hand=='p' && bef!='s'){
        score += s;
        bef = 's';
      }
      else{
        // 勝てないのであいこか負け，k個先でかぶらないように選ぶ
        bef = 'o';
      }
    }
  }
  
  cout << score << endl;
      
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int[] a = new int[n];
            int idx1 = -1;
            for (int i = 0; i < n; i++) {
                a[i] = sc.nextInt();
                if ( a[i] == 1 ) {
                    idx1 = i;
                }
            }

            int ans = 0;
            for (int i = 0; i < n; i++) {
                ans++;
                for (int j = 0; j < k; j++)
                    i++;
                i--;
                if ( i >= n - 1 ) {
                    break;
                } else {
                    i--;
                }
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 50552
#include <iostream>
#include <string>
#include <set>

using namespace std;

set <string> old;

int main() {

  int n, ans = 0;
  string str;
  cin >> n;
  for(int i = 1;i <= n;i++){
    cin >> str;
    ans++;
    if(old.find(str) != old.end()){
      ans--;
    }else{
      old.insert(str);
    }
  }
  cout << ans;
  return 0;
}


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

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

int n,m,s[52][52];
char c[52][52];

int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>m;
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
			cin>>c[i][j];
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
			if(c[i][j]=='.')  for(register int k=0;k<8;k++)
				if(c[i+dx[k]][j+dy[k]]=='#')  s[i][j]++;
	for(register int i=1;i<=n;cout<<endl,i++)
		for(register int j=1;j<=m;j++)
			if(c[i][j]=='#')  cout<<"#";
			else  cout<<s[i][j];
	return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int> H(N);
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    int max = H[0];
    int cnt = 0;
    for(int i=0;i<N;i++){
        if(max<=H[i]){
            cnt++;
        }
        if(max<H[i]){
            max = H[i];
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;
using Int = long long;
#define REP(i, n) for (int i = 0; i < n; i++)
char upper(char c) { return c + ('A' - 'a'); }
int main()
{
    string a, b; cin >> a >> b;
    int n = max(a.size(), b.size());
    a = string(n - a.size(), '0') + a;
    b = string(n - b.size(), '0') + b;
    if (a > b) cout << "GREATER" << endl;
    else if (a < b) cout << "LESS" << endl;
    else cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 100000000
int main(){

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        int in; cin >> in;
        in--;
        a[in] = i;
    }
    a.push_back(-1);
    int ans = 1;
    int tmp = 1;
    for(int i = 0; i < n; i++){
        if(a[i] < a[i + 1]){
            tmp++;
        }else{
            ans = max(ans, tmp);
            tmp = 1;
        }
    }
    cout << n - ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<pair<long int,pair<int,int>>> xyhs(N);
  for(int i=0;i<N;i++){
    int x,y,h;
    cin>>x>>y>>h;
    pair<int,int> xy(x,y);
    pair<long int, pair<int,int>> h_xy(h, xy);
    xyhs.at(i)=h_xy;
  }
  sort(xyhs.begin(),xyhs.end());
  reverse(xyhs.begin(),xyhs.end());
  for(int cx=0;cx<=100;cx++){
    for(int cy=0;cy<=100;cy++){
      long int prev_H=-1;
      for(int i=0;i<N;i++){
        long long int h=xyhs.at(i).first;
        if(h==0&&prev_H!=-1){
          long int zero_H=prev_H-abs(xyhs.at(i).second.first-cx)-abs(xyhs.at(i).second.second-cy);
          if(zero_H>0){break;}
          else if(i==N-1){cout<<cx<<' '<<cy<<' '<<prev_H<<endl;return 0;}
        }else{
          long long int H=h+abs(xyhs.at(i).second.first-cx)+abs(xyhs.at(i).second.second-cy);
          if(prev_H==-1){prev_H=H;}
          else if(prev_H!=H){break;}
          else if(i==N-1){cout<<cx<<' '<<cy<<' '<<H<<endl;return 0;}
        }
      }
    }
  }
}

Measured memory_bytes: 256
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
const int N = 1e5+2;
const int mod = 1e9+7;
ld dp[3000][3000];
int n;
ld p[3000];
ld solve(int idx,int rem)
{
    if(idx == n+1)
    {
        if(rem == 0)
            return (ld)1;
        else return (ld)0;
    }
    if(dp[idx][rem]!=(ld)-1)
        return dp[idx][rem];
    ld ans = 0;
    ans = ans+((ld)1-p[idx])*(solve(idx+1,rem));
    if(rem>0)
    ans = ans+(p[idx]*solve(idx+1,rem-1));
    dp[idx][rem] = ans;
    return ans;
}
signed main()
{
    fast;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    for(int i=1;i<3000;i++)
    {
        for(int j=0;j<3000;j++)
            dp[i][j] = -1;
    }
    ld ans = 0;
    for(int k=(n/2)+1;k<=n;k++)
    {
         ans=ans+solve(1,k);
    }
    cout<<fixed<<setprecision(12)<<ans;
}

Measured memory_bytes: 141184
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<pi> vpi;

#define debugone(x) cout << #x << " " << x << endl;
#define debugtwo(x) cout << #x << "-------------" << endl;for(auto &it: x) cout << it << " ";cout << endl;
#define debugthree(x, i, j) cout << #x << "------------" << endl;cout << "from " << i << " to " << j << endl;for(int k=i; k<=j; k++) cout << x[k] << " ";cout << endl;

const int mod = (int)1e9 + 7;

bool bulbSwitch[11][11];

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int k;
		cin >> k;
		for(int j = 0; j < k; j++){
			int swi;
			cin >> swi;
			bulbSwitch[i][swi] = true;
		}
	}

	int p[m];

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

	int ans = 0;
	for(int i = 0; i < (1 << n); i++){
		vector<int> cnt(m);
		for(int swi = 1; swi <= n; swi++){
			for(int bulb = 0; bulb < m; bulb++){
				if(bulbSwitch[bulb][swi] && (i & (1 << (swi - 1)))){
					cnt[bulb]++;
				}
			}
		}
		bool allOn = true;
		for(int bulb = 0; bulb < m; bulb++){
			if(cnt[bulb]%2 != p[bulb]){
				allOn = false;
				break;
			}
		}

		if(allOn) ans++;
	}

	cout << ans << endl;

}	

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	string s,t;
	ll ans=0,tmp=0;
	cin>>s;
	rep(i,s.size()-1){
		if(s[i]=='A')t+='A';
		else if(s[i]=='B'&&s[i+1]=='C')t+='D',i++;
		else t+='Z';
	}
	rep(i,t.size()){
		if(t[i]=='A')tmp++;
		if(t[i]=='Z')tmp=0;
		if(t[i]=='D'){
			ans+=tmp;
		}
	}
	print(ans);
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define ll long long 
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
int n;
ll a[233333];
deque<ll> q;
int main()
{
	n=read();
	for(rg int i=1;i<=n;++i)
	{
		a[i]=read();
		q.push_back(a[i]);
	}
	q.push_back(a[n]);
	int tot=0;
	int flag=0;
	bool flag1=0;
	while(q.size()!=0)
	{
//		cout<<tot<<" "<<q.size()<<endl;
		int top=q.front();
		q.pop_front();
		if(top==q.front())
		{
			continue;
		}
		int top2=q.front();
		if(top<top2&&flag==0)//单增 
		{
			tot++;
			flag=1;
			continue;
		}
		else if(top>top2&&flag==0)
		{
			tot++;
			flag=2;
			continue;
		}
		else if(top>top2&&flag==1)
		{
		
			flag=0;
			continue;
		}
		else if(top<top2&&flag==2)
		{
	
			flag=0;
			continue;
		}
	}
//	a[n+1]=a[n];
//	for(rg int i=1;i<=n;i++)
//	{
//		if(a[i]==a[i+1])
//		{
//			continue;
//		}
//		if(a[i]<a[i+1]&&flag1==0)
//		{
//			flag1=1;
//			flag=1;//1--单增 2--单减 
//			tot++;
//		}
//		else if(a[i]>a[i+1]&&flag1==0)
//		{
//			flag1=1;
//			flag=2;
//			tot++;
//		}
//		else if(a[i]<a[i+1]&&flag1==1&&flag==2)//现在为单增却标记为单减 
//		{
//			tot++;
//			flag1=0;
//			flag=1;
//			++i;
//		}
//		else if(a[i]>a[i+1]&&flag1==1&&flag==1)//现在为单减却标记为单增 
//		{
//			tot++;
//			flag=2;
//			flag1=0;
//			++i;
//		}
////		cout<<"i="<<i<<" "<<tot<<" "<<flag<<endl;
//	}
	cout<<tot;
}

Measured memory_bytes: 1792
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-x))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x7fffffffffffffff;

Finline uint rnd()
{
	static uint seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());
	bool f(false);
	while(ch<48||ch>57) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();
	while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	if(f) x=-x;
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args)
{
	read(t);read(args...);
}
Finline int read_str(char *s)
{
	char ch(getchar());
	while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;
	*tar=ch,ch=getchar();
	while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=100005;
struct LBase{
	ll d[63];
	bool insert(ll x)
	{
		for(int i=62;i>=0;--i)
		{
			if((x>>i)&1)
			{
				if(!d[i])
				{
					d[i]=x;
					return true;
				}
				else x^=d[i];
			}
		}
		return false;
	}
}B;
char s[N];
void MAIN()
{
	memset(B.d,0,sizeof(B.d));
	int n;
	read(n);
	std::vector<ll> v(n);
	for(int i=0;i<n;++i) read(v[i]);
	read_str(s);
	for(int i=n-1;i>=0;--i)
	{
		if(s[i]=='0')
		{
			B.insert(v[i]);
		}
		else
		{
			if(B.insert(v[i]))
			{
				printf("1\n");
				return;
			}
		}
	}
	printf("0\n");
}
int main()
{
	int _;
	read(_);
	while(_--) MAIN();
	return 0;
}


Measured memory_bytes: 3564