akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
using static Atcoder.IO;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var N = RInt;
            var a = RSInt;

            long ans = long.MaxValue;
            for (int i = -100; i <= 100; i++)
            {
                long cal = 0;
                for (int j = 0; j < N; j++)
                {
                    cal += (a[j] - i) * (a[j] - i);
                }
                ans = Min(cal, ans);
            }
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 28096
//S.G.N.//
#include <bits/stdc++.h>
using namespace std;
typedef vector< long long > vi;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define fr(n) for(ll i=0;i<n;i++)
#define tr(a) for(auto it=a.begin();it!=a.end();it++)
#define N 998244353445 
#define PI 3.1415926535897932384
#define F first
#define S second
#define mp make_pair
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
void solve()
{
 ll n,w;
 cin>>n>>w;
 ll dp[n+1][w+1];
 ll we[n];
 ll v[n];
 fr(n)
 cin>>we[i]>>v[i];
 for(int i=0;i<=n;i++)
  dp[i][0]=0;
for(int i=0;i<=w;i++)
{
  dp[0][i]=0;
}
fr(n)
{
rep(j,1,w+1)
{
  dp[i+1][j]=dp[i][j];
  if(j-we[i]>=0)
    dp[i+1][j]=max(dp[i+1][j],dp[i][j-we[i]]+v[i]);
}
}
cout<<dp[n][w];
}
int main()
{
  
  #ifndef ONLINE_JUDGE
     * freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
  FAST
  ll test;
test=1;
  //cin>>test;
  while(test--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 82456
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict(list)
#import bisect
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    # 選ぶ3人の頭文字がどうなっているかというと、'M','A','R'や、'A','C','H'のように、
    # 'MARCH'の中から選べる"異なる"3文字となっている
    # たとえば頭文字'M','A','R' に絞って考えると、 それぞれの文字で始まる人が、
    # 5,9,4人だった場合、組み合わせの数は 5 * 9 * 4 = 180 となる
    # これをすべて異なる3文字の組み合わせで調べ上げて、足し合わす。
    # ただし、各頭文字で始まる人がいなかった場合に、Keyerrorに注意

    # Python では ある頭文字で始まる人が何人いるかは、
    # collections.Counterを使って数え上げられる。
    # また、5個の中から異なる3個を取る組み合わせの列挙は、
    # itertools.combinationsを使える
    from collections import Counter
    from itertools import combinations

    n = int(input())
    l = [input()[0] for _ in range(n)]
    lc = Counter(l) # これで数えれる
    #print(lc)
    #     5
    # MASHIKE
    # RUMOI
    # OBIRA
    # HABORO
    # HOROKANAI
    # Counter({'H': 2, 'M': 1, 'R': 1, 'O': 1})

    con = []
    for c in 'MARCH': # ここ文字列でもいけるんだ
        if c in lc:
            con.append(lc[c]) # 辞書登録してるね。
            # ここで、conリスト　に 頭文字の個数を入れる。
    ans = 0
    for a,b,c in combinations(con,3): # conリストにある全通りの組み合わせを試す。
        ans += a * b * c
    print(ans)

if __name__ == '__main__':
  main()


Measured memory_bytes: 4216
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n,d,a = inp
t = []
n.times do |i|
  t << inp
end
t.sort!
st = []
dum = 0
ans = 0
t.each do |x,h|
  while st.size>0
    break if(st[0][0]+d >= x)
    dum -= st[0][1]
    st.shift
  end
  if (dum < h)
    sa = h-dum
    k = r_up(sa,a)
    ans += k
    st.push([x+d,k*a])
    dum += k*a
  end
end

p ans

Measured memory_bytes: 19344
#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(){
	string s;
	cin >> s;
	int f = 0;
	if(s.at(5) == '0'){
		if(s.at(6)-'0' <= 4) f = 1;
	}
	if(f == 0){
		cout << "TBD" << endl;
	}else{
		cout << "Heisei" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

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

    double s = 0;

    for(double i = 0; i < N; i++){
        double a;
        cin >> a;

        s += 1/a;
    }

    cout << to_string(1/s) << endl;

    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  string s;
  cin >> s;

  int m = 754;
  re(i, s.size()-2) {
    string a = s;
    string b = a.substr(i, 3);
    int num = stoi(b.c_str());
    if(abs(num-753) < m) m = abs(num-753);
  }

  cout << m << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
int n, a, b, z;
cin >> n >> a >> b;
if (a <= b)
cout << a << " ";
else
cout << b << " ";
z = a + b;
if (z - n > 0)
cout << z - n;
else
cout << 0;
return 0;
}

Measured memory_bytes: 256
A = input()
A_dic = {}
for i in A:
    if i in A_dic:
        A_dic[i] += 1
    else:
        A_dic[i] = 1

m = 1
for i in range(2,len(A)+1):
    m += len(A) - i + 1

for i in A_dic.values():
    m -= (i*(i-1))/2

print(int(m))


Measured memory_bytes: 3500
D = gets.to_i
C = gets.chomp.split.map(&:to_i)
s = D.times.map{gets.split.map(&:to_i)}
t = D.times.map { gets.to_i }
ans = 0
c = Array.new(26, 0)

(0..D-1).each do |i|
  (0..25).each do |l|
    c[l] += C[l]
    c[t[i]-1] = 0
  end
  ans += s[i][t[i]-1] - c.sum
  puts ans
end



Measured memory_bytes: 14176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  ll a,b,k;
  cin >> a >> b >> k;
  if(a-k<0){
    cout << "0 " << max(0ll,b-(k-a)) << endl;
  }
  else cout << a-k << " " << b << endl;
  return 0;
}


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

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().ToInt();
        var hxis = CRL().ArrayLongs();
        var count = 1;
        for (int i = 1; i < n; i++)
        {
            var flag = false;
            for (int j = 0; j < i; j++)
            {
                if (hxis[j] <= hxis[i])
                {
                    continue;
                }

                flag = true;
                break;
            }

            if (flag)
            {
                continue;
            }

            count++;
        }

        CWL(count);
    }
}

public static partial class Program
{
    //テンプレここから
    private static long ToInt(this string str) => long.Parse(str);
    private static long[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] { 0, -1, 0, 1 };
    public static long[] dy = new long[] { -1, 0, 1, 0 };
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array)
    {
        var list = array.ToList();
        list.Sort();
        return list.ToArray();
    }
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    //テンプレここまで
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 998244353;


const int MAX = 1000000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列を計算
long long PER(int n,int k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return (fac[n] * finv[n-k]) % MOD;
}

long long modpow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = (ret * x) % MOD;  
        x = (x * x) % MOD;
        n >>= 1;  
    }
    return ret;
}

int main(){
    COMinit();
    ll n,m,k;
    cin >> n >> m >> k;
    ll ans =0;
    for(ll i=n-1-k;i<=n-1;i++){
        ll res = modpow((m-1),i);
        res = (res * m)%MOD;
        ans = (ans + (COM(n-1,i)*res)%MOD)%MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27028
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int commit = 1<<M;
		
		System.out.println(commit * (M*1900 + (N-M)*100));
				
		sc.close();
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

#define DEBUG 1

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
  #define DFUNC(fname, ...) fname(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFUNC(fname, ...)
#endif

ll N, K;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N >> K;

  ll top = N+1;
  ll bot = K;
  double sum = 0.0;
  double p = 1.0;
  while (top > 1) {
    ll num = min(N+1, top) - bot;
    if (num > 0) {
      sum += (double)num / N * p;
    }
    top = bot;
    bot = (top + 1) >> 1;
    p *= 0.5;
  }
  cout << setprecision(15) << sum << endl;

  return 0;
}



Measured memory_bytes: 256
n=int(input()) 

today_a,today_b,today_c=0,0,0
for i in range(n) : 
    a,b,c=map(int,input().split()) 
    tomorrow_a=a+max(today_b,today_c)
    tomorrow_b=b+max(today_a,today_c)
    tomorrow_c=c+max(today_a,today_b)

    today_a=tomorrow_a
    today_b=tomorrow_b
    today_c=tomorrow_c

print(max(tomorrow_a,tomorrow_b,tomorrow_c))

Measured memory_bytes: 3064
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.length(); ++i)
    {
        if (s[i] == '+')
        {
            ++cnt;
        }
        else
        {
            --cnt;
        }
    }
    cout << cnt;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ priority_queue<ll, vector<ll>, greater<ll>>

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

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

ll po[200002][21] = {};
ll factorial(ll n) {
  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    ans += i;
    ans %= MOD;
  }
  return ans;
}
int main() {
  ll N;
  vector<ll> A;
  cin >> N;
  REP(i, N) {
    ll a = 0;
    cin >> a;
    string s = BIT(20, a);
    REP(j, 20) {
      if (s[j] == '1')
        po[i + 1][j] = po[i][j] + 1;
      else
        po[i + 1][j] = po[i][j];
    }
  }
  ll l = 0, r = 1, ans = 0;
  bool sucs = false;
  N++;
  while (l < N && r < N) {
    bool ok = true;
    REP(i, 20) {
      if (po[r][i] - po[l][i] > 1) {
        ok = false;
        break;
      }
      // cout << l << "," << r << "," << po[r][i] << "," << po[l][i] << endl;
    }
    if (!ok) {
      l++;
    } else {
      ans += r - l;
      r++;
    }
  }
  if (sucs)
    ans += r - 1 - l;
  cout << ans << endl;
  return 0;
}


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

result = []
while len(a) > 0:
    c = True
    for i in range(len(a)-1, -1, -1):
        if i+1 == a[i]:
            result.append(a[i])
            a.pop(i)
            c = False
            break
    if c:
        result = [-1]
        break

for i in result[::-1]:
    print(i)

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

using namespace std;


int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    vector<int> stable;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        --a[i];
        if (a[i] == i)
            stable.push_back(i);
    }
    vector<int> bad;
    int ans = 0;
    for (int i = 0; i < stable.size(); ++i) {
        if (i + 1 < stable.size() && stable[i] + 1 == stable[i + 1]) {
            ++ans;
            ++i;
        } else
            bad.push_back(stable[i]);
    }
    ans += bad.size();
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <cmath>
#define lp(n) for(int i=0;i<n;i++)
using namespace std;

int n,z,w,a1,a2;
int main(){
	cin>>n>>z>>w;
	lp(n-1)
		cin>>a1;
	cin>>a2;
	if(n==1)
		cout<<abs(w-a2)<<endl;
	else cout<<max(abs(w-a2),abs(a1-a2))<<endl;
	return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<vector<int>> A(n,vector<int>(m));
  vector<int> b(m);
  vector<int> c(n,0);

  rep(i,n) {
    rep(j,m) {
      cin >> A[i][j];
    }
  }
  rep(i,m) {
    cin >> b[i];
  }

  rep(i,n) {
    rep(j,m) {
      c[i] += A[i][j] * b[j];
    }
  }
  rep(i,n) {
    cout << c[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3180
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < W; i++) printf("#");
		printf("\n");

		for(int i = 1; i < H-1; i++){
			printf("#");
			for(int j = 1; j < W-1; j++) printf(".");
			printf("#\n");
		}

		if(H > 1){
			for(int i = 0; i < W; i++) printf("#");
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2556
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a;
        for (int i=0; i<N; i++) {
            a = sc.nextInt();
            if (a % 2 != 0) {
                System.out.println("first");
                return;
            }
        }
        System.out.println("second");
    }
}


Measured memory_bytes: 48292
S = gets.strip


s=[]
S.chars do |ss|
    s<<ss
end

su=s.uniq
if su.length!=2
    puts "No"
    exit
end
a=S[0]
c=0
s.each do |ss|
    if a==ss
        c+=1
    end
end
if c==2
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 1788
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n, k; cin >> n >> k;

    cout << (k == 1 ? 0 : n - k) << endl;
    
}

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

#define in_fre freopen("redir.txt", "r", stdin);
#define out_fre freopen("out5.txt", "w", stdout);
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug(i) printf("\nDebug %d\n",i);
#define mod 1000000007
#define ll long long int

int main()
{	
clock_t begin, end;
double time_spent;
begin = clock();


	long long 
	int n;
  cin>>n;
  if((n/1000)*1000<n)
  	cout<<((n/1000)+1)*1000-n;
  else 
  	cout<<((n/1000))*1000-n;

end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
cerr<<"Time spent = "<<time_spent<<endl;

return 0;
}

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

int n,h,a[100010],b[100010],mx,ans;

int main()
{
	cin>>n>>h;
	for(int i=0;i<n;i++) cin>>a[i]>>b[i];
	
	sort(a,a+n,greater<int>());
	mx=a[0];
	
	sort(b,b+n,greater<int>());
	for(int i=0;i<n;i++) if(b[i]>mx&&h>0) {h-=b[i];ans++;}
	
	if(h>0) ans+=(h+mx-1)/mx;
	
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main() {
    int N,K;
    scanf("%d %d", &N,&K);
    string S;
    cin >> S;
    string out = "";
    for (int i=0; i<N; i++) {
        if (i==K-1) {
            putchar(tolower(S[i]));
        } else {
            putchar(toupper(S[i]));
        }
    }
    return 0;
}

Measured memory_bytes: 256
/*
 
*/ 
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // FOR QUERY PROBLEM DON'T FORGET TO UNCOMMENT THIS
    ll d, t, s;
    cin >> d >> t >> s;
    if(s*t >= d)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}
 
/*
 
*/  

Measured memory_bytes: 3636
import copy
S = [c for c in input()]

X = [[]]
for i in range(len(S) - 1):
    X0, X1 = [], []
    for x in X:
        x0 = copy.deepcopy(x)
        x0.append(0)
        X0.append(x0)
        x1 = copy.deepcopy(x)
        x1.append(1)
        X1.append(x1)
    X = X0 + X1
Y = []
for x in X:
    bf = ''
    for i in range(len(S)):
        bf = bf + str(S[i])
        if i == len(S) - 1 or x[i] == 1:
            Y.append(int(bf))
            bf = ''
    if bf != '':
        Y.append(int(bf))
print(sum(Y))


Measured memory_bytes: 3700
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define printfloat(x) cout << setprecision(7) << (x) << endl;

long double pi = 3.14159265359;

int a,b;

int main(){
    cin >> a >> b;
    if(a <= 2*b) cout << 0 << endl;
    else cout << a-2*b << endl;


return 0;
}

Measured memory_bytes: 3632
N=int(input())
LA=list(map(int,input().split()))
ans=[]

def gcd(m,n):
    if m==0 or n==0:
        return m+n
    while n:
        m,n=n,m%n
    return m

La=[0]
Lb=[0]

for n in range(N-1):
    La.append(gcd(La[n],LA[n]))
    Lb.append(gcd(Lb[n],LA[-(n+1)]))

for n in range(N):
    ans.append(gcd(La[n],Lb[-(n+1)]))
        
print(max(ans))

Measured memory_bytes: 14076
#include <stdio.h>
#include <math.h>
int abs(int n){
    if(n > 0){
        return n;
    } else {
        return -n;
    }
}


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

  int count = 0;
  double sum;
  for(int i = 0; i < n; i++){
      for(int k = i+1; k < n; k++){
          sum = 0;
        for(int j = 0; j < d; j++){
          sum += (x[i][j]-x[k][j])*(x[i][j]-x[k][j]);
        }
        double a = sqrt(sum);
       // printf("%f " , a);
        if(ceil(a)==floor(a)){
            count++;
        }
      }
  }
  /*
  sum = 0;
  for(int i = 0; i < d; i++){
      sum += (x[d-1][i]-x[0][i])*(x[d-1][i]-x[0][i]);
  }
  sum = sqrt(sum);
  printf("%f " , sum);
  if(ceil(sum)==floor(sum)){
        count++;
  }*/
  printf("%d", count);
  return 0;
}


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

int main() {
  int n,ans;
  cin >> n;

  for (int i=1;i<=n;i+=2) {
    int c = 0;
    for (int j=1;j<=i;++j) {
      if (i%j==0) {
        ++c;
      }
    }

    if (c==8) ++ans;
  }
  cout << ans << endl;
}


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

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T> inline void scf(T &x)
{
    bool f = 0;
    x = 0;
    char c = getchar();
    while(c != '-' && (c < '0' || c > '9')) c = getchar();
    if(c == '-') f = 1, c = getchar();
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    if(f) x = -x;
    return;
}

template <typename T1, typename T2> void scf(T1 &x, T2 &y)
{
    scf(x);
    return scf(y);
}

template <typename T1, typename T2, typename T3> void scf(T1 &x, T2 &y, T3 &z)
{
    scf(x);
    scf(y);
    return scf(z);
}

template <typename T1, typename T2, typename T3, typename T4> void scf(T1 &x, T2 &y, T3 &z, T4 &w)
{
    scf(x);
    scf(y);
    scf(z);
    return scf(w);
}

inline char mygetchar()
{
    char c = getchar();
    while(c == ' ' || c == '\n') c = getchar();
    return c;
}

template <typename T> inline bool chkmax(T &x, const T &y)
{
    return y > x ? x = y, 1 : 0;
}

template <typename T> inline bool chkmin(T &x, const T &y)
{
    return y < x ? x = y, 1 : 0;
}

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

//---------------------------------------------------------head----------------------------------------------------

int n, k, d, mx;

int main()
{
    scf(n, k, d);
    mx = d;
    rep(i, n - 1) {
        int x;
        scf(x);
        chkmax(mx, x);
        d = __gcd(d, x);
    }
    puts(k > mx || k % d ? "IMPOSSIBLE" : "POSSIBLE");
    return 0;
}


Measured memory_bytes: 256
N, C, K = map(int,input().split())
T = []
for _ in range(N):
  T.append(int(input()))
T.sort()
cnt=1
s=0
for i in range(1,N):
  if (T[i] > T[s]+K) or (i==s+C):
    cnt += 1
    s=i
print(cnt)

Measured memory_bytes: 7384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
pair<int,int>x[200005],y[200005]; int n,v[200005];
P rng[200005];
int ne[200005];
#define mod 1000000007

int seg[(1<<19)];
void update(int k,int a){
	k+=(1<<18)-1;
	seg[k]=a;
	while(k>0){
		k=(k-1)/2;
		seg[k]=(seg[k*2+1]+seg[k*2+2])%mod;
	}
}
int query(int a,int b,int k,int l,int r){
	if(r<a||b<l) return 0;
	if(a<=l&&r<=b) return seg[k];
	return (query(a,b,k*2+1,l,(l+r)/2)+query(a,b,k*2+2,(l+r)/2+1,r))%mod;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int a,b; scanf("%d%d",&a,&b);
		x[i] = mp(a,b);
	}
	sort(x+1,x+n+1);
	int L;
	for(int i=1;i<=n;i++){
		v[i] = x[i].sc;
		y[i] = mp(v[i],i);
	}
	sort(y+1,y+n+1);
	int pre = 0;
	for(int i=1;i<=n;i++){
		pre = max(pre,y[i].sc);
		rng[y[i].sc].sc = pre;
	}
	pre = INF;
	for(int i=n;i>=1;i--){
		pre = min(pre,y[i].sc);
		rng[y[i].sc].fi = pre;
		
	}
	for(int i=1;i<=n;i++){
		ne[rng[i].sc] = max(ne[rng[i].sc],rng[i].fi);
	}
	update(0,1); int hoge = 0;
	for(int i=1;i<=n;i++){
	    hoge = max(hoge,ne[i-1]);
		int x = query(hoge,i-1,0,0,(1<<18)-1);
		update(i,x); 
	}
	cout<<query(y[n].sc,n,0,0,(1<<18)-1)<<endl;
}

Measured memory_bytes: 8064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		
		if(isShiritori(a,b) && isShiritori(b,c)) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
		sc.close();

	}
	
	public static boolean isShiritori(String a, String b) {
		return a.charAt(a.length()-1) == b.charAt(0);
	}

}



Measured memory_bytes: 21716
def main():
    mod = 998244353
    n = int(input())
    ab = [tuple(map(int, input().split())) for _ in [0]*n]
    ab.sort()
    next_a = [-1]*n
    dp = [0]*(n+1)
    dp[n] = 1
    for i in range(n-1, -1, -1):
        a0, b0 = ab[i]
        dist = a0+b0
        now = i
        while now < n-1:
            a1, b1 = ab[now+1]
            if a1 < dist:
                now = next_a[now+1]
            else:
                break
        next_a[i] = now
    for i in range(n-1, -1, -1):
        dp[i] = (dp[i+1]+dp[next_a[i]+1]) % mod
    print(dp[0] % mod)


main()

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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)

#define si(d)  scanf("%d",&d)
#define sll(d) scanf("%lld",&d)
#define pin(d) printf("%d\n",d)
#define pln(d) printf("%lld\n",d)
#define nl 	   printf("\n")

#define ll long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi vector<int>
#define pii pair<int,int> 
#define piii pair<pair<int,int>,int> 
#define all(v) v.begin(), v.end()

#define chalne_de continue
int mod=1000000007;
const int N = 1000005;

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int a[n+1];
	rep(i,0,n)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	int ans = a[n-1] - a[0];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream> 
#include<bits/stdc++.h> 
using namespace std;
int main(){ 
	ios::sync_with_stdio(false); 
	cin.tie(0); 
	int N,K;
	cin>>N>>K;
	vector<int> h(N);
	for(int i=0;i<N;i++){ 
		cin>>h[i];
	}
	vector<long long> dp(N,0);
	dp[1]=dp[0]+abs(h[1]-h[0]);
	for(int i=1;i<N;i++){ 
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]); 
		int bot=max(0,i-K);
		for(int j=i-2;j>=bot;j--){ 
			dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i])); 
			} 
	} 
	cout<<dp[N-1];



		
	
	return 0;
} 



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

#define REP(i,n) for (int i=0;i<(n);++i)

using namespace std;

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

    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> points(N, K - Q);
    REP(_, Q) {
        int A;
        cin >> A;
        --A;
        ++points[A];
    }
    REP(i, N) {
        cout << (points[i] > 0 ? "Yes" : "No") << '\n';
    }
    cout << flush;

    return 0;
}

Measured memory_bytes: 1024
S=input()
if S.find('A')==0 and len(S)-2>=S.find('C')>=2:
	S=S.replace('A','a',1)
	S=S.replace('C','c',1)
	if S.islower():
		print('AC')
	else:
		print('WA')
else:
	print('WA')

Measured memory_bytes: 2940
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <list>


constexpr int INF = 1050000000;
constexpr int MOD = 1000000007;
constexpr long long int LONGINF = 1005000000000000000;
using namespace std;

using ll = long long;


int main() {

	ll n, x; cin >> n >> x;
	ll a[100005];

	memset(a, 0, sizeof(a));


	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	ll ans = 0;

	for (int i = 1; i <= n; i++) {
		while (a[i] + a[i + 1] <= x) { i++; }
		if (a[i] + a[i + 1] <= x) { i++; }
      if(i>n){break;}
		ll check = max(a[i] + a[i + 1] - x, a[i - 1] + a[i] - x);
		ans += check; 
		a[i] =a[i]-check;
		a[i - 1] =a[i-1]-check;
		a[i + 1] =a[i+1]-check;
	}

	cout << ans << endl;


}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll n, k;
    cin>>n>>k;
    ll n1=n;
    cout<<min(n1%k, abs(k-n1%k));
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  int b;
  b=a;
  a -= b / 1000 * 1000;
  if(a!=0){
    cout<<1000 - a<<'\n';
  }
  else{
    cout<<0<<'\n';
  }
  return 0;
}



Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();

        String[] input = line.split(" ", 0);

        int all = Integer.valueOf(input[0]).intValue();
        int a = Integer.valueOf(input[1]).intValue();

        line = sc.nextLine();
        input = line.split(" ", 0);

        for(int x = 0; x<a; x++){
            all -= Integer.valueOf(input[x]).intValue();
        }

        if(all >= 0) {
            System.out.println(all);
        }else{
            System.out.println(-1);
        }

    }
}

Measured memory_bytes: 38812
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#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 oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,d;
  	ci(n>>d);
  ll A[n][d];
  FOR(i,0,n){
    FOR(j,0,d){
      ci(A[i][j])
    }
  }
  
  ll ans=0;
  
  FOR(i,0,n){
    FOR(j,0,n){
      ll sum=0;
      FOR(k,0,d){
        sum+=(A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
      }
      ll a=sqrt(sum)/1;
      if(a*a==sum&&sum!=0){
        ans++;
      }       
    }
  }
  co(ans/2)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                               \
  ifstream in("atcoder-problems/codefestival_2016_qualB_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, A, B;
  cin >> N >> A >> B;

  string S;
  cin >> S;

  ll cnta = 0, cntb = 0;
  rep(i, N) {
    if (S[i] == 'a') {
      if (cnta + cntb < A + B) {
        cout << "Yes" << endl;
        cnta++;
      } else
        cout << "No" << endl;
    } else if (S[i] == 'b') {
      if (cnta + cntb < A + B && cntb < B) {
        cout << "Yes" << endl;
        cntb++;
      } else
        cout << "No" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

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

int main(){
  int A,B;
  cin >> A >> B;
  if(A==B)
    cout << A+B << endl;
  else if(A>B)
    cout << 2*A-1 << endl;
  else
    cout << 2*B-1 << endl;
}

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

using namespace std;

long long inf=1000000007;

int main(){
	long long a,b,c,k;
	cin>>a>>b>>c>>k;
	long long ans=0;

	if(a>=k){
		ans+=k;
	}else{
		ans+=a;
		k-=a;
		if(b>=k){

		}else{
			k-=b;
			ans-=k;
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <vector>

using namespace std;


int main()
{
	string line;

	cin >> line;

	int ans = 0;
	for (int ci = 0; ci < line.size(); ci++) {
		if (line[ci] == '+') ans++;
		if (line[ci] == '-') ans--;
	}

	printf("%d", ans);
	return 0;
}



Measured memory_bytes: 256
n = int(input())
total=10*100

def sum_digits(num):
    sum = 0
    while True:
        if num == 0:
            break
        sum += num%10
        num //= 10
    return sum

for a in range(1, n):
    b = n - a
    total = min(total, sum_digits(a)+sum_digits(b))

print(total)


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

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

int gcd3(int a, int b, int c)
{
  b = gcd(a, b);
  return gcd(b,c);
}

int main()
{
  int n;
  cin >> n;
  
  int sum = 0;
  for(int a=1;a<=n;a++){
      for(int b=1;b<=n;b++){
          for(int c=1;c<=n;c++){
            sum+= gcd3(a,b,c);
          }
      }
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 3636
def solve_operator(left_num, operator, right_num):
    if operator == '+':
        return left_num + right_num
    elif operator == '-':
        return left_num - right_num
    else:
        return left_num * right_num

if __name__ == '__main__':
    stack = []
    for ele in [x for x in input().split()]:
        if ele.isdigit():
            stack.append(int(ele))
        else:
            right_num = stack.pop()
            left_num = stack.pop()
            stack.append(solve_operator(left_num, ele, right_num))
print(stack[0])


Measured memory_bytes: 5604
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::*;
//use std::collections::HashSet;
use std::cmp::*;
//use std::collections::VecDeque;

fn main() {
  input! {
      N:usize,
      D:[(usize,usize);N]
  }
  let mut cnt = 0;
  for (d1, d2) in D {
    if d1 == d2 {
      cnt += 1;
      if cnt >= 3 {
        println!("Yes");
        return;
      }
    } else {
      cnt = 0;
    }
  }
  println!("No");
}


Measured memory_bytes: 2188
#include <stdio.h>

int main()
{
	unsigned long x, y;
	unsigned long tmp;

	scanf("%lu %lu", &x, &y);
	if (x < y) {
		tmp = x;
		x = y;
		y = tmp;
	}
	
	while (y > 0) {
		tmp = x % y;
		x = y;
		y = tmp;
	}

	printf("%lu\n", x);

return 0;
}



Measured memory_bytes: 2140
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll dp[3001][3001];//dp[l][r]:左端が l 枚目，右端が r 枚目の状態から始めた時の，(先手の得点) - (後手の得点) の最大値（手番が先手の時）または最小値（手番が後手の時）
ll coef(int i,int j,int N){
	return (N-(j-i+1))%2*2-1;
}
int main(){
	int N;
	ll a[3001];
	scan(N);
	rep(i,N){
		scan(a[i]);
	}
	rep(k,N){
		rep(i,N-k){
		int j=i+k;
			if(j==i) dp[i][j]=-coef(i,j,N)*a[i];
			else{
				if(coef(i,j,N)==-1){
					dp[i][j]=max(dp[i+1][j]-coef(i,j,N)*a[i],dp[i][j-1]-coef(i,j,N)*a[j]);
				}
				else{
					dp[i][j]=min(dp[i+1][j]-coef(i,j,N)*a[i],dp[i][j-1]-coef(i,j,N)*a[j]);
				}
			}
		}
	}
	prin(dp[0][N-1]);
	return 0;
}


Measured memory_bytes: 70016
#include<bits/stdc++.h>
using namespace std;
struct UnionFind
{
	vector<int> par;
	vector<int> sizes;
	UnionFind(int N):par(N),sizes(N,1)
	{
		for(int i=0;i<N;i++)
		{
			par[i]=i;
		}
	}
	int root(int x)
	{
		if(par[x]==x)
		{
			return x;
		}
		else
		{
			return par[x]=root(par[x]);
		}
	}
	int size(int x)
	{
		return sizes[root(x)];
	}
	void unite(int x,int y)
	{
		int rx=root(x);
		int ry=root(y);
		if(rx==ry)
		{
			return;
		}
		par[ry]=rx;
		sizes[rx] += sizes[ry];
	}
	bool same(int x,int y)
	{
		int rx=root(x);
		int ry=root(y);
		return rx==ry;
	}
};

int main()
{
    long long N,M;
    cin >> N >> M;
    vector<pair<int,int>> AB(M);
    for(int i=0;i<M;i++)
    {
        int a,b;
        cin >> a >> b;
        AB[i].first=a-1;
        AB[i].second=b-1;
    }
    vector<long long> ans(M);
    UnionFind uf(N);
    ans[M-1]=N*(N-1)/2;
    for(int i=M-1;i>0;i--)
    {
        if(uf.same(AB[i].first,AB[i].second))
        {
            ans[i-1]=ans[i];
        }
        else
        {
            long long asize =(long long)uf.size(AB[i].first);
            long long bsize =(long long)uf.size(AB[i].second);
            uf.unite(AB[i].first,AB[i].second);
            ans[i-1]=ans[i]-asize*bsize;
        }
    }

    for(int i=0;i<M;i++)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int MAXP = 8e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct Trie {
	struct Node {
		int child[3], ind;
		bool tag;
	} a[MAXP];
	int n, root, size, ans[MAXP];
	void build(int depth, int &root, int sum, int cur) {
		root = ++size;
		if (depth == 0) {
			a[root].ind = sum;
			return;
		}
		build(depth - 1, a[root].child[0], sum, cur * 3);
		build(depth - 1, a[root].child[1], sum + cur, cur * 3);
		build(depth - 1, a[root].child[2], sum + cur + cur, cur * 3);
	}
	void init(int x) {
		build(n = x, root, 0, 1);
	}
	void shift() {
		swap(a[root].child[1], a[root].child[2]);
		a[root].tag ^= true;
	}
	void pushdown(int root) {
		if (a[root].tag) {
			for (int i = 0; i <= 2; i++) {
				swap(a[a[root].child[i]].child[1], a[a[root].child[i]].child[2]);
				a[a[root].child[i]].tag ^= true;
			}
			a[root].tag = false;
		}
	}
	void inc(int depth, int root) {
		int x = a[root].child[0];
		int y = a[root].child[1];
		int z = a[root].child[2];
		a[root].child[0] = z;
		a[root].child[1] = x;
		a[root].child[2] = y;
		if (depth == 0) return;
		pushdown(root), inc(depth - 1, a[root].child[0]);
	}
	void work(int depth, int root, int sum, int cur) {
		if (depth == 0) {
			ans[a[root].ind] = sum;
			return;
		}
		pushdown(root);
		work(depth - 1, a[root].child[0], sum, cur * 3);
		work(depth - 1, a[root].child[1], sum + cur, cur * 3);
		work(depth - 1, a[root].child[2], sum + cur + cur, cur * 3);
	}
	void getans() {
		work(n, root, 0, 1); int bit = 1;
		for (int i = 1; i <= n; i++)
			bit = bit * 3;
		for (int i = 0; i < bit; i++)
			printf("%d ", ans[i]);
		printf("\n");
	}
} Trie;
int n, len; char s[MAXN];
int main() {
	read(n), Trie.init(n);
	scanf("\n%s", s + 1);
	len = strlen(s + 1);
	for (int i = 1; i <= len; i++)
		if (s[i] == 'S') Trie.shift();
		else Trie.inc(n, Trie.root);
	Trie.getans();
	return 0;
}


Measured memory_bytes: 21836