jiahuimbzuai/CoQuIR huggingface dataset:
//  [typescript]
{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    const [H, N] = r.nn()
    const A = r.nn()

    const sum = A.reduce((a, b) => b + a, 0)

    return H - sum > 0 ? 'No' : 'Yes'
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}
//  [python]
N = int(input())
X = list(map(int, input().split()))

argsort = [[x, i] for i, x in enumerate(X)]
argsort.sort()

indices = {(i + 1): x for i, (x, _) in enumerate(argsort)}

argsort = [[i, j] for j, [_, i], in enumerate(argsort)]
argsort.sort()

ranks = [j + 1 for _, j in argsort]

median = N // 2
for i in range(0, N):
    r = ranks[i]
    if r <= median:
        print(indices[median + 1])
    else:
        print(indices[median])
//  [python]
n = int(input())
a = list(map(int, input().split()))

import numpy as np
b = np.argsort(a)
idx = np.argsort(b)
for i in range(n):
    if idx[i] < n / 2:
        print(a[b[int(n / 2)]])
    else:
        print(a[b[int(n / 2) - 1]])
//  [python]
import numpy as np

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

M = np.median(X)

Y = sorted(X)
a = Y[int(len(Y)/2 - 1)]
b = Y[int(len(Y)/2)]

for x in X:
    if x <= a:
        print(b)
    else:
        print(a)
//  [java]
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.Map.Entry;

public class Main{
	
	public static void main(String[] args) throws IOException{
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		ArrayList<int[]> list1 = new ArrayList<>();
		for(int i = 0; i < N; i++){
			int index = i;
			int x = in.nextInt();
			int[] p = {index, x};
			list1.add(p);
		}
		Collections.sort(list1, (p1,p2)->Integer.compare(p1[1],p2[1]));
		
		ArrayList<int[]> list2 = new ArrayList<>();
		int m1 = list1.get(N / 2 - 1)[1], m2 = list1.get(N / 2)[1];
		
		for(int i = 0; i < N; i++){
			int[] p = list1.get(i);
			int index = p[0];
			int mx;
			if(i <= N / 2 - 1) mx = m2;
			else mx = m1;
			int[] pp = {index, mx};
			list2.add(pp);
		}
		Collections.sort(list2, (p1,p2)->Integer.compare(p1[0],p2[0]));
		
		for(int[] p : list2) System.out.println(p[1]);
	}
}
//  [java]
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();

			List<Long> orglist = new ArrayList<>(n);
			for (int i = 0; i < n; i++) {
				orglist.add(scanner.nextLong());
			}

			List<Long> sortList = new ArrayList<>(orglist);
			Collections.sort(sortList);

			int pos = n / 2;
			long val1 = sortList.get(pos - 1);
			long val2 = sortList.get(pos);

			for (int i = 0; i < n; i++) {
				long val = orglist.get(i);
				if (val <= val1) {
					System.out.println(val2);
				} else {
					System.out.println(val1);
				}
			}
		}
	}
}
//  [java]
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int X[][]=new int[N][2];
		int A[]=new int[N];
		int z=0,y=N/2;
		while(z<N){
			X[z][0]=stdIn.nextInt();
			X[z][1]=z;
			z++;
		}z=0;
		Arrays.sort(X, (a, b) -> Long.compare(a[0], b[0]));
		while(z<N){
			if(z<y)
				A[X[z][1]]=X[y][0];
			if(z==y)
				A[X[z][1]]=X[y-1][0];
			if(z>y)
				A[X[z][1]]=X[y-1][0];
			z++;
		}z=0;
		while(z<N){
			System.out.println(A[z]);
			z++;
		}
	}
}
//  [cpp]
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main(){

    // It's one of two elements though right? 

    // So I think we need to sort these ... we do ... 
    // Is it just one of two values?

    // Do we need to do the sum like maths is fun ... ? No because we are always removing one so always be odd. 

    // 6
    // 5 5 4 4 3 3
    // 3 3 4 4 5 5
    // 4 4 4 4 4 4
    


    // needs to maintain original indexes ...
    // vector< vector<int> > indexes 


    // 4

    // 2 4 4 3

    // 2 3 4 4

    // 4 3 3 4

    // 4 4 3 3 


    // 

    int n;
    cin >> n;

    map< int, vector<int> > indexes;
    
    int original[n];
    int nums[n];
    
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
        original[i] = nums[i];
    }

    sort(nums, nums + n);

    for (int i = 0; i < n; i++) {
        indexes[nums[i]].push_back(i + 1);
    }

    int med1 = nums[(n / 2) - 1];
    int med2 = nums[(n / 2)];

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

        int org_num = original[i];
        int org_indx = indexes[original[i]][0];
        indexes[original[i]].erase(indexes[original[i]].begin());

        // cout << " i : " << i + 1 << " n : " << n << " (n / 2) + 1 : " << (n / 2) + 1 << " (n / 2) : " << (n / 2) << endl; 
        // cout << " original[i] : " << org_num << " org_indx : " << org_indx << endl;

        if (org_indx == (n / 2) + 1){
            cout << med1 << endl;
        }
        else if (org_indx == (n / 2)){
            cout << med2 << endl;
        }
        else if (org_indx < (n / 2) + 1){
            cout << med2 << endl;
        } else {
            cout << med1 << endl;
        }

    }


    return 0;
}
//  [cpp]
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;



int main() 
{
  ll N; cin>>N;
  vector<pair<ll,ll>> vecX(N);
  rep(i,N)
  {
    cin>>vecX.at(i).first;
    vecX.at(i).second=i;
  }
  sort(vecX.begin(),vecX.end());
  map<ll,ll> mapX;
  rep(i,N)
  {
    if(i<N/2) {mapX[vecX.at(i).second]=vecX.at(N/2).first; continue;}
    mapX[vecX.at(i).second]=vecX.at(N/2-1).first;
  }  
  rep(i,N)
  {
    cout<<mapX.at(i)<<endl;
  }  
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>

uint32_t numList[200000];
uint32_t numListSorted[200000];

int cmpfunc(const void * a, const void * b) {
	return *(uint32_t *)a - *(uint32_t *)b;
}

static void printMedians(const uint32_t * const numList, const uint32_t * const numListSorted, const uint32_t listSize) {
	const uint32_t medianLeft = numListSorted[listSize / 2 - 1];
	const uint32_t medianRight = numListSorted[listSize / 2];

	for (uint32_t idx = 0; idx < listSize; idx++) {
		if (numList[idx] <= medianLeft) {
			printf("%I32u\n", medianRight);
		}
		else {
			printf("%I32u\n", medianLeft);
		}
	}
}

int main(void) {
	uint32_t listSize;

	scanf("%I32u\n", &listSize);

	for (uint32_t idx = 0; idx < listSize - 1; idx++) {
		scanf("%I32u ", &(numList[idx]));
	}
	scanf("%I32u", &(numList[listSize - 1]));
	memcpy(numListSorted, numList, sizeof(uint32_t)*listSize);

	qsort(numListSorted, listSize, sizeof(uint32_t), cmpfunc);

	printMedians(numList, numListSorted, listSize);

	return 0;
}
//  [c]
/*2019/10/02 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}

typedef struct{
    int x;
    int i;
    int rank;
}group_t;
 
int asc1_t(const void *a,const void *b){if(((group_t*)a)->x < ((group_t*)b)->x)return -1;else if(((group_t*)a)->x == ((group_t*)b)->x)return 0;else return 1;}
int asc2_t(const void *a,const void *b){if(((group_t*)a)->i < ((group_t*)b)->i)return -1;else if(((group_t*)a)->i == ((group_t*)b)->i)return 0;else return 1;}
//int desc_t(const void *a,const void *b){if((group_t*)a->d < (group_t*)b->d)return 1;else if((group_t*)a->d == (group_t*)b->d)return 0;else return -1;}

int main(){
    int n;
    int x[200000];
    group_t group[200000];
    int midl,midr;

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x[i]);
        group[i].x=x[i];
        group[i].i=i;
    }
    qsort(group,n,sizeof(group_t),asc1_t);
    midl=group[n/2-1].x;
    midr=group[n/2].x;
    for(int i=0;i<n;i++){
        group[i].rank=i;
    }
    qsort(group,n,sizeof(group_t),asc2_t);

    for(int i=0;i<n;i++){
        if(group[i].rank<n/2){
            printf("%d\n",midr);
        }else{
            printf("%d\n",midl);
        }
    }
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int x[200005];
int sorted[200005];

int int_compare(int *x, int *y);

void trickle_down(void *base, size_t i, 
		size_t n_memb, size_t data_size,
		int (*compare)(const void *, const void *));

void sort(void *base, size_t n_memb, size_t data_size, 
		int (*compare)(const void *, const void *));

void memswap(void *x, void *y, size_t size);

int main()
{
	int n;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x[i]);

		sorted[i] = x[i];
	}

	sort(sorted, n, sizeof(int), (int (*)(const void *, const void *))int_compare);

	for (int i = 0; i < n; i++) {
		if (x[i] < sorted[n / 2]) {
			printf("%d\n", sorted[n / 2]);
		} else {
			printf("%d\n", sorted[n / 2 - 1]);
		}
	}

	return 0;
}


//ソート本体(ヒープソート)
void sort(void *base, size_t n_memb, size_t data_size, 
		int (*compare)(const void *, const void *))
{
	int i;

	//ヒープ構築
	for (i = n_memb / 2; i >= 0; i--) {
		trickle_down(base, i, n_memb, data_size, compare);
	}

	//最大のものを末尾へ移動し、ヒープを再構築
	for (i = n_memb - 1; i >= 1; i--) {
		memswap((unsigned char *)base,
				(unsigned char *)base + (data_size * i), data_size);

		trickle_down(base, 0, i, data_size, compare);
	}

	return;
}

//上のソートに必要なヒープ性を保つ関数
//みんなのデータ構造 p181 参考
void trickle_down(void *base, size_t i, 
		size_t n_memb, size_t data_size,
		int (*compare)(const void *, const void *))
{
	size_t l, r;
	size_t j = i;
	unsigned char *arr = base;
	
	do {
		i = j;

		r = 2 * i + 2;
		l = 2 * i + 1;

		if (l < n_memb &&
				compare(arr + l * data_size, arr + j * data_size) > 0) {
			j = l;
		}

		if (r < n_memb &&
				compare(arr + r * data_size, arr + j * data_size) > 0) {
			j = r;
		}

		if (i != j) {
			memswap(arr + i * data_size, arr + j * data_size, data_size);
		}

	} while (i != j);

	return;
}

//比較関数群
int int_compare(int *x, int *y)
{
	if (*x > *y) {
		return 1;
	} else if (*x == *y) {
		return 0;
	} else {
		return -1;
	}
}

void memswap(void *x, void *y, size_t size)
{
	if (x != y) {
		while (size--) {
			*((unsigned char *)x + size) ^= *((unsigned char *)y + size);
			*((unsigned char *)y + size) ^= *((unsigned char *)x + size);
			*((unsigned char *)x + size) ^= *((unsigned char *)y + size);
		}
	}

	return;
}
//  [javascript]
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt()
    let X = cin.getIntArray(N).map((v, i) => { return { value: v, index: i } });
    X.sort((a, b) => a.value - b.value);
    let P = new Array(N);
    for (let n = 0; n < N; n++) {
        P[X[n].index] = n;
    }
    let c = N / 2;
    for (let n = 0; n < N; n++) {
        let i = P[n] >= c ? c - 1 : c;
        console.log(X[i].value);
    }
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'

function main(input) {

    input = input.split('\n')
    let n = ~~input[0]
    let x = input[1].split(' ').map(v => ~~v) //.sort((a, b) => a - b)
    let x2 = input[1].split(' ').map(v => ~~v).sort((a, b) => a - b)
    let mid = x2[n / 2]
    let index = 0
    for (let i = 0; i < n; i++) {

        // 
        if (x[i] < mid) {
            index = (n) / 2

        } else {
            index = (n) / 2 - 1
        }

        console.log(x2[index])

    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0].split(" ")[0]);
    var X = lines[1].split(" ").map(i => Number(i));
    var ans = 0;

    var x = X.concat().sort((a, b) => a - b);

    // 削除するX[i]がx[N/2]以下なら，中央値はx[N/2]
    // 削除するX[i]がx[N/2]以上なら，中央値はx[N/2-1]
    for (var i = 0; i < N; i++) {
        if (X[i] < x[N / 2]) { ans = x[N / 2] }
        else { ans = x[N / 2 - 1] }

        console.log(ans)
    }
});
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	xs := make([]int, n)
	for i := range xs {
		fmt.Scan(&xs[i])
	}
	ys := make([]int, n)
	copy(ys, xs)
	sort.Ints(ys)
	ml, mr := ys[n/2-1], ys[n/2]
	for _, x := range xs {
		if x <= ml {
			fmt.Println(mr)
		} else {
			fmt.Println(ml)
		}
	}
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	all := make([]int, N)
	preall := make([]int, N)
	ReadN(all, 0, N)
	copy(preall, all)
	sort.Ints(all)

	s := all[N/2]
	m := N - 1 - N/2

	for i := 0; i < len(preall); i++ {
		if s > preall[i] {
			fmt.Println(s)
		} else {
			fmt.Println(all[m])
		}
	}
}

func ReadN(all []int, i, n int) {
	if n == 0 {
		return
	}
	if m, err := Scan(&all[i]); m != 1 {
		panic(err)
	}
	ReadN(all, i+1, n-1)

}

func Scan(a *int) (int, error) {
	return fmt.Scan(a)
}

func remove(ints []int, index int) []int {
	result := []int{}
	for i := 0; i < len(ints); i++ {
		if i != index {
			result = append(result, ints[i])
		}
	}
	return result
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}
	tmp := make([]int, len(nums))
	copy(tmp, nums)
	sort.Ints(tmp)
	l := tmp[n/2-1]
	r := tmp[n/2]
	for i := 0; i < n; i++ {
		v := nums[i]
		if l < v {
			fmt.Println(l)
		} else {
			fmt.Println(r)
		}
	}
}
//  [ruby]
n   = gets.to_i
ary = gets.split.map(&:to_i)

n.times do |i|
  ary[i] = [ary[i], i]
end

ary.sort!

n.times do |i|
  ary[i] << ary[n / 2 - i / (n / 2)][0]
end

ary.sort_by{|a| a[1]}.each do |x|
  puts x[2]
end
//  [ruby]
n = gets.to_i
xs = gets.split.map(&:to_i)
ys = xs.sort
med = {}
ys.each_with_index do |y, i|
  if i < n / 2
    med[y] = ys[n / 2]
  else
    med[y] = ys[n / 2 - 1]
  end
end
xs.each { |x| p med[x] }
//  [ruby]
n = gets.chomp.to_i
x = gets.chomp.split(' ').map(&:to_i)

a = []
n.times{|i| a.push( {:index => i, :value => x[i]} )}
a.sort!{|lhs, rhs| lhs[:value] <=> rhs[:value]}

b = [0] * n
n.times{|i| b[ a[i][:index] ] = i }

n.times do |i|
  j = b[i]
  
  if j >= (n / 2) then
    puts a[(n / 2) - 1][:value].to_s
  else
    puts a[n / 2][:value].to_s
  end
end
//  [rust]
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut x: Vec<(usize, i64)> = (0..n).map(|i| (i, read())).collect();

    x.sort_by_key(|&k| k.1);
    let candidate = [x[(n / 2) - 1].1, x[n / 2].1];
    for i in 0..n / 2 {
        x[i].1 = candidate[1];
    }
    for i in n / 2..n {
        x[i].1 = candidate[0];
    }
    x.sort_by_key(|&k| k.0);

    for x_i in x {
        println!("{}", x_i.1);
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}
//  [python]
a = int(input())
b = input()
#print(a)
#print(b)

num = b.count('ABC')
print(num)
//  [python]
N = int(input())
S = input()

count = sum(1 for i in range(N - 2) if S[i:i + 3] == "ABC")
print(count)
//  [python]
n = input()
s = input()
print(s.count('ABC'))
//  [python]
N = int(input())
S=str(input())
cnt=0
for i in range(N-2):
    if S[i:i+3] =='ABC':
        cnt+=1
print(cnt)
//  [python]
# -*- coding: utf-8 -*-
import numpy as np

n = int(input())
s = str(input())

state = 0
ans = 0

for i in range(n - 2):
    letters = s[i] + s[i + 1] + s[i + 2]
    if letters == 'ABC':
        ans += 1

print(ans)
//  [python]
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

n = int(sys.stdin.buffer.readline())
s = sys.stdin.buffer.readline().decode().rstrip()

ok = 0
for i in range(len(s)):
    if s[i:i+3] == 'ABC':
        ok += 1
print(ok)
//  [java]
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		String s = br.readLine();
		br.close();

		int ans = 0;
		int idx = 0;
		while (idx < n) {
			idx = s.indexOf("ABC", idx);
			if (idx >= 0) {
				ans++;
				idx++;
			} else {
				break;
			}
		}
		System.out.println(ans);
	}
}
//  [java]
import java.util.*;
import java.lang.*;
import java.util.stream.*;
import java.util.function.*;

// 文字列を一文字ずつ配列にしてStream
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] firstArr = sc.nextLine().split(" ");
        System.out.println(solve(getInputAsArray(sc, "1")));
    }

    private static List<String[]> getInputAsArray(Scanner sc, String count) {
        List<String[]> result = new ArrayList<>();
        IntStream.range(0, Integer.parseInt(count)).forEach(i -> result.add(sc.nextLine().split(" ")));
        return result;
    }

    private static Long[] convertStrToInt(String[] strArray) {
        return Arrays.stream(strArray).map(e -> new Long(Long.parseLong(e))).toArray(Long[]::new);
    }

    private static long outputResult(long a, long b) {
        return LongStream.range(0, b).reduce((long) 0, (sum, i) -> sum += (Math.pow(10, i) * a));
    }

    private static String solve(List<String[]> input) {
        Predicate<String> predicate = (str) -> str.equals("A") || str.equals("B") || str.equals("C");
        BiPredicate<String, String> strCheker = (accum, str) -> {
            // System.out.println(accum + " " + str);
            Map<String, String> map = new HashMap<>();
            map.put("A", "");
            map.put("B", "A");
            map.put("C", "AB");
            return accum.equals(map.get(str));
        };
        ArrayList<String> result = new ArrayList<>();
        Arrays.stream(input.get(0)[0].split("")).reduce("", (accum, value) -> {
            // System.out.println("---" + accum + "----" + value);
            if (value.equals("A")) {
                return "A";
            }
            if (strCheker.test(accum, value)) {
                accum += value;
            } else {
                return "";
            }
            if (accum.equals("ABC")) {
                // System.out.println("avc");
                result.add(value);
                return "";
            }
            return accum;
        });
        return String.valueOf(result.size());
    }
}

class Resp {
    private long min = Long.MAX_VALUE;
    private int cont = 0;

    public Resp(long min, int cont) {
        this.min = min;
        this.cont = cont;
    }

    public long getMin() {
        return this.min;
    }

    public void setMin(long min) {
        this.min = min;
    }

    public int getCont() {
        return this.cont;
    }

    public void setCont(int cont) {
        this.cont = cont;
    }

    public void addCont() {
        this.cont++;
    }

}
//  [java]
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    final int n = scanner.nextInt();
    final String s = scanner.next();
    final String s1 = s.replaceAll("ABC", "a");
    List<String> sl = Arrays.asList(s1.split(""));
    System.out.println(sl.stream()
        .filter(e -> e.equals("a"))
        .count());
  }
}
//  [java]
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();

		int count = (int)IntStream.range(0, n - 2).filter(i -> s.substring(i, i + 3).equals("ABC")).count();
		System.out.println(count);
	}
}
//  [cpp]
#include <stdio.h>
int main(void){
  
  int n,abc=0,i;
  char s[51];
  
  scanf("%d",&n);
  scanf("%s",s);
  
  for(i=0; i<n-2; i++) if(s[i]=='A') if(s[i+1]=='B') if(s[i+2]=='C') abc++;
    
  printf("%d",abc); 
    
    return 0;  
}
//  [cpp]
#include <stdio.h>
int main(void){
  
  int n,abc=0,i;
  char s[50];
  
  scanf("%d",&n);
  scanf("%s",s);
  
  for(i=0; i<n-2; i++) if(s[i]=='A') if(s[i+1]=='B') if(s[i+2]=='C') abc++;
    
  printf("%d",abc); 
    
    return 0;  
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, count = 0;
  string S;
  cin >> N >> S;
 
  for ( int i = 0; i < ( N - 2 ); i++ ) {    
    if( S.compare( i, 3, "ABC" ) == 0 ) {
      count++;
    }
  } 
  cout << count << endl;
  return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n;
	cin>>s;
	int cnt=0;
	for(int i=0;i<n;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			cnt++;
		} 
	}
	cout<<cnt;
	return 0;
}
//  [c]
#include <stdio.h>
#define MAX 100
int main(){
    int n;
    int ans=0;
    char s[MAX];
    scanf("%d %s", &n, s);
    for (int i = 0; i <n ; ++i) {
        if(s[i]=='A' && s[i+1]=='B'&& s[i+2]=='C'){
            ans++;
        }
    }
    printf("%d", ans);
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
	int n;
	char s[50]={'\0'};
	int i,ans=0;

	scanf("%d\n",&n);
	scanf("%s",s);
	for(i=0;i<n;i++){
		if(s[i]=='\0'||s[i+1]=='\0'||s[i+2]=='\0'){
			break;
		}
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll nCr(int n,int k){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(void){
  int n;
  scanf("%d",&n);
  char s[n+1];
  scanf("%s",s);
  int ans=0;
  FOR(n-2){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      i+=2;
      ans++;
    }
  }
  PRN(ans);
  return 0;
}
//  [c]
#include<stdio.h>
int main()
{
    char s[51];
    int n,i,count=0;
    scanf("%d %s",&n,s);
    for(i=0;i<n;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}
//  [c]
main(c,s)char*s;{for(scanf("%*d%s");s=strstr(s,"ABC");++c)++s;printf("%d",c-1);}
//  [c]
#include<stdio.h>
#include<string.h>
typedef long long int lli;
int main() {
  int n,i,cnt=0;
  scanf("%d", &n);
  char s[n];
  scanf("%s", &s);
  for(i=0;i<n-2;i++){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
      cnt++;
    }
  }

  printf("%d", cnt);
  return 0;
}
//  [javascript]
'use strict';
console.log(function(args){
  const _tmp = args.trim().split('\n');
  const N = _tmp[0]|0;
  const S = _tmp[1];
  let count = 0;
  for ( let i = 0; i + 3 <= N; i++ ) {
    if ( S.slice(i,i+3) === 'ABC' ) count++;
  }
  return count.toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));
//  [javascript]
function Main (input) {
  input = input.split("\n");
  var N = parseInt(input[0], 10);
  var S = input[1].split("");
  var ans = 0;
  for (var i = 0; i < N; i++) {
    if (S[i] == "A" && S[i+1] == "B" && S[i+2] == "C") {
      ans++;
    }
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input){
    input = input.split('\n');
    inputN = parseInt(input[0]);
    inputS = input[1];
    leng = inputS.length;
    out = 0;

    for(i=0;i<leng-2;i++){
        if(inputS[i]=='A' && inputS[i+1]=='B' && inputS[i+2]=='C'){
            out++;
        }
    }

    console.log(out);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  let S = input[1];
  const trg = 'ABC';

  let ret = 0;
  while(true){
    let num = S.indexOf(trg)
    if(num !== -1){
      S = S.slice(num+3);
      ret += 1;
    } else {
      break;
    }
  }

  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";

function Main(input) {
	let textNum = input.split('\n')[0]*1;
  	let text = input.split('\n')[1];
  	let ans = 0;
  	for(let i =0; i< textNum - 2; i++){
    	if(text[i]== "A" 
           && text[i + 1]== "B"
           && text[i + 2]== "C"
        ){
        	ans++;
        }
    }
  	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){e.exports=require("fs")},function(e,t,n){"use strict";n.r(t);var r=n(0);!function(e){e.split("\n")[0];var t=e.split("\n")[1].match(/ABC/g);t?console.log(t.length):console.log(0)}(r.readFileSync("/dev/stdin","utf8").trim())}]);
//  [go]
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	_ = sc.i()
	S := sc.s()

	fmt.Println(strings.Count(S, "ABC"))

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}
//  [go]
package main

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

func solve() {
	n := getInt()
	s := getString()

	ans := 0
	abc := "ABC"
	for i := 0; i+len(abc) <= n; i++ {
		if s[i:i+len(abc)] == abc {
			ans++
		}
	}
	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}
//  [go]
package main
 
import (
	"fmt"
	"regexp"
)
 
func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
 
	r := regexp.MustCompile(`ABC`)
	fmt.Println(len(r.FindAllStringSubmatch(s, -1)))
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	s := nextStr()

	cnt := 0
	for i := 0; i < n-2; i++ {
		if s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C' {
			cnt++
		}
	}

	fmt.Println(cnt)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
//  [go]
package main

import (
    "fmt"
)

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

    var result string = "ABC"

//    var slice = strings.Split(s, "")

    var j int = 0
    for i := 0; i <= n-3; i++  {
        var char string = s[i:i+3]
        if char == result {
            j++
        }
    }
    fmt.Println(j)

}
//  [ruby]
#!/usr/bin/env ruby
# require 'pry'

n = gets.chomp
s = gets.chomp

ary=s.scan('ABC')
puts ary.length
//  [ruby]
n = gets.chomp
s = gets.chomp
counter = 0

while s.include?('ABC')
  s.slice!('ABC')
  counter += 1
end

print counter
//  [ruby]
N = gets.to_i
S = gets.chomp.to_s
puts (S.scan(/ABC/)).length
//  [ruby]
n = gets.to_i
s = gets.chomp

ans = 0
(s.length-2).times do |i|
  if s[i..(i+2)] == "ABC"
    ans += 1
  end
end

puts ans
//  [ruby]
a=gets.to_i
b=gets.chomp
puts b.scan("ABC").length
//  [ruby]
def main
  n = gets.to_i
  s = gets.chomp
  cnt = 0
  (0..n-3).each do |i|
    if s[i,3] == "ABC"
      cnt += 1
    end
  end
  puts cnt
end

main
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let s: String = read();
    let mut cnt = 0;
    for i in 0..n - 2 {
        if &s[i..i + 3] == "ABC" {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}
//  [rust]
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut cnt = 0;
	for number in 0..(buf.len() - 3) {
		let s = &buf[number..(number+3)];
		if s == "ABC" {
			cnt = cnt + 1;
		}
	}
	println!("{}", cnt);
}
//  [rust]
use proconio::input;

fn main() {
  input! {
    N: usize,
    S: String,
  }
  let mut result = 0;
  for i in 0..N - 2 {
    if S[i..i + 3] == String::from("ABC") {
      result += 1;
    }
  }
  println!("{}", result);
}
//  [swift]
let a=Int(readLine()!)!
let s=Array(readLine()!.characters)

var ans = 0
var i = 0
for i in 0..<a {
  if ( (i + 3 <= a) ) {
  	if(s[i] == "A" && s[i + 1] == "B" && s[i + 2] == "C") {
      ans += 1
    }
  } else {
    break
  }
}

print(ans)
//  [swift]
let n=Int(readLine()!)!
var k=readLine()!
let t=Array(k)
var count=0
for i in 0...n-3{
  if t[i]=="A" && t[i+1]=="B" && t[i+2]=="C"{
    count+=1
  }
}
print(count)
//  [swift]
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readStr() -> [String] {
  let str:String = readLine()!
  let arr:[String] = str.components(separatedBy: " ")
  return arr
}

let nb=readInts()
let n=nb[0]
let strs=readStr()
let S=strs[0]

var ans=0

for i in 0..<n-2{
  let c1=S[S.index(S.startIndex,offsetBy:i)]
  let c2=S[S.index(S.startIndex,offsetBy:i+1)]
  let c3=S[S.index(S.startIndex,offsetBy:i+2)]
  if (c1=="A")&&(c2=="B")&&(c3=="C"){ans+=1}
}

print(ans)
//  [typescript]
import * as fs from 'fs';

//in
// 10
// ZABCDBABCQ
//out
// 2
function main(inp: string): void {
    const n: number = parseInt(inp.split('\n')[0]);
    const s: string = inp.split('\n')[1];

    let ans: number = 0;
    let idx: number = 0;
    while (s.indexOf('ABC', idx) > -1) {
        ans++;
        idx = s.indexOf('ABC', idx) +1;
    }
    console.log(ans);
}

main(fs.readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    const [N] = r.nn()
    const [S] = r.ss()

    let res = 0

    for (let i = 0; i < N - 2; i++) {
      if (S[i + 0] + S[i + 1] + S[i + 2] === 'ABC') {
        res++
      }
    }

    return res
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};const isPrime=(n:number):boolean=>{if(n<2)return false;const suq=Math.sqrt(n);for(let i=2;i<=suq;i++){if(n%i==0){return false;}}return true;};
const main=()=>{
  let [n,s]=[tn(),ts()],c=0
  for(let i=0;i<n-2;i++){
    if(s[i]=='A'&&
    s[i+1]=='B'&&
    s[i+2]=='C')c++
  }
  to(c)
}
main()
//  [typescript]
function main(input) {
  inputs = input.split("\n")
  len = inputs[0]
  str = inputs[1]
  
  let index = 0
  let count = 0
  while (index + 3 <= len) {
    if (str.substr(index, 3) == "ABC") {
      count++
    }
    index++
  }
  console.log(count)
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));
//  [typescript]
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);


const n : number = +input[0];
const s : string = input[1];
const ss = s.split('');

let ans : number = 0;

for  (let i = 0; i < n-2; i++){
    if (ss[i] !== 'A'){ continue; }
    if (ss[i+1] === 'B' && ss[i+2] === 'C'){
        ans += 1;
    }
}
console.log(ans);
//  [python]
def simulator(n, a, b, s):
    print()
    boolean_list = ['No'] * n
    count = 0
    for i in range(n):
        if s[i]=='a' and count < a+b:
            count += 1
            boolean_list[i] = 'Yes'
        if s[i]=='b' and count < a+b and s[:i].count('b') <b :
            count += 1
            boolean_list[i] = 'Yes'
    
    for _ in boolean_list:
        print(_)

n, a, b = map(int,input().split())
s = input()
simulator(n, a, b, s)
//  [python]
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b = inpl()
s = input()
kaku = 0
e = 0
for _,t in enumerate(s):
    if t == 'a':
        if kaku < a+b:
            print('Yes')
            kaku += 1
        else: print('No')
    elif t == 'b':
        if kaku < a+b and e < b:
            print('Yes')
            kaku += 1; e+= 1
        else: print('No')
    else:
        print('No')
//  [python]
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n, a, b = MAP()
s = STR()
c = 0
d = 0
for i in range(n):
    if s[i] == 'a' and c < a + b:
        print('Yes')
        c += 1
    elif s[i] == 'b' and c < a + b and d < b:
        print('Yes')
        c += 1
        d += 1
    else:
        print('No')
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    int n = ni();
    int a = ni();
    int b = ni();
    String str = sc.next();

    int x = 0;
    int y = 0;
    for (char c : str.toCharArray()) {
      if (c == 'a') {
        // kokunai
        if (x + y < a + b) {
          System.out.println("Yes");
          ++x;
        } else {
          System.out.println("No");
        }
      } else if(c == 'b') {
        // kaigai
        if (x + y < a + b && y < b) {
          System.out.println("Yes");
          ++y;
        } else {
          System.out.println("No");
        }
      } else {
        System.out.println("No");
      }
    }
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}
//  [cpp]
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstdio>

using namespace std;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    char data[100001];
    scanf("%s", data);
    int nai = 0, gai = 0;
    for (int i = 0; i < n; i++) {
        if (data[i] == 'a' ) {
            if (nai + gai < a+b) {
                nai++;
                puts("Yes");
            } else {
                puts("No");
            }
        } else if (data[i] == 'b' ) {
            if (nai + gai < a+b && gai < b) {
                gai++;
                puts("Yes");
            } else {
                puts("No");
            }
        } else {
            puts("No");
        }
    }
    









    return 0;
}
//  [cpp]
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define loop(i,a,b) for(int i = a; i < b; i++)
#define rep(i,a) loop(i,0,a)


int main()
{	
	int n,a,b;
	cin>>n>>a>>b;
	
	int na=0;
	int nb=0;
	
	string s;
	cin>>s;
	
	int i = 0;
	while(s[i]!='\0'){
		switch(s[i]){
			case 'a': if(na+nb<a+b){
									cout<<"Yes"<<endl;
									na++;
									break;
			}
			case 'b': if(na+nb<a+b&&nb<b){
									cout<<"Yes"<<endl;
									nb++;
									break;
			}
			default: cout<<"No"<<endl;
		}
		i++;
	}
			
	return 0;
}
//  [cpp]
#include <iostream>
#include <vector>
#include <string>
#include <memory.h>
#include <cstring>
#include <set>
#include <algorithm>
using namespace std;

int N, A, B;

int main()
{
	string s;
	while(cin>>N>>A>>B)
	{
		cin>>s;
		int total=0, oc=0;
		for(int i=0; i<s.size(); i++)
		{
			if(s[i] == 'a')
			{
				if(total < A+B) 
				{
					cout<<"Yes"<<endl;
					total++;
				}
				else cout<<"No"<<endl;
			}
			else if(s[i] == 'b')
			{
				if(total < A+B && oc < B) 
					{
						cout<<"Yes"<<endl;
						total++;
					}
				else cout<<"No"<<endl;
				oc++;
			}
			else cout<<"No"<<endl;
		}
	}
}
//  [c]
#include <stdio.h>
#include <string.h>
int main() {
	char s[100001];
	int n, a, b, pass = 0, fpass = 0;
	scanf("%d%d%d", &n, &a, &b);
	scanf("%s", s);
	for (int i = 0; i < strlen(s); i++) {
		if (s[i] == 'a') {
			if (pass < a + b) {
				printf("Yes\n");
				pass++;
			} else {
				printf("No\n");
			}
		} else if (s[i] == 'b') {
			if (pass < a + b && fpass < b) {
				printf("Yes\n");
				fpass++;
				pass++;
			} else {
				printf("No\n");
			}
		} else {
			printf("No\n");
		}
	}
	return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>

int main(){
  int n, a, b;  scanf("%d%d%d", &n, &a, &b);
  char s[100002];  scanf("%s", s);

  int count = 0;
  int bcount = 0;
  for(int i=0; i<strlen(s); i++){
    if(s[i] != 'c' && count < a+b){
      if(s[i] == 'b'){
	if(++bcount <= b){
	  count++;
	  printf("Yes\n");
	}else{
	  printf("No\n");
	}
      }else{
	count++;
	printf("Yes\n");
      }
    }else{
      printf("No\n");
    }
  }
  return 0;
}
//  [c]
#include <stdio.h>

int main(void)
{
  int n, a, b;
  scanf("%d %d %d", &n, &a, &b);
  char s[n];
  int i = 0;
  int frg = 0;
  int pass = 0;
  while (i < n)
  {
    scanf("%s", &s[i]);
    if (s[i] == 'a')
    {
      if (pass < a + b)
      {
        printf("Yes\n");
        pass++;
      }
      else
        printf("No\n");
    }
    else if (s[i] == 'b')
    {
      frg++;
      if ((pass < a + b) && (frg <= b))
      {
        printf("Yes\n");
        pass++;
      }
      else
        printf("No\n");
    }
    else if (s[i] == 'c')
      printf("No\n");
    i++;
  }
  return 0;
}
//  [javascript]
// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.
  var input = input.split("\n");
  var N = parseInt(input[0].split(' ')[0]);
  var A = parseInt(input[0].split(' ')[1]);
  var B = parseInt(input[0].split(' ')[2]);
  var participants = input[1].split('');

  // var arr = tmp.map(function(n){return parseInt(n)});

  var tracker = 0;
  var b_tracker = 0;

  for (var i=0, len=participants.length; i<len; i++){
    switch (participants[i]) {
      case 'a':
        if (tracker<(A+B)){
          console.log('Yes\n');
          tracker++;
        }else{
          console.log('No\n');
        }
        break;
      case 'b':
        if((tracker<(A+B)) && (b_tracker<B)){
          console.log('Yes\n');
          b_tracker++;
          tracker++;
        }else{
          console.log('No\n');
        }
        break;
      case 'c':
        console.log('No\n');
        break;
      default:
        console.log('No\n');
    }

  }

	//output
	// console.log(max_iteration);
}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  var input = input.split("\n");
  var data = input[0].split(" ");
  var N = parseInt(data[0]);
  var A = parseInt(data[1]);
  var B = parseInt(data[2]);
  var string = input[1];

  var count = 0;
  var abroadRank = 0;

  for(var i= 0; i < string.length; i++){
    if(string.charAt(i) == "a"){
      if(count < (A+B)){
        count++;
        console.log("Yes");
      }else{
        console.log("No");
      }
    }else if(string.charAt(i) == "b"){
      abroadRank++;
      if(count < (A+B) && abroadRank <= B){
        count++;
        console.log("Yes");
      }else{
        console.log("No");
      }
    }else{
      console.log("No");
    }
  }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));