akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
using namespace std;
typedef long long s64;

const int ONE = 2000005;

int get()
{
		int res = 1, Q = 1; char c;
		while( (c = getchar()) < 48 || c > 57)
			if(c == '-') Q = -1;
		if(Q) res = c - 48;
		while( (c = getchar()) >= 48 && c <= 57)
			res = res * 10 + c - 48;
		return res * Q;
}

int n, k;
int a[ONE];

#include <map>
map <int, int> times, f;

#include<vector>

int A[ONE];

int main()
{
		n = get(), k = get();

		int now = 0;
		for(int i = 1; i <= n; i++)
		{
			a[i] = get(), times[a[i]]++;
			if(times[a[i]] == 1) now++;
		}

		int total = 0;
		for(int i = 1; i <= n; i++)
			if(!f[a[i]]) A[++total] = times[a[i]], f[a[i]] = 1;
		

		sort(A + 1, A + total + 1);

		int ans = 0;
		for(int i = 1; i <= total; i++)
		{
			if(now <= k) break;
			ans += A[i], now--;
		}

		cout << ans<<endl;
}

Measured memory_bytes: 23936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n, W;    cin >> n >> W;
    vector<ll> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(n+1, vector<ll>(n*1000+1, LINF));
    dp[0][0] = 0;
    rep(i, n){
        for(ll j=0; j<=n*1000; j++){
            dp[i+1][j] = dp[i][j];
            if(v[i]<=j) dp[i+1][j] = min(dp[i][j-v[i]]+w[i], dp[i+1][j]);
        }
    }
    ll res=0;
    rep(i, n*1000+1) if(dp[n][i]<=W){
        res = i;
        //cout << i << ' ' << dp[n][i] << endl;
    }
    cout << res << endl;

}


Measured memory_bytes: 83232
#include <iostream>
using namespace std;
int main()
{
  for(;;){
    int n;
    cin >> n;
    if(n==0) break;
    int count = 0;
    for(int i=1; i<n; i++){
      int sum = i;
      for(int j=i+1; j<n; j++){
        sum += j;
        if(sum == n){
          count++;
          break;
        }else if(sum > n) break;
      }
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
s = input()
 
s_f = s[:2]
s_s = s[2:]
 
if (int(s_f) > 12 or int(s_f) == 0) and (int(s_s) > 12 or int(s_s) == 0):
    print('NA')
elif int(s_f) > 12 or int(s_f) == 0:
    print('YYMM')
elif int(s_s) > 12 or int(s_s) == 0:
    print('MMYY')
 
else:
    print('AMBIGUOUS')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) //
#endif
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
using db = double;
int n;
const int maxn = 600;
ll dp[maxn][maxn];
ll w[maxn][maxn];
ll p[maxn][maxn];
ll to[maxn][maxn];
const ll inf = 1ll << 59;
ll get(int a, int b, int c, int d){
	if(a > b || c > d)return 0;
	return p[b][d] - (c == 0 ? 0 : p[b][c-1]) - (a == 0 ? 0 : p[a-1][d]) + (a == 0 || c == 0 ? 0 : p[a-1][c-1]);
}
ll get_to(int l, int r){
	return to[r][r] - to[l-1][r] - to[r][l-1] + to[l-1][l-1];
} 
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(int i = 1;i <= n;++i)for(int j = 1;j <= n;++j)if(i != j)cin >> w[i][j];
	for(int i = 1;i <= n;++i)for(int j = 1;j <= n;++j)p[i][j] = p[i-1][j] + p[i][j-1] - p[i-1][j-1] + w[i][j];
	for(int i = 1;i <= n;++i)for(int j = 1;j <= n;++j)to[i][j] = to[i-1][j] + to[i][j-1] - to[i-1][j-1] + (i < j ? w[i][j] : 0);
	for(int i = 1;i <= n;++i)fill(dp[i], dp[i] + maxn, inf);
	for(int i = 1;i <= n;++i){
		dp[i][1] = get_to(1, i);
		for(int j = 2;j <= i;++j){
			for(int k = 1;k < j;++k){
				dp[i][j] = min(dp[i][j], dp[j-1][k] + get_to(j, i) + get(j, i, 0, k-1));
			}
			// cout << i << ' ' << j << ' ';dout(dp[i][j])<<'\n';
		}
	}
	ll res = inf;
	for(int i = 1;i <= n;++i)res = min(res, dp[n][i]);
	cout << res << '\n';
}

Measured memory_bytes: 11008
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> 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().expect("failed to parse token")
}

static mut ANS: i64 = std::i64::MAX;

fn dfs(n: usize, m: usize, a: &mut Vec<usize>, x:i64, v: &mut Vec<i64>, b: &mut Vec<Vec<i64>>){
    if a.len() == n {
        let mut sum = 0;
        let mut understand: Vec<i64> = vec![0; m];
        let mut i = 0;
            for j in a.iter(){
                let mut k = 0;
                if *j == 1 {
                    sum += v[i];
                    //本によって各アルゴリズムに対して理解度をアップさせる
                    for l in b[i].iter(){
                        understand[k] += l;
                        k += 1;
                    }
                }
                i += 1;
            }
        
        let mut goal = true;
        for u in understand.iter(){
            if *u < x {
                goal = false;
            }
        }
        if goal {
            unsafe{
                ANS = std::cmp::min(ANS,sum);
            }
        }
        //println!("sum{}",sum);
        //println!("understand{:?}", understand);
        return;
    }

    for i in 0..2 {
        a.push(i);
        dfs(n,m,a,x,v,b);
        a.pop();
    }
}


fn main() {
    let n: usize = read();
    let m: usize = read();
    let x: i64 = read();
    let mut value = Vec::new();
    let mut books: Vec<Vec<i64>> = vec![vec![-1; m]; n];

    for i in 0..n {
        value.push(read::<i64>());
        books[i] = (0..m).map(|_| read::<i64>()).collect();
    }

    let mut a: Vec<usize> = Vec::new();
    dfs(n,m,&mut a,x, &mut value, &mut books);
    unsafe{
        if ANS == std::i64::MAX {
            println!("-1");
        }else{
            println!("{}", ANS);
        }
    }
}


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

using namespace std;

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

    vector<vector<pair<int, int>>> tree(N);
    for ( int i = 0; i < N-1; i++ ) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        tree.at(a).push_back(make_pair(b, c));
        tree.at(b).push_back(make_pair(a, c));
    }

    int Q, K;
    cin >> Q >> K;
    K--;
    vector<pair<int, int>> xy(Q);
    for ( int i = 0; i < Q; i++ ) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        xy.at(i) = make_pair(x, y);
    }

    vector<long long> dist(N, -1);  /* 頂点Kからの距離 */
    dist.at(K) = 0;
    priority_queue<int, vector<int>, greater<int>> pq;
    pq.push(K);
    while ( !pq.empty() ) {
        int cur = pq.top(); pq.pop();
        for ( auto itr : tree.at(cur) ) {
            if ( dist.at(itr.first) < 0 ) {
                dist.at(itr.first) = itr.second + dist.at(cur);
                pq.push(itr.first);
            }
        }
    }

    for ( int i = 0; i < Q; i++ ) {
        int x = xy.at(i).first;
        int y = xy.at(i).second;
        printf("%lld\n", dist.at(x) + dist.at(y));
    }

    return 0;
}


Measured memory_bytes: 11928
n,m=map(int,input().split())
dp=[1]*n 
for i in range(m):
    dp[int(input())-1]=0
if n==1:
  if m==1:
    print(0)
  else:
    print(1)
else:
  if dp[1]==1:
    dp[1]=1+dp[0]
  for j in range(n-2):
    if dp[j+2]==1:
      dp[j+2]+=(dp[j]+dp[j+1]-1)
  print(dp[-1]%1000000007)

Measured memory_bytes: 511912
#include<cstdio>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

int main() {
    while (1) {
        char ch;
        scanf("%c", &ch);

        if (ch == '\n') {
            printf ("%c", ch);
            break;
        }
        if (ch >= 65 && ch <= 90) {
            ch += 32;
            printf("%c", ch);
        } else if (ch > 96 && ch < 123) {
            ch -= 32;
            printf("%c", ch);
        } else {
            printf("%c",ch);
        }
    }


    return 0;
}


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

int main () {
  int A, B, C;
  cin >> A >> B >> C;
  int max = 0;
  max = A;
  if ( max < B ) max = B;
  else if ( max < C ) max = C;
  
  if ( max == A ) cout << max * 10 + B + C << endl;
  else if ( max == B ) cout << max * 10 + A + C << endl;
  else if ( max == C ) cout << max * 10 + B + A << endl;
}
  

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

int main(){
  int64_t N, n;
  cin >> N;
  n = N;
  map<int64_t,int64_t> list;
  vector<int64_t> P(0);
  int64_t a = 2;
  while(n >= a*a){
    if(n%a == 0){
      if(list.count(a) == false){
        list[a] = 1;
        P.push_back(a);
      }
      else{
        list[a]++;
      }
      n /= a;
    }
    else
      a++;
  }
  
  if(n != 1){
    if(list.count(n))
      list[n]++;
    else{
      list[n] = 1;
      P.push_back(n);
    }
  }
  
  int64_t ans = 0, cnt = 0, i = 0;
  
  while(N != 0){
    if(i >= P.size())
      break;
    int64_t num = P[i];
    for(int j = 0; j < cnt; j++){
      num *= P[i];
    }
    cnt++;
    list[P[i]] -= cnt;
    if(list[P[i]] >= 0){
      N /= num;
      ans++;
      continue;
    }
    else{
      cnt = 0;
      i++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 1<<16;

class RSQ2{
public:
  ll n,dat[2*MAX_N-1],td[2*MAX_N-1];
  RSQ2(){n=MAX_N,memset(dat,0,sizeof(dat)),memset(td,0,sizeof(td));};
  
  ll add(int a,int b,ll x,int k=0,int l=0,int r=-1){
    if(r==-1) r=n;
    if(r<=a||b<=l)return 0;
    if(a<=l&&r<=b){
      dat[k]+=(r-l)*x; 
      td[k]+=x;
      return dat[k];
    }

    dat[k]+=(min(r,b)-max(l,a))*x;
    ll kl=k*2+1,kr=k*2+2,t=td[k]*(r-l)/2;
    dat[kl]+=t, dat[kr]+=t;
    td[kl]+=td[k], td[kr]+=td[k];
    td[k]=0;
    
    ll vl=add(a,b,x,k*2+1,l,(l+r)/2);
    ll vr=add(a,b,x,k*2+2,(l+r)/2,r);
    return vl+vr;
  }
  
  ll sum(int a,int b){return a>=b? 0:add(a,b,0);}
};


struct data{int l,r;};
struct P{int x,y;};
const int B=30000;

int main(){
  int n;
  while(cin>>n,n){
    vector<vector<data> > LR(MAX_N);
    vector<P> A(n);
    for(int i=0;i<n;i++)cin>>A[i].x>>A[i].y,A[i].x+=B,A[i].y+=B;
    for(int i=1;i<=n;i++)
      if(A[i%n].y==A[i-1].y)
	LR[A[i%n].y].push_back((data){A[i-1].x,A[i%n].x});
    
    map <int,data> C;
    for(int i=0;i<4;i++)cin>>A[i].x>>A[i].y,A[i].x+=B,A[i].y+=B;
    for(int i=1;i<=4;i++)
      if(A[i%4].y==A[i-1].y)C[A[i%4].y]=(data){A[i-1].x,A[i%4].x};
    
    RSQ2 T;
    ll ans=0;
    for(int i=0,cl=0,cr=0;i<MAX_N;i++){
      if(C.count(i)&&!cl&&!cr) cl=C[i].l,cr=C[i].r;
      else if(C.count(i)) cl=cr=0;

      for(int j=0;j<LR[i].size();j++){
	int l = LR[i][j].l,r=LR[i][j].r;
	l<r ? T.add(l,r,1): T.add(r,l,-1);
      }
      ans+=T.sum(0,cl)+T.sum(cr,T.n);
    }
    cout <<ans<<endl;
  }


  return 0;
}

Measured memory_bytes: 6696
#if 1

#include <bits/stdc++.h>
using namespace std;
int n,m;
long long t[800005],t2[800005];
vector <pair <int,int> > a[200005];

void up(int x,int l,int r,int rl,int rr,long long c)
{
    if(rl <= l&&r <= rr)
    {
        t[x] += c;
        t2[x] += c;
        return;
    }
	int mid = (l+r) >> 1;
	if(rl <= mid) up(x*2,l,mid,rl,rr,c);;
	if(rr > mid) up(x*2+1,mid+1,r,rl,rr,c);
	t[x] = max(t[x*2],t[x*2+1])+t2[x];
}

int main()
{
    int x,y,z;
    scanf("%d %d", &n, &m);
    for(int i = 1;i <= m;i++)
    {
        scanf("%d %d %d", &x, &y, &z);
        a[y].push_back({x,z});
    }
    for(int i = 1;i <= n;i++)
    {
        up(1,1,n,i,i,t[1]);
        for(int j = 0;j < a[i].size();j++)
        {
            up(1,1,n,a[i][j].first,i,a[i][j].second);
        }
    }
    printf("%lld",max((long long)0,t[1]));
}

#endif // 1


Measured memory_bytes: 22912
#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,K;cin>>N>>K;

    int ans=0;
    rep(i,N){
        int a;cin>>a;
        ans+=min(a,K-a);
    }
    cout<<ans*2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
	int n;
	int mod = 1e9+7;
	scanf("%d", &n);

	int DP[101][4][4][4]={};
	int i,j,k;

	for( i=0; i<4; i++ )
  for( j=0; j<4; j++ )
  for( k=0; k<4; k++ )
  DP[3][i][j][k] = 1;
	
	DP[3][0][1][2] = 0;
	DP[3][0][2][1] = 0;
	DP[3][1][0][2] = 0;
	int a, b, c, d;
	
	for( i=3; i<n; i++ ) {
		for( a=0; a<4; a++ ) {
			for( b=0; b<4; b++ ) {
				for( c=0; c<4; c++ ) {
					for( d=0; d<4; d++ ) {
						if(DP[i][a][b][c] == 0)continue;
						if(b==0 && c==1 && d==2)continue;
						if(b==0 && c==2 && d==1)continue;
						if(a==0 && c==1 && d==2)continue;
						if(a==0 && b==1 && d==2)continue;
						if(b==1 && c==0 && d==2)continue;
						DP[i+1][b][c][d] += DP[i][a][b][c];
						DP[i+1][b][c][d]%=mod;
					}
				}
			}
		}
	}
	int ans = 0;
	for( a=0; a<4; a++ ) {
			for( b=0; b<4; b++ ) {
				for( c=0; c<4; c++ ) {
					ans += DP[n][a][b][c];
					ans %=mod;
				}
			}
	}
	printf("%d", ans);
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x = abs(a - c), y = abs(b - d);
    ll g = __gcd(x, y);
    x /= g;
    y /= g;
    cout << (x + y - 1) * g << newl;

    return 0;
}

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

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, X);
    CIN(int, A);

    int ans = 10;
    if (X < A) ans = 0;
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

string str1,str2;
int main() {
    int n;
    scanf("%d",&n);
    cin>>str1>>str2;

    LL res=1;
    int i=0;
    int sta;//前一种状态
    if(str1[i]==str2[i]){//竖
        res*=3;
        i++;
        sta=1;
    }
    else{//横
        res*=6;
        i+=2;
        sta=2;
    }

    while(i<n){
        if(str1[i]==str2[i]){//竖
            if(sta==1)//前面是竖
                res=res*2%MOD;
            i++;
            sta=1;
        }
        else{//横
            if(sta==1)//前面是竖
                res=res*2%MOD;
            else//前面是横
                res=res*3%MOD;
            i+=2;
            sta=2;
        }
    }

    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

DP = [False] * (k + 1)

for i in range(1, k+1):
    DP[i] = any(not DP[i-a] for a in A if i - a >= 0)

print('First' if DP[k] else 'Second')

Measured memory_bytes: 46300
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

d = ni()

if d == 25:
    print("Christmas")
elif d == 24:
    print("Christmas Eve")
elif d == 23:
    print("Christmas Eve Eve")
elif d == 22:
    print("Christmas Eve Eve Eve")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,c=0,d=0;
  cin>>n;
  ll a[n],b[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i]/n;
    d+=a[i]/n;
    a[i]%=n;
  }
  c+=d;
  while(d!=0){
    for(int i=0;i<n;i++){
      a[i]+=d-b[i];
    }
    d=0;
    for(int i=0;i<n;i++){
      b[i]=a[i]/n;
      d+=a[i]/n;
      a[i]%=n;
    }
    c+=d;
  }
  cout<<c;
}

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



int main() {
    int n;
    long int k;
    cin >> n >> k;
    
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    
    vector<int> all(200005), r;
    
    int ans = 0;
    int p = 1;
    int cnt = 0;
    while(all[p] <= 2) {
        if(all[p] <= 1)
            cnt++;
        
        if(k == cnt - 1) {
            ans = p;
            break;
        }
        
        all[p]++;
        if(all[p] == 2) {
            r.push_back(p);
        }
        p = a[p];
    }
    
    if(k > cnt) {
        k -= cnt;
        ans = r[k % (int)r.size()];
    }
    
    cout << ans << endl;
    
    return 0;
}




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

int main() {
	int N;
	cin >> N;
	int X[N];
	for (int i = 0; i < N; i++)
		cin >> X[i];
	int minsum = 2000000000;
	for (int P = 1; P <= 100; P++) {
		int sum = 0;
		for (int i = 0; i < N; i++) {
			sum += pow(X[i] - P, 2);
		}
		minsum = min(sum, minsum);
	}
	cout << minsum << endl;
	return 0;
}


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

int main(){
  int a[5];cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  int k;cin >> k;
  for(int i=0;i<4;i++){
    for(int j=i+1;j<5;++j){
      if(abs(a[i]-a[j])>k){cout << ":(" << endl;return 0;}
    }
  }
  cout << "Yay!" << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import sys

sys.setrecursionlimit(10**6)


N = int(input())
g = defaultdict(set)

for x, y in [map(int, input().split()) for _ in range(N-1)]:
    g[x].add(y)
    g[y].add(x)

M = 10**9 + 7


def dfs(u, p):
    w = 1
    b = 1
    for v in g[u]:
        if p == v:
            continue
        wn, bn = dfs(v, u)
        w *= wn + bn
        b *= wn
        w %= M
        b %= M
    return w, b
print(sum(dfs(1, -1))%M)


Measured memory_bytes: 129136
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	string s,t;
	while(cin>>s>>t)
	{
		int minn=(int)t.size();
		for(int i=0;i+(int)t.size()<=(int)s.size();i++)
		{
			int cnt=0;
			for(int j=i;j<i+(int)t.size();j++)
			{
				if(s[j]!=t[j-i])
					cnt++;
			}
			
			if(cnt<minn)
				minn=cnt;
		}
		cout<<minn<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int n, r;
    cin >> n >> r;

    if(n >= 10){
        cout << r << '\n';
    }else{
        cout << r+(100*(10-n)) << '\n';

    }
    
    
    return 0;
}


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

typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差

ld mysqrtl(ld x)
{
	int cnt = 0;
  ld a = sqrt((double)x); // 近似値
  do {
    a = (a + x/a) / 2.0L;
	cnt++;
  } while (cnt < 100000000);
  return a;
}

int main() {
	long double a, b, c;
	cin >> a >> b >> c;
	string ans = "No";
	if( (mysqrtl(a * b) ) < (c-a-b)/2.0 ) ans = "Yes";
	cout << ans << endl;
	return 0;
}

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

prices = [1]
idx = 1
while 6 ** idx <= N:
    prices.append(6 ** idx)
    idx += 1
idx = 1
while 9 ** idx <= N:
    prices.append(9 ** idx)
    idx += 1

prices.sort()

dp = [float('inf') for _ in range(N + 1)]
dp[0] = 0
for n in range(N + 1):
    for price in prices:
        dp[n] = min(dp[n], dp[n - price] + 1)

print(dp[-1])


Measured memory_bytes: 6296
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn main() {
    let s : String = get_one();
    let mut t = "".to_string();
    let mut i = 0;
    for x in s.chars() {
        if i % 2 == 0 {
            t.push(x);
        }
        i += 1;
    }
    println!("{}", t);
}


Measured memory_bytes: 4352
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

a, b, k = MAP()
a -= k
if a<0:
    b+=a
    a = 0
if b<0:
    b=0

print(str(a) + ' ' + str(b))

Measured memory_bytes: 66028
#include<bits/stdc++.h>
#define ll long long int
#define p pair<ll,ll>
#define pp pair<pair<ll,ll>,ll>
#define fi first
#define se second
#define opti ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const ll N = 1e6+6;
ll t,i,j,k,n,m,q;
int main()
{
    opti

        cin>>n;
        ll a[n+10];
        a[0]=0;
        for(i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        a[n+1] = 0;
        ll ans[n+10];
        ans[0]=0;
        for(i=1;i<=n+1;i++)
        {
           ans[i] = ans[i-1] + abs(a[i] - a[i-1]); 
        }
        for(i=1;i<=n;i++)
        {
            cout<<ans[n+1] - (ans[i+1] - ans[i-1]) + abs(a[i+1] - a[i-1])<<endl;
        }
    return 0;
}


Measured memory_bytes: 2816
r,c=map(int,input().split())
a=[list(map(int,input().split())) for i in range(r)]
b=[[0]*(c+1) for i in range(r+1)]


for i in range(r):
    for j in range(c):
        b[i][j]=a[i][j]
        b[r][j]+=a[i][j]
        b[i][c]+=a[i][j]
        b[r][c]+=a[i][j]

for i in b:
  print(*i)


Measured memory_bytes: 6260
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    println!("{}", (n / 2) * (n - n / 2));
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <map>

using namespace std;


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

    map <char, int> M;
    for (int i = 0; i < w.length(); i++){
        M[w[i]] ++;
    }

    bool flag = true;
    for (char i = 'a'; i <= 'z'; i++){
        if (M[i] % 2 == 1){
            flag = false;
            break;
        }
    }

    if (flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N, K; cin >> N >> K;
  vector<int> A(N);
  for(int i=0; i<N; i++)
    cin >> A[i];
  vector<int> divs;
  int Asum = accumulate(A.begin(), A.end(), 0);
  for(int i=1; i*i<=Asum; i++){
    if(Asum%i == 0){
      divs.push_back(i);
      if(i*i != Asum) divs.push_back(Asum/i);
    }
  }
  int Rsum, ans, minKforD, r;
  ans = 1;
  vector<int> R;
  for(auto d: divs){
    for(auto a: A)
      R.push_back(a%d);
    sort(R.begin(), R.end(), greater<int>());
    Rsum = accumulate(R.begin(), R.end(), 0);
    r = Rsum/d;
    minKforD = 0;
    for (int i=0; i<r; i++){ // R[i] != 0 の個数はr以上あるので考えなくていい
      minKforD += d - R[i];
    }
    if(minKforD <= K)
      ans = max(ans, d);
    R.clear();
  }
  
  cout << ans << endl;
  return 0;
}

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

x = 0
l = [0]
s = set([0])
flag = False
for i in range(N):
    x = A[x]-1
    if x in s:
        break
    s.add(x)
    l.append(x)

for i in range(len(l)):
    if l[i]==x:
        break

y = len(l)
z = i

if K<len(l):
    print(l[K]+1)
else:
    #print(z)
    #print(y)
    #
    #print((K-z)%(y-z))
    #print(z)
    print(l[z + (K-z)%(y-z)]+1)

Measured memory_bytes: 124824
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

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

    int k;
    int cnt = 0;
    
    cin >> n >> k;
    if(n % 2){
        //余り有り
        cnt = n / 2 + 1;
    }else{
        cnt = n / 2;
    }
    //cout << cnt << endl;
    if(k <= cnt){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm> 
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 

int main (){
    ll n ;
    cin >> n ;
    if(n == 1){
        cout << 0 << endl ;
        return 0 ;
    }
    ll k = ll(sqrt(double(n))) ;
    vector<bool> is_prime (k + 1, true) ;
    is_prime[0] = false ;
    is_prime[1] = false ; 
    rep(i, k + 1){
        if(is_prime[i]){
            for(int j = 2*i ; j <= k ; j += i){
                is_prime[j] = false ;
            }
        }
    }
    ll ans = 0 ;
    for(int i = 2 ; i <= k ; i++){
        if(n == 1){
            break ;
        }
        ll t = 0 ;
        if(is_prime[i]){
            while(n % i == 0){
                n /= i ;
                t++ ; 
            }
            ll p = 1 ;
            while(1){
                t -= p; 
                if(t < 0){
                    break ; 
                }
                ans++ ; 
                p++ ;
            }
        }
    }
    if(n != 1){
        ans++ ;
    }
    cout << ans << endl ;
    return 0 ;
}

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

int main()
{
   int N,M; cin>>N>>M;
   vector<vector<int>> s(M);
   for(int i=0;i<M;i++){
      int k; cin>>k;
      while(k--){
         int a; cin>>a;
         s[i].push_back(a-1);
      }
   }
   vector<int> p(M);
   for(int i=0;i<M;i++) cin>>p[i];

   int ans=0;
   for(int S=0;S<(1<<N);S++){
      bool ok=true;
      for(int i=0;i<M;i++){
         int cnt=0;
         for(int j:s[i]) if(S>>j&1) cnt++;
         if(cnt%2!=p[i]) ok=false;
      }
      if(ok) ans++;
   }
   cout<<ans<<endl;
   return 0;
}



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

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

  string str = "hi";

  FOR(i,1,5){
    if(S == str) {
      cout << "Yes" << endl;
      return 0;
    }
    str += "hi";
  }

  cout << "No" << endl;
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int D, T, S;
    cin>>D>>T>>S;
    string ans;
    if(T*S >= D) ans = "Yes";
    else ans = "No";
    cout << ans << endl;
}

Measured memory_bytes: 3624
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int mod = 998244353;
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
const int maxN = 2005 * 3;
const int SHIFT = (2005 * 3) / 2;
int dp[maxN][maxN + maxN / 2];
int n;
int c[maxN][4];
inline void upd(int& a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> mod;
    c[0][0] = 1;
    for (int i = 1; i <= 3 * n; i++) {
        c[i][0] = 1;
        for (int j = 1; j < 4; j++) {
            c[i][j] = sum(c[i - 1][j], c[i - 1][j - 1]);
        }
    }
    for (int i = 1; i <= 3 * n; i++) {
        for (int j = 1; j < 4; j++) {
            for (int k = 1; k <= j; k++) {
                c[i][j] = mult(c[i][j], k);
            }
        }
    }
    dp[0][SHIFT] = 1;
    for (int i = 0; i <= 3 * n - 1; i++) {
        for (int bal = -i / 2; bal <= i; bal++) {
            if (!dp[i][bal + SHIFT]) continue;
            int d = dp[i][bal + SHIFT];
            for (int len = 1; len <= 3 && i + len <= 3 * n; len++) {
//                if (i == 0 && len == 3)
                int nxtbal = bal;
                if (len == 1) nxtbal++;
                if (len == 2) nxtbal--;
                upd(dp[i + len][nxtbal + SHIFT], mult(d, c[i + len - 1][len - 1]));

            }
        }
    }
    int sm = 0;
    for (int bal = 0; bal <= 3 * n; bal++) sm = sum(sm, dp[3 * n][bal + SHIFT]);
    cout << sm;
    return 0;
}

Measured memory_bytes: 210176
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << (x) << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << ((a)[qwq]);\
		else cerr << ", " << ((a)[qwq]);\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }
template<typename A, typename B>
ostream& operator << (ostream& out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}

const LL P = 1000000007;
const int maxN = 5000 + 5;
int n, A, B;
LL f[maxN][2], f2[maxN][2], g[maxN], g2[maxN], h[maxN][2][2], p2[maxN];

#define bin(a) for(int a = 0; a < 2; ++a)

int main() {
	cin >> n >> A >> B;
	p2[0] = 1;
	for(int i = 1; i <= n; ++i) p2[i] = p2[i - 1] * 2 % P;
	
	if(A > B) swap(A, B);
	if(A == 1) {
		cout << p2[n] << endl;
		return 0;
	}
	
	memset(h, 0, sizeof(h));
	for(int i = A; i <= B; ++i) h[i][0][0]++;
	for(int i = 1; i <= B; ++i) h[i][1][1]++;
	for(int i = 1; i < B; ++i) {
		for(int j = 1; i + j <= B; ++j)
			bin(a) (h[i + j][a][1] += h[i][a][0]) %= P;
		bin(a) (h[i + A][a][0] += h[i][a][1]) %= P;
		for(int j = A + 1; i + j <= B; ++j)
			bin(a) (h[i + j][a][0] += h[i][a][1]) %= P;
	}
//	for(int i = 1; i <= n; ++i)
//		eprintf("%lld %lld %lld %lld\n", h[i][0][0], h[i][0][1], h[i][1][0], h[i][1][1]);
	for(int i = 1; i < B; ++i) memset(h[i], 0, sizeof(h[i]));
	
	memset(f, 0, sizeof(f));
	memset(g, 0, sizeof(g));
	memset(g2, 0, sizeof(g2));
	memset(f2, 0, sizeof(f2));
	
	for(int i = 1; i <= n; ++i) bin(a) bin(b)
		(f[i][b] += h[i][a][b]) %= P;
	for(int i = 1; i < A; ++i) g2[i]++;
	for(int i = 1; i <= n; ++i) {
		bin(a) (f2[i][a] += f[i][a]) %= P;
		for(int j = 1; i + j <= n; ++j)
			bin(a) bin(b) (f2[i + j][b] += f[i][a] * p2[j - 1]) %= P;
		g[i] = (P + p2[i - 1] - f2[i][1]) % P;
		for(int j = 1; j < A && i + j <= n; ++j) (g2[i + j] += g[i]) %= P;
		
		for(int j = 1; i + j <= n; ++j) bin(b)
			(f[i + j][b] += g2[i] * h[j][1][b]) %= P;
	}
//	displaya(g, 1, n);
//	displaya(g2, 1, n);
	cout << ((f2[n][0] + f2[n][1]) % P) << endl;
	return 0;
}



Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int sum=0;
  sum += (N/100000000)%10;
  sum += (N/10000000)%10;
  sum += (N/1000000)%10;
  sum += (N/100000)%10;
  sum += (N/10000)%10;
  sum += (N/1000)%10;
  sum += (N/100)%10;
  sum += (N/10)%10;
  sum += N%10;
  if (N%sum == 0){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}
  


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

int main() {
   int N;
   cin >> N;
   int A[N];
   for (int i=0; i<N; i++) {
       cin >> A[i];
   }
   sort(A,A+N);
   long long count=0;
   for (int i=1; i<N; i++) {
       count+=A[N-i/2-1];
   }
   cout << count << endl;
}

Measured memory_bytes: 4372
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String[] S = new String[N];
		for( int i=0; i<N; i++ ){
			S[i] = sc.next();
			String[] str = new String[10];
			for( int j=0; j<10; j++ ){
				str[j] = String.valueOf(S[i].charAt(j));
			}
			Arrays.sort(str);
			S[i] = "A";
			for( int j=0; j<10; j++ ){
				S[i] += str[j];
			}
		}
		Arrays.sort(S);
		long ans = 0;
		long count = 1;
		for( int i=1; i<N; i++ ){        
			if( S[i].equals(S[i-1]) ){
				count++;
            }              
			if( !(S[i].equals(S[i-1])) || i==N-1 ){           
				ans += count*(count-1)/2;           
				count = 1;
			}
		}   
		System.out.println(ans);
	}
}


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

int main(){
  int N,A,B,P1,P2;
  cin >> N >> A >> B;
  P1=A*N,P2=B;
  if(P1<=P2){
    cout << P1 <<endl;
  }
  else{
    cout << P2 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

int N, A, B;
string s;
int ans[100005];

void solve() {
	int bb = 0;
	int ab = 0;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'a') {
			if (ab < A + B) {
				ans[i] = 1;
				ab += 1;
			}
		} else if (s[i] == 'b') {
			if (ab < A + B && bb + 1 <= B) {
				ans[i] = 1;
				bb += 1;
				ab += 1;
			}
		} 
	}
	for (int i = 0; i < N; i++) {
		if (ans[i] == 1) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

int main() {
	cin >> N >> A >> B;
	cin >> s;
	solve();
	return 0;
}




Measured memory_bytes: 1280
N,Y = map(int,input().split())

ans = -1,-1,-1
for x in range(N+1):
    for y in range(N+1-x):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y:
            ans = x,y,z
            break
    else:
        continue

print(*ans)

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

struct robot {
	int X;
	int from;
	int to;
};


bool fromSort(const robot& a, const robot& b) {
	return a.from < b.from;
}

int main(void) {
	int N;
	cin >> N;
	vector <robot> r(N);
	for (int i = 0; i < N; i++) {
		int X, L;
		cin >> X >> L;
		r[i].X = X;
		r[i].from = X-L;
		r[i].to = X+L;
	}

	int ans = N;
	sort(r.begin(), r.end(), fromSort);

	int lpos = 0;
	int rpos = 1;
	while ((lpos < N) && (rpos < N)) {
		int l1 = r[lpos].from;
		int r1 = r[lpos].to;
		int l2 = r[rpos].from;
		int r2 = r[rpos].to;

		if (r1 <= l2) { // ぶつからない
			lpos = rpos;  // 左側は消さなくてよい
			rpos = lpos+1;
		} else { // より右側まで伸びている方を消す
			if (r1 < r2) {
				// 右側を消す
				ans--;
				rpos += 1;
			} else {
				// 左側を消す
				ans--;
				lpos = rpos;
				rpos = lpos+1;
			}
		}
	}
	cout << ans << endl;
  return 0;
}


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

int main(){
 	int a, b;	
  	cin >> a >> b;
	vector<int> A(1000), B(1000);
  	
  	vector<int> yen;
  	for(int i = 0; i < 1000; i++){
    	A.at(i) = floor(double((i+1)*0.08));
      	B.at(i) = floor(double((i+1)*0.1));
      	
      	if((a == A.at(i))&&(b == B.at(i))){
        	yen.push_back(i+1);
        }
    }
  		
  	if(yen.size() == 0){cout << -1 << endl;}
  	else{cout << yen.at(0) << endl;}
  	
}	

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

int main(void)
{
    int n, c=0;
    char s[51];

    scanf("%d%s", &n, s);

    for (int i=0; i<n-2; i++) {
        if (strncmp(s+i, "ABC", 3)==0) c++;
    }

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

    return 0;
}

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

map<int,int> mp;
int main(){
	int n, a, ans = 0;
	scanf("%d", &n);
	for(int i = 0;i < n;i++){
		scanf("%d", &a);
		if(mp[a]){
			mp[a] = 0;
			ans--;
		}else{
			mp[a] = 1;
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll);
ll mod_fact(ll, ll);
ll mod_inv(ll, ll);
ll gcd(ll, ll);
//
int main(){
    int k;
    cin >> k;
    if(k <= 9) {cout << k; return 0;}
    queue<ll> q;
    for(int i = 1; i <= 9; i++) q.push(i);
    int cnt = 1;
    while(cnt < k){
        auto i = q.front();
        q.pop();
        int d = i % 10;
        if(d == 0){
            q.push(i * 10);
            q.push(i * 10 + 1);
        }else if(d == 9){
            q.push(i * 10 + 8);
            q.push(i * 10 + 9);
        }else{
            q.push(i * 10 + d - 1);
            q.push(i * 10 + d);
            q.push(i * 10 + d + 1);
        }
        cnt++;
    }
    cout << q.front();
}

Measured memory_bytes: 1792
// C++ program to count 
// trailing 0s in n! 
#include <iostream> 
using namespace std; 

// Function to return trailing 
// 0s in factorial of n 
long long findTrailingZeros(long long n) 
{ 
	// Initialize result 
	long long count = 0; 

	// Keep dividing n by powers of 
	// 5 and update count 
	for (long long i = 10; n / i >= 1; i *= 5) 
		count += (n / i); 

	return count; 
} 

// Driver Code 
int main() 
{ 
	long long n;
  cin >> n;
  if(n%2 == 0)
	cout << findTrailingZeros(n);
  else cout << 0;
	return 0; 
} 


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, M: int):
    if N >= M // 2:
        print(M // 2)
    else:
        print(N + (M - N*2) // 4)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll n;
    cin >> n;
    for(ll i = 1; i <= 50000; i++){
        double k = (double)i*(1.08);
        ll x = (ll) k;
        if(x == n) ANS(i);
    }
    ANS(":(")
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


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

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

print(1+p.index(p[c]+(K-p[c])%(i-p[c]) if K>=p[c] else K))


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

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 1000000007;
using mint = Fp<MOD>;


int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}

//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap
auto pfactor(int n){
  map<int,int> res;
  int t=sqrt(n);
  for(int i=2;i<=t;i++){
    for(;n%i==0;n/=i)res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
vector<int>kai(0);
void kaizyou(vector<int>&kai){
    rep(i,kai.size()){
        kai[i+1]=kai[i]*(i+1)%MOD;
      }
  }
int comb(int a,int b){
  return (kai[a]*gyaku(kai[a-b]))%MOD*gyaku(kai[b])%MOD;
}
////////////////////////////////////////////////////////////////////////
signed main() {
  int n;
  cin>>n;
  if(n>=30)cout<<"Yes";
  else cout<<"No";
  }


Measured memory_bytes: 3716
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s, t, u;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  
  if(s==u){
    cout << a-1 << " " << b << endl;
  } else {
    cout << a << " " << b-1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256