akhauriyash/Code-Regression huggingface dataset:
void main() {
  problem();
}

void problem() {
  auto A = scan!int;
  auto B = scan!int;
  auto C = scan!int;
  auto K = scan!int;

  int solve() {
    int answer;

    if (K <= A) return K;
    if (K <= A+B) return A;

    auto nokori = K - A - B;
    return A - nokori;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


Measured memory_bytes: 2764
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n;
  scanf("%d", &n);
  vector<int> cnt(n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    --x;
    ++cnt[x];
  }
  sort(cnt.begin(), cnt.end(), greater<int>());
  while (cnt.size() && cnt.back() == 0) cnt.pop_back();
  reverse(cnt.begin(), cnt.end());
  vector<int> pre(cnt.size() + 1);
  for (int i = 0; i < cnt.size(); ++i) pre[i + 1] = pre[i] + cnt[i];
  for (int i = 1; i <= n; ++i) {
    int ret;
    if (i == 1) {
      ret = n;
    } else if (i > cnt.size()) {
      ret = 0;
    } else if (i == cnt.size()) {
      ret = cnt[0];
    } else {
      int low = 0, high = n;
      while (low != high) {
        int mid = (low + high + 1) / 2;
        auto it = upper_bound(cnt.begin(), cnt.end(), mid);
        int sum = (cnt.end() - it) * mid + pre[it - cnt.begin()];
        if ((int64)mid * i > sum) {
          high = mid - 1;
        } else {
          low = mid;
        }
      }
      ret = high;
    }
    printf("%d\n", ret);
  }

  return 0;
}


Measured memory_bytes: 3072
ans a b
	| a < b = "a < b"
	| a > b = "a > b"
	| a == b = "a == b"

main = do
	line <- getLine
	let a = read . head . words $ line :: Int
	let b = read . last . words $ line :: Int
	putStrLn $ ans a b


--main = do
--	line <- getLine
--	let a = read . head . words $ line :: Int
--	let b = read . last . words $ line :: Int
--	putStrLn (show (a * b) ++ " " ++ show (a * 2 + b * 2))

Measured memory_bytes: 3628
n = gets.chomp.to_i
as = gets.split.map(&:to_i)
h = Hash.new(0)
as.each do |a|
  h[a] += 1
end
b = h.select { |k,v| v > 1 }.sort_by { |e| e.first }
if b.size >= 2
  if b[-1].last >= 4
    puts b[-1].first ** 2
  else
    puts b[-1].first * b[-2].first
  end
else
  puts 0
end


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

vector<ll> pw2(51,1);
vector<ll> pw10(19,1);

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
	ll N; cin>>N;
	vector<ll> A(N+1);
	rep1(i,N) cin>>A[i];

	ll ans=0;
	rep1(i,N){
		ll j=A[i];
		if(A[j]==i && A[i]==j) ans++;
	}
		
	cout<<ans/2;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,i,x;
 cin >> N;
  
  for (i = 0; i < N; i++) {
    int l,r;
    cin >> l >> r;
    x += r - l + 1;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
 
public class Main {
  	static Gcd gc;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
      	int result = 0;
        gc = new Gcd();
      	for(int i=1;i<=num;i++){
          for(int j=1;j<=num;j++){
            int tmp = gc.gcd(i,j);
            for(int k=1;k<=num;k++){
         		//最初の2数の最大公約数を取得
      			result += gc.gcd(tmp,k);
            }
          }
        }
      System.out.println(result);
    }
}

class Gcd{
	public int gcd(int a,int b){
  		int tmp = 0;
  		int amari=-1;
  		if(a>=b){
    		tmp = a;
    		a = b;
  		}else{
    		tmp = b;
  		}

 		 while(amari != 0){
    		amari = a%tmp;
           	a = tmp;
           	tmp = amari;
  		 }
  		return a;
	}
}

Measured memory_bytes: 35724
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
	int N, M, i;
	cin >> N >> M;
	for (i = M / N; i >= 1; i--)
	{
		if (M%i == 0) {
			cout << i << endl;
			return 0;
		}
	}
	

}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,flg[100001]={0},cnt,i;
	char s[100001];
	scanf("%d %s",&n,s);
	cnt=0;
	for(i=0;i<n-1;i++){
		if(s[i]!=s[i+1]&&flg[i]==0){
			cnt++;
			flg[i+1]=1;
		}
	}
	printf("%d\n",cnt);
	return 0;
}


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

using namespace std;

int main(){
    long long int N,A,sz;
    vector<long long int> vec;
    cin >> N;
    unordered_map<int,int> mp;
    for(int i=0;i<N;i++){
        cin >> A;
        if(mp[A]==0){
            mp[A] =1;
        }else{
            vec.push_back(A);
            mp[A] = 0;
        }
    }

    sz = vec.size();

    if(sz<2){
        cout << "0" << endl;
    }else{
        sort(vec.begin(),vec.end());
        cout << vec[sz-1]*vec[sz-2] << endl;
    }
}

Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin>>x;
  for(int i=x;i>=1;i--){
    int n=i;
    if(i==1)
      cout<<i<<endl;
    for(int j=2;j*j<=n;j++){
      while(n%j==0)
        n/=j;
      if(n==1){
        cout<<i<<endl;
        i=1;
      }
      n=i;
    }
  }
}

Measured memory_bytes: 3680
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    int odd,even;
    odd=(m+1)/2;
    for(int i=1;i<=odd;i++)
    {
        printf("%d %d\n",i,i+((odd-i+1)*2-1));
    }
    for(int i=1;i<=m-odd;i++)
    {
        printf("%d %d\n",odd*2+i,odd*2+i+(2*(m-odd-i+1)));
    }
    return 0;
}


Measured memory_bytes: 1720
import Control.Monad
import Data.List

main :: IO()
main = do
    n <- readLn :: IO Int
    ll <- replicateM n getLine
    let li = map ((map toInt).words) ll
        la = map (f.(take 3).reverse.sort) li
    putStr $ unlines $ map (\x -> if x then "YES" else "NO") la

toInt :: String -> Int
toInt s = read s :: Int

f :: [Int] -> Bool
f (x:xs) = x*x == (sum $ map (^ 2) xs)

Measured memory_bytes: 4488
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		// 計算
		int result = 0;
		int[] l = new int[n];
		int[] r = new int[n];
		int[] g = new int[n];
		for(int i = 0; i < n; i++){
		    if(i == 0){
		        l[i] = a[i];
		    }else{
		        l[i] = gcd(l[i-1], a[i]);
		    }
		}
		for(int i = n - 1; i >= 0; i--){
		    if(i == n - 1){
		        r[i] = a[i];
		    }else{
		        r[i] = gcd(r[i+1], a[i]);
		    }
		}
		for(int i = 0; i < n; i++){
		    int now = 0;
		    if(i == 0){
		        now = r[i+1];
		    }else if(i == n - 1){
		        now = l[i-1];
		    }else{
		        now = gcd(l[i-1], r[i+1]);
		    }
		    result = max(result, now);
		}
		
		// 出力
        System.out.println(result);
	}

	static int gcd(int x, int y){
	    if(x < y){
	        int temp = x;
	        x = y;
	        y = temp;
	    }
	    if(y == 0) return x;
	    if(x%y == 0) return y;
	    return gcd(y , x%y);
	}
}

Measured memory_bytes: 50576
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define es cout<<" "
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;
template<class T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts> 
auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<int> v(n+2, 0);
    rep (m) {
        int l, r;
        cin >> l >> r;
        v[l] += 1;
        v[r+1] -= 1;
    }
    int s = 0;
    int ans = 0;
    repeat_from_to (i, 1, n) {
        s += v[i];
        if (s == m) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

import sys
sys.setrecursionlimit(1000000)

import collections

N, M, P = rl()
E = []
edges = collections.defaultdict(list)
redges = collections.defaultdict(list)
for i in range(M):
	a, b, c = rl()
	E.append((a-1, b-1, P-c))
	edges[a-1].append(b-1)
	redges[b-1].append(a-1)

visited = {}
def dfs(n):
	if n in visited: return
	visited[n] = 1
	for e in edges[n]:
		dfs(e)
rvisited = {}
def rdfs(n):
	if n in rvisited: return
	rvisited[n] = 1
	for e in redges[n]:
		rdfs(e)

dfs(0)
rdfs(N-1)
ok = [False] * N
for n in range(N):
	if n in visited and n in rvisited:
		ok[n] = True
V = list(range(N))

def belmanford(V, E, s=0):
	D = [float('inf')] * len(V)
	D[s] = 0
	P = [None] * len(V)
	update = True
	step = 0
	while update:
		update = False
		for u, v, c in E:
			if not ok[u]: continue
			if not ok[v]: continue
			if D[v] > D[u] + c:
				D[v] = D[u] + c
				P[v] = (u, c)
				update = True
		step += 1
		if step > N:
			return None, None
	return D, P

D, P = belmanford(V, E)
if D == None:
	print(-1)
else:
	print(max(-D[N-1], 0))


Measured memory_bytes: 88612
#include <queue>
#include <iostream>
using namespace std;
int main() {
  string word;
  priority_queue<int> Q;// intを格納する優先度つきキュー
  while (cin >> word){
    if(word == "insert"){
      int num;
      cin >> num;
      Q.push(num);
    }
    else if(word == "extract"){
      int n = Q.top(); // 先頭をコピーして
      Q.pop(); // 先頭要素を廃棄
      cout << n << endl;
    }
    else if (word == "end"){
      break;
    }
}
}



Measured memory_bytes: 7080
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()
a = [MAP() for _ in range(n)]
dp = [[0,0,0] for _ in range(n+1)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            dp[i+1][k] = max(dp[i+1][k],dp[i][j]+a[i][k])

print(max(dp[n]))

Measured memory_bytes: 76320
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int n, k; cin >> n >> k;

	int max_k = (n - 1) * (n - 2) / 2;
	if (max_k < k) {
		cout << -1 << endl;
		return 0;
	}

	int nedge = n - 1 + (max_k - k);
	cout << nedge << endl;

	FOR_LE(i, 2, n) {
		cout << 1 << " " << i << endl;
	}

	nedge -= n - 1;
	int i = 2;
	int j = 3;
	while (nedge != 0) {
		cout << i << " " << j << endl;
		j++;
		if (n < j) {
			i++;
			j = i + 1;
		}
		nedge--;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define Q 150
#define N 1000

int Lcs(char *,char *);

int c[N+1][N+1];
char x[Q+1][N+1],y[Q+1][N+1];

int main(){
 
  int q,i;
  
  scanf("%d",&q);
  
  for(i=0;i<q;i++){

    scanf("%s",x[i]);
    scanf("%s",y[i]);
        
  }
  
  for(i=0;i<q;i++){
    printf("%d\n",Lcs(x[i],y[i]));
  }

  return 0;
  
}

int Lcs(char *a,char *b){
  int i,j,m,n,u,v;
  
  m=strlen(a);
  n=strlen(b);

  //初期化
  for(i=0;i<=m;i++){
    c[i][0]=0;
  }
  for(j=1;j<=n;j++){
    c[0][j]=0;
  }
    
  for(i=1,u=0;i<=m;i++,u++){
    for(j=1,v=0;j<=n;j++,v++){
      if(a[u]==b[v]){
	c[i][j]=c[i-1][j-1]+1;
      }else if(c[i-1][j]>=c[i][j-1]){
	c[i][j] = c[i-1][j];
      }else{
	c[i][j]=c[i][j-1];
      }
    }
  }//for


  return c[m][n];

}





Measured memory_bytes: 5700
fun main(args: Array<String>)
{
    val n = readInt()
    val a = mutableListOf<Int>()
    for (i in 1..n) {
        a.add(readInt())
    }

    val sorted = mutableListOf<Int>()
    for(i in 1..n) {
        sorted.add(a[i-1])
    }
    sorted.sortDescending()
    val first = sorted[0]
    val second = sorted[1]

    for(i in 1..n) {
        println(if (a[i-1] == first) second else first )
    }
}


// Read an integer
// Usage: val a = readInt()
private fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
private fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
private fun readString() = readLine()!!


Measured memory_bytes: 57640
#include<bits/stdc++.h>
#define make_pair mp
#define first fi
#define second se
using namespace std;
int n;
long long ans,a[300050];
int main(){
	cin>>n;
	for(int i=1;i<=3*n;i++)
		cin>>a[i];
	sort(a+1,a+1+3*n);
	for(int i=3*n-1;n>0;n--,i-=2){
		ans+=a[i];
	}
	cout<<ans;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }

    int check = 0;
    int pre = a[0];
    int count = 1;
    for(int i=1; i<n; ++i){
        if(pre == a[i] && check == 0){
            continue;
        }
        else if(pre >= a[i] && check >= 0){
            check = 1;
        }
        else if(pre <= a[i] && check <= 0){
            check = -1;
        }
        else{
            check = 0;
            ++count;
        }
        pre = a[i];
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 640
#include <queue>
#include <iostream>
#include <vector>

using namespace std;

int main(){
  long long int N, M;
  cin >> N >> M;
  vector< vector<int> > G(N);
  for(int i = 0; i < M; ++i){
    int a, b;
    cin >> a >> b;
    --b;--a;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> C(N, 0);
  C[0] = 1;
  bool f = true;
  queue<int> wait;
  wait.push(0);
  while(!wait.empty()){
    int i = wait.front();
    wait.pop();
    for(int j = 0; j < G[i].size(); ++j){
      int v = G[i][j];
      if(!C[v]){
        C[v] = -C[i];
        wait.push(v);
      }else if(C[v] != -C[i]){
        f = false;
        break;
      }
    }
    if(!f) break;
  }
  if(f){
    long long int c = 0;
    for(int i = 0; i < N; ++i){
      if(C[i] > 0) ++c;
    }
    cout << c*(N-c) - M << endl;
  }else cout << N*(N-1)/2 - M << endl;
  return 0;
}


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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i = (int)m; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPM(i,m,n) for(int i = (int)m; i >= (int)n; i--)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

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

struct pos {
    int y, x;
};

int main() {
    int n;
    cin >> n;
    char s[n][n];
    rep(i, n) rep(j, n) cin >> s[i][j];

    int cnt = 0;

    rep(a, n) {
        char s_new[n][n];
        rep(i, n) rep(j, n) s_new[i][j] = s[(i + a) % n][j];

        bool ok = true;

        rep(i, n) rep(j, n) {
            if (s_new[i][j] != s_new[j][i]) ok = false;
        }
        
        if (ok) cnt++;
    }

    cout << cnt * n << endl;

    return 0;
}

Measured memory_bytes: 384
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	pasta := 0
	pastb := 0
	s := getNextString(scanner)
	for i := 0; i < n; i++ {
		if pasta+pastb >= a+b {
			fmt.Fprintln(writer, "No")
			continue
		}
		if s[i] == 'c' {
			fmt.Fprintln(writer, "No")
			continue
		}
		if s[i] == 'a' {
			pasta++
			fmt.Fprintln(writer, "Yes")
			continue
		}
		if pastb < b {
			pastb++
			fmt.Fprintln(writer, "Yes")
			continue
		}
		fmt.Fprintln(writer, "No")
	}
}


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

const LL P = 998244353;
const int maxN = 100000 + 233;
LL gcd(LL x, LL y) {
	return y == 0 ? x : gcd(y, x % y);
}
int n, a[maxN];

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> a[i];
	sort(a, a + n);
	LL ans = 1;
	for(int i = 0; i < n; ++i) ans = ans * gcd(a[i], i) % P;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int r, g, b, n;
        cin >> r >> g >> b >> n;
        int ans = 0;
        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= n; j++){
                int x = r * i + j * g;
                if(n - x >= 0 and (n - x) % b == 0){
                    ans++;
                }
            }
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 31488
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"YES\n":"NO\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  bool f = false;
  if(n == 3) f = true;
  if(n == 5) f = true;
  if(n == 7) f = true;
  YesorNo(f);
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
// by Isaunoya
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
#define int long long
typedef pair<int,int> pii;
inline int read() {
	int x=0,neg=1;
	char c=getchar();
	while(!isdigit(c)) {
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x) {
	if(x<0) {
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else {
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD) {
	int ans=1;
	while(e) {
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read(),m=read(),s=read(),c[55],d[55];
struct edge {
	int u,v,w;
	edge() {
		/*ycxakioi*/
	}
	edge(int _u,int _v,int _w) {
		u=_u;
		v=_v;
		w=_w;
	}
};
const int MAGIC=2456;
inline int id(int x,int y) {
	return x*(MAGIC+1)+y;
}
vector<edge> g[55*2555];
int dist[55*2555],vis[25*2555];
priority_queue<pii,vector<pii>,greater<pii> > q;
signed main() {
#ifdef LOCAL
	freopen("testdata.in", "r", stdin);
#endif
	fz(i,1,m) {
		int u,v,a,b;
		cin>>u>>v>>a>>b;
		fz(j,0,MAGIC) {
			if(j>=a) {
//				cout<<id(u,j)<<endl;
				g[id(u,j)].push_back(edge(id(u,j),id(v,j-a),b));
				g[id(v,j)].push_back(edge(id(v,j),id(u,j-a),b));
			}
		}
	}
	fz(i,1,n)	c[i]=read(),d[i]=read();
	fz(i,1,n) {
		fz(j,0,MAGIC-1) {
			int cur=j+c[i];
			if(cur>=MAGIC) {
				g[id(i,j)].push_back(edge(id(i,j),id(i,MAGIC),d[i]));
			} else {
				g[id(i,j)].push_back(edge(id(i,j),id(i,cur),d[i]));
			}
		}
	}
//	cout<<"g[2458].size()="<<g[2458].size()<<endl;
	fillbig(dist);
	dist[id(1,min(s,MAGIC))]=0;
	q.push({0,id(1,min(s,MAGIC))});
	while(!q.empty()) {
		pii p=q.top();
		q.pop();
		int sum=p.fi,x=p.se;
//		cout<<x<<" "<<dist[x]<<endl;
		if(sum>dist[x])	continue;
//		puts("-1");
		foreach(it,g[x]) {
			int y=it->v,z=it->w;
//			cout<<"y="<<y<<" "<<z<<endl;
			if(dist[y]>dist[x]+z) {
				dist[y]=dist[x]+z;
				q.push({dist[y],y});
			}
		}
	}
	fz(i,2,n) {
		int mn=0x3f3f3f3f3f3f3f3fll;
		fz(j,0,MAGIC)	mn=min(mn,dist[id(i,j)]);
		cout<<mn<<endl;
	}
	return 0;
}

Measured memory_bytes: 30116
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int isPrime(int);

int main()
{
  int n, *data, k = 0, i, key;

  /*??\??????????????°????±????*/
  scanf("%d", &n);

  data = (int *)malloc(n * sizeof(int));

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

  for(i = 0; i < n; i++){
    key = isPrime(data[i]);
    if(key == 1)
      k++;
  }
  printf("%d\n", k);
  free(data);
  return 0;
}

int isPrime(int x)
{
  int i;
  if(x == 2)
    return 1;

  if(x < 2 || x % 2 == 0)
    return 0;

  i = 3;
  
  while(i <= sqrt(x)){
    if(x % i == 0)
      return 0;
    i += 2;
  }
  return 1;
}

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

int P,Q,A,N;

int rec(int child, int parent, int th, int pre) {
  if(th == N) return 0;
  int res = 0;
  for(int i = min(pre,A/parent); i >= 1; --i) {
    int nc = child*i+parent;
    int np = parent*i;
    if(Q*nc > P*np) break;
    if(Q*nc == P*np) {
      ++res;
      break;
    }
    else res += rec(nc,np,th+1,i);
  }
  return res;
}

int main() {
  while(cin >> P >> Q >> A >> N && (P|Q|A|N)) {
    cout << rec(0,1,0,A) << endl;
  }
  return 0;
}

Measured memory_bytes: 868
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	double xa,ya,ra,xb,yb,rb;
	for(int i=0;i<n;i++){
		cin>>xa>>ya>>ra>>xb>>yb>>rb;
		double l = sqrt((xb-xa)*(xb-xa)+(yb-ya)*(yb-ya));
		if(l>ra+rb){
			cout<<"0"<<endl;
		}else if(l<rb-ra && l>ra-rb){
			cout<<"-2"<<endl;
		}else if(l<ra-rb && l>rb-ra){
			cout<<"2"<<endl;
		}else{
			cout<<"1"<<endl;
		}
	}
	return 0;
}

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

#define null				""
#define all(dat)			dat.begin(), dat.end()
#define over(msg)			cout << msg << endl, exit(0);
#define loop(i, to)			for (int i = 0; i < to; ++i)
#define cont(i, to)			for (int i = 1; i <= to; ++i)
#define foreach(i, dat)		for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long			num;

using namespace std;

bool g[1005][1005];
int n, m, mod = 1e9 + 7;
num dp[1005][1005];

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	cont (i, n) {
		string s;
		cin >> s;
		loop (j, s.size()) {
			g[i][j + 1] = s[j] == '#';
		}
	}
	dp[1][1] = 1;
	cont (i, n) {
		cont (j, m) {
			if (g[i][j])  continue;
			dp[i][j] += dp[i - 1][j] + dp[i][j - 1];
			dp[i][j] %= mod;
		}
	}
	cout << dp[n][m] << endl;
}


Measured memory_bytes: 9216
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

string S = "";

int main() {
	cin >> S;
	ll tot = 0;
	ll cnt1 = 0;
	ll cnt0 = 0;
	for(int i = 0; i < S.size(); i++) {
		if(S[i] == '0') {
			if(cnt1) {
				cnt1--;
				tot += 2;
			}
			else {
				cnt0++;
			}
		}
		else {
			if(cnt0) {
				cnt0--;
				tot += 2;
			}
			else {
				cnt1++;
			}
		}
	}
	printf("%lld\n", tot);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
ll a[N], b[N];
const int M = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	ll res = 0;
	
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i] = b[i - 1] + a[i];
	}
	for(int i = n; i >= 1; i--) {
		res = (res + (a[i] * (b[i - 1] % M)) % M) % M;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 6740
#include <stdio.h>
void solve(void)
{
	int n,m,i;
	int t[100];
	int sum = 0;
	scanf("%d",&n);
	for(i=0;i<n;++i){
		scanf("%d", t+i);
		sum+=t[i];
	}
	scanf("%d",&m);
	for(i=0;i<m;++i){
		int p,x;
		scanf("%d %d",&p,&x);
		
		printf("%d\n",sum - t[p-1] + x);
	}
}
int main(int argc, char **argv)
{
	solve();
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
map<int, int> mp;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010];
    rep(i, N) cin >> A[i];
    rep(i, N) mp[A[i]]++;
    int ans = 0;
    rep(i, N) {
        if(mp[A[i]] % 2 == 1) {
            ans++;
            mp[A[i]] = 0;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8528
import re
s = input()
t =input()

cand = []

for i in range(len(s)-len(t)+1):
    
    # i番目からtと同じ長さの文字列を取りだす
    td = s[i: i+len(t)]
    
    for j in range(len(t)):
        if td[j] == '?':
            td = td[0:j] + t[j] +td[j+1:]
        elif td[j] != t[j]:
            break;
    
    if td == t:
        cand.append(s[0:i] + td + s[i+len(t):])


if len(cand) == 0:
    print('UNRESTORABLE')
else:
    cand = list(map(lambda x: x.replace('?', 'a'), cand))
    print(min(cand))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
//#define int long long
using namespace std;

string n,s;

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>s;
	cout<<(s[0]==n[0])+(s[1]==n[1])+(s[2]==n[2])<<endl;	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi = acos(-1);
#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll n, L; cin >> n >> L;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    ll last_pos = -1;
    REP(i, n-1) {
        if (a[i] + a[i+1] >= L) {
            last_pos = i;
        }
    }
    if (last_pos >= 0) {
        cout << "Possible" << endl;
        REP(i, last_pos) cout << i+1 << endl;
        RFOR(i, last_pos, n-1) cout << i+1 << endl;
    }
    else {
        cout << "Impossible" << endl;
    }
}


Measured memory_bytes: 1664
// --------------
// Tejas Pandey  |
// 19 - 01 - 20  |
// ABC #152      |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define lim 1000007
#define vi vector<int>
typedef long long int ll;


ll mpow(ll a,ll b){
	ll res = 1;
	while(b){
		if(b&1)
			res *= a,res %= mod;
		a *= a;
		a %= mod;
		b >>= 1;
	}
	return res;
}
bool prime[lim];
vector<ll> primes;
void seive(){
	for(int i = 2;i < lim;i++){
		if(!prime[i]){
			primes.push_back(i);
			for(int j = 2*i;j < lim;j += i)
				prime[j] = 1;
		}
	}
}

void solve(ll n){
	int cur = 0,flg = 0;
	while(n - 1){
		if(n%primes[cur]);
		else{
			int cnt = 0;
			n /= primes[cur];
			while(!(n%primes[cur]))
				n /= primes[cur],cnt++;
		}
		cur++;
	}
}

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int n;
		cin >> n;
		ll a[n];
		seive();
		int cnt[primes.size()];
		memset(cnt,0,sizeof(cnt));
		for(int i = 0;i < n;i++){
			cin >> a[i];
			int cur = 0;
			int f = a[i];
			while(primes[cur]*primes[cur] <= f){
				if(f%primes[cur]);
				else{
					int cnte = 0;
					while(!(f%primes[cur]))
						f /= primes[cur],cnte++;
					cnt[cur] = max(cnt[cur],cnte);
				}
				cur++;
			}
			if(f - 1){
				int x = (lower_bound(primes.begin(),primes.end(),f) - primes.begin());
				cnt[x] = max(cnt[x],1);
			}
		}
		ll pro = 1;
		for(int i = 0; i < primes.size();i++){
			pro *= mpow(primes[i],cnt[i]);
			pro %= mod;
		}
		ll ans = 0;
		for(int i = 0;i < n;i++)
			ans += (pro*mpow(a[i],mod - 2))%mod,ans %= mod;
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(998244353)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF (int)2e18
#define EPS 1e-9
#define int long long
#define MAX 100009
int fun(int arr[], int n, int k){
	/*dp[i] = min cost to reach ith stone(taking any number of steps in previous move)
	Note that we don't require a 2d array dp[i][j] because
	after you know the min cost to reach stone i, minimum cost to further stones
	will depend only on this value. It is not like you can get a lesser cost by taking some different
	steps*/
	int dp[n+1];
	for(int i = 1; i <= n; i++) dp[i] = INF;
	dp[1] = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= k; j++){
			dp[i] = min(dp[i], ((i-j >= 1)? abs(arr[i]-arr[i-j]) + dp[i-j] : INF));
		}
	}
	return dp[n];
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	int T=1;
	//cin >> T;
	FOR1(i, T)
	{
		//cout << "Case #" << i << ": \n";
		int n, k; cin >> n >> k;
        int a[n+1];
        FOR1(i, n) cin >> a[i];
        cout << fun(a, n, k);
		cout<<'\n';
	}
	return 0;
}


Measured memory_bytes: 1920
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')
A,B,X=map(int, input().split())
if A > X:
    print('NO')
elif X-A <= B:
    print('YES')
else:
    print('NO')


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

int main(){

	int h, w;
	while (std::cin >> h >> w, h || w){

		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if (i % 2 == 0){
					if (j % 2 == 0)std::cout << "#";
					else std::cout << ".";
				}
				if (i % 2 == 1){
					if (j % 2 == 0)std::cout << ".";
					else std::cout << "#";
				}
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
#pragma endregion

void solve() {
    string s;
    cin >> s;
    int n = (int)s.size();
    vector<ll> power2(n+1), power3(n+1);
    power2.at(0) = 1;
    power3.at(0) = 1;
    for (int i=1; i<n+1; i++) {
        power2.at(i) = power2.at(i-1) * 2;
        power2.at(i) %= MOD;
        power3.at(i) = power3.at(i-1) * 3;
        power3.at(i) %= MOD;
    }
    ll res = 0;
    int cnt = 0;
    for (int i=0; i<n; i++) {
        if (s.at(i) == '1') {
            res += power2.at(cnt) * power3.at(n-i-1);
            res %= MOD;
            cnt++;
        }
    }
    res += power2.at(cnt);
    res %= MOD;
    cout << res << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 2000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] d = new int[n];
		for(int i=0; i<n;i++) {
			d[i] = sc.nextInt();
		}
		sc.close();
		
		int ans=0;
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				ans += d[i]*d[j];
			}
		}
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 23892
import sys
from collections import deque
sys.setrecursionlimit(10**6)
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def BFS(n,m,table,dist):
    next = deque([0])
    while next:
        tmp = next.popleft()
        for rep in table[tmp]:
            if dist[rep]==-1:
                dist[rep] = tmp+1
                next.append(rep)
    return not -1 in dist

def main():
    n,m = IL()
    table = [[] for _ in range(n)]
    for _ in range(m):
        a,b = IL()
        table[a-1].append(b-1)
        table[b-1].append(a-1)
    dist = [-1]*n
    dist[0] = 0
    if BFS(n,m,table,dist):
        print('Yes')
        for i in range(1,len(dist)):
            print(dist[i])
    else:  print('No')
    return

if __name__=='__main__':
    main()

Measured memory_bytes: 36856
import sys
from collections import deque, Counter, defaultdict

input = sys.stdin.readline
MOD = (10**9+7)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr


def pow_k1(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x


def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
        x%=MOD
    return K * x


def main():
    n = int(input())
    al = list(map(int, input().split())) 
    lcm_dic = defaultdict(int)
    # lcm_dic = {}
    # al_facs = []
    for a in al:
        fac = factorization(a)
        # a_fac_dic = {}
        for f in fac:
            # lcm_dic.setdefault(f[0],0)
            lcm_dic[f[0]] = max(f[1], lcm_dic[f[0]])
            # a_fac_dic[f[0]] = f[1]
        # al_facs.append(a_fac_dic)


    lcm = 1
    for prime, cnt in lcm_dic.items():
        lcm *= pow_k1(prime,cnt)

    
    # ans = sum( [ lcm//a for a in al] ) % MOD
    ans = 0
    for a in al:
        ans += lcm//a
        # ans%=MOD
    ans%=MOD


    # ans = 0
    # for al_f in al_facs:
    #     curr_val = 1
    #     for prime, cnt in lcm_dic.items():
    #         if prime in al_f:
    #             curr_val *= pow_k(prime,(cnt-al_f[prime]))
    #             curr_val%=MOD
    #         else:
    #             curr_val *= pow_k(prime,cnt)
    #             curr_val%=MOD
    #     ans += curr_val
    #     ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (s == u) {
        --a;
    } else {
        --b;
    }
    cout << a << " " << b << endl;
    return 0;
}



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

int main() {
  int64_t N,ans=1;
  cin>>N;
  vector<int64_t> S(N+1,1);
  for(int64_t i=2;i<=N;i++){
    int64_t k=1;
    while(i*k<=N){
      S.at(i*k)++;
      k++;
    }
    ans+=i*S.at(i);
  }
  cout<<ans;

}


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

unsigned int n,ans,up,lef,rig;
char action[10];

void north(){
	int tmp = up;
	up = lef;
	lef = 7-tmp;
}

void south(){
	int tmp = lef;
	lef = up;
	up = 7-tmp;
}

void east(){
	int tmp = rig;
	rig = up;
	up = 7-tmp;
}

void west(){
	int tmp = up;
	up = rig;
	rig = 7-tmp;
}

void right(){
	int tmp = lef;
	lef = rig;
	rig = 7-tmp;
}

void left(){
	int tmp = rig;
	rig = lef;
	lef = 7-tmp;
}


void solve(const char a){
	switch(a){
	case 'N':
		north();
		break;
	case 'S':
		south();
		break;
	case 'E':
		east();
		break;
	case 'W':
		west();
		break;
	case 'R':
		right();
		break;
	case 'L':
		left();
		break;
	}
}

void input(){
	for(int i=0; i<n; i++){
		cin >> action;
		solve(action[0]);
		ans += up;
	}
}

int main(){
	while(true){
		cin >> n;
		if(n==0)
			return 0;
		up = 1;
		lef = 2;
		rig = 3;
		ans = 1;
		input();
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  ll n,k; cin >> n >> k;
  vector<ll> C(1e5+1,0);

  rep(i, n){
    ll a,b; cin >> a >> b;
    C[a] += b;
  }

  ll sum = 0;
  int ans;
  rep(i, C.size()){
    sum += C[i];
    if(sum >= k){
      ans = i;
      break;
    }
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 1024
A,B,C,X,Y=map(int,input().split())
#print(A,B,C,X,Y)
M=max(X,Y)*2
ans=float('inf')
for i in range(M+1):
  x=max(0,X-i//2)
  y=max(0,Y-i//2)
  #x=max(0,X-(-(-i//2)))
  #y=max(0,Y-(-(-i//2)))
  tmp=A*x+B*y+C*i
  if ans>tmp:
    ans=tmp
print(ans)

Measured memory_bytes: 3064
#include <iostream>
 #include <vector>
 #include <algorithm>
 #include <map>
 #include <set>
 #include <cmath>
 #include <cstring>
 #include <iomanip>
 #include <random>
 #include <chrono>
 #include <queue>
 #include <math.h>
 using namespace std;

int kiriage(int a){
  int k=a%10;
  if(k>0) {
    int t=a/10;
    return (t+1)*10;
  }
  else return a;
}

int main(){
  int a,b,c,d,e;
  cin >>a >>b>>c>>d>>e;
  
  int ans=kiriage(a)+kiriage(b)+kiriage(c)+kiriage(d)+kiriage(e);
  
  int t=kiriage(a)-a;
  
  t=max(t,kiriage(b)-b);
  t=max(t,kiriage(c)-c);
  t=max(t,kiriage(d)-d);
  t=max(t,kiriage(e)-e);
  
  ans=ans-t;
  cout <<ans<<endl;
  
  

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=200+10;

    char mp[N][N];
    int val[N];bool vis[N];
    bool err;int n;
    queue<int> q;
    void bfs(int st)
    {
        while(q.size())q.pop();
        q.push(st);vis[st]=1;
        while(q.size())
        {
            int x=q.front();q.pop();
            fo(y,1,n) if(mp[x][y]=='1')
            {
                if(vis[y])
                {
                    if(abs(val[x]-val[y])%2==0) {err=1;break;}
                }
                else val[y]=val[x]+1,vis[y]=1,q.push(y);
            }
        }
    }
    void main()
    {
        n=qread();fo(i,1,n) scanf("%s",mp[i]+1);
        int mx=-1;
        fo(st,1,n)
        {
            memset(vis,0,sizeof vis);
            memset(val,0,sizeof val);
            err=0;bfs(st);
            if(!err) fo(i,1,n) chmax(mx,val[i]+1);
        }
        write(mx);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


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

using namespace std;
typedef long long ll;

ll N;
vector<ll> v[1000];

int main(){
    cin >> N;
    if(N < 1){
        cout << "No" << endl;
        return 0;
    }
    N *= 2;
    ll n = -1;
    for(int i=1;i*i<=N;i++){
        if(N % i != 0) continue;
        if(N / i != i+1) continue;
        n = i;
        break;
    }
    if(n == -1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    cout << n+1 << endl;
    for(int i=0;i<n;i++) v[0].push_back(i+1);
    ll count = n+1;
    for(int i=1;i<n+1;i++){
        for(int j=0;j<i;j++) v[i].push_back(v[j][i-1]);
        for(int j=i;j<n;j++) v[i].push_back(count++);
    }
    for(int i=0;i<n+1;i++){
        cout << n;
        for(int j=0;j<n;j++) cout << " " << v[i][j];
        cout << endl;
    }
    return 0;
}

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

int main() {
	string s;
	cin >> s;
	ll k;
	cin >> k;
	rep(i, s.size()) {
		if (s[i] == '1') {
			k--;
			if (k == 0) {
				cout << 1 << endl;
				return 0;
			}
			continue;
		}
		cout << s[i] << endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

'''
N種類のドーナツ、お菓子の粉Xグラム
mグラム消費するとドーナツを1種類作ることができる

条件：必ずN種類のドーナツを1つ以上作る
その上で
最大で作れる個数を作る

優先すべきは全てのドーナツを作ること
次に最小の粉で作れるドーナツを最大まで作ること
'''
N, X = map(int,input().split())

li = [input().strip() for i in range(N)]

li = list(map(int,li))

m = li[0]#最小の初期値
c = 0 #全て1つ分の値段の保持

for i in li:
    if i < m:
        m = i
    c += i

# N 個分は確定で存在しているからあとはもっとも安いの何個？

t = int((X - c) / m) + N

print(t)


Measured memory_bytes: 3064