akhauriyash/Code-Regression huggingface dataset:
//
// Created by MengHaitao on 2019/11/27 0027.
//
//Bubble Sort
#include <iostream>
using namespace std;
int arr[1005], n, count;
void swap(int &a, int &b) { a ^= b ^= a ^= b; }   //交换两个数
void bubbleSort() {
    for (int i = 0; i < n; ++i) {
        for (int j = n-1; j >i; --j) {
            if (arr[j-1] > arr[j]) {
                swap(arr[j-1], arr[j]);
                count++;
            }
        }
    }
    for (int j = 0; j < n; ++j) {
        if (j == n - 1) cout << arr[j] << endl;
        else
            cout << arr[j] << " ";
    }
    cout<<count<<endl;
}

void solve() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    bubbleSort();
}

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


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l;
  cin >> n >> l;
  vector<int> vec(n);
  for (int i = 1; i <= n; i++) {
    vec[i - 1] = i + l - 1;
  }
  sort(vec.begin(), vec.end(),
       [](int i, int j) -> bool { return abs(i) < abs(j); });
  int ans = 0;
  for (int i = 1; i < n; i++) {
    ans += vec[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//file_name:ABC78_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int x,y,z;
    cin >> x >> y >> z;



    ll ans = 0;

    x -= z;

    ans = x/(y+z);

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
const ll MOD = 1e9 + 7;
#define rep(i,k) for(int i=0;i<k;i++)
ll n, i, j, k, o, p, l, z,x,y,h,w,sa=0,m;
ll a[200010] = {}, b[200010], inf = 1000000000000;
string s;
vector<vector<ll>> va(100005);
queue<ll> q;
pair<ll, ll> pp;
ll par[100005];

ll root(ll x) {
	if (par[x] == x) {
		return x;
	 }
	else {
		return par[x] = root(par[x]);
	}
}

bool same(ll x, ll y) {
	return root(x) == root(y);
}

void unite(ll x, ll y) {
	x = root(x);
	y = root(y);
	if (x == y)return;
	par[x] = y;
}
void shokika(ll* par, ll n) {
	rep(i, n)par[i] = i;
}
int main() {
	cin >>n>>m;
	shokika(par,n+3);
	rep(i, m){
		cin >> x >> y>>z;
	//	cout << root(x)<<" "<< root(y) << "\n";
		if (same(x, y))continue;
		unite(x, y);
		sa++;
		
		}
	cout << n-sa;
	return 0;
	
}

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

template <typename T>
vector<pair<T, int>> factorize(T x) {
	vector<pair<T, int>> res;
	for (T i = 2; i * i <= x; i++) {
		if (x % i == 0) {
			res.emplace_back(i, 0);
			while (x % i == 0) {
				res.back().second++;
				x /= i;
			}
		}
	}
	if (x > 1) {
		if (!res.empty() && res.back().first == x)
			res.back().second++;
		else
			res.emplace_back(x, 1);
	}
	return res;
}

int main()
{
	ll A, B;
	cin >> A >> B;
	ll X = __gcd(A, B);
	auto ps = factorize(X);
	cout << ps.size() + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
string s[100];
int N;
int rec(int& idx, int dep){
  if(isdigit(s[idx][dep])) return s[idx++][dep]-'0';
  else if(s[idx++][dep]=='+'){
    int ret = 0;
    while(s[idx].length()==dep+2) ret += rec(idx, dep+1);
    return ret;
  }
  else {
    int ret = 1;
    while(s[idx].length()==dep+2) ret *= rec(idx, dep+1);
    return ret;
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  while(cin>>N&&N){
    FOR(i,0,N){
      cin>>s[i];
    }
    s[N]="";
    int idx = 0;
    cout<<rec(idx,0)<<endl;
  }
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
const ll MOD = 1e9 + 7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++){
        if (i % k == 0)
        {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
    return 0;
}

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

int main() {
  int n,k;cin>>n>>k;
  int an[n];rep(i,n)an[i]=0;
  int d, a;
  rep(i,k){
    cin>>d;
    rep(j,d) {
      cin>>a;
      an[a-1] ++ ;
    }
  }
  int cnt=0;
  rep(i,n) if(an[i]==0) cnt++;
  cout<<cnt;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
using namespace std;
using lint = long long;
int main(){
  int N;cin>>N;
  lint count[5]={0,0,0,0,0};
  for(int i=0;i<N;i++){
    string S; cin>>S;
    if(S[0]=='M') count[0]++;
    else if(S[0]=='A') count[1]++;
    else if(S[0]=='R') count[2]++;
    else if(S[0]=='C') count[3]++;
    else if(S[0]=='H') count[4]++;
  }
  lint ans=0;
  for(int i=0;i<3;i++){
    for(int j=i+1;j<5;j++){
      for(int k=j+1;k<5;k++)
        ans+=count[i]*count[j]*count[k];
    }
  }
  
  cout<<ans<<endl;
  return 0;
}
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
int n,cnt=1,tr[N][2];
LL L;
char s[N];
LL lowbit(LL x){
	return x&-x;
}
LL pan(int x,LL t){
    if(x==0)return lowbit(L-t+1);
    return pan(tr[x][0],t+1)^pan(tr[x][1],t+1);
}
void Insert(char a[]){
    int ro=1;
    for(int i=1;a[i];i++){
        if(tr[ro][a[i]-'0']==0)tr[ro][a[i]-'0']=++cnt;
        ro=tr[ro][a[i]-'0'];
    }
}
int main(){
    scanf("%d%lld",&n,&L);
    for(int i=1;i<=n;i++){
        scanf("%s",s+1);
        Insert(s);
    }
    if(pan(1,0LL)==0LL)puts("Bob");
    else puts("Alice");
}

Measured memory_bytes: 9328
using System;
using System.Linq;
using System.Threading;

namespace AtCoderBeginnerContest162
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = ReadInt();
			var result = 0;
			for (var i = 1; i <= input; i++)
			{
				for (var j = 1; j <= input; j++)
				{
					for (var k = 1; k <= input; k++)
					{
						result += CulcurateGCD(CulcurateGCD(i, j), k);
					}
				}
			}
			Console.WriteLine(result);
		}

		static int CulcurateGCD(int a, int b)
		{
			var big = a;
			var small = b;
			if (a < b)
			{
				big = b;
				small = a;
			}

			while (big % small != 0)
			{
				var tmp = big;
				big = small;
				small = tmp % small;
			}
			return small;
		}

		public static int ReadInt()
			=> int.Parse(Console.ReadLine());

		public static int[] ReadIntArray()
			=> Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

		public static long ReadLong()
			=> long.Parse(Console.ReadLine());

		public static long[] ReadLongArray()
			=> Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

		public static string ReadString()
			=> Console.ReadLine();

		public static string[] ReadStringArray()
			=> Console.ReadLine().Split();
	}
}


Measured memory_bytes: 27400
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cmath>
using namespace std;

int main()
{
	string s;
	unordered_map<char, int> mp;
	cin >> s;


	for (int i = 0; i < s.length(); i++) {
		char c = s.at(i);
		mp[c]++;
	}

	bool result = true;
	if (mp.size() != 2){
		result = false;
	}

	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		if (itr->second != 2){
			result = false;
			break;
		}
	}

	if (result) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
//
//  main.cpp
//  Walking Takahashi
//
//  Created by Bryan on 15/08/20.
//  Copyright © 2020 mac. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main()
{
    long long X,K,D;
    scanf ("%lld %lld %lld",&X,&K,&D);
    if (X<0)
        X = -X;
        long long div = X/D;
        div = K - div;
        if (div<0)
            printf ("%lld\n",abs(X-K*D));
        else if (div%2 == 0)
            printf ("%lld\n",abs(X%D));
        else
            printf ("%lld\n",abs(D-X%D));
    
    
   
            
}


Measured memory_bytes: 3824
use std::cmp::Ordering;

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

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

pub trait BinarySearch<T> {
    fn lower_bound(&self, &T) -> usize;
    fn upper_bound(&self, &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

fn main() {
    let _: usize = read();
    let a: Vec<u64> = read_vec();
    let b: Vec<u64> = read_vec();

    let mut ans = 0;
    for c in 1..30 {
        let c = 2u64.pow(c);
        let half_c = c / 2;
        let temp_a = a.iter().map(|x| x % c).collect::<Vec<_>>();
        let mut temp_b = b.iter().map(|x| x % c).collect::<Vec<_>>();
        temp_b.sort();
        let mut counts = 0;
        for a_num in temp_a {
            if a_num < half_c {
                let lb = temp_b.lower_bound(&(half_c - a_num));
                let ub = temp_b.lower_bound(&(c - a_num));
                counts += ub - lb;
            } else if a_num == half_c {
                let lb = temp_b.lower_bound(&half_c);
                counts += lb;
            } else {
                let lb = temp_b.lower_bound(&(c - a_num));
                let ub = temp_b.lower_bound(&(c + half_c - a_num));
                counts += temp_b.len() - ub + lb;
            }
        }
        if counts % 2 == 1 {
            ans += half_c;
        }
    }
    println!("{:?}", ans);
}


Measured memory_bytes: 13788
s = input()
s = s[::-1]
t = ['maerd', 'remaerd', 'esare', 'resare']

while s:
    l = len(s)
    for i in[7,6,5]:
        while s[:i:] in t:
            s = s[i::]
    if l == len(s):
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 9132
#include <stdio.h>

int main(){

  int a,b,c;  
  scanf("%d %d %d",&a,&b,&c);
  // && ||
  if(a < b && b < c){
    printf("Yes\n");
  }

  else{
    printf("No\n");
  }
  
 

  return 0; 
}

Measured memory_bytes: 580
#include <iostream>
#include <algorithm>
#include <vector>


using lli = long long int;
template <class T> using Vec = std::vector<T>;
template <class T> using Wec = std::vector<Vec<T>>;


std::vector<int> A;
int main(void){
    int n, m; scanf("%d%d", &n, &m);
    A.resize(n, 0);
    for(int i = 0; i < m; i++){
        int a, b; scanf("%d%d",&a, &b);
        A[--a]++;A[--b]++;
    }
    bool flag = true;
    for(int i = 0; i < n; i++) if(A[i] & 1){ flag = false; break;}
    puts(flag ? "YES" : "NO");
    return 0;
}

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

int main() {
    long long n,w;    cin>>n>>w;
    long long dp[100005];
    memset(dp, 1e9+1, sizeof(dp));
    long long mx_till_now=0;
    dp[0]=0;
    for(long long i=0;i<n;i++){
        long long wi,vi;cin>>wi>>vi;
        for(long long j=mx_till_now;j>=0;j--)if( dp[j]!=1e9+1 && (dp[j] + wi==1e9+1 ||(dp[j] + wi)<=w )){
                dp[j+vi] = min ( dp[j+vi] , dp[j] + wi );
                mx_till_now=max(mx_till_now,j+vi);
        }
    }   
    cout<<mx_till_now;
    
    return 0;
}

Measured memory_bytes: 4424
#include<bits/stdc++.h>
#define speed ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define endl '\n'

using namespace std;

main()
{
  speed;
  int n,i;
  cin>>n;
  ll int a[n+1],b[n];
  for (i=0;i<n+1;i++)
    cin>>a[i];
  for (i=0;i<n;i++)
    cin>>b[i];
  ll int ans=0;
  for (i=0;i<n;i++)
  {
    if (a[i]>=b[i])
    	ans+=b[i];
    else if (a[i]+a[i+1]>=b[i])
    {
      ans+=b[i];
      a[i+1]-=(b[i]-a[i]);
    }
    else
    {
      ans+=a[i]+a[i+1];
      a[i+1]=0;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    s=SI()
    cc=Counter(s)
    if len(cc)<3:
        print(0)
        exit()
    tot=1
    for c in cc.values():tot*=c
    for i,c in enumerate(s):
        for j in range(1,min(i,n-1-i)+1):
            if s[i-j]!=c and c!=s[i+j] and s[i-j]!=s[i+j]:
                tot-=1
    print(tot)

main()

Measured memory_bytes: 68632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
  cin>>b[i];
  vector<int> c(a+1);
  c[0]=0;
  rep1(i,a)
    c[i]=b[i-1]+c[i-1];
  sort(all(c));
  int d=0,e=0;
  rep(i,a+1){
    d++;
  if(c[i]!=c[i+1]){
    e+=d*(d-1)/2;
  d=0;
  }
    if(i==a)
      e+=d*(d-1)/2;
  }
cout<<e<<endl;
}

Measured memory_bytes: 3328
def cost(n, k, nums):
    dp = [0] * n
    dp[0] = 0
    dp[1] = abs(nums[0] - nums[1])
    for i in range(2, n):
        dp[i] = min(abs(nums[i]-nums[j]) + dp[j] for j in range(max(0, i-k), i))
    return dp[-1]

n, k = [int(i) for i in input().split()]
nums = [int(i) for i in input().split()]
print(cost(n, k, nums))

Measured memory_bytes: 13980
from sys import stdin
input = stdin.readline

n=int(input())
sp = [list(input().split()) for _ in range(n)]

sorted_sp=sorted(sp, key=lambda x:(x[0],-int(x[1])))

for i in range(n):
    for j in range(n):
        if sorted_sp[i]==sp[j]:
            print(j+1)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
using ll = long long;
ll t[200010],mx = 100000000000000;
int n;
void built(){
	for(int i = n-1;i>0;i--){
		t[i] = min(t[i<<1],t[i<<1|1]);
	}
}

void update(ll p,ll a){
	for(t[p+=n] = a;p>1;p >>= 1){
		t[p>>1] = min(t[p],t[p^1]);
	}
}

ll query(int l, int r){
	ll mn = mx;
	for(l += n, r += n; l<r; l >>= 1,r >>= 1){
		if(l&1) mn = min(mn,t[l++]);
		if(r&1) mn = min(mn,t[--r]);
	}
	return mn;
}
string s;
ll dp[100010];
vector<int> v;
int main(){
	int i,m;
	cin >> n >> m >> s;
	n++;
	built();
	dp[n - 1] = 0;
	update(n - 1,dp[n - 1]);
	for(i=n - 2;i>=0;i--){
		dp[i] = query(i + 1,min(n,i + m + 1)) + 1;
		if(s[i]=='1') dp[i] = mx;
		update(i,dp[i]);
	}
	if(dp[0]>=mx){
		cout << -1 << endl;
		return 0;
	}
	int now = 0;
	while(now<n - 1){
		for(i=now + 1;i<n;i++){
			if(dp[i]==dp[now] - 1){
				v.push_back(i - now);
				now = i;
				break;
			}
		}
	}
	for(i=0;i<v.size();i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 3452
use std::cmp;
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

const INF: i32 = 2147483647;

struct Input {
    n: usize,
    k: usize,
    h: Vec<i32>,
}

fn read_input(cin_lock: &mut StdinLock) -> Input {
    let n = next_token(cin_lock);
    let k = next_token(cin_lock);
    let h = (0..n).map(|_| next_token(cin_lock)).collect();
    Input { n, k, h }
}

fn solve(input: Input) {
    let mut dp = vec![0; input.n + input.k];
    for i in 0..input.n {
        dp[i] = INF;
    }
    dp[0] = 0;

    for i in 0..input.n {
        let v = input.h[i];
        for j in 1..input.k + 1 {
            if i + j > input.n - 1 {
                break;
            }
            dp[i + j] = cmp::min(dp[i + j], dp[i] + (v - input.h[i + j]).abs());
        }
    }
    println!("{}", dp[input.n - 1]);
}

fn next_token<T: FromStr>(cin_lock: &mut StdinLock) -> T {
    cin_lock
        .by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>()
        .parse::<T>()
        .ok()
        .unwrap()
}

fn main() {
    let cin = stdin();
    let mut cin_lock = cin.lock();
    let input = read_input(&mut cin_lock);
    solve(input);
}


Measured memory_bytes: 2792
#include <stdio.h>

int main(void) {
int input[2];
int i;
int temp;

for (i = 0; i < 3000; i++) {
scanf("%d %d",&input[0], &input[1]);
if (input[0] == 0 && input[1] == 0) break;
if (input[0] > input[1]) {
temp = input[0];
input[0] = input[1];
input[1] = temp;
}
printf("%d %d\n", input[0], input[1]);
}

return 0;
} 


Measured memory_bytes: 2048
s = int(input())
L = []
i = 0
while True :
    i += 1
    if i == 1 :
        L.append(s)
    else :
        if L[-1] % 2 != 0 :
            s = 3*L[-1] + 1
        else :
            s = L[-1]//2
        if s in L :
            ans = i
            break
        else :
            L.append(s)
print(ans)
#print(L)



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

using namespace std;

int main() {
  int A, B, K; cin >> A >> B >> K;
  vector<int> commonDivisors;

  for(int i = 1; i <= 100; i++) {
    if((A % i == 0) && (B % i == 0)) {
      commonDivisors.push_back(i);
    }
  }
  cout << commonDivisors.at(commonDivisors.size() - K) << endl;
}


Measured memory_bytes: 256
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def japonska_gierka(): 
    N = wczytaj_liste()[0]
    A = wczytaj_liste()
    X = 0
    Y = 0
    wynik = [[None for i in range(N+1)] for j in range(N+1)]
    for dlugosc_kolejki in range(N+1):
        zabrano = N - dlugosc_kolejki
        for lewo in range(zabrano+1): 
            prawo = zabrano - lewo
            if dlugosc_kolejki == 0: 
                wynik[lewo][prawo] = 0 
            else:
                wynik[lewo][prawo] = max(A[lewo]-wynik[lewo+1][prawo], A[-prawo-1]-wynik[lewo][prawo+1])
    print(wynik[0][0])
    
japonska_gierka()

Measured memory_bytes: 172168
#D問題
#Bellman-Ford法(最短距離)
def BellmanFord(edges,num_v,source):
    #グラフの初期化
    inf=float("inf")
    dist=[inf for i in range(num_v)]
    dist[source-1]=0
    #辺の緩和
    for i in range(num_v):
        for edge in edges:
            if dist[edge[0]-1] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
    return dist

N,M = map(int,input().split())
ABC = []
for i in range(M):
    a,b,c = map(int,input().split())
    ABC.append([a,b,-c])
    
Dist = BellmanFord(ABC,N,1)

negative = [False for i in range(N)]
inf = float("inf")
for i in range(N):
    for j in range(M):
        if Dist[ABC[j][0]-1] == inf:
            continue
        if Dist[ABC[j][1]-1] > Dist[ABC[j][0]-1]+ABC[j][2]:
            Dist[ABC[j][1]-1] = Dist[ABC[j][0]-1]+ABC[j][2]
            negative[ABC[j][1]-1] = True
            
        if negative[ABC[j][0]-1] == True:
            negative[ABC[j][1]-1] = True


if negative[N-1]:
    print("inf")
else:
    print(-Dist[-1])
    


Measured memory_bytes: 46696
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static String S;
	boolean flg = false;

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int ret = C - (A - B);
		ret = Math.max(ret, 0);
		System.out.println(ret);
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21332
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef long long int Int;
typedef pair<int, int> P;
const int MAX_N = 105;
const int INF = 1e9;

int main() {
  Int G[MAX_N][MAX_N], N, M, S, G1, G2;
  while(cin >>N >>M >>S >>G1 >>G2 && N){
    --S; --G1; --G2;
    REP(i, N) REP(j, N) G[i][j] = (i == j ? 0 : INF);
    REP(i, M){
      int f, t, c; cin >>f >>t >>c;
      G[f - 1][t - 1] = c;
    }
    Int ans = INF;
    REP(k, N) REP(i, N) REP(j, N) G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
    REP(i, N) ans = min(ans, G[S][i] + G[i][G1] + G[i][G2]);
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	ll a, b, c; cin >> a >> b >> c;
	ll k; cin >> k;
	if (k % 2 == 1) {
		cout << b - a << "\n";
	}
	else cout << a - b << "\n";

	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

char t[111][111];

int main2() {
  int A = nextInt();
  int B = nextInt();
  int N = 100;

  REP(i, N) REP(j, N) t[i][j] = '.';
  REP(i, N) REP(j, N) {
    if (i == N-1) t[i][j] = '#';
    else if (i > 0 && j % 2 == 1) t[i][j] = '#';
  }

  int a = 1, b = 1;
  for (int i = 2; i < N - 1 && b < B; i += 2) {
    for (int j = 1; j < N - 1 && b < B; j += 2) {
      t[i][j] = '.';
      b++;
    }
  }
  for (int i = N - 3; i >= 0 && a < A; i -= 2) {
    for (int j = 2; j < N - 1 && a < A; j += 2) {
      t[i][j] = '#';
      a++;
    }
  }

  cout << N << " " << N << endl;
  REP(i, N) {
    REP(j, N) cout << (char)t[i][j];
    cout << endl;
  }
  return 0;
}

int main() {
  // for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

string s;
int N, K;

long long com(long long n, long long r) {
	if(r < 0 || r > n) return 0;
	else if(r == 1) return n;
	else if(r == 2) return n * (n-1) / 2;
	else return n * (n-1) * (n-2) / 6;
}

long long mypow(long long n, long long k) {
	long long res = 1;
	for(int i = 0; i < k; i++) res *= n;
	return res;
}

long long solve(int i, int k, bool smaller) {
	if(i == N) {
		if(k == 0) return 1;
		else return 0;
	}

	if(k == 0) return 1;

	if(smaller) return com(N-i, k) * mypow(9, k);
	else {
		if(s[i] == '0') return solve(i+1, k, false);
		else {
			long long zero = solve(i+1, k, true);
			long long aida = solve(i+1, k-1, true) * (s[i] - '1');
			long long icchi = solve(i+1, k-1, false);
			return zero + aida + icchi;
		}
	}
}

int main() {
	cin >> s >> K;
	N = s.size();
	cout << solve(0, K, false) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct edge{
	ll to,cost,t;
};

struct state{
	ll d,city,ag;
};

bool operator>(const state& a,const state& b){
    return a.d>b.d;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,m,s;
	cin>>n>>m>>s;
	vector<vector<edge>> g(n);
	rep(i,m){
		ll u,v,a,b;
		cin>>u>>v>>a>>b;
		u--,v--;
		g[u].push_back({v,a,b});
		g[v].push_back({u,a,b});
	}
	vector<ll> c(n),d(n);
	rep(i,n){
		cin>>c[i]>>d[i];
	}
	chmin(s,ll(1000));
	vector<vector<ll>> dist(n,vector<ll>(10001,inf));//j==1000は銀貨無限枚
	priority_queue<state,vector<state>,greater<state>> que;
	dist[0][s]=0;
	que.push({0,0,s});
	while(!que.empty()){
		auto now=que.top();
		que.pop();
		ll v=now.city,ag=now.ag;
		if(dist[v][ag]<now.d) continue;
		for(auto to:g[v]){
			if(ag==1000){//銀は無限にある
				if(chmin(dist[to.to][1000],dist[v][1000]+to.t)){
					que.push({dist[to.to][1000],to.to,1000});
				}
			}else{
				if(ag>=to.cost){
					if(chmin(dist[to.to][ag-to.cost],dist[v][ag]+to.t)){
						que.push({dist[to.to][ag-to.cost],to.to,ag-to.cost});
					}
				}
				ll nag=ag;
				ll nt=to.t;
				while(nag<1000){
					nag+=c[v];
					chmin(nag,ll(1000));
					nt+=d[v];
					if(nag>=to.cost){
						if(chmin(dist[to.to][nag-to.cost],dist[v][ag]+nt)){
							que.push({dist[to.to][nag-to.cost],to.to,nag-to.cost});
						}
					}
				}
			}
		}
	}
	FOR(i,1,n){
		ll ans=inf;
		rep(j,10001) chmin(ans,dist[i][j]);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 28172
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int N = Integer.parseInt(str);
        double ans = 0;
        for (int i=0;i < N;i++){
            String s = br.readLine();
            String[] t = s.split(" ");
            if (t[1].equals("JPY")){
                ans = ans+Integer.parseInt(t[0]);
            } else {
                ans = ans+Double.parseDouble(t[0])*380000.0;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 20820
N=int(input())
X=input()

def pop(x): #10進数
    ret=0
    while x>0:
        ret+=x%2
        x//=2
    return ret

def solve(x): #10進数
    ret=0
    while x>0:
        pop_c=pop(x)
        x%=pop_c
        ret+=1
    return ret

mod=X.count("1") #>0
original_plus=0
original_minus=0
for i in range(N):
    if X[N-1-i]=="1":
        if mod>1:
            original_minus+=pow(2,i,mod-1)
        original_plus+=pow(2,i,mod+1)
original_plus%=mod+1
if mod>1:
    original_minus%=mod-1
for i in range(N):
    if X[i]=="0":
        tmp=original_plus+pow(2,N-1-i,mod+1)
        tmp%=mod+1
        print(solve(tmp)+1)
    else:
        if mod==1:
            print(0)
            continue
        tmp=original_minus-pow(2,N-1-i,mod-1)
        tmp%=mod-1
        print(solve(tmp)+1)


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

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

  vector<int> c(26);
  rep (i, s.length()) c.at(s.at(i) - 'a')++;

  int num = -1;
  char ans;
  for (int i = 0; i <= 25; i++) {
    if (c.at(i) == 0) {
      num = i;
      ans = i + 'a';
      break;
    }
  }

  if (num == -1) {
    cout << "None" << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 512
//BISMILLAHHIR RAHMANIR RAHIM
#include<bits/stdc++.h>
using namespace std;
typedef long long int            ll;
typedef unsigned long long int   ull;
#define min3(a,b,c)              min(a,min(b,c))
#define F                        first
#define S                        second
#define PB                       push_back
#define MP                       make_pair
#define PI                       2*acos(0.0)
int main()
{
    int n,m;
    cin>>n>>m;
    int ara[n],cnt=1,sum=0;
    for(int i=0; i<n; i++)cin>>ara[i];
    for(int i=0; i<n; i++){
        sum+=ara[i];
        if(sum<=m){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  long long num[10000];
  long long n,m,o,temp,sum;
  scanf("%lld",&m);
  for(n=0;n<m;n++){
    scanf("%lld",&num[n]);
  }
  for(n=0;n<m-1;n++){
    for(o=n;o<m;o++){
      if(num[o]>num[n]){
        temp=num[o];
        num[o]=num[n];
        num[n]=temp;
      }
    }
  }
  for(n=0,sum=0;n<m;n++){
    sum+=num[n];
  }
  printf("%lld %lld %lld\n",num[m-1],num[0],sum);
  return 0;
}

Measured memory_bytes: 676
a=list(map(int,input().split()))
#print(a)
if a[0]==a[1]:
  if a[0] != a[2]:
    print('Yes')
  else:
    print('No')
elif a[0]==a[2]:
  if a[0] != a[1]:
    print('Yes')
  else:
    print('No')
elif a[2]==a[1]:
  if a[1] != a[0]:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 3064
from collections import deque
N = int(input())
alist = list(map(int,input().split()))
money = 1000
kabu = 0
zogen = []
flag = 0

def buy(i):
    global alist
    global money
    global kabu
    kabu = money//alist[i]
    money -= kabu*alist[i]

def sell(i):
    global alist
    global money
    global kabu
    money += kabu*alist[i]
    kabu = 0

best = 0

for i in range(N):
    if i < N-1:
        if flag == 0:
            if alist[i] < alist[i+1] :
                buy(i)
                flag = True
                continue
            elif alist[i] > alist[i+1]:
                flag == False
                continue
            else:
                continue

        if flag == True:
            if alist[i] > alist[i+1]:
                sell(i)
                flag = False
            else:
                continue
        elif flag == False:
            if alist[i] < alist[i+1]:
                buy(i)
                flag = True
            else:
                continue
    else:
        if flag == True:
            sell(i)
            flag = False

print(money)


Measured memory_bytes: 9472
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


ll a,b,c,d[100005] = {},n,m;
string s,t;

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

    if(b < a)P(0);
    else P(10);

    
    return  0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
int i[1111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e,f;
  string s;
  cin >>s;
  if(s[0]==s[1]) d++;
  if(s[1]==s[2]) d++;
  if(s[2]==s[3]) d++;
  if(d>0) cout <<"Bad\n";
  else cout <<"Good\n";
  return (0);
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>

using namespace std;

int main(void){
	int i,j,k,a,b,n;
	char s[100001];
	scanf("%d %d %d %s" ,&n ,&a ,&b ,s);
	for(i=0;i<n;i++){
		if(s[i] == 'a' && a + b){
			printf("Yes\n");
			a--;
		}
		else if (s[i] == 'b' && a + b && b){
			printf("Yes\n");
			b--;
		}
		else printf("No\n");
	}
	return 0;
}

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

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


int main(){
    long long A, B, C, D, ans, CDiv, DDiv, CDDiv;
    cin >> A >> B >> C >> D;
    CDiv = B/C - (A-1)/C;
    DDiv = B/D - (A-1)/D;
    CDDiv = B/(C*D/gcd(C, D)) - (A-1)/(C*D/gcd(C, D));
    
    ans = (B-A+1) -CDiv -DDiv + CDDiv;
    cout << ans << endl;	
}


Measured memory_bytes: 256
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

s = S()

cnt = 0
max = 0
for i in s:
    if i == "R":
        cnt += 1
    else:
        if max < cnt:
            max = cnt
        cnt = 0

if max < cnt:
    max = cnt

print(max)

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

int main(void) {
  int N;
  cin >> N;
  if (N == 1) {
    cout << "Hello World" << endl;

  } else {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }

  return 0;
}

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

using namespace std;
using int64 = long long;
//const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  string T;
  cin >> T;
  for(auto &c : T) {
    if(c == '?') c = 'D';
  }
  cout << T << "\n";
}

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

int main(){
    int n;
    cin >> n;
    int a[n+1],b[n];
    for(int i=0; i<n+1; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    long long ans = 0;
    for(int i=0; i<n; i++){
        if(a[i] <= b[i]){
            ans += a[i];
            b[i] -= a[i];
            if(a[i+1] <= b[i]){
                ans += a[i+1];
                a[i+1] = 0;
            }
            else {
                ans += b[i];
                a[i+1] -= b[i];
            }
        }
        else {
            ans += b[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int x;
	int y;
	cin >> x >> y;
	if (x<y){
		cout << "a < b\n";
	}
	else if (x>y){
		cout << "a > b\n";
	}
	else{
		cout << "a == b\n";
	}
	return 0;
}

Measured memory_bytes: 2996
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
# import sys
# sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    s = input()
    t = input()
    q = int(input())
    sa = [0]*(len(s)+1)
    sb = [0]*(len(s)+1)
    ta = [0]*(len(t)+1)
    tb = [0]*(len(t)+1)
    for i in range(1 , len(s)+1):
        if s[i-1] == "A":
            sa[i] = sa[i - 1] + 1
        else:
            sa[i] = sa[i - 1]

        if s[i-1] == "B":
            sb[i] = sb[i - 1] + 1
        else:
            sb[i] = sb[i - 1]

    for i in range(1,len(t)+1):
        if t[i-1] == "A":
            ta[i] = ta[i - 1] + 1
        else:
            ta[i] = ta[i - 1]

        if t[i-1] == "B":
            tb[i] = tb[i - 1] + 1
        else:
            tb[i] = tb[i - 1]

    for i in range(q):
        a, b, c, d = map(int, input().split())
        sl, sr = (sa[b] - sa[a - 1]) % 3, (sb[b] - sb[a - 1]) % 3
        tl, tr = (ta[d] - ta[c - 1]) % 3, (tb[d] - tb[c - 1]) % 3
        sl += sr * 2
        tl += tr * 2
        sl %= 3
        tl %= 3
        if sl == tl:
            print("YES")
        else:
            print("NO") 
    


if __name__ == '__main__':
    main()


Measured memory_bytes: 15260
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#define ll long long
#define maxn 200005
#define re register
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

void write(int x)
{
	if(x>=10) write(x/10);
	putchar(x%10+'0');
}

ll f[45];

int main()
{
	int n; cin>>n;
	f[0]=2;
	for(int i=1;i<=n;i++) f[i]=f[i-1]*2+2;
	cout<<f[n];
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a;
    for(int i=0; i<n; i++){
        int aa;
        cin >> aa;
        a.push_back(aa);
    }
    int m;
    cin >> m;
    vector<int> b;
    for(int i=0; i<m; i++){
        int bb;
        cin >> bb;
        b.push_back(bb);
    }

    vector<int> result;
    // aとbの和集合を作る
    set_union(begin(a), end(a), begin(b), end(b), inserter(result, end(result)));

    for(int i=0; i<result.size(); i++){
        cout << result[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 6524
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  vector<int64_t> A(N + 1);
  int64_t count = 0;
  int64_t next = 1;
  bool found = false;
  for (int64_t i = 1; i <= N; ++i) {
    cin >> A[i];
    if (A[i] == next) {
      found = true;
      ++next;
    } else {
      ++count;
    }
  }
  if (found) {
    cout << count << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 1792