akhauriyash/Code-Regression huggingface dataset:
N, K = gets.split.map(&:to_i)
S = gets.chomp.chars
zero_c = 0
one_c = 0
group = Array.new
(S + (S[-1] == '0' ? ['1'] : ['0'])).each.with_index do |ch, i|
  if ch == '0'
    zero_c += 1
    if one_c > 0
      group.push([:one, one_c])
      one_c = 0
    end
  else # ch == '1'
    one_c += 1
    if zero_c > 0
      group.push([:zero, zero_c])
      zero_c = 0
    end
  end
end
zero_c = group.count { |(t, _)| t == :zero }
if zero_c <= K
  puts S.size
  exit 0
end

sum_list = Array.new
group.unshift([:one, 0]) if group[0][0] == :zero
group.push([:one, 0]) if group[-1][0] == :zero
sum = group[0][1]
1.step(by: 2, to: group.size - 2) do |i|
  _, zero_c = group[i]
  _, one_c = group[i + 1]
  sum += zero_c + one_c
  sum_list.push([sum, one_c])
end

ans = 0
(0..(sum_list.size - K)).each do |i|
  sum1, one_c = i == 0 ? [0, 0] : sum_list[i - 1]
  sum2, _ = sum_list[i + K - 1]
  n = sum2 - sum1 + one_c
  ans = n if n > ans
end
puts ans


Measured memory_bytes: 17532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n),b(n);
	rep(i,n) cin >> a.at(i);
	rep(i,n) cin >> b.at(i);
	ll cnt=0,sum1=0,sum2=0;
	rep(i,n){
		sum1+=a.at(i);
		sum2+=b.at(i);
	}
	cnt=sum2-sum1;
	if(cnt<0){
		cout << "No" << endl;
	}
	else if(cnt==0){
		bool flg=true;
		rep(i,n) if(a.at(i)!=b.at(i)) flg=false;
		if(flg) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else{
		ll cnt1=0,cnt2=0;
		rep(i,n-1){
			if(a.at(i)%2!=b.at(i)%2){
				cnt2++;
				b.at(i)++;
			}
			if(a.at(i)<b.at(i)){
				cnt1+=(b.at(i)-a.at(i))/2;
			}
			else{
				cnt2+=a.at(i)-b.at(i);
			}
		}
		if(cnt1>cnt || cnt2>cnt || a.at(n-1)+(cnt-cnt1)*2!=b.at(n-1)+(cnt-cnt2)) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.util.Arrays;

/*Question
n ????????´??°???????????°??? S ??¨???q ????????°????????´??°???????????°??? T ??????????????????T ?????????????????´??°????????§ S ?????????????????????????????° C ???????????????????????°???????????????????????????????????? 
*/

/*Input
???????????? n??????????????? S ?????¨??? n ????????´??°??????????????? q??????????????? T ?????¨??? q ????????´??°???????????????????????? 
*/

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		//??\???

		int n = Integer.parseInt(br.readLine());
		String[] tmp = br.readLine().split(" ");
		int[] s = new int[n];
		for (int a = 0;a < n;a++){
			s[a] = Integer.parseInt(tmp[a]);
		}
		n = Integer.parseInt(br.readLine());
		tmp = br.readLine().split(" ");
		int[] t = new int[n];
		for (int a = 0;a < n;a++){
			t[a] = Integer.parseInt(tmp[a]);
		}

		//?¨??????¨
		int len; //??????????????????????¨????
		int b = 0;

		//????????¨ - ?????´?????????????????°????¨????
		int count = 0;

		//??´?????????
		Arrays.sort(s);
		Arrays.sort(t);

		/*????????????????????????
		/????????????????????´?????\?????§??¢?´¢??????????????????????????¨??????????????????????????£???
		*/
		for (int a = 0;a < t.length;a++){
			while (b < s.length) {
				if (t[a] < s[b]) {
					break;
				} else if (t[a] == s[b]) {
					count++;
					len = b;
					break;
				}
				b++;
			}
		}

		//??????
		System.out.println(count);
	}
}

Measured memory_bytes: 53088
#include <iostream>
#include <vector>

using namespace std;

#define int long long

signed main()
{
    int n, t;
    vector<int> ts;

    cin >> n >> t;

    ts.resize(n);

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

    ts.push_back(1e9 * 2 + 10);

    int ans = 0;
    int prev = 0;
    int now = 0;

    for(int i = 0; i < ts.size(); ++i)
    {
        if(now < ts[i])
        {
            //cout << now << " " << prev << endl;
            ans += now - prev;
            prev = ts[i];
        }
        now = ts[i] + t;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld  = long double;
using pll = pair<ll, ll> ;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=1LL<<60;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-9; //微調整用（EPSより小さいと0と判定など）

//MODINT
//変数名.nでint型の数値を受け取る
struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};
 
mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int ii() { int x; scanf("%d", &x); return x; }
long long il() { long long x; scanf("%lld", &x); return x; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od(double x) { printf("%.15f ", x); }
void old(long double x) { printf("%.15Lf ", x); }
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
auto op = [&](auto p) -> void{ cout << p; };
auto ov = [&](auto vec) -> void{ cout << vec; };
void br() { putchar('\n'); }
 
#define gcd __gcd //llは受け取ってくれない
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define ALL(a) a.begin(),a.end() //sort(ALL(vec));
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define PB push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// 空白区切りだけ --> return s << "(" << p.first << " " << p.second << ")";
// 見やすくしたいとき --> return s << "(" << p.first << " " << p.second << ")";
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
	}
	return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	int len = vv.size();
	for (int i = 0; i < len; ++i) {
		s << vv[i] << endl;
	}
	return s;
}

//最大値、最小値を更新する。aよりbのが大きい（小さい）か等しければaを更新してtrueを返す。そうでなければ何もせずfalseを返す chmax(nowmax,x);
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

// ----- template end ---- //
 
// ------- library ------- //



// ----- library end ----- //



int main() {

  int N = ii();
  
  int a;
  int ans = 0;
  while (cin >> a){
    while (a%2==0) {
      a /= 2;
      ans += 1;
    }
  }
  
  oi(ans);
  
  
  
// -- main() end -- //
}


Measured memory_bytes: 256
import heapq

N,M = map(int,input().split())
original_value = list(map(int,input().split()))
value = []

for v in original_value:
  heapq.heappush(value,v*(-1))

for i in range(M):
  num = (heapq.heappop(value)*(-1)//2)*(-1)
  heapq.heappush(value,num)

print(sum(list(map(lambda x: x*(-1), value))))


Measured memory_bytes: 15044
import sys
 
nm=input().split()
a=input().split()
n=int(nm[0])
m=int(nm[1])
lista=[]
for i in a:
  lista.append(int(i))
count=0
suma=sum(lista)
thre=suma/4/m
for i in lista:
  if i >= thre:
    count+=1
  if count >= m:
    print('Yes')
    sys.exit()
print('No')

Measured memory_bytes: 3064
#include <stdio.h>

int H, W, N;
int sr, sc;
char S[300000];
char T[300000];

/* target masu ugokase ba torinozoku */
int yaru(int target, int limit, char zyun, char gyaku) {
	int left = target;
	int i;
	for (i = 0; i < N; i++) {
		if (S[i] == zyun) left--;
		if (left <= 0) return 1;
		if (T[i] == gyaku && left < limit) left++;
	}
	return 0;
}

int main(void) {
	int torinozoku = 0;

	if (scanf("%d%d%d", &H, &W, &N) != 3) return 1;
	if (scanf("%d%d", &sr, &sc) != 2) return 1;
	if (scanf("%299999s", S) != 1) return 1;
	if (scanf("%299999s", T) != 1) return 1;

	torinozoku = torinozoku || yaru(sc, W, 'L', 'R'); /* left */
	torinozoku = torinozoku || yaru(sr, H, 'U', 'D'); /* up */
	torinozoku = torinozoku || yaru(W - sc + 1, W, 'R', 'L'); /* right */
	torinozoku = torinozoku || yaru(H - sr + 1, H, 'D', 'U'); /* down */

	puts(torinozoku ? "NO" : "YES");

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, A[10101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    int ans = 0;
    rep(i, 0, N) {
        while (A[i] % 2 == 0) {
            A[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}


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

namespace ForAtCoder
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());

            List<string> ss = new List<string>();

            for (int i = 0; i < n; i++)
            {
                ss.Add(Console.ReadLine());
            }

            var hs = new HashSet<string>(ss);

            Console.WriteLine(hs.Count);
        }
    }

}


Measured memory_bytes: 39008
n = int(input())
numbers = list(map(int, input().split()))

def div(x):#各要素を2で割って返す関数
    return x/2

count = 0
while 1:
    flag = 0
    for num in numbers:
        if num % 2:#2で割り切れない
            flag=1
            break
    if flag==1:
        break
    count += 1
    numbers = list(map(div,numbers))

print(count)


Measured memory_bytes: 9248
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include<stdio.h>
#include<cstdio>
#include<cstring>
#include<string>
#include<math.h>

using namespace std;






int i, n, mannzoku[100], j, temp, goukei, ryouri[100], bonasu[100];;
string mozi,kopi;
int main() {
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> ryouri[i];
		ryouri[i]--;
	}
	for (i = 0; i < n; i++) {
		cin >> mannzoku[i];
	}
	for (i = 0; i < n; i++) {
		cin >> bonasu[i];
	}
	goukei = mannzoku[ryouri[0]];

	for (i = 1; i < n; i++) {
		goukei = goukei+mannzoku[ryouri[i]];
		if (ryouri[i - 1] == ryouri[i]-1 ) {
			goukei=goukei + bonasu[ryouri[i - 1]];
		}
	}
	printf("%d\n",goukei);

	return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: String = read();
    let chars = N.chars();
    let mut carry = 0;
    let mut ans = 0;
    let mut peekable = chars.rev().peekable();
    while let Some(c) = peekable.next() {
        let now = c.to_digit(10).unwrap() + carry;
        if now == 10 {
            carry = 1;
        } else if now == 5 {
            match peekable.peek() {
                None => {
                    carry = 0;
                    ans += now;
                }
                Some(c2) => {
                    let c2 = c2.to_digit(10).unwrap();
                    if c2 >= 5 {
                        carry = 1;
                        ans += 5;
                    } else {
                        carry = 0;
                        ans += 5;
                    }
                }
            }
        } else if now >= 6 {
            ans += 10 - now;
            carry = 1;
        } else {
            carry = 0;
            ans += now;
        }
    }
    if carry == 1 {
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 6524
#include<bits/stdc++.h>
using namespace std  ;
int main ()
{
    long long  n ;
    cin >> n ;
    long long  ans = 1e18 ;
    for(long long  i = 1 ;i <= sqrt(n) ;i++)
    {
        if(n%i==0)
        {
            ans=min(ans,i+ n/i);
        }
    }
    cout<<ans-2<<endl;
    return 0 ;
}


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

const ll INF = 1'000'000'001;
const ll MAX_V_SUM = 100'000;

int main() {
  ll n, w;
  cin >> n >> w;

  vector<ll> ws(n + 1), vs(n + 1);
  for (int i = 1; i <= n; ++i)
    cin >> ws[i] >> vs[i];

  vector<vector<ll>> dp(n + 1, vector<ll>(MAX_V_SUM + 1, INF));
  dp[0][0] = 0;

  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= MAX_V_SUM; ++j) {
      int p = j - vs[i];
      dp[i][j] = min(dp[i - 1][j], p < 0 ? ws[i] : dp[i - 1][p] + ws[i]);
    }
  }

  int ans = 0;
  for (int j = 1; j <= MAX_V_SUM; ++j) {
    if (dp[n][j] <= w)
      ans = j;
  }

  cout << ans << endl;
}

Measured memory_bytes: 80256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	string s; cin >> s;
	cout << (s[0] == '9' || s[1] == '9' ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
void main() {
    long[] tmp = readln.split.to!(long[]);
    long a = tmp[0], b = tmp[1], x = tmp[2];
    writeln(b / x - (a == 0 ? -1 : (a - 1) / x));
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

using namespace std;

#define ll long long

void solve() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            sum += v[i] * v[j];
        }
    }
    cout << sum;
}

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

    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int i;
	string s;
	cin>>s;
	for(i=0;i<s.size();i++)
		if(s[i]=='C') break;
	for(int j=i+1;j<s.size();j++)
		if(s[j]=='F') {cout<<"Yes";return 0;}
	cout<<"No";
	return 0;
}

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

int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 3608
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
   int h,n,p,c=0;
   cin >> h >> n;
   for(int i=0; i<n; i++){
       cin >> p;
       c+=p;
   }
   if(c>=h){
       cout << "Yes" << endl;
   }
   else{
       cout << "No" << endl;
   }
  
   return 0;
}




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

int selectionSort(int M,vector<int> &A){
  int s = 0;

  for(int i=0;i<M;++i){
    bool flag = false;
    int minj = i;
    for(int j=i;j<M;++j){
      if(A.at(j) < A.at(minj)){
        minj = j;
        flag = true;
      }
    }
    if(flag){
      swap(A.at(i),A.at(minj));
      s += 1;
    }
  }
  return s;
}
int main(){
  int N;
  int cnt;

  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;++i){
    cin >> vec.at(i);
  }

  cnt = selectionSort(N,vec);
  for(int i=0;i<N-1;++i){
    cout << vec.at(i) << " ";
  }
    cout << vec.at(N-1) << endl;
    cout << cnt << endl;
}



Measured memory_bytes: 3088
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(ll i=0;i<n;++i)
#define END(x) (*(x.end()-1))
#define INF (INT_MAX / 2)

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)*b;
}

int main(void){
    ll n,m;
    cin>>n>>m;
    ll L=1,R=n;
    ll l,r;
    rep(i,m){
        cin>>l>>r;
        L=max(L,l);
        R=min(R,r);
    }
    if(L>R){
        cout<<0;
        return 0;
    }
    cout<<R-L+1;
}
/*

*/


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int a, b;
    cin >> a >> b;
    int n = 1, ans = 0;
    while(n < b){
        n += a - 1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}

int main() {
  int X,Y;
  cin >> X >> Y;
  int kame=0;
  int turu=0;
  int check=0;
  for(int i=0;i<=X;i++){
    kame=i;
    turu=X-i;
    if(kame*4+turu*2==Y){
      check=1;
    }
  }
  if(check==1){
    Yes();
  }
  else{
    No();
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
using ll = long long;

int main(){
    string s;
    cin >>s;
    int n=s.size();
    for(int i=0;i<n;i++){
        s.replace(i,1,"x");
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	ll m; cin>>m;
	string s; cin>>s;
	ll n=s.size();
	vl a(n+1),b(n+1);
	rep(i,1,n+1){
		a[i]=a[i-1];
		if(s[i-1]=='W')a[i]++;
	}
	//rep(i,0,n+1)cout<<a[i]<<" ";
	//cout<<endl;
	b[n]=0;
	for(ll i=n-1;i>=0;i--){
		b[i]=b[i+1];
		if(s[i]=='R')b[i]++;
	}
	ll ans=MOD;
	rep(i,0,n+1){
		ll k=min(a[i],b[i]);
		k += max(a[i],b[i])-min(a[i],b[i]);
		chmin(ans,k);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6820
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10001;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<int> values(100), weights(100), dp(MAX, INF);
int N, W;
/* function */
void calcDPTable() {
    dp[0] = 0;
    for (int i = 0; i < N; i++) for (int v =  MAX; v >= 0; v--)
        if (v - values[i] >= 0) dp[v] = min(dp[v], dp[v - values[i]] + weights[i]);
}
void calcAns() {
    int ans = 0;
    for (int v = 0; v <= 10000; v++)
        if (dp[v] <= W) ans = v;
    cout << ans << '\n';
}

/* main */
int main(){
    cin >> N >> W;
    // for (int i = 0; i < N; i++) cin >> weights[i] >> values[i];
    for (int i = 0; i < N; i++) cin >> values[i] >> weights[i];

    calcDPTable();
    calcAns();
}



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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

void solve() {
    string s;
    read(s);
    
    int n = s.size();
    FOR(i, n - 2, -1, -1) {
        if (i & 1 && s.substr(0, (i + 1) / 2) == s.substr((i + 1) / 2, (i + 1) / 2)) {
            print(i + 1);
            return;
        }
    }
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
    //read(tt);
    FOR(tt) {
        //write("Case #", i + 1, ": ");
        solve();
        
    }
    
}



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

int main()
{
    int N;
    cin >> N;
   vector<int64_t> A(N);
   for (int i=0; i<N; i++){
    cin >> A.at(i);
   }
   
   sort(A.begin(), A.end());
   
   int flag=0;
   for (int i=0; i<N-1;i++){
    if (A.at(i+1)==A.at(i)){
        flag=1;
    }
   }
   
   if (flag==0){
   cout << "YES" << endl;
   } else{
   cout << "NO" << endl;
   }
}

Measured memory_bytes: 1792
import numpy as np
H,W,K=map(int, input().split())
M=np.array([list(input()) for _ in range(H)])
ans=np.zeros((H,W),int)
k=0

for i in range(H):
    l=0
    for j in range(W):
        if M[i,j]=='#':
            k+=1
            ans[i,l:j+1]=k
            l=j+1

            
for i in range(H):
    for j in range(W):
        if ans[i,j]==0:
            ans[i,j]=ans[i,j-1]
            
            
for j in range(W):
    J=W-j-1
    for i in range(H):
        I=H-i-1
        if I!=H-1 and ans[I,J]==0:
            ans[I,J]=ans[I+1,J]


for i in range(H):
    if sum(ans[i,:])==0:
        if i!=0:
            ans[i,:]=ans[i-1,:]
        if i==0:
            ans[i,:]=ans[1,:]
            
for row in ans:
    print(*row)

Measured memory_bytes: 16504
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        n: u64,
        v: [u64; n]
    }
    let mut ans:bool = true;
    for i in v.iter(){
        ans &= if i % 2 == 0 { if i % 3 != 0 && i % 5 != 0 {false} else {true} } else {true}
    }
    println!("{}", if ans {"APPROVED".to_string()} else {"DENIED".to_string()})
}


Measured memory_bytes: 4352
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>
#include<fstream>
#include<array>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

long long safe_mod(long long x, long long m) {
	x %= m;
	if (x < 0) x += m;
	return x;
}

pair<long long, long long> inv_gcd(long long a, long long b) {
	a = safe_mod(a, b);
	if (a == 0) return { b, 0 };
	long long s = b, t = a;
	long long m0 = 0, m1 = 1;

	while (t) {
		long long u = s / t;
		s -= t * u;
		m0 -= m1 * u;
		auto tmp = s;
		s = t;
		t = tmp;
		tmp = m0;
		m0 = m1;
		m1 = tmp;
	}
	if (m0 < 0) m0 += b / s;
	return { s, m0 };
}

pair<long long, long long> crt(const vector<long long>& r,const vector<long long>& m) {
	int n = int(r.size());
	long long r0 = 0, m0 = 1;
	for (int i = 0; i < n; i++) {
		long long r1 = safe_mod(r[i], m[i]), m1 = m[i];
		if (m0 < m1) {
			swap(r0, r1);
			swap(m0, m1);
		}
		if (m0 % m1 == 0) {
			if (r0 % m1 != r1) return { 0, 0 };
			continue;
		}
		
		long long g, im;
		tie(g, im) = inv_gcd(m0, m1);

		long long u1 = (m1 / g);
		if ((r1 - r0) % g) return { 0, 0 };

		long long x = (r1 - r0) / g % u1 * im % u1;

		r0 += x * m0;
		m0 *= u1;
		if (r0 < 0) r0 += m0;
	}
	return { r0, m0 };
}

vector<int> get_divisor(int N)
{
	vector<int> ret;
	rep(i, 1, sqrt(N) + 1) {
		if (N % i == 0) {
			ret.push_back(i);
			if (i * i != N) ret.push_back(N / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}

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

	int N;
	cin >> N;

	auto div = get_divisor(2 * N);

	int ans = INF;
	for (auto v : div)
	{
		int m0 = v, m1 = (2 * N) / v;
		int r0 = 0, r1 = m1 - 1;
		auto res = crt({ r0,r1 }, { m0,m1 });
		if (res.second == 0)continue;
		if (res.first > 0)chmin(ans, res.first);
		else chmin(ans, res.first + res.second);
	}

	cout << ans << endl;

	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    map<string, int> mp;
    int n;
    cin >> n;
    string s;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        mp[s]++;
    }
    int m;
    cin >> m;
    string t;
    for (int i = 0; i < m; ++i) {
        cin >> t;
        mp[t]--;
    }

    int res = 0;
    for(auto x : mp){
        res = max(res, x.second);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e6)+10;
vii adj(N);
int a[N];
int b[N];
void  solve(){

}
int32_t main()
{
    FIO
    int n; cin>>n;
    mii m;
    fi(i,n) {
        cin>>a[i];
        m[a[i]]++;
    }
    for(int i=0;i<=m.rbegin()->first;i++) b[i]=0;
    int maxz=m.rbegin()->first;
    // if(maxz==1){
    //     cout<<"pairwise coprime\n";
    //     return 0;
    // }
    int ok=0;
    for(int i=2;i<=maxz;i++){
        int cnt=0;
        if(b[i]) continue;
        for(int j=i;j<=maxz;j+=i){
            if(m.find(j)!=m.end()) cnt+=m[j];
            b[j]=1;
        }
        if(cnt>1) {
            // cout<<i<<" ";
            ok=1;
            break;
        }
    }
    if(!ok) cout<<"pairwise coprime\n";
    else {
        int gc=a[0];
        fir(i,1,n) gc=__gcd(gc,a[i]);
        if(gc==1) cout<<"setwise coprime\n";
        else cout<<"not coprime\n";
    }
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

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

int main() {
	int n, k;
	cin >> n;
	int H[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >> H[i];
	} 

	for (int i = 1; i <= n; i++) {
		cout << "node " << i << ": ";
		cout << "key = " << H[i] << ", ";
		if (i > 1) cout << "parent key = " << H[i / 2] << ", ";
		if (2 * i <= n) cout << "left key = " << H[2 * i] << ", ";
		if (2 * i + 1 <= n) cout << "right key = " << H[2 * i + 1] << ", ";
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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();
        int x = sc.nextInt();
        if (a + b >= x && a <= x) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}




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

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

	int n = N.size();
	int ans = N[0] - '0' - 1;
	ans += (n - 1) * 9;
	if( N.substr( 1, n - 1 ) == string( n - 1, '9' ) || n == 1 ) {
		ans++;
	}

	cout << ans << endl;
}


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

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

    int mincos = 1e9;

    for(int y = -100; y <= 100; y++){
        int cost = 0;
        for(int i = 0; i < N; i++){
            cost += pow((a[i] - y), 2);
        }
        mincos = min(mincos, cost);
    }
    cout <<mincos << endl;

}

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

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const double PI = acos(-1.0);
ll dx[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };
ll dy[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/05/13  Problem: ABC 061 D / Link: http://abc061.contest.atcoder.jp/tasks/abc061_d  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----

強連結成分があればinf
でなければーでダイクストラ？
ベルマンフォードでした

----解説ここまで---- */

ll N, M;


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

	cin >> N >> M;
	vector<vector<pll>>G = vector<vector<pll>>(N, vector<pll>());
	FOR(i, 0, M) {
		int a, b, c; cin >> a >> b >> c;
		a--;
		b--;
		G[a].push_back({ b,c });
	}
	ll INF = 1e18;
	vector<ll>dist1(N, -INF);
	vector<ll>dist2;
	dist1[0] = 0;
	FOR(i, 0, N + 1) {
		FOR(j, 0, N) {
			FOR(k, 0, (int)G[j].size()) {
				dist1[G[j][k].first] = max(dist1[G[j][k].first], dist1[j] + G[j][k].second);
			}
		}
	}

	dist2 = dist1;
	FOR(i, 0, N + 1) {
		FOR(j, 0, N) {
			FOR(k, 0, (int)G[j].size()) {
				dist2[G[j][k].first] = max(dist2[G[j][k].first], dist2[j] + G[j][k].second);
			}
		}
	}

	if (dist1[N - 1] != dist2[N - 1]) {
		cout << "inf" << endl;
	}
	else {
		cout << dist1[N - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func getInt() (n int) {
	sc.Scan()
	n, _ = strconv.Atoi(sc.Text())
	return n
}

func main() {
	A := getInt()
	B := getInt()

	if A <= 2*B {
		fmt.Println(0)
	} else {
		fmt.Println(A - 2*B)
	}
}


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

int main()
{
	int N, K, Q;
	cin >> N >> K >> Q;

	int X[N], A[Q];

	for (int i = 0; i < N; i++)
	{
		X[i] = K - Q;
	}

	for (int i = 0; i < Q; i++){
		cin >> A[i];
		X[A[i]-1]++;
	}

	for(int i = 0; i < N; i++){
		if(X[i] <= 0){
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1408
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <cassert>
using namespace std;

#define sz(a) int((a).size())
#define rep(i, s, n)  for(int i = s; i <= (n); ++i)
#define rev(i, n, s)  for(int i = (n); i >= s; --i)
#define fore(x, a) for(auto &&x : a)
typedef long long ll;
const int mod = 1000000007;
const int N = 2005;

vector<int> g[N];
bool v[N];

void go(int x, int p, int d) {
  v[x] = 1;
  if (d == 0) return;
  fore(y, g[x]) {
    if (y == p) continue;
    go(y, x, d - 1);
  }
}
vector<pair<int, int>> e;

int main() {
#ifdef loc
  if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
    assert(0);
  }
  freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
#endif
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n, k;
  cin >> n >> k;
  rep(i, 0, n - 2) {
    int x, y;
    cin >> x >> y;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
    e.emplace_back(make_pair(x, y));
  }
  int res = 0;
  rep(i, 1, n) {
    memset(v, 0, sizeof(v));
    go(i, -1, k / 2);
    int cur = 0;
    rep(j, 1, n) {
      cur += v[j];
    }
    res = max(res, cur);
  }
  rep(i, 0, n - 2) {
    memset(v, 0, sizeof(v));
    go(e[i].first, e[i].second, (k - 1) / 2);
    go(e[i].second, e[i].first, (k - 1) / 2);
    int cur = 0;
    rep(j, 1, n) {
      cur += v[j];
    }
    res = max(res, cur);
  }
  cout << n-res << endl;
  return 0;
}

Measured memory_bytes: 512
from itertools import product

n, m = map(int, input().split())
ks = {}
for i in range(m):
    tmp = list(map(int, input().split()[1:]))
    ks[i] = [t-1 for t in tmp]
p = list(map(int, input().split()))

onoffs = []
for onoff in product('01', repeat=n):
    _ = [int(bin) for bin in onoff]
    onoffs.append(_)

res = 0
for i in range(len(onoffs)):
    tmp = 0
    for j in range(m):
        obj = []
        for k in ks[j]:
            obj.append(onoffs[i][k])
        if sum(obj) % 2 == p[j]:
            tmp += 1
    if tmp == m:
        res += 1

print(res)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
#define MEM(a, x) memset(a, x, sizeof a)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

template<typename T> void dbg(T &x) {cerr << x << endl;}
template<typename T> void dbga(T &x, int &n) {for(int i = 0; i < n; i++) {cerr << i << ": "; cerr << x[i] << endl;} }
template<typename T> void dbgv(T &x) {bool first = true; cerr << "{"; for(auto i : x) {if(!first) cerr << ","; cerr << i; first = false;} cerr << "}" << endl;}

const ll MOD = 1e9 + 7;

ll fastexp(ll a, ll x, ll m) {
	if(x == 0)
		return 1;

	ll ans = 1;
	while(x > 0) {
		if(x&1)
			ans = (ans * a) % m;
		a = (a * a) % m;
		x /= 2;
	}

	return ans;
}

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

	int x, y;
	cin >> x >> y;

	if((x + y) % 3 != 0)
		cout << 0 << endl;
	else if(2 * x - y < 0 || 2 * y - x < 0)
		cout << 0 << endl;
	else {
		ll n = (x + y) / 3;
		ll k = (2 * x - y) / 3;

		dbg(n);
		dbg(k);

		ll ans = 1;
		for(int i = 1; i <= n; i++)
			ans = (ans * i) % MOD;
		for(int i = 1; i <= (n-k); i++)
			ans = (ans * fastexp(i, MOD-2, MOD)) % MOD;
		for(int i = 1; i <= k; i++)
			ans = (ans * fastexp(i, MOD-2, MOD)) % MOD;

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int bitcount(int n){
    n = (n & 0x55555555) + (n >> 1 & 0x55555555);
    n = (n & 0x33333333) + (n >> 2 & 0x33333333);
    n = (n & 0x0f0f0f0f) + (n >> 4 & 0x0f0f0f0f);
    n = (n & 0x00ff00ff) + (n >> 8 & 0x00ff00ff);
    return (n & 0x0000ffff) + (n >>16 & 0x0000ffff);
}

int main(){
    int n;
    cin >> n;
    vector<int> store(n, 0);
    vector<vector<int> > gain(n, vector<int>(11, 0));
    for(int i=0; i<n; i++){
        for(int j=0; j<10; j++){
            int tmp;
            cin >> tmp;
            store[i] = store[i]*2 +tmp;
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<=10; j++){
            cin >> gain[i][j];
        }
    }

    int ans = -inf;
    for(int i=1; i<(1<<10); i++){
        int subans = 0;
        for(int j=0; j<n; j++){
            subans += gain[j][bitcount(i&store[j])];
        }
        ans = max(ans, subans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//   Sourav Verma IPG_2013  ABV_IIITMG Task @ Codeforces & Atcoder

#include<bits/stdc++.h>

#define ll                    long long int
#define loop(i,a,b)           for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)          for(int i=(int)a;i<=(int)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define count_1(n)            __builtin_popcountll(n)
#define pb                    push_back
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define itoc(c)               ((char)(((int)'0')+c))
#define vi                    vector<int>
#define vvi                   vector<vi>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define mini                  INT_MIN
#define sv()                  int t; scanf("%d",&t); while(t--)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll lcm(int x, int y) { return x * 1ll * y / (int)__gcd(x, y); }
ll hcf(ll a, ll b) {if(b>a) return (hcf(b, a)); if(a%b==0) return b; return (hcf(b, a%b));} 
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}


int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0);
    vector<ll> a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(all(a));
    ll c1=0,c2=0;
    c1=(a[2]/2)*a[1]*a[0];
    c2=(a[2]-(a[2]/2))*a[1]*a[0];
    cout<<abs(c1-c2)<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <string.h>
#include <cstring>
#include <algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

int main(){
	int a, b, x;
	cin >> a >> b >> x;
	if (x >= a && (x - a) <= b) cout << "YES" << "\n";
	else cout << "NO" << "\n";
}


Measured memory_bytes: 256
# Taro's Shopping
while True:
  n, m = map(int, input().split())
  if n+m == 0:
    break
  a = sorted(list(map(int, input().split())))
  ans = 0
  pos = n-1
  for i in range(n):
    while pos>i and a[i]+a[pos]>m:
      pos -= 1
    if pos<=i:
      break
    ans = max(ans , a[i]+a[pos])
  print(ans if ans>0 else 'NONE')


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, K;
  cin >> A >> B >> C;
  cin >> K;
  int total;
  total = max(A, max(B, C));
  int bai = 1;
  for (int i = 1; i <= K; i++) {
    bai *= 2;
  }
  total *= (bai - 1);
  total += (A + B + C);
  cout << total << endl;
  return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> V(n);
    for (int i=0;i<n;i++) cin >> V[i];
    vector<int> C(n);
    for (int i=0;i<n;i++) cin >> C[i];
    int ans = 0;
    for (int i=0;i<n;i++){
        if (V[i]-C[i]>=0) ans += (V[i]-C[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256