akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    int b=9999,c;
    string a,t,tt,ttt;
    cin >> a;
    for(int i=0;i<a.size()-2;i++){
        t=a[i];
        tt=a[i+1];
        ttt=a[i+2];
        c=100*stoi(t)+10*stoi(tt)+stoi(ttt);
        b=min(b,abs(c-753));
    }
    cout << b;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
index=1
allSum =0
while index<n+1:
    listS = list(str(index))
    index2 =0
    sum=0
    while index2< len(listS):
        sum+=int(listS[index2])
        index2+=1
    if sum > a-1 and sum < b+1:
        allSum+=index
    index+=1

print(allSum)


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

int main() {
  int64_t n, x, y;
  int64_t ans=0;
  cin>>n;
  int64_t m=n+1;
  vector<int64_t> mon(m);
  for (int i = 0; i < m; i++) {
    cin>>mon.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin>>x;
    y=min(x, mon.at(i));
    ans+=y;
    x-=y;
    y=min(x, mon.at(i+1));
    ans+=y;
    mon.at(i+1)-=y;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>/*toupperとかが入っている*/
#include<vector>/*可変長配列vectorのインクルード*/

const int MOD=1000000007;/* 1,000,000,007 で割った余りを出力する　のとき使う*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/

int r;

int main(void) {
  cin >> r;

  cout << 3*r*r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = long long;
const int SIZE = 200001;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n; ll k; cin >> n >> k;
    int G[SIZE];
    rep(i, n) cin >> G[i+1];
    vector<int> order(SIZE, 0); order[1]++;
    int ans = 1;
    while (!order[G[ans]]){
        order[G[ans]] = order[ans]+1;
        ans = G[ans];
        k--;
        if (k == 0){
            cout << ans << endl;
            return 0;
        }
    }
    int roopsize = order[ans] - order[G[ans]] + 1;
    k %= roopsize;
    rep(i, k)ans = G[ans];
    cout << ans << endl;
}

Measured memory_bytes: 4732
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")
# define int long long

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e7;

int w[107], v[107], dp[107][N];

int32_t main() {
    speed;
    int n, W;
    cin >> n >> W;
    for ( int i = 1; i <= n; i++ ) {
        cin >> w[i] >> v[i];
    }
    for ( int i = 1; i <= n; i++ ) {
        for ( int j = 0; j <= W; j++ ) {
            dp[i][j] = dp[i - 1][j];
            if ( w[i] <= j )
                dp[i][j] = max( dp[i - 1][j - w[i]] + v[i], dp[i][j] );
        }
    }
    cout << dp[n][W];
}


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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b){
        int t=a;
        a=b;
        b=t;
    }
    if(b>c){
        int t=b;
        b=c;
        c=t;
    }
    if(a>b){
        int t=a;
        a=b;
        b=t;
    }
    cout <<a<<" "<<b<<" "<<c<< endl;
return 0;
}


Measured memory_bytes: 3092
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll K,A,B;
	cin >>K>>A>>B;
	
	// 解法
	ll ans = 0;
	if (B-A<=2){
		ans = K+1;
	}
	else{
		ll sousa23 = (K-(A-1))/2;
		ll sousa1 = K - sousa23*2;
		// printf("%lld %lld\n", sousa1, sousa23);
		ans = sousa1 + sousa23*(B-A) + 1;
		
	}
	
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll h,w,k;
    cin>>h>>w>>k;
    char a[h][w];
    ll cnt=0;
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    ll ans=0;
    for(ll i=0;i<(1LL<<h);i++){
        for(ll j=0;j<(1LL<<w);j++){
            cnt=0;
            for(ll ii=0;ii<h;ii++){
                for(ll jj=0;jj<w;jj++){
                    if(!(i&(1LL<<ii)) && !(j&(1LL<<jj))){
                            if(a[h-ii-1][w-jj-1]=='#'){
                                cnt++;
                            }
                        }
                    
                }
            }
            if(cnt==k){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

int W, N, v[1000], w[1000], dp[1001][1001];

int main() {
  for (int I = 1;; I++) {
    scanf("%d\n", &W);
    if (!W) return 0;
    scanf("%d\n", &N);
    for (int i = 0; i < N; i++)
      scanf("%d,%d\n", &v[i], &w[i]);
    for (int j = 0; j <= W; j++)
      dp[N][j] = 0;
    for (int i = N-1; i >= 0; i--)
      for (int j = 0; j <= W; j++)
        if (j >= w[i])
          dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]]+v[i]);
        else
          dp[i][j] = dp[i+1][j];
    int maxv = 0, maxw = 0;
    for (int j = 0; j <= W; j++)
      if (dp[0][j] > maxv) {
        maxv = dp[0][j];
        maxw = j;
      }
    printf("Case %d:\n%d\n%d\n", I, maxv, maxw);
  }
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{
	int n, a;				//Value n, a.
	int i;
	int min, max;			//Answers.
	long sum;

	scanf("%d", &n);

	i = 0;
	sum = 0;
	while(i < n)
	{
		scanf("%d", &a);
		if(i == 0)
		{
			min = a;
			max = a;
		}

		if(min > a)
			min = a;
		if(max < a)
			max = a;

		sum = sum + a;
		i++;
	}

	printf("%d %d %ld\n", min ,max, sum);
	return (0);
}



Measured memory_bytes: 2148
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

vector<int> color(210, 0);
bool odd = false;

void dfs(int cv, int pv, vector<vector<int>> &G){

    for(auto nv : G[cv]){
        if(color[nv] != 0){
            if(color[cv] == color[nv]) odd = true;
        }
        else{
            if(color[cv] == 1) color[nv] = 2;
            else color[nv] = 1;

            dfs(nv, cv, G);
        }
    }
    return ;
}


vector<vector<int>> dist(210, vector<int>(210, inf));
void warshall_floyd(int n){
    for(int i=0; i<n; i++) dist[i][i] = 0;

    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

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

    int n; cin>>n;
    vector<vector<int>> G(n);
    
    for(int i=0; i<n; i++){
        string s; cin>>s;
        for(int j=0; j<n; j++){
            if(s[j] == '1'){
                G[i].emplace_back(j);
                G[j].emplace_back(i);
                dist[i][j] = 1;
                dist[j][i] = 1;
            }
        }
    }

    color[0] = 1;
    dfs(0, -1, G);

    if(odd){
        cout << -1 << endl;
        return 0;
    }

    warshall_floyd(n);

    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            chmax(ans, dist[i][j] + 1);
        }
    }

    cout << ans << endl;

    return 0;
}

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

int H, W, A, B;

void output(vector<vector<int>> &s) {
  rep(i,H) {
    rep(j,W) {
      cout << s.at(i).at(j);
    }
    cout << endl;
  }
}

bool solve(vector<vector<int>> &s, int a1, int b1) {
  vector<int> r(H,0);
  vector<int> c(W,0);
  rep(i,H) {
    rep(j,W) {
      if ( r.at(i) < a1 && c.at(j) < b1 ) {
        s.at(i).at(j) = 1;
        r.at(i)++;
        c.at(j)++;
      }
      else {
        s.at(i).at(j) = 0;
      }
    }
  }
  rep(i,H) {
    if ( r.at(i) != a1 && r.at(i) != W - a1 ) {
      return false;
    }
  }
  rep(j,W) {
    if ( c.at(j) != b1 && c.at(j) != H - b1 ) {
      return false;
    }
  }
  return true;
}

int main() {
  //input
  cin >> H >> W >> A >> B;
  //calc
  vector<vector<int>> s(H, vector<int>(W));
  bool solved = true;
  if ( solve(s, A, B) ) {
  }
  else if ( solve(s, W-A, B) ) {
  }
  else if ( solve(s, A, H-B) ) {
  }
  else if ( solve(s, W-A, H-B) ) {
  }
  else {
    solved = false;
  }
  //output
  if ( solved ) {
    output(s);
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 5120
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define ll long long
using namespace std;
int main() {
     int n,a,b;
     scanf("%d%d%d",&n,&a,&b);
     int sum=abs(a-b)-1;
     if(sum%2)
     {
          printf("Alice\n");
     }
     else printf("Borys\n");
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "\n[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "\n[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]\n";
}

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...);
}


int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    int N;
    scanf("%d", &N);

    while (true) {
        int i = 2;
        for (; i <= sqrt(N) && N % i; ++i) { }
        if (i == N || N % i) {
            printf("%d\n", N);
            break;
        }
        N++;
    }

    return 0;
}



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

int main() {
  string s;
  string t;
  cin >> s >> t;
  if(s.length() < t.length()) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  bool res = false;
  for(int i = s.length() - t.length(); i >= 0; i--) {
    bool ok = true;
    for(int j = 0; j < t.length(); j++) {
      if(s[i + j] != t[j] && s[i + j] != '?') {
        ok = false;
        break;
      }
    }
    if(ok) {
      for(int j = 0; j < t.length(); j++) {
        s[i + j] = t[j];
      }
      res = true;
      break;
    }
  }
  if(!res) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  for(int i = 0; i < s.length(); i++) {
    if(s[i] == '?') {
      s[i] = 'a';
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B] = input[0].map(Number);

  return A !== 2 && B !== 2 ? "Yes" : "No";
};

console.log(main(read()));


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

int main(){
  int64_t N, K;
  cin >> N >> K;
  vector<pair<int64_t, int64_t>> P(N);
  for(int64_t i=0; i<N; i++){
    cin >> P.at(i).first >> P.at(i).second;
  }
  sort(P.begin(), P.end());
  int64_t X=0;
  for(int64_t i=0; i<N; i++){
    X+=P.at(i).second;
    if(X>=K){
      cout << P.at(i).first << endl;
      break;
    } 
  }
}

Measured memory_bytes: 1792
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int m;
    scan(m);

    foreach (i ; 0 .. m) {
        string s = readln.chomp;
        writeln(solve(s));
    }
}

int solve(string s) {
    int res;

    auto rbt = redBlackTree!(string)();

    foreach (i ; 1 .. s.length) {
        auto a = s[0..i].dup.to!(string), ar = s[0..i].dup.retro.to!(string);
        auto b = s[i..$].dup.to!(string), br = s[i..$].dup.retro.to!(string);

        rbt.insert(a~b);
        rbt.insert(a~br);
        rbt.insert(ar~b);
        rbt.insert(ar~br);
        rbt.insert(b~a);
        rbt.insert(b~ar);
        rbt.insert(br~a);
        rbt.insert(br~ar);
    }

    debug {
        writeln(rbt);
    }

    return rbt.length.to!int;
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define int long long
#define all(v) (v).begin(),(v).end()
using namespace std;
const int INF=1000000000000;
int s(int a,int b){
  return a+b+min(a,b);
}
signed main(){
  int a,b,Q;
  cin>>a>>b>>Q;
  vector<int> A(a),B(b);
  for(int &i:A)cin>>i;
  for(int &i:B)cin>>i;
  while(Q--){
    int x;
    cin>>x;
    int it1=lower_bound(all(A),x)-A.begin(),it2=lower_bound(all(B),x)-B.begin();
    cout<<min({
      (it1!=a && it2!=b?max(abs(A[it1]-x),abs(B[it2]-x)):INF),
      (it1!=a && it2?s(abs(A[it1]-x),abs(B[it2-1]-x)):INF),
      (it1 && it2!=b?s(abs(A[it1-1]-x),abs(B[it2]-x)):INF),
      (it1 && it2?max(abs(A[it1-1]-x),abs(B[it2-1]-x)):INF)
    })<<endl;
  }
}

Measured memory_bytes: 4772
import sys
from fractions import gcd
def input(): return sys.stdin.readline().strip()


def main():
    S = input()
    N = 0
    arr = []
    pre = S[0]
    num = 0
    for c in S:
        N += 1
        if c == pre:
            num += 1
        else:
            arr.append(num)
            num = 1
        pre = c
    arr.append(num)
    #print(arr)

    ans = 0
    for i in range(len(arr)):
        ans += arr[i] * (-1) ** i
    print(N - abs(ans))
    """
    i = 0
    while i < N:
        if arr[i] <= arr[i + 1]:
            arr[i + 1] -= arr[i]
            arr[i] = 0
            i += 1
        else:
            arr[i + 2] += arr[i] - arr[i + 1]
            arr[i] = 0
            arr[i + 1] = 0
            i += 2
    """

if __name__ == "__main__":
    main()


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

using namespace std;
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  int sum = 0;
  int a;
  rep(i, m) {
    cin >> a;
    sum += a;
  }
  if (n - sum < 0) {
    cout << -1 << endl;
  } else {
    cout << n - sum << endl;
  }
  return 0;
}


Measured memory_bytes: 3516
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.StringTokenizer;
 
public class Main {
	public static void main(String[] args) throws IOException {
		MScanner sc = new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		//int n=sc.nextInt();
		//int[]in=new int[n];for(int i=0;i<n;i++)in[i]=sc.nextInt();
		int n=sc.nextInt();int ans=0;
		for(int i=n;i>0;i--) {
			int x=i;int c=0;
			while(x>0) {
				c++;x/=10;
			}
			if(c%2==1)ans++;
		}
		pw.println(ans);
		pw.close();
		pw.flush();
 
	}
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

int n;
vector<lint> a, b;
lint mod = 1000000007;

// a^n mod pを計算　O(log n)
long long pow_mod(long long a, long long n, long long p) {
    if (n == 0) return 1;
    if (n & 1) return pow_mod(a, n - 1, p) * a % p;
    long long temp = pow_mod(a, n / 2, p);
    return temp * temp % p;
}

pair<lint, lint> reg(lint x, lint y) {
    lint div = gcd(x, y);
    x /= div, y /= div;
    if (y < 0) {
        x *= -1, y *= -1;
    }
    if (y == 0 && x < 0) {
        x *= -1;
    }
    return {x, y};
}

pair<lint, lint> auth(pair<lint, lint> p) {
    lint x = -p.second, y = p.first;
    if (y < 0) {
        x *= -1, y *= -1;
    }
    if (y == 0 && x < 0) {
        x *= -1;
    }
    return {x, y};
}

int main() {
    cin >> n;
    map<pair<lint, lint>, lint> count;
    a.resize(n), b.resize(n);
    vector<pair<lint, lint>> vec;
    lint zeros = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        if (a[i] == 0 && b[i] == 0) {
            zeros++;
            continue;
        }
        auto v = reg(a[i], b[i]);
        vec.push_back(v);
        count[v]++;
    }
    set<pair<lint, lint>> trash;
    lint ans = 1;
    for (int i = 0; i < (int)vec.size(); i++) {
        if (trash.count(vec[i])) {
            continue;
        }
        auto o = auth(vec[i]);
        lint mul = (pow_mod(2, count[vec[i]], mod) + pow_mod(2, count[o], mod) - 1) % mod;
        ans = ans * mul % mod;
        trash.insert(vec[i]);
        trash.insert(o);
    }
    if (ans < 0) {
        return 1;
    }
    lint res = (zeros % mod + ans % mod - 1) % mod;
    if (res < 0) {
        res = (res + mod) % mod;
    }
    cout << res << endl;
}

Measured memory_bytes: 59392
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;

int main(){
    string s;
    cin >> s;
    cout<<s;
    
    if(s[s.length()-1]=='s'){
        cout<<'e';
    }
    cout<<'s'<<endl;
    return 0;
}


Measured memory_bytes: 3624
class UnionFind():
    def __init__(self, n):
        self.par = [-1 for i in range(n)]

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x]) # contraction
            return self.par[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return False
        if self.par[x] > self.par[y]:
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x
        return True

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]


n, m = map(int, input().split())
edge = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

uf = UnionFind(n)
ans = n * (n-1) // 2
anss = []
for i in reversed(range(m)):
    anss.append(ans)
    # print(uf.par)
    # print(uf.size, [uf.size[uf.find(i)] for i in range(n)])
    a, b = edge[i]
    if not uf.same(a, b):
        ans -= uf.size(a) * uf.size(b)
    # print(i, a, b)

    uf.unite(a, b)

for i in reversed(range(m)):
    print(anss[i])


Measured memory_bytes: 33404
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(n) begin(n),end(n)

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  int N;
  cin>>N;
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
    int A;
    cin>>A;
    while(A%2 == 0)
    {
      ANS++;
      A /=2;
    }
  }
  cout<<ANS;
  
  
  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int i,j,x[100],N,minj,count=0,tmp;
 
  scanf("%d",&N);

  for(i=0;i<N;i++){

    scanf("%d",&x[i]);
  
  }
 
  for(i=0;i<N;i++){
    minj = i;
    for(j = i;j<N;j++){
      if(x[j]<x[minj]){
	minj = j;
      }
    }
    if(i != minj){
      tmp = x[i];
      x[i] = x[minj];
      x[minj] = tmp;
      count++;
    }
  }
 
  for(i=0;i<N-1;i++){
    
    printf("%d ",x[i]);

  }
  
    printf("%d\n%d\n",x[N-1],count);

  
 
  return 0;
}

Measured memory_bytes: 600
"""
python3 b_ans.py
3          
8 12 40
[3, 2, 3]
全部を割って、一番割れなかった数を返せば、事足りる。面白い！
"""

N = int(input())
A = [int(i) for i in input().split()]
ans = [0]*N
for i in range(N):
    while A[i] % 2 == 0:
        A[i] //= 2
        ans[i] += 1
print(min(ans))


Measured memory_bytes: 3060
//#include<stdio.h>
//#include<stdlib.h>
#include<bits/stdc++.h>
//#define Min(a,b,c) min((a),min((b),(c)))
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-11
#define MEM(x) memset(x,0,sizeof(x))
//#define N 200005
#define M
#define pi 3.14159265359
using namespace std;
typedef long long LL;
vector<LL> ans; 
int mod=1e9+7;
int main(){
	char c[100005];
	char t[100005];
	scanf("%s",c);
	scanf("%s",t);
	int a[100005];
	memset(a,0,sizeof(a));
	int b[100005];
	memset(b,0,sizeof(b));
	for(int i=0;c[i]!=0;i++){
		a[i+1]=a[i];
		if(c[i]=='A')
		a[i+1]++;
		else
		a[i+1]+=2;
	}
	for(int i=0;t[i]!=0;i++){
		b[i+1]=b[i];
		if(t[i]=='A')
		b[i+1]++;
		else
		b[i+1]+=2;
	}
	int q;
	scanf("%d",&q);
	while(q--){
		int w,x,y,z;
		scanf("%d %d %d %d",&w,&x,&y,&z);
		//printf("%d %d %d %d\n",a[x],a[w-1],b[z],b[y-1]);
		if((a[x]-a[w-1])%3==(b[z]-b[y-1])%3)
		printf("YES\n");
		else
		printf("NO\n");
	}
}
/*
Y  * (5y-4)(y+1)*/


Measured memory_bytes: 1536
import java.util.*

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val n = scanner.nextLong()
	val t = scanner.nextLong()
	val ct = mutableListOf<Pair<Long, Long>>()
	for (i in 1..n)
		ct.add(scanner.nextLong() to scanner.nextLong())
	val result = ct.asSequence()
			.filter { it.second <= t }
			.minBy { it.first }
	println(result?.first ?: "TLE")
}

Measured memory_bytes: 33560
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
    ll n;
    vector<ll> d;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        ll di;
        cin >> di;
        d.emplace_back(di);
    }
    sort(d.begin(), d.end());
    ll ans = 0;
    if (n%2!=0) ans  = 0;
    else {
        ans = d[n/2] - d[n/2-1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
def middle_square(n, s)
  sprintf("%0#{2 * n}d", s**2).slice(n - 2, n).to_i
end

count = 1
n = gets.chomp.to_i

n.times do
  puts "Case #{count}:"
  s = gets.chomp.to_i
  10.times do
    s = middle_square(4, s)
    puts s
  end
  count += 1
end

Measured memory_bytes: 8616
//#pragma GCC optimize (2)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(),v.end()
ll quick_pow(ll base, ll n) {
    ll ans = 1;
    while (n ) {
        if (n & 1 )
            ans *= base;
        base *= base;
        n >>= 1;
    }
    return ans;
}
void solve();
int main() {
    int T=1;
//    cin>>T;
    while (T--){
        solve();
    }
    return 0;
}
void solve(){
    int l,r,d;
    cin>>l>>r>>d;
    cout<<r/d - l/d + (int)(l%d==0) <<endl;
}


Measured memory_bytes: 3588
#include<stdio.h>

int main(void)
{
	int n, m, l;
	int i, j,k;
	int A[100][100] = { 0 }, B[100][100] = {0};
	long long C[100][100] = { 0 };
	scanf("%d %d %d", &n, &m,&l);
	for (i = 0;  i< n; i++)
	{
		for (j = 0; j < m; j++)
		{
			scanf("%d", &A[i][j]);
		}
	}
	for (i = 0; i< m; i++)
	{
		for (j = 0; j < l; j++)
		{
			scanf("%d", &B[i][j]);
		}
	}
	for (i = 0; i< n; i++)
	{
		for (j = 0; j < l; j++)
		{
			for (k = 0; k < m; k++)
			{
				C[i][j] = C[i][j] + A[i][k] * B[k][j];
			}
			printf("%lld", C[i][j]);
			if (j != l - 1) printf(" ");
		}
		printf("\n");
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;

int main(){
    ll K, S;
    cin >> K >> S;
    ll ans = 0;
    for(ll i = 0; i <= K; i++){
        for(ll j = 0; j <= K; j++){
            if(S - i - j >= 0 && S - i - j <= K) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
void main()
{
    long n, w;
    rdVals(n, w);

    long[][] items = new long[][](4);
    long w0, v0;
    rdVals(w0, v0);
    items[0] ~= v0;
    foreach (i; 1 .. n)
    {
        long wi, vi;
        rdVals(wi, vi);
        items[wi-w0] ~= vi;
    }

    long[][] lists = new long[][](4);
    long[] len = new long[4];
    foreach (i; 0 .. 4)
    {
        items[i].sort!"a > b";
        lists[i].length = items[i].length + 1;
        len[i] = lists[i].length;
        foreach (j, x; items[i])
        {
            lists[i][j+1] = lists[i][j] + items[i][j];
        }
    }

    long result;
    foreach (i; 0 .. len[0])
    {
        long w1 = w0 * i;
        long v1 = lists[0][i];
        if (w1 > w) break;
        foreach (j; 0 .. len[1])
        {
            long w2 = w1 + (w0 + 1) * j;
            long v2 = v1 + lists[1][j];
            if (w2 > w) break;
            foreach (k; 0 .. len[2])
            {
                long w3 = w2 + (w0 + 2) * k;
                long v3 = v2 + lists[2][k];
                if (w3 > w) break;
                foreach (l; 0 .. len[3])
                {
                    long w4 = w3 + (w0 + 3) * l;
                    long v4 = v3 + lists[3][l];
                    if (w4 > w) break;
                    result = max(result, v4);
                }
            }
        }
    }

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

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

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

vector<bool> eratosthenes(int n) {
	vector<bool> prime(n + 1);
	for (int i = 2; i <= n; i++) {
		prime[i] = true; // 初期化
	}
	prime[0] = prime[1] = false;
	for (int i = 2; i*i <= n;i++) {
		if (prime[i]) {
			for (int j = i * 2; j <= n; j += i) {
				prime[j] = false;
			}
		}
	}
	return prime;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll x,n;
	scanf("%lld", &x);

	n = x / 11*2;
	int modNum = x % 11;
	if (modNum > 0 && modNum <= 6) {
		n++;
	}
	else if (modNum > 6) {
		n += 2;
	}
	cout << n << endl;

	return 0;
}


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

int main() {
  int n; std::cin >> n;
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    int e; std::cin >> e;
    if (e != i) ++cnt;
  }
  if (cnt <= 2) std::cout << "YES" << std::endl;
  else std::cout << "NO" << std::endl;
  
  return 0;
} 

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

int main() {
  int N;
  int abc = 0;
  string S;
  cin >> N;
  cin >> S;
  for (int i = 0; i < N-2; i++) {
    if (S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C') {
      abc++;
    }
  }
  cout << abc << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        
        long[] xh = new long[n];
        for(int i=0; i<n; i++){
            long x = Integer.parseInt(sc.next());
            long h = Integer.parseInt(sc.next());
            xh[i] = (x<<32) + h;
        }
        Arrays.sort(xh);
        
        PriorityQueue<Long> q = new PriorityQueue<>();
        q.add(-1L >>> 1);
        long ans = 0;
        long exp = 0;
        for(int i=0; i<n; i++){
            int x = (int)(xh[i]>>32);
            int h = (int)xh[i];
            
            long peek = q.peek();
            while((peek>>32)<x){
                exp -= (int)peek;
                q.poll();
                peek = q.peek();
            }
            
            long add = (h+a-1)/a - exp;
            add = Math.max(0, add);
            ans += add;
            
            exp += add;
            if((x+d*2L)<=(long)1e9){
                q.add(((x+d*2L)<<32)+add);
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 65756
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=2e3+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,a[N],ans[N],du[N];
bool G[N][N],vis[N];
vector<int> E[N];
void dfs(int u,int fa) {
    vis[u]=1;
    if(fa) E[fa].pb(u),du[u]++;
    for(int v=1;v<=n;v++) if(G[u][v]&&!vis[v]) dfs(v,u);
}
priority_queue<pii> q;
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=gi();
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++) if(__gcd(a[i],a[j])!=1) G[i][j]=G[j][i]=1;
    for(int i=1;i<=n;i++) if(!vis[i]) dfs(i,0);
    for(int i=1;i<=n;i++) if(!du[i]) q.push(mp(a[i],i));
    int tot=0;
    while(!q.empty()) {
        pii u=q.top();q.pop();ans[++tot]=u.fi;
        for(int v:E[u.se]) if(!--du[v]) q.push(mp(a[v],v));
    }
    for(int i=1;i<=tot;i++) printf("%d ",ans[i]);
    return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
int N,x,y;
int m[2][444][444];
int main(){
    cin>>N>>x>>y;
    for(int i=0;i<444;i++){
        fill(m[0][i],m[0][i]+444,1e9);
        fill(m[1][i],m[1][i]+444,1e9);
    }
    m[0][0][0]=m[1][0][0]=0;
    for(;N--;swap(m[0],m[1])){
        int a,b,c;
        cin>>a>>b>>c;
        for(int i=0;i<=400;i++){
            for(int j=0;j<=400;j++){
                m[1][i][j]=min(m[1][i][j],m[0][i][j]);
                m[1][i+a][j+b]=min(m[0][i+a][j+b],m[0][i][j]+c);
            }
        }
    }
    int ans=1e9;
    for(int i=1;i<444;i++){
        for(int j=1;j<444;j++){
            if(i*y==j*x)
                ans=min(ans,m[0][i][j]);
        }
    }
    if(ans==1e9){
        cout<<"-1";
    }
    else{
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    public static class Program
    {
        static void Main()
        {
            var array = Console.ReadLine().Split(' ').Select(i => i.ToInt()).ToArray();
            var N = array[0];
            var D = array[1];
            var points = new int[N][];
            for (int i = 0; i < N; i++)
            {
                points[i] = Console.ReadLine().Split(' ').Select(x => x.ToInt()).ToArray();
            }

            int count = 0;
            for (int y = 0; y < points.Length - 1; y++)
            {
                for (int y2 = y + 1; y2 < points.Length; y2++)
                {
                    if (IsDistanceInteger(points[y], points[y2])) ++count;
                }
            }
            Console.WriteLine(count);
        }

        private static bool IsDistanceInteger(int[] y, int[] z)
        {
            var distance = Math.Sqrt(y.Zip(z, (a, b) => (int)Math.Pow(Math.Abs(a - b),2d)).Sum());
            return distance == Math.Floor(distance);
        }

        public static int ToInt(this string param) => int.Parse(param);
    }
}


Measured memory_bytes: 13652
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
typedef long long ll;
using namespace std;
int gcd(int a,int b){
	if(a<b)swap(a,b);
	int r=a%b;
	while(r){
		a=b;
		b=r;
		r=a%b;
	}
	return b;
}
int main(){
	int w,h,c;cin>>w>>h>>c;
	int g=gcd(w,h);
	cout<<(w/g)*(h/g)*c<<endl;
}



Measured memory_bytes: 3136
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class AWeatherPrediction {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s; cin >> s;
      string ret;
      if (s[0] == 'S') {
        ret = "Cloudy";
      } else if (s[0] == 'C') {
        ret = "Rainy";
      } else {
        ret = "Sunny";
      }
      cout << ret << endl;
    }
};

signed main() {
  AWeatherPrediction solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 2e5 + 5;
const ll mod = 1000;
const double PI = acos(-1.0);
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }

int n, a, b;
string val;

void solve()
{
	int ca = 0, cb = 0;
	cin >> n >> a >> b;
	cin >> val;
	int len = val.length();
	rep(i, 0, len)
	{
		if (val[i] == 'c')
		{
			puts("No");
		}
		else
		{
			if (val[i] == 'a')
			{
				if (ca + cb + 1 <= a + b)
				{
					ca++;
					puts("Yes");
				}
				else
				{
					puts("No");
				}
			}
			else
			{

				if (ca + cb + 1 <= a + b&&cb+1<=b)
				{
					cb++;
					puts("Yes");
				}
				else
				{
					puts("No");
				}
			}
		}
	}
}

int main()
{
	solve();
	return 0;
}




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

typedef pair<int, pair<char, int> > table;
table dp[200005];
int last[26];
char str[200005];
int main(){
	scanf("%s",str);
	int n = (int)strlen(str);
	for(int i=0;i<26;i++) last[i] = n;
	dp[n] = {1, {'-', n}};
	dp[n+1] = {0, {'-', n}};
	for(int i=n-1;i>=0;i--){
		dp[i] = {n+1, {'-', n+1}};
		last[str[i] - 'a'] = i;
		for(int j=0;j<26;j++){
			table candi = {dp[last[j]+1].first + 1, {'a' + j, last[j]+1}};
			if(dp[i].first > candi.first){
				dp[i] = candi;
			}
		}
	}
	for(int i=0;i<n;i=dp[i].second.second){
		printf("%c", dp[i].second.first);
	}
	printf("\n");
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000009
using namespace std;
int used[214514];
ll sum[214514];
ll ans[214514];
vector<int> nd[214514];
int main(){
	int n,q;
	cin>>n>>q;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		nd[x].pb(y);
		nd[y].pb(x);
	}
	for(int i=0;i<q;i++){
		int p,x;
		cin>>p>>x;
		sum[p] += x;
	}
	queue< pair<int, ll> > que;
	que.push(mp(1, 0));
	while(!que.empty()){
		pair<int, ll> cur = que.front(); que.pop();
		int idx = cur.first;
		ll csum = cur.second;
		used[idx] = 1;
		ans[idx] = csum + sum[idx];
		for(int i=0; i<nd[idx].size();i++){
			if( used[ nd[idx][i] ] == 0){
				que.push( mp( nd[idx][i], csum + sum[idx] ) );
			}
		}
	}
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 21492
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

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

    long long all = 0;
    for (auto x : A) {
        all ^= x;
    }
    
    for (int i = 0; i < n; ++i) {
        cout << (all ^ A[i]) << (i == n - 1 ? '\n' : ' ');
    }

    return 0;
}

Measured memory_bytes: 4716
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
#define M 1000000007
ll n,ans,p[1000005],s;
ll pw(ll x,ll y){
    ll res=1;
    while(y>0){
        if(y&1)res=(res*x)%M;
        x=(x*x)%M;
        y>>=1;
    }
    return res;
}
ll cm(ll x,ll y){
    return p[x]*pw(p[x-y],M-2)%M*pw(p[y],M-2)%M;
}
int main(void){
    scanf("%lld",&n);
    p[0]=1;
    for(int i=1;i<=n;i++)p[i]=(p[i-1]*i)%M;
    for(ll k=n/2;k<=n-1;k++){
        ll c=cm(k-1,n-1-k)*p[k]%M*p[n-1-k]%M;
        ans=(ans+(c+M-s)%M*k%M)%M;
        s=c;
    }
    printf("%lld\n",ans);
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int N;
	cin >> N;
	int sum = 0, tempN = N;
	while (tempN % 10 != 0) {
		sum += tempN % 10;
		tempN /= 10;
	}
	if (N % sum == 0) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}	
	
	return 0;
}


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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define int long long

using namespace std;

using P = pair<int, int>;
using ll = long long;

const long long INF = LLONG_MAX/3;
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

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

class UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
public:
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
#define double long double
signed main(){
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	int ans1=0,ans2=0;
	double memo=0;
	rep(i,f/(a*100)+1){
		rep(j,f/(b*100)+1){
			if(a*100*i+b*100*j>f){
				continue;
			}
			int n=f-a*100*i-b*100*j;
			rep(s,n/c+1){
				rep(t,n/d+1){
					if(c*s+d*t>n||(c*s+d*t+a*100*i+b*100*j)==0||(a*i+b*j)*e<c*s+d*t)continue;
					if((double)(c*s+d*t)/(double)(c*s+d*t+a*100*i+b*100*j)+0.001>memo){
						memo=(double)(c*s+d*t)/(double)(c*s+d*t+a*100*i+b*100*j)+0.001;
						ans1=(c*s+d*t+a*100*i+b*100*j);
						ans2=(c*s+d*t);
					}
				}
			}
		}
	}
	cout<<ans1<<" "<<ans2<<endl;
}

Measured memory_bytes: 256