akhauriyash/Code-Regression huggingface dataset:
from collections import deque

s = input()
q = int(input())

deq = deque(s)
pol = 0
for _ in range(q):
    query = input()
    if query[0] == '1':
        pol ^= 1
        continue
    _, f, c = query.split()
    op = int(f) - 1
    if op ^ pol:
        deq.append(c)
    else:
        deq.appendleft(c)

if pol:
    print(''.join(reversed(deq)))
else:
    print(''.join(deq))

Measured memory_bytes: 14404
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL((a))), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

void rev(auto &(a), auto i)
{
  if (a.at(i) == 'L') a.at(i) = 'R';
  else a.at(i) = 'L';
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  VI op;
  VB checked(N, false);
  REP(i, N)
  {
    if (K == 0) break;
    if (i == 0 || i == N-1) continue;
    if (checked.at(i)) continue;
    if ((S.at(i) != S.at(i-1)) && (S.at(i) != S.at(i+1)))
    {
      checked.at(i-1) = true;
      checked.at(i) = true;
      checked.at(i+1) = true;
      op.push_back(i);
      K--;
    }

  }
  REPx(x, op)
    {
      if (S.at(x) == 'L') S.at(x) = 'R';
      else S.at(x) = 'L';
    }
  int s, e;
  bool flg = false;
  REP(i, N-1)
  {
    if (K == 0) break;
    if (S.at(i) != S.at(i+1) && !flg)
    {
      s = i;
      flg = true;
    }
    else if (S.at(i) != S.at(i+1) && flg)
    {
      rev(S, i);
      e = i+1;
      flg = false;
      K -= 1;
    }
    else if(S.at(i) == S.at(i+1) && flg) rev(S, i);
  }
  if (flg) rev(S, N-1);
  int ans = 0;
  REP(i, N-1)
  {
    if (S.at(i) == S.at(i+1)) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int n, num;
	
	int a[10];
	
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> num;
		a[0] = (num * num / 100) % 10000;
		for(int j = 1; j < 10; j++){
			a[j] = (a[j - 1] * a[j - 1] / 100) % 10000;
		}
		printf("Case %d:\n", i + 1);
		for(int j = 0; j < 10; j++){
			printf("%d\n", a[j]);
		}
	}
	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
int main(void){
	char a;
	scanf("%c",&a);
	if(a==65){//A
		printf("T");
	}else if(a==67){//C
		printf("G");
	}else if(a==71){//G
		printf("C");
	}else if(a==84){//T
		printf("A");
	}
	
	return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

const int N = 110;

pair<int, int> p[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (p[i].first == p[i].second) {
      ++cnt;
    } else {
      cnt = 0;
    }
    if (cnt == 3) {
      cout << "Yes" << '\n';
      return 0;
    }
  }
  cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  vector<char> vec(4);
  vec = {S[0],S[1],S[2],S[3]};
  sort(ALL(vec));
  if(vec[0]==vec[2])
  {
    cout << "No" << endl;
    return 0;
  }
  if(vec[0]==vec[1]&&vec[2]==vec[3])
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;

bool ar[2005][2005];
vector <int> row[2005],col[2005];

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

    int h,w;
    cin >> h >> w;

    for (int i=0;i<2005;i++){
        ar[0][i]=1;
        ar[i][0]=1;
        ar[h+1][i]=1;
        ar[i][w+1]=1;
    }

    for (int i=1;i<=h;i++){
        string s;
        cin >> s;

        for (int j=1;j<=w;j++){
            ar[i][j]=(s[j-1]=='#');
        }
    }

    for (int i=0;i<=h+1;i++){
        for (int j=0;j<=w+1;j++){
            if (ar[i][j]) row[i].pb(j);
        }
    }

    for (int j=0;j<=w+1;j++){
        for (int i=0;i<=h+1;i++){
            if (ar[i][j]) col[j].pb(i);
        }
    }

    int ans=0;
    for (int i=1;i<=h;i++){
        for (int j=1;j<=w;j++){
            if (!ar[i][j]){
                auto rlow=upper_bound(row[i].begin(),row[i].end(),j);
                auto rupp=rlow--;
                auto clow=upper_bound(col[j].begin(),col[j].end(),i);
                auto cupp=clow--;

                ans=max(ans,*rupp-*rlow+*cupp-*clow-3);
            //    cerr << *rupp - *rlow + *cupp - *clow - 1 << " "; 
            }
        }
        //cerr << el;
    }

    cout << ans << el;

    return 0;
}

Measured memory_bytes: 36352
#include<iostream>
using namespace std;
#define MAX 100003
#define NIL -1

struct node {
	int parent, left, right;
};
struct node T[MAX];
int LEFT;

void Preorder(int u){
	if(T[u].parent == NIL) cout<<"Preorder"<<endl;
	// else cout<<" ";
	cout<<" "<<u;
	if(T[u].left != NIL){
		Preorder(T[u].left);
	}
	if(T[u].right != NIL){
		Preorder(T[u].right);
	}
	if(T[u].parent == NIL) cout<<endl;
}
void Inorder(int u){
	if(T[u].parent == NIL) cout<<"Inorder"<<endl;
	
	if(T[u].left != NIL){
		Inorder(T[u].left);
	}
	// if(u != LEFT) cout<<" ";
	cout<<" "<<u;
	if(T[u].right != NIL){
		Inorder(T[u].right);
	}
	if(T[u].parent == NIL) cout<<endl;
}
void Postorder(int u){
	if(T[u].parent == NIL) cout<<"Postorder"<<endl;
	
	if(T[u].left != NIL){
		Postorder(T[u].left);
	}
	if(T[u].right != NIL){
		Postorder(T[u].right);
	}
	// if(u != LEFT) cout<<" ";
	cout<<" "<<u;
	if(T[u].parent == NIL) cout<<endl;
}

void lef(int u){
	if(T[u].left != NIL){
		lef(T[u].left);
	} else LEFT = u;
}

int main(){
	int n, id, k, c, c2, root, left, right;
	cin>>n;
	
	for(int i = 0; i < n; i++)
		T[i].parent = T[i].left = T[i].right = NIL;
	
	
	for(int i = 0; i < n; i++){
		cin>>id>>left>>right;
		T[id].left = left;
		T[id].right = right;
		if(left != NIL){
			T[left].parent = id;
		}
		if(right != NIL){
			T[right].parent = id;
		}
	}
	
	for(int i = 0; i < n; i++){
		if(T[i].parent == NIL) root = i;
	}
	lef(root);
	Preorder(root);
	Inorder(root);
	Postorder(root);
	
	return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
    string s;
    cin>>k;
    cin>>s;
    for(i=0;i<min((int)s.size(),(int)k);i++)
    {
        cout<<s[i];
    }
    if(s.size()>k)
    {
        cout<<"...";
    }
    
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


const ll INF = numeric_limits<ll>::max();

int main(){
    ll n, m, s;
    cin >> n >> m >> s;

    vector<vector<array<ll, 3>>> net(n);  // nxt, ai, bi
    vector<ll> c(n), d(n);

    ll ub = 0;

    REP(i, m){
        ll ui, vi, ai, bi;
        cin >> ui >> vi >> ai >> bi;
        ui--; vi--;
        net.at(ui).push_back({vi, ai, bi});
        net.at(vi).push_back({ui, ai, bi});

        ub += ai;
    }

    REP(i, n){
        cin >> c.at(i) >> d.at(i);
    }

    vector<vector<ll>> mintime(n, vector(ub + 1, INF));
    s = min(s, ub);
    mintime.at(0).at(s) = 0;
    priority_queue<array<ll, 3>, vector<array<ll, 3>>, greater<array<ll, 3>>> que;
    que.push({0, 0, s});
    while(!que.empty()){
        const auto [tcur, cur, ccur] = que.top(); que.pop();
        if(tcur > mintime.at(cur).at(ccur)){ continue; }
        for(const auto [nxt, ai, bi] : net.at(cur)){
            if(ccur < ai){ continue; }
            const ll t2 = tcur + bi;
            const ll c2 = ccur - ai;
            if(t2 < mintime.at(nxt).at(c2)){
                mintime.at(nxt).at(c2) = t2;
                que.push({t2, nxt, c2});
            }
        }

        const ll t2 = tcur + d.at(cur);
        const ll c2 = min(ccur + c.at(cur), ub);
        if(t2 < mintime.at(cur).at(c2)){
            mintime.at(cur).at(c2) = t2;
            que.push({t2, cur, c2});
        }
    }

    for(ll i = 1; i < n; ++i){
        cout << *min_element(ALL(mintime.at(i))) << endl;
    }
    return 0;
}


Measured memory_bytes: 7476
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
    if ('0' <= s[i] && s[i] <= '9')
      ret = 10 * ret + s[i] - '0';
  return ret;
}

int main(int argc, char **argv) {
    i64 n;
    __int128 k;

    string kstr;
    cin >> n >> kstr;
    k = parse(kstr);

    vector<i64> as(n);
    vector<bool> visit(n, false);
    for (int i=0; i<n; ++i) {
        cin >> as[i];
        --as[i];
    }

    i64 loop_remain{0};
    i64 loop_size{0};
    i64 loop_start;
    i64 current{0},next;
    while(true) {
        visit[current] = true;
        next = as[current];
        if (visit[next] == true) {
            loop_start=next;
            break;
        }
        current = next;
    }
    //cout << " " << loop_start << endl;
    current=0;
    while(true) {
        if (current == loop_start) break;
        current = as[current];
        ++loop_remain;
    }
    //cout << " " << loop_remain << endl;
    while(true) {
        next = as[current];
        ++loop_size;
        if (next == loop_start) {
            break;
        }
        current = next;
    }
    //cout << " " << loop_size << endl;

    if (k < loop_remain) {
        i64 ans=0;
        for (int i=0; i<k; ++i) {
            ans = as[ans];
        }
        cout << (ans+1) << endl;
        return 0;
    }
    i64 mod_k = (k-loop_remain) % loop_size;

    i64 ans=loop_start;
    for (int i=0; i<mod_k; ++i) {
        ans = as[ans];
    }

    cout << (ans+1) << endl;
    return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
int main()
{
    int n;cin>>n;
    int b = 1000;
    for(int i = 1; i <= n / 2; i++){
        int sum = 0;
        int a = i;
        while(a){
            sum += a % 10;
            a /= 10;
        }
        a = n - i;
        while(a){
            sum += a % 10;
            a /= 10;
        }
        b = min(b, sum);
    }
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define pb         push_back
#define mp         make_pair

template<class T> void pp(T a,int n){rep(i,n)cout<<a[i]<<' ';cout<<endl;}
typedef long long ll;

const int inf = (1 << 29);
const int N = 200;

class Edge{
public:
  int f,t,c;
};

int cost[N][N];
void wf(int n){
  rep(k,n)rep(i,n)rep(j,n)cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
}

int getname(string &in,map<string,int> & M){
  int index=M.size();
  if (M.find(in) == M.end())M[in]=index;
  return M[in];
}



bool getdata(int n,map<string,int> & M,vector<Edge> &in){    
  bool contra=false;
  rep(i,n){
    string from,to;
    int f,t,c;
    int idum;char cdum;
    cin>>idum>>from>>cdum>>idum>>cdum>>c>>to;
    f=getname(from,M);
    t=getname(to,M);
    if(c < 0)swap(f,t),c*=-1;
    in.pb((Edge){f,t,c});
    if (cost[f][t] != inf)contra=true;
    cost[f][t]=c;
    cost[t][f]=-c;
  }
  return contra;
}

main(){
  int n;
  while(cin>>n && n){
    rep(i,N){
      rep(j,N)cost[i][j]=inf;
      cost[i][i]=0;
    }
    map<string,int> M;
    vector<Edge> in;
    bool iscontra=getdata(n,M,in);
    wf(M.size());
    bool isok=true;

    n = M.size();


    rep(i,n && isok){
      rep(j,n && isok){
	if (i == j)continue;
	if (cost[i][j] == inf)continue;
	rep(k,n && isok){
	  if (cost[i][k] >= inf/2 || cost[k][j] >= inf/2)continue;
	  if (cost[i][j] != cost[i][k]+cost[k][j]){
	    //cout << i<<" " << k <<" " << j << endl;
	    //	    cout << cost[i][j] <<" " << cost[i][k]<<" " << cost[k][j] <<endl;

	    isok=false;
	    break;
	  }
	}
      }
    }
    


    if (isok&&!iscontra)puts("Yes");
    else puts("No");
  }
}

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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  int ans = 0;
  rep(i, h) { cin >> c[i]; }
  vector<vector<bool> > bl(h, vector<bool>(w, false));
  rep(i, h) rep(j, w) {
    if (c[i][j] == '#') {
      bl[i][j] = true;
    }
  }

  for (int bit1 = 0; bit1 < (1 << h); ++bit1) {
    for (int bit2 = 0; bit2 < (1 << w); ++bit2) {
      vector<vector<bool> > check(h, vector<bool>(w, false));
      check = bl;
      rep(i, h) {
        if (bit1 & (1 << i)) {
          rep(j, w) {
            if (c[i][j] == '#') check[i][j] = false;
          }
        }
      }
      rep(i, w) {
        if (bit2 & (1 << i)) {
          rep(j, h) {
            if (c[j][i] == '#') check[j][i] = false;
          }
        }
      }
      int cnt1 = 0;
      rep(i, h) rep(j, w) {
        if (check[i][j]) cnt1++;
      }
      if (cnt1 == k) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int K, T;
    cin >> K >> T;
    vector<int> A(T);
    rep(i, T) cin >> A[i];
    
    sort(A.rbegin(), A.rend());
    if (K & 1) {
        int X = max(0, A[0] - (K + 1) / 2);
        cout << 2 * X << endl;
    } else {
        int X = max(0, A[0] - K / 2);
        if (X == 0) cout << 0 << endl;
        else cout << 1 + 2 * (X - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    int ans = 1e9;
    for (int i = 0; i < n; i++) {
        int a; std::cin >> a;
        int cnt = 0;
        while (a > 0 && ~a & 1) cnt++, a >>= 1;
        ans = std::min(ans, cnt);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> a(N+1),ans(N+1,0);
    int ans_cnt = 0;
    for (size_t i = 1; i <= N; i++)
    {
        scanf("%d", &a[i]);
    }for (int i = N; i >= 1; i--)
    {
        int sum = 0;
        for (size_t m = 2*i; m <= N; m += i)
        {
            sum += ans[m];
        }
        if(sum%2!=a[i]){
            ans[i] = 1;
            ans_cnt++;
        }
    }
    cout << ans_cnt << endl;
    for (size_t i = 1; i <= N; i++)
    {
        if (ans[i]==1)
        {
            cout << i << " ";
        }
    }
    cout <<endl;
    
    

    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include<math.h>
 
using namespace std;
 
int couent = 0;
int keisann(int a) {
    if (a == 2) { couent++; }
    if (a % 2 == 0) { return 0; }
    int v = sqrt(a);
    for (int i = 3; i <= v; i+=2)
    {
        if (a%i == 0) {
            return 0;
        }
    }
    couent++;
}
int main()
{
    int dataset;
    cin >> dataset;
    for (size_t i = 0; i < dataset; i++)
    {
        int a;
        cin >> a;
        keisann(a);
    }
    cout << couent << endl;
}

Measured memory_bytes: 3092
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/



int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  ll numA = 0, numB = 0;
  rep(i, S.size()){
    if(S[i] == 'a'){
      if(numA + numB < A + B){
        numA++;
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }else if(S[i] == 'b'){
      if(numA + numB < A + B && numB < B){
        numB++;
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 896
N, M, K = [int(item) for item in input().split()]
MOD = 10**9 + 7

n = 2 * 10**5 + 10
fac = [1] + [0] * n
fac_inv = [1] + [0] * n
for i in range(1, n+1):
    fac[i] = fac[i-1] * (i) % MOD
    # Fermat's little theorem says
    # a**(p-1) mod p == 1
    # then, a * a**(p-2) mod p == 1
    # it means a**(p-2) is inverse element
    fac_inv[i] = fac_inv[i-1] * pow(i, MOD-2, MOD) % MOD

def mod_nCr(n, r):
    if n == 0 and r == 0:
        return 1
    if n < r or n < 0:
        return 0
    tmp = fac_inv[n-r] * fac_inv[r] % MOD
    return tmp * fac[n] % MOD 

total = 0
for i in range(M):
    total += (M - i) * N * N * mod_nCr(M * N - 2, K - 2) * i
    total %= MOD  
for i in range(N):
    total += (N - i) * M * M * mod_nCr(M * N - 2, K - 2) * i
    total %= MOD  
print(total)

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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    vec.at(i)=a;
  }
  bool judge=true;
  for(int i=0; i<n; i++){
    int x=vec.at(i);
    if(x%2==1) continue;
    if(x%3==0||x%5==0) continue;
    judge=false;
  }
  if(judge==true) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}


Measured memory_bytes: 256
using System;
public class c
{
  public static void Main()
  {
    string[] A_B_C = Console.ReadLine().Split(' ');
    int A = int.Parse(A_B_C[0]);
    int B = int.Parse(A_B_C[1]);
    int C = int.Parse(A_B_C[2]);
    if(C<B/A)Console.WriteLine(C);
    else Console.WriteLine(B/A);
  }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;cin>>n;
    int ans = 0;
    rep(i, n+1){
        int t = i;
        int keta = 0;
        while(t>0){
            t/=10;
            keta++;
        }
        if(keta%2==1){
            ans++;
        }
    }
    cout << ans << 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)
using ll = long long;
using P = pair<int,int>;
static const ll INF = 1000000000000000000;
static const ll MOD = 1000000007;

int main(){
	int n;
	cin >> n;
	if(n % 1000 == 0){
		cout << 0 << endl;
	}
	else{
		cout << 1000 - (n % 1000) << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3604
s=input()
count1=0
count2=0
for i in range(len(s)):
    if (i%2==0):
        if s[i]=='1':
            count2+=1
        else:
            count1+=1
    if (i%2==1):
        if s[i]=='0':
            count2+=1
        else:
            count1+=1
print(min(count1,count2))


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    ll h,w;cin>>h>>w;
    if(h==1||w==1){
        cout<<1<<endl;
        return 0;
    }
    cout<<h*w-(h*w)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b;cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0)
        cout<<"Possible"<<endl;
    else
        cout<<"Impossible"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include<stdio.h>

int main() {

	int a, b, i, j, fake;
	int c[3];

	scanf("%d %d", &a, &b);

	c[0] = a + b;
	c[1] = a - b;
	c[2] = a * b;

	for (i = 0; i < 3; i++) {
		for (j = 0; j < 2; j++) {
			if (c[j] < c[j + 1]) {
				fake = c[j];
				c[j] = c[j + 1];
				c[j + 1] = fake;
			}
		}
	}

	printf("%d", c[0]);

	return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  long long int n,k[105],ans=100000000,sum;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>k[i];
  }
  for(int i=-100;i<=100;++i){
    sum=0;
    for(int j=0;j<n;++j){
      sum+=(k[j]-i)*(k[j]-i);
    }
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define VI vector<int>
#define pii pair<int,int>
#define INF 0x3f3f3f3f
using namespace std;
int n, X[1010], Y[1010];
int movx[] = {1,-1,0,0};
int movy[] = {0,0,1,-1};
char mov[] = {'L', 'R', 'D', 'U'};
string solve(LL x, LL y, LL pw){
	string ans = "";
	for(LL i = pw-1; i >= 0; i--){
		for(int j = 0; j < 4; j++){
			LL nx = x + movx[j]*(1LL<<i);
			LL ny = y + movy[j]*(1LL<<i);
			if(llabs(nx) + llabs(ny) <= ((1LL<<i)-1)){
				x = nx;
				y = ny;
				ans += mov[j];
				break;
			}
		}
	}
	reverse(ans.begin(), ans.end());
	return ans;
}
int main(){
	scanf("%d", &n);
	int p = -1;
	for(int i = 0; i < n; i++){
		scanf("%d %d", &X[i], &Y[i]);
		if(p == -1) p = (abs(X[i]) + abs(Y[i]))%2;
		else if(abs(X[i] + abs(Y[i]))%2 != p){
			printf("-1\n");
			return 0;
		}
	}
	if(!p){
		for(int i = 0; i <n; i++) X[i]--;
	}
	int mx = 0;
	for(int i = 0; i < n; i++){
		mx = max(mx, abs(X[i]) + abs(Y[i]));
	}
	LL pw = 1;
	for(; (1LL<<pw)-1 < mx; pw++);
	printf("%d\n", pw + !p);
	for(LL i = 0; i < pw; i++){
		if(i == 0 && !p) printf("1 ");
		printf("%lld ", (1LL<<i));
	}
	printf("\n");
	for(int i = 0; i < n; i++) mx = max(mx, abs(X[i]) + abs(Y[i]));
	for(int i = 0; i < n; i++){
		string x = solve(X[i], Y[i], pw);
		printf("%s%s\n", !p ? "R":"", x.c_str());
	}
	return 0;
}

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

const int N = 1e5 + 7;

int fa[N];
vector<pair<int, pair<int, int> > > v;
vector<pair<int, pair<int, int> > > e;

void init()
{
    v.clear();
    e.clear();
    for(int i = 0;i < N;i ++)
        fa[i] = i;
}

void addEdge(int u, int v, int w)
{
    e.push_back(make_pair(w, make_pair(u, v)));
}

int find(int x)
{
    if(fa[x] != x)
        fa[x] = find(fa[x]);
    return fa[x];
}

void merge(int a, int b)
{
    a = find(a);
    b = find(b);
    if(fa[a] != fa[b])
        fa[a] = fa[b];
}

int main()
{
    int n;
    while(cin >> n)
    {
        init();
        for(int i = 0;i < n; i ++)
        {
            int x, y;
            cin >> x >> y;
            v.push_back(make_pair(i, make_pair(x, y)));
        }
        sort(v.begin(), v.end(), [](pair<int, pair<int, int>> a, pair<int, pair<int, int>> b) {
            return a.second < b.second;
        });
        for(int i = 1; i < n; i ++)
        {
            auto p1 = v[i - 1].second;
            auto p2 = v[i].second;
            addEdge(v[i].first, v[i - 1].first, min(abs(p1.first - p2.first), abs(p1.second - p2.second)));
        }
        sort(v.begin(), v.end(), [](pair<int, pair<int, int>> a, pair<int, pair<int, int>> b) {
            return a.second.second < b.second.second || (a.second.second == b.second.second && a.second.first < b.second.first);
        });
        for(int i = 1; i < n; i ++)
        {
            auto p1 = v[i - 1].second;
            auto p2 = v[i].second;
            addEdge(v[i].first, v[i - 1].first, min(abs(p1.first - p2.first), abs(p1.second - p2.second)));
        }
        long long sum = 0;
        sort(e.begin(), e.end(), [](pair<int, pair<int, int>> a, pair<int, pair<int, int>> b) {
            return a.first < b.first;
        });
        for(int i = 0;i < e.size(); i ++)
        {
            int u = e[i].second.first;
            int v = e[i].second.second;
            int w = e[i].first;
            if(find(u) == find(v))
                continue;
            sum += w;
            merge(u, v);
        }
        cout << sum << endl;
    }
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

ll pw(ll a, ll p){

	if(p ==0)return 1;


	if(p%2 ==0){
		ll tmp = pw(a,p/2);

		return (tmp*tmp)%1000000007;
	}else {
		return  (a*pw(a, p-1))%1000000007;
	}

}
ll c(ll n , ll k){

	ll a =1;

	for(int i=n; i>n-k; i-- ){
		a =(a*i)%1000000007;
	}

	ll b =1;

	for(int i=1; i<=k; i++){
		b =(b*pw(i,1000000005))%1000000007;
	}


	return (a*b)%1000000007;
}




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


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



	if((x+y) %3){
		writeln(0);
		return 0;
	}

	int n = (x+y)/3;

	x -=n; y -=n;

	if(x<0 || y <0){
		writeln(0);
		return 0;
	}

	writeln(c(x+y,x));



}




Measured memory_bytes: 256
import java.util.*;
import java.math.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[] S = sc.next().toCharArray();

        int cnt = 0;
        int j = 0;
        for (int i = 0; i < N; i++) {
            if (S[i] == 'A') {
                j=1;
            } else if (j == 1 && S[i] == 'B') {
                j+=1;
            } else if (j == 2 && S[i] == 'C') {
                cnt+=1;
                j=0;
            } else {
                j = 0;
            }
        }

        System.out.println(cnt);

    }
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int main() {
	ll n;
	cin >> n;
	ll res = 1;
	vector<ll> a(n);
	FOR(i, 0, n - 1) {
		cin >> a[i];
		if (a[i] == 0) {
			ps(0);
			return(0);
		}
	}
	FOR(i, 0, n - 1) {
		double bai = double(1000000000000000000) / double(res);
		//dump(bai);
		//dump(a[i])
		if (bai < a[i]) {
			ps(-1);
			return(0);
		}
		else {
			res *= a[i];
		}
		if (res > 1000000000000000000 || res < 0) {
			ps(-1);
			return(0);
		}
	}
	pv(res);
	return(0);
}

Measured memory_bytes: 4052
#include <cstddef>
#include <limits>
#include <climits>
#include <cfloat>
#include <cstdint>
#include <cstdlib>
#include <new>
#include <typeinfo>
#include <exception>
#include <initializer_list>
#include <stdexcept>
#include <cassert>
#include <cerrno>
#include <system_error>
#include <string>

#if __has_include(<string_view>)
#   include <string_view>
#endif

#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>

#if __has_include(<filesystem>)
#   include <filesystem>
#endif

#include <cstdio>
#include <cinttypes>


#include <regex>
#include <atomic>
#include <thread>
#include <mutex>
#include <shared_mutex>
#include <condition_variable>
#include <future>

using namespace std::literals ;

int K, S;

void input(){
  std::cin >> K >> S;
}

int main(){
  input();
  
  int ans = 0;
  for ( int i = 0 ; i <= K ; ++i ){
    for ( int j = 0 ; j <= K ; ++j ){
      if ( (S - i - j) >= 0 && (S - i - j) <= K )
        ++ans;
    }
  }
  
  std::cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define nl '\n'
#define dbg(a) cout<<#a<<"="<<a<<endl
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define ll long long
#define vl vector<ll>
#define pll pair<ll, ll>
#define ii pair<int,int>
#define vi vector<int>
#define md 998244353
#define inf 100000000


using namespace std;

int solve()
{
    int h, w, k;
    cin>>h>>w>>k;
    string a[h];
    for(int i=0;i<h;i++) cin>>a[i];

    ll ans=0;

    for(int r=0;r<(1<<h);r++)
    {
        for(int c=0;c<(1<<w);c++)
        {
            ll ct=0;
            for(int i=0;i<h;i++)
            {
                for(int j=0;j<w;j++)
                {
                    if(r&(1<<i) || c&(1<<j)) continue;
                    ct+=a[i][j]=='#';
                }
            }
            ans+=ct==k;
        }
    }
    cout<<ans<<endl;
    return 0;
}

int main()
{
    fast;
    solve();

    return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;
int a[N];
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,m,i,j,l=1,r,mid,ans,t=0;
    scanf("%d%d",&n,&m);r=(ans=(n<<=1)+1)-2;
    rep(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+i);
	while(l<=r){
        mid=(l+r)>>1;
        if(!(mid&1))mid|=1;
        i=mid;j=n;
        while(i<=j){
            if(a[i]+a[j]<m)break;
            ++i;--j;
        }
        //printf("judge mid=%d result=%d\n",mid,i>j);
        if(i>j)r=(ans=mid)-2;else l=mid+2;
    }
    //printf("ans=%d\n",ans);
    i=1;j=ans-1;
    while(i<=j){
        cmax(t,a[i]+a[j]  );
        ++i;--j;
    }
    i=ans;j=n;
    while(i<=j){
        cmax(t,a[i]+a[j]-m);
        ++i;--j;
    }
    printf("%d",t);
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))


avg1 = sum(a) // n
avg2 = avg1
if sum(a) % n != 0:
    avg2 = avg1 + 1

ans1 = 0
ans2 = 0 
for i in range(n):
    ans1 += (a[i] - avg1) ** 2
    ans2 += (a[i] - avg2) ** 2

print(min(ans1, ans2))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(1000000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

def is_lunlun(n):
    s = str(n)
    for i in range(len(s)-1):
        if abs(int(s[i])-int(s[i+1])) > 1:
            return False
    return True

def slv(k):
    if k <= 9:
        return k
    lunlun = list(range(1, 10))
    q = deque(lunlun)

    while True:
        n = q.popleft()
        for i in (-1, 0, 1):
            d = n % 10
            if 0 <= d + i <= 9:
                l = n * 10 + d+i
                q.append(l)
                lunlun.append(l)
                if len(lunlun) == k:
                    return lunlun[-1]




def main():
    K = read_int()
    print(slv(K))



if __name__ == '__main__':
    main()


Measured memory_bytes: 9968
n = int(input())
i = 0
p0 = 0
p1 = 0
while i < n:
    s = list(map(str, input().split(' ')))
    if s[0] > s[1]:
        p0 += 3
    elif s[0] < s[1]:
        p1 += 3
    else:
        p0 += 1
        p1 += 1
    i += 1
print(str(p0) + ' ' + str(p1))


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
typedef long long ll;
typedef pair<int,int> pii;
//---------------------
#define MAXN 50
//---------------------

ll n;
int main(){
	cin>>n;
	cout<<(n-2)*180<<endl;
    
    return 0;

}


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

using namespace std;

int main() {
	int N,W;
    cin >> N >> W;

    vector<long long> w(N+1), v(N+1);
    for (int i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
    }

    // 1からiまでの品物の中で重さの和がj以下の品物の価値の総和の最大値dp[i][j]
    vector<vector<long long>> dp(N+1, vector<long long>(W+1, 0));

    // dp開始
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j - w[i] >= 0) {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j - w[i]] + v[i]);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    cout << dp[N][W] << endl;
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int A[N];
  int sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }

  sort(A, A + N);
  reverse(A, A + N);

  if(A[M - 1] >= (double)sum / 4 / M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int m,d,n=0;
cin>>m>>d;
if(d>=22&&m>=4)
{
 for(int i=22;i<=d;i++)  
 {
     int t=i;int t1=t%10;t=t/10;int t2=t%10;
     if(t1>1&&t2>1&&t1*t2<=m)
     {
        n++; 
         //cout<<t1*t2<<"-"<<i<<"\n";
     }
     
     
     
     
 }
    
}  
cout<<n;    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 256
from copy import copy
import random
random.seed(1)
import math
import sys
input = sys.stdin.readline
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last = [0]*26
ans = [0]*D
score = 0
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    ans[i] = idx+1
    score += max(ps)
for k in range(1,41001):
    na = copy(ans)
    x = random.randint(1,365)
    y = random.randint(1,365)
    na[x-1] = na[y-1]
    last = [0]*26
    ns = 0
    for i in range(D):
        last[na[i]-1] = i+1
        ns += s[i][na[i]-1]
        for j in range(26):
            ns -= c[j]*(i+1-last[j])
    if k%100 == 1:
        T = 200-(199*k/41000)
    p = pow(math.e,-abs(ns-score)/T)
    if ns > score or random.random() < p:
        ans = na
        score = ns
for a in ans:
    print(a)

Measured memory_bytes: 84320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N % 10; // 1の位
  b = (N % 100 - a) / 10; // 10の位
  c = ((N % 1000) - (b * 10 + a)) /100; // 100の位
  d = (N - (c * 100 + b * 10 + a )) /1000;
  
  if (a == b && a == c) {
    cout << "Yes" << endl;
  }
  else if (b == c && b == d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    map<int,int> A;
    int N; cin >> N;
    REP(i,N){
        int a; cin >> a;
        A[a]++;
    }

    int ans = 0;
    for(auto a: A){
        ans += a.second - 1;
    }
    cout << N - (ans + ans%2) << endl;
    return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
	int N,W; cin >> N >> W;
	vector<int> v(N), w(N);
	for(int i = 0; i < N; i++){
		cin >> v[i] >> w[i];
	}
	vector<int> now(W+1,0), prev(W+1,0);
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= W; j++){
			if(j - w[i] >= 0){
				now[j] = max(prev[j], prev[j-w[i]] + v[i]);
			}
			else now[j] = prev[j];
		}
		swap(now, prev);
	}
	cout << prev.back() << endl;

	return 0;
}




Measured memory_bytes: 3172
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import deque

h,w = li()
a = [list(lc()) for _ in range(h)]

que = deque()

dist = [[-1]*w for _ in range(h)]

for i, ai in enumerate(a):
    for j, aij in enumerate(ai):
        if aij == "#":
            que.append((0, (i, j)))
            dist[i][j] = 0
        
drs = [0,1,0,-1]
dcs = [1,0,-1,0]

while que:
    cur, (r,c) = que.popleft()
    dist[r][c] = cur
    
    for dr, dc in zip(drs, dcs):
        if 0 <= r+dr < h and 0 <= c+dc < w:
            if dist[r+dr][c+dc] == -1:
                dist[r+dr][c+dc] = cur + 1
                que.append((cur+1, (r+dr, c+dc)))
                
ans = 0
for di in dist:
    for dij in di:
        ans = max(ans, dij)
print(ans)

Measured memory_bytes: 145500
require 'matrix'
include Math

EPS = 0.000001

loop do
	n = gets.to_i
	break if n == 0

	anchors = (1..n).map{gets.split.map &:to_f}
	max = -Float::INFINITY
	
	anchors.each do |x, y, z|
		if anchors.all?{|a, b, r| (x-a)**2 + (y-b)**2 + z**2 <= r**2 + EPS}
			max = z if z > max
		end
	end
	
	anchors.combination(2) do |u, v|
		u, v = v, u if u[-1] < v[-1]
		(a1, b1, r1), (a2, b2, r2) = u, v
		d = Math.hypot(a1-a2, b1-b2)
		l = (d + (r1**2 - r2**2) / d) / 2
		q = l / d
		next if q < 0 || 1 < q
		x = (1-q)*a1 + q*a2		
		y = (1-q)*b1 + q*b2
		z = sqrt(r1**2 - (x-a1)**2 - (y-b1)**2)
		if anchors.all?{|a, b, r| (x-a)**2 + (y-b)**2 + z**2 <= r**2 + EPS}
			max = z if z > max
		end
	end
	
	anchors.combination(3) do |u, v, w|
		(a1, b1, r1), (a2, b2, r2), (a3, b3, r3) = u, v, w
	
		mat = Matrix[
			[2*(a1-a2), 2*(b1-b2)],
			[2*(a2-a3), 2*(b2-b3)]
			]
		next if mat.singular?
	
		v = Vector[
			r2**2 - r1**2 + a1**2 - a2**2 + b1**2 - b2**2,
			r3**2 - r2**2 + a2**2 - a3**2 + b2**2 - b3**2
			]
	
		x, y =  *(mat.inv * v)
		d = r1**2 - (x-a1)**2 - (y-b1)**2
		next if d < 0
		z = sqrt(d)
	
		if anchors.all?{|a, b, r| (x-a)**2 + (y-b)**2 + z**2 <= r**2 + EPS}
			max = z if z > max
		end
	end
	p max
end

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

int main(){
  int X, thou, five;
  cin >> X;
  thou = int(X / 500);
  five = int((X % 500) / 5);
  int result = thou * 1000 + five * 5;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
	long long a, b;
	cin >> a >> b;

	if (a > b) {
		int t = a;
		a = b;
		b = t;
	}

	long long i = a;
	while (1 < i) {
		if (a % i == 0 && b % i == 0) {
			cout << a * b / i << endl;
			return 0;
		}

		i--;
	}

	cout << a * b << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<char>a(3);
  for (int i=0;i<3;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  vector<char>b(3);
  b={'a','b','c'};
  if (a==b){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256