akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
  double a,b,c,d,e,f;
  while(cin >>a>>b>>c>>d>>e>>f){
    double x=(c*e-b*f)/(a*e-b*d),y=(c*d-a*f)/(b*d-a*e);
    if(x==0)x=0;
    if(y==0)y=0;
    cout <<fixed<<setprecision(3)<< x <<" "<< y <<endl;
  }
  return 0;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	// your code goes here
	int A=read();
	string op;
	cin >> op;
	int B=read();
	
	if(op[0]=='+') cout << A+B;
	else cout << A-B;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
const ll MOD = 1000000007;
//------------------------------------------------------------------------------
void _main()
{
    int n, m;
    cin >> n >> m;
    vector<ll> x(n), y(m);
    rep(i, 0, n) cin >> x[i];
    rep(i, 0, m) cin >> y[i];

    ll X = 0;
    rep(k, 0, n)
    {
        X += k * x[k] - (n - k - 1) * x[k];
        X %= MOD;
    }

    ll Y = 0;
    rep(k, 0, m)
    {
        Y += k * y[k] - (m - k - 1) * y[k];
        Y %= MOD;
    }

    cout << ((X * Y) % MOD) << endl;
}


Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn check(a: i64, b: i64, n: i64, h: &Vec<i64>) -> bool {
    let c = a - b;
    h.iter()
        .filter_map(|x| if x - n * b > 0 { Some(x - n * b) } else { None })
        .map(|x| (x + c - 1) / c)
        .sum::<i64>() <= n
}

fn rec(low: u64, high: u64, a: i64, b: i64, h: &Vec<i64>) -> u64 {
    let mid = (low + high) / 2;

    if low == mid {
        return high;
    }

    if check(a, b, mid as i64, h) {
        rec(low, mid, a, b, h)
    } else {
        rec(mid, high, a, b, h)
    }
}

fn main() {
    let nab: Vec<i64> = util::gets();

    let h = (0..nab[0]).map(|_| util::get()).collect();
    println!("{}", rec(0, 1000_000_000, nab[1], nab[2], &h));
}


Measured memory_bytes: 4352
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
using namespace std;
const int mod=998244353;
typedef long long ll;
int n;
char s[41];
char A[41],B[41];
int b[41];
ll f[39][39],ans;
map<int,int>mp;
inline void deal(int S){
	int top=0,hh=0;
	rep(i,0,n-1)if(S>>i&1)A[++top]=s[i+1];
	_rep(i,n-1,0)if((~S)>>i&1)A[++top]=s[i+1];
	rep(i,1,n)B[i]=A[i];
	reverse(B+1,B+n+1);
	//puts(A+1);
	rep(i,1,n)hh=(hh*97ll+(A[i]-'a'+1))%mod;
	if(mp[hh])return;
	mp[hh]=1;
	//puts(B+1);
	memset(f,0,sizeof f);
	f[0][0]=1;
	rep(i,0,n+n-1)
		rep(j,0,min(i,n)){
			if(!f[j][i-j])continue;
			if(A[j+1]==s[i+1])f[j+1][i-j]+=f[j][i-j];
			if(B[i-j+1]==s[i+1])f[j][i-j+1]+=f[j][i-j];
		}
	ans+=f[n][n];
}
int main(){
	//freopen("string.in","r",stdin);
	//freopen("string.out","w",stdout);
	scanf("%d%s",&n,s+1);
	rep(i,0,(1<<n)-1)
		deal(i);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6400
#include <iostream>
using namespace std;
int main(void){
    int n, a, b, total_a, total_b;
    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        total_a = 0;
        total_b = 0;
        for(int i=1; i<=n; i++){
            cin >> a >> b;
            if(a > b){
                total_a += a + b;
            }
            else if(b > a){
                total_b += a + b;
            }
            else{
                total_a += a;
                total_b += b;
            }
        }
        cout << total_a << " " << total_b << endl;
    }
    return 0;
    
}



Measured memory_bytes: 3080
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a > b)
		{
			System.out.println("a > b");
		}
		else if(a < b)
		{
			System.out.println("a < b");
		}
		else
		{
			System.out.println("a == b");
		}
		sc.close();
	}
}


Measured memory_bytes: 26328
package main

import "fmt"

func main() {
	var n int

	fmt.Scanf("%d", &n)

	var squares = make([]int, n)
	for i := 0; i < n; i++ {
		var temp int
		fmt.Scanf("%d", &temp)
		squares[i] = temp
	}

	fmt.Println(inc_arr(squares))
}

func naive(squares []int) int {
	n := len(squares)
	max := 0
	for i := 0; i < n; i++ {
		count := 0
		j := i
		for j+1 < n {
			if squares[j+1] > squares[j] {
				break
			} else {
				j++
				count++
			}
		}
		if count > max {
			max = count
		}
	}

	return max
}

func inc_arr(arr []int) int {
	n := len(arr)

	prev := arr[0]
	for i := 1; i < n; i++ {
		temp := arr[i]
		arr[i] = temp - prev
		prev = temp
	}

	max := 0
	count := 0
	for j := 1; j < n; j++ {
		if arr[j] > 0 {
			count = 0
		} else {
			count++
		}
		if count > max {
			max = count
		}
	}

	return max
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// string p=s.substr(0,len);
// string q=s.insert(0,str);
// sort(arr, arr+n, greater<int>());
// cout<<fixed<<setprecision(9)<<pi<<endl
// const  double pi = acos(-1.0);
// sort(v.rbegin(),v.rend());
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	string s,t,u;
	int a,b;
	
	cin>>s>>t;
	cin>>a>>b;
	cin>>u;

	if(u==s)
	{
		cout<<a-1<<" "<<b<<endl;
	}
	else
	{
		cout<<a<<" "<<b-1<<endl;
	}
}

Measured memory_bytes: 3608
import sys
import numpy as np 

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, k = I[:2]
x = I[2:]

def main():
    d = np.minimum(x, k - x)
    return np.sum(d) * 2

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 20520
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		int sum = 0;
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		    sum += a[i];
		}
		Arrays.sort(a);
		
		// 計算
		int result = 0;
		if(sum%10 != 0){
		    System.out.println(sum);
		    return;
		}
		for(int i = 0; i < n; i++){
		    if((sum - a[i])%10 != 0){
		        result = sum - a[i];
		        break;
		    }
		}

		// 出力
		System.out.println(result);
	}
}



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

int main() {
    int x=0;
    int maxX = 0;
    int N;
    string S;
    cin >> N;
    cin >> S;

    for(int i=0; S[i]!='\0'; i++)
    {
        if(S[i]=='I') x += 1;
        else x -= 1;

        if(maxX < x) maxX = x;
    }
    cout << maxX << endl;
    return 0;
}

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

using namespace std;

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template<class T>
void print(vector<T>& V, bool spaced = true) {
    string space;
    spaced ? space = " " : space = "";
    for(int i = 0; i < V.size(); i++) {
        cout<< V[i] << space;
    }cout<< '\n';
}

template<class T>
void printendl(vector<T>& V) {
    for(int i = 0; i < V.size(); i++) {
        cout<< V[i] << '\n';
    }
}

template<class T>
T gcd(T a, T b) {
    T r;
    while (b != 0) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

template <class T>
T lcm (T a, T b) {
    return a / gcd(a, b) * b;
}

template<class T>
T Max(T a, T b) {
    return (a < b) ? b : a;
}

template<class T>
T Min(T a, T b) {
    return (a < b) ? a : b;
}

//str

bool isPalindrome(string str){
    
    int length = str.length();
 
    for (int i = 0; i < (length / 2); i++)
        if (str[i] != str[length - 1 - i])
            return false;
 
    return true;    
}

void reverseStr(string& str) 
{ 
    int n = str.length(); 
    for (int i = 0; i < n / 2; i++) 
        swap(str[i], str[n - i - 1]); 
}
 

//Read through the messages at the end when you're done

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll x; cin>> x;
    ll ans = 0;
    ll k = x/500;
    x = x - 500*k;
    ll j = x/5;
    cout << 1000*k + 5*j << '\n';
    
    

    return 0;
}

    //Use long long da5eel rabbak!
    //Dont use endl;
    //DONT SUBMIT IZA UR NOT SURE WALLAHI BTENDAM
    //Dear Amine, just because it worked for the test cases doesnt necessarily mean it is correct.
    //Dear Amine, try it on ur own test cases iza ur not SURE
    //In case u didnt use long long, CHECK FOR POTENTIAL OVERFLOWS
    //DONT FORGET TO MOD EVERYTHING IZA U NEED TO MOD



Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

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

	vector<int> a(n);
	for (int i = 0; i < n ; i++)
	{
		cin >> a.at(i);
	}

	sort(a.begin(), a.end());

	cout << a.at(n - 1) - a.at(0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)

// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;

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;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    string C1,C2; cin >> C1 >> C2;
    if(C1[0]==C2[2] && C1[1]==C2[1] && C1[2]==C2[0]) pr("YES");
    else pr("NO");
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxN=1e3+123;


//dp[i][k] i taye aval carry k ro ba
int n,x,ans;
int32_t main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x;
    ans+=x-1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
a,b=map(int,input().split())

if b-a < 5:
    res = 0
    for i in range(a,b+1):
        res = res ^ i
    print(res)
else:
    a2 = ((a+3)//4)*4
    b2 = (b//4)*4

    res = 0
    for i in range(a,a2):
        res = res ^ i
    for i in range(b2,b+1):
        res = res ^ i
    print(res)

Measured memory_bytes: 38512
N = int(input())
li = [list(map(int,input().split())) for _ in range(N)]

dp = [[0,0,0] for _ in range(N)]
dp[0] = li[0]

for i in range(N-1):
  for j in range(3):
    for k in range(3):
      if j == k: continue
      dp[i+1][j] = max(dp[i+1][j], dp[i][k] + li[i+1][j])
print(max(dp[-1]))


Measured memory_bytes: 47412
Scanf.(Array.(scanf" %d %d %d"@@fun n m x->
	let l,r = init m (fun _->scanf" %d"@@fun v->v)
	|> fold_left(fun (l,r) v->if v<x then (l+1,r) else (l,r+1))(0,0)
	in print_int @@ min l r));;

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, Z, W;

int main()
{
    cin >> N >> Z >> W;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    if (N == 1)
        cout << abs(a[0] - W) << "\n";
    else
        cout << max(abs(a[N - 1] - W), abs(a[N - 1] - a[N - 2])) << "\n";
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

signed main() {
	int n; cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; ++i)
		cin >> p[i];
	int mn = 1000000000; // 今までの最小値
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (mn >= p[i]) ++cnt;
		mn = min(mn, p[i]);
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void) {

	int n;
	string s;
	char c;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> c;
		s += c;
	}

	if (s.find("Y") != string::npos)
		cout << "Four" << '\n';
	else
		cout << "Three" << endl;	

	return 0;
}

Measured memory_bytes: 256
import math
def py():
    print("yes")
def pn():
    print("no")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0

s = input()
for a in range(len(s)-1):
    for b in range(a+1,len(s)):
        if s[a] == s[b]:
            neko = 1
if neko:
    pn()
else:
    py()

Measured memory_bytes: 8956
#include<stdio.h>
int main(void){
  int x,y,z;
  int a;
  
  scanf("%d %d %d",&x,&y,&z);
  
  a=x;
  x=y;
  y=a;
  
  a=z;
  z=x;
  x=a;
  
  printf("%d %d %d",x,y,z);
         
  return 0;
         }

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

int main(){
long long S,X; cin>>X; long long ans=0; S=100;
  for(long long i=0; S<X; i++)
  {S=S*1.01; ans++;}
  cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

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

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！

int main() {
    ll n,x=0,i=1;
    cin >> n;
    while(i<n*10){
        x+=max(n/i-(n/(i*10))*10,0LL);
        i*=10;
    }
    if(n%x==0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
input_line1 = input().split(' ')
input_line2 = input().split(' ')
stT = input()
numN = int(input_line1[0])
numK = int(input_line1[1])
numR = int(input_line2[0])
numS = int(input_line2[1])
numP = int(input_line2[2])

vioR = []
vioS = []
vioP = []
result = [0] * numN 

for i, c in enumerate(stT):
  if i + numK < numN and stT[i + numK] == c and result[i] == 0:
    result[i + numK] = -1
  if result[i] != -1:
    result[i] = c

score = 0
for i in result:
    if i == 'r':
        score += numP
    elif i == 's':
        score += numR
    elif i == 'p':
        score += numS
print(score)

Measured memory_bytes: 4084
"""D."""

import sys


def input() -> str:  # noqa: A001
    """Input."""
    return sys.stdin.readline()[:-1]


class UnionFindTree:
    """Union-find."""

    def __init__(self, n: int) -> None:
        """Init."""
        self.n = n
        self.rank = [-1] * n

    def find_root(self, x: int) -> int:
        """Find root."""

        if self.rank[x] < 0:
            return x

        self.rank[x] = self.find_root(self.rank[x])
        return self.rank[x]

    def union(self, x: int, y: int) -> None:
        """Unite two trees."""
        x_root = self.find_root(x)
        y_root = self.find_root(y)

        if x_root == y_root:
            return

        if x_root > y_root:
            x_root, y_root = y_root, x_root

        self.rank[x_root] += self.rank[y_root]
        self.rank[y_root] = x_root

    def get_size(self, x: int) -> int:
        """Get size."""
        return self.rank[self.find_root(x)] * -1

    def is_same(self, x: int, y: int) -> bool:
        """Is same group."""
        return self.find_root(x) == self.find_root(y)


n, m = map(int, input().split(' '))

tree = UnionFindTree(n)

for _ in range(m):
    a, b = map(int, input().split(' '))
    tree.union(a - 1, b - 1)

ans = 0

for i in range(n):
    ans = max(ans, tree.get_size(i))

print(ans)


Measured memory_bytes: 16688
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int h,w,n;
    cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;
}

Measured memory_bytes: 256
datas = $stdin.read.split("\n")
n = datas[0].to_i
datas = datas.drop(1)
max = datas[1].to_i - datas[0].to_i
min = datas[0].to_i
for i in 1..n - 1
  max = [max,datas[i].to_i - min].max
  min = [min,datas[i].to_i].min
end
puts  max


Measured memory_bytes: 19096
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e6;
ll inf = LLONG_MAX, mod1 = 1e9 + 7, mod2 = 998244353;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll md[200010][2];
ll solve(ll x)
{
    if (!x) return 0;
    bitset<40> bt = x;
    ll t = bt.count();
    return (1 + solve(x % t));
}

int main()
{
    fast_io;
    ll n, i, k0 = 0, n1 = 0, n2 = 0, nw;
    string a;
    cin >> n >> a;
    for (i = 0; i < n; i++)
        if (a[i] == '1') k0++;
    md[0][0] = md[0][1] = 1;
    for (i = 1; i < n; i++)
    {
        if (k0 > 1) md[i][0] = (2 * md[i - 1][0]) % (k0 - 1);
        md[i][1] = (2 * md[i - 1][1]) % (k0 + 1);
    }
    for (i = 0; i < n; i++)
    {
        if (a[i] == '0') continue;
        if (k0 > 1) n1 = (n1 + md[n - i - 1][0]) % (k0 - 1);
        n2 = (n2 + md[n - i - 1][1]) % (k0 + 1);
    }
    for (i = 0; i < n; i++)
    {
        if (k0 == 1 && a[i] == '1')
        {
            cout << "0\n";
            continue;
        }
        if (a[i] == '0') nw = (n2 + md[n - i - 1][1]) % (k0 + 1);
        else nw = (n1 - md[n - i - 1][0] + k0 - 1) % (k0 - 1);
        cout << 1 + solve(nw) << '\n';
    }
    return 0;
}

Measured memory_bytes: 6860
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<sstream>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++ )
int d[4];
bool flg = false;
string s = "+-*";
int calc( int a, int op, int b){
  if( op == 0) return a + b;
  if( op == 1) return a - b;
  return a * b;
}
bool solve(int a, int b, int c){
  flg++;
  if(calc( calc( calc( d[0], a, d[1]), b, d[2]), c, d[3]) == 10){
    return printf("(((%d %c %d) %c %d) %c %d)\n", d[0], s[a], d[1], s[b], d[2], s[c], d[3]);
  }
  if(calc( calc( d[0], a, d[1]), b, calc( d[2], c, d[3])) == 10){
    return printf("((%d %c %d) %c (%d %c %d))\n", d[0], s[a], d[1], s[b], d[2], s[c], d[3]);
  }
  if(calc( calc( d[0], a, calc( d[1], b, d[2])), c, d[3]) == 10){
    return printf("((%d %c (%d %c %d)) %c %d)\n", d[0], s[a], d[1], s[b], d[2], s[c], d[3]);
  }
  return flg = false;
}

bool judge(){
  rep(i,3) rep(j,3) rep(k,3) if(solve( i, j, k)) return true;
}
int main(){
  while(flg = true){
    rep(i,4) cin >> d[i];
    if(!d[0] && !d[1] && !d[2] && !d[3]) break;
    sort(d, d + 4);
    do if(judge()) break; while(next_permutation(d,d+4));
    if(!flg) puts("0");
  }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    vector<string>s(3);
    for (int i = 0; i < 3; ++i) {
        cin >>s[i];
    }
    for (int i = 0; i < 3; ++i) {
        cout <<s[i][i];
    }
    cout <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  int t,n,i,j,k,l,l1,a,v,b,w;
  cin>>a>>v;
  cin>>b>>w;
  cin>>t;
  if(a<b)
  {
    if(v<=w) cout<<"NO";
    else
    {
      k=(b-a)/(v-w);
      if((b-a)%(v-w)==0) ;
      else k++;
      if(t>=k) cout<<"YES";
      else
       cout<<"NO";
    }
  }
  else
  {
    if(v<=w) cout<<"NO";
    else
    {
      k=(a-b)/(v-w);
      if((a-b)%(v-w)==0) ;
      else k++;
      if(t>=k) cout<<"YES";
      else
       cout<<"NO";
    }
  }
}

Measured memory_bytes: 3596
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	a := nextInt()
	ans := 1
	inc := false
	dec := false
	for i := 1; i < N; i++ {
		b := nextInt()
		if !inc && !dec {
			if a > b {
				dec = true
			} else if a < b {
				inc = true
			}
		}
		if a > b && inc {
			//fmt.Println("dec", a, b)
			ans++
			inc = false
			dec = false
		} else if a < b && dec {
			//fmt.Println("inc", a, b)
			ans++
			inc = false
			dec = false
		}
		a = b
	}

	fmt.Println(ans)
}


Measured memory_bytes: 3424
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}
//三種類の文字しか含まない
int main() {
    string S;
    cin >> S;
    map<char, int> cnt;
    REP(i, S.length()) { cnt[S[i]]++; }
    if(S.length() == 1) {
        cout << "YES" << endl;
        return 0;
    }
    int kinds = 0;
    if(cnt['a'] != 0) {
        kinds++;
    }
    if(cnt['b'] != 0) {
        kinds++;
    }
    if(cnt['c'] != 0) {
        kinds++;
    }
    if(kinds == 1 and S.length() > 1) {
        cout << "NO" << endl;
        return 0;
    }
    if(kinds == 2 and S.length() > 2) {
        cout << "NO" << endl;
        return 0;
    } else if(kinds == 2 and S.length() <= 2) {
        cout << "YES" << endl;
        return 0;
    }
    //三種類のときを考える
    int N = S.length();
    //全部同じ回数かどれか位置だけおおい
    bool flag = true;
    for(int i = 'a'; i <= 'c'; i++) {
        if(cnt[(char)i] == N / 3 or cnt[(char)i] == N / 3 + 1) {
            continue;
        } else {
            flag = false;
        }
    }
    if(flag) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    n = I()
    if n in [10,100,1000,10000,100000]:
        return 10

    s = [c for c in str(n)]
    return sum(map(int, s))


print(main())



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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

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

    int n;
    cin>>n;
    map<string, int> m;
    string s;
    while(n--)
    {
        cin>>s;
        m[s]++;
    }   
    cout<<m.size();

    return 0;
}

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

/* -------------------------------- Template -------------------------------- */

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template<typename T> T inf() { assert(false); }
template<> constexpr int inf<int>() { return 1e9; }
template<> constexpr ll inf<ll>() { return 1e18; }
template<> constexpr ld inf<ld>() { return 1e30; }

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha;
  cout.imbue(loc);

  int N;
  cin >> N;
  ll a = 1, b = 1;
  REP(i,N) {
    ll x, y;
    cin >> x >> y;
    ll p = max((a + x - 1) / x, (b + y - 1) / y);
    a = x * p;
    b = y * p;
  }
  cout << a + b << endl;
  return 0;
}


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


void main() {
    int n;
    int[] a;

    scan(n);
    a = readln.split.to!(int[]);

    int[] pos = new int[](n + 2);

    foreach (int i, ai; a) {
        pos[ai] = i + 1;
    }

    debug {
        writeln("pos:", pos);
    }

    auto rbt = redBlackTree(0, n + 1);
    long ans;

    foreach (i ; 1 .. n + 1) {
        int prev = rbt.lowerBound(pos[i]).back;
        int next = rbt.upperBound(pos[i]).front;

        debug {
            writefln("prev:%d, next:%d", prev, next);
        }

        ans += 1L * i * (pos[i] - prev) * (next - pos[i]);

        rbt.insert(pos[i]);
    }

    writeln(ans);
}



struct Stack(T) {
private:
    int N, peek;
    T[] data;

public:
    this(int size) 
    {
        N = size;
        data = new T[](N);
    }

    bool empty() @property
    {
        return peek == 0;
    }

    bool full() @property
    {
        return peek == N;
    }

    void push(T x) @property
    {
        assert(!full);
        data[peek++] = x;
    }

    void pop() @property
    {
        assert(!empty);
        --peek;
    }

    T top() @property
    {
        return data[peek - 1];
    }

    void clear() @property
    {
        peek = 0;
    }

    int length() @property
    {
        return peek;
    }

}



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



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

Measured memory_bytes: 19600
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  for (int i= 0; i < N; i++){
    cin >> a[i];
  }
  for (int i=0; i<N;i++){
    b[a[i]-1] = i+1;
  }
  for (int i=0;i<N;i++){
    cout << b[i] << ' ';
  }
  cout << endl;
  return 0;
}


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

    typedef long long ll;

    #define Canuc80k cin.tie(0); cout.tie(0);
    #define I_am ios_base::sync_with_stdio(false);
    #define REP(i,a,b) for (int i = a; i < b; i ++)
    #define FOR(i,a,b) for (int i = a; i <= b; i ++)
    #define FORD(i,a,b) for (int i = a; i >= b; i --)

    const int N = 1e6 + 1;
    const int M = 1e9 + 7;

    string str;
    ll n, k, i, pp[N];

    int main() {
        I_am Canuc80k;

        cin >> n >> k;
        while (k --) {
            int l;
            cin >> l;
            while (l --) {
                int i;
                cin >> i;
                pp[i] ++;
                if (pp[i] == 1) n --;
            }
        }
        
        cout << n;
    }

Measured memory_bytes: 3692
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vint a(3);
    REP(i,3)cin >> a[i];
    sort(ALL(a));
    cout << a[0]+a[1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int main(){
  ll k,a,b;
  cin>>k>>a>>b;
  if(k<=a || b-a<2) cout<<k+1<<endl;
  else{
    ll ans=0;
    k-=a+1;
    ans=b;
    if(k%2==0) ans+=(k/2)*(b-a);
    else ans+=(k/2)*(b-a)+1;
    cout<<ans<<endl;
  }
    

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    using namespace std;
    using ll = long long;
    using P = pair<int,int>;
     
    const ll MX = 1e18;
     
    int main() {
      int n;
      cin >> n;
      ll ans = 1;
      bool ng = false;
      rep(i,n) {
        ll a;
        cin >> a;
        if (a == 0) {
          cout << 0 << endl;
          return 0;
        }
        if (ng || (MX+1)/ans < a || ans*a > MX) {
          ng = true;
        }
        ans *= a;
      }
      if (ng) cout << -1 << endl;
      else cout << ans << endl;
      return 0;
    }

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

int main()
{
    int N, M, P;
    cin>>N>>M>>P;
    vector<int> A(M), B(M);
    vector<long long> C(M);
    for (int i=0; i<M; i++)
    {
        cin>>A[i]>>B[i]>>C[i];
        A[i]--;
        B[i]--;
    }

    long long oo = 0x1fffffffffffffffLL;
    vector<long long> D(N, -oo);
    D[0] = 0;
    bool up = false;
    for (int i=0; i<2*N; i++)
    {
        if (i==N)
            up = false;
        for (int j=0; j<M; j++)
        if (D[A[j]] > -oo)
        {
            if (B[j]==N-1 && D[A[j]]+C[j]-P>D[B[j]])
                up = true;
            D[B[j]] = max(D[B[j]], D[A[j]]+C[j]-P);
        }
    }
    cout<<(up ? -1 : max(D[N-1], 0LL))<<endl;
}


Measured memory_bytes: 384
using System;
using System.Linq;

public class AtCoder_158_C
{
    public static void Main()
    {
        int[] line1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int a = line1[0]; // 8%
        int b = line1[1]; // 10%

        for (int i = 0; i < 10; i++)
        {
            int bBase = b * 10 + i;
            if (bBase * 8 / 100 == a)
            {
                Console.WriteLine(bBase);
                return;
            }
        }
        Console.WriteLine(-1);
    }
}


Measured memory_bytes: 13268
H,W = list(map(int,input().split()))
h,w = list(map(int,input().split()))
list = [[1]*W for i in range(0,H)]
for i in range(h):
    for j in range(W):
        list[i][j] = 0
for i in range(H):
    for j in range(w):
        list[i][j] = 0
result = sum(map(sum, list))
print(result)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int countR = 0;
  int countW = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'R'){
      countR++;
    }
    else if (S.at(i) == 'W'){
      countW++;
    }
  }
  
  if (countR == 0 || countW == 0){
    cout << 0 << endl;
    return 0;
  }
  
  int A = 0;
  int B = 0;
  vector<int>red(countR);
  vector<int>white(countW);
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'R'){
      red.at(A) = i;
      A++;
    }
    else if (S.at(i) == 'W'){
      white.at(B) = i;
      B++;
    }
  }
  sort(red.begin(), red.end());
  reverse(red.begin(), red.end());
  sort(white.begin(), white.end());
  
  int counta = 0;
  int countb = 0;
  for (int i = 0; i < countR; i++) {
    if (red.at(i) > countR - 1){
      counta++;
    }
    else {
      break;
    }
  }
  for (int i = 0; i < countW; i++) {
    if (white.at(i) < countR){
      countb++;
    }
    else {
      break;
    }
  }
 
  cout << max(counta,countb) << endl;
}



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

int K, S;

int main() {
    cin >> K >> S;
    
    int ans = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - x - y;
            if (0 <= z && z <= K) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * http://abc071.contest.atcoder.jp/tasks/abc071_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		
		String c = "None";
		for(int i='a'; i<='z'; i++){
			if(!s.contains(""+(char) i)) {
				c = ""+(char)i;
				break;		
			}
		}
		
		System.out.println(c);

	}

}

Measured memory_bytes: 24148
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()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn vs(a: &mut Vec<Vec<usize>>, n: usize, p1: usize, p2: usize, done: &mut Vec<bool>) -> bool {
    if done[p2 - 1] {
        a[p1 - 1].push(p2);
        done[p1 - 1] = true;
        return false;
    } else if let Some(p3) = a[p2 - 1].pop() {
        if p1 != p3 {
            done[p1 - 1] = true;
            a[p1 - 1].push(p2);
            return vs(a, n, p2, p3, done);
        }
        done[p1 - 1] = true;
        done[p2 - 1] = true;
        return true;
    }
    false
}

fn day(a: &mut Vec<Vec<usize>>, n: usize) -> u32 {
    let mut done: Vec<bool> = vec![false; n];
    let mut cnt: u32 = 0;
    for p1 in 1..(n + 1) {
        if done[p1 - 1] {
            continue;
        } else if let Some(p2) = a[p1 - 1].pop() {
            if vs(a, n, p1, p2, &mut done) {
                cnt += 1;
            }
        }
    }
    cnt
}

fn all(a: &mut Vec<Vec<usize>>, n: usize) -> i32 {
    let mut vs_cnt: u32 = 0;
    let mut day_cnt: i32 = 0;

    while vs_cnt < ((n * (n - 1)) / 2) as u32 {
        let tmp = day(a, n);
        if tmp == 0 {
            day_cnt = -1;
            break;
        } else {
            vs_cnt += tmp;
        }
        day_cnt += 1;
    }

    return day_cnt;
}

fn main() {
    let n: u32 = read();
    println!("{}", (((n + 1) / 2) as f32) / (n as f32));
}


Measured memory_bytes: 4352
n, a, b = map(int, input().split())
s = input()

A = 0
B = 0
for i in s:
    if A + B < a + b:
        if i == "a":
            A += 1
            print("Yes")
        elif i == "b" and B < b:
            B += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 4016
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=1e5+10;
const int mod=1e9+7;
ll f[N];
ll pows(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1)
        {
            ans=ans*a%mod;
        }
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
ll invs(ll a)
{
    return pows(a,mod-2);
}
ll C(ll n,ll m)
{
    if(m<n)
    {
        return 0;
    }
    return f[m]*invs(m-n)%mod*invs(n)%mod;
}
ll n,k;
ll a[N];
ll inv[N];
int main()
{
    f[0]=1;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        f[i]=f[i-1]*i%mod;
        inv[i]=pows(i,mod-2);
    }
    sort(a+1,a+1+n);
    ll sum=a[k];
    ll p=1;
    for(int i=k+1;i<=n;i++)
    {
        p=p*(i-1)%mod*inv[i-k]%mod;
        sum=(sum+a[i]*p%mod)%mod;
    }
    sum-=a[n-k+1];
    p=1;
    for(int i=k+1;i<=n;i++)
    {
        p=p*(i-1)%mod*inv[i-k]%mod;
        sum=(sum-a[n-i+1]*p%mod)%mod;
    }
    cout<<(sum+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 5928
H,W,M=map(int,input().split())
#二次元リストではなく列行を一個のボムで消してくれるためそれぞれのリストを用意。
sumh = [0] * H
sumw = [0] * W
bomb=[]

for i in range(M):
    h,w=map(int,input().split())
    sumh[h-1]+=1
    sumw[w-1]+=1
    bomb.append((h,w))

#爆弾の個数の最大値とその最大値がいくつずつあるか(ch,cw)に保存。最大の列と最大の行のいずれかの組み合わせに置くことで爆破数を最大化できる。
maxh=max(sumh)
maxw=max(sumw)
ch=sumh.count(maxh)
cw=sumw.count(maxw)
#print(maxh,maxw,ch,cw)

#爆弾のある場所がH,Wの座標で両方共で最大個数の場所であった場合その数を加算
count=0
for h,w in bomb:
    if sumh[h-1]==maxh and sumw[w-1]==maxw:
        count+=1
#print(count)

#破壊できる数は、そのマスに爆破対象があるとき一つ減ってしまう。
if count==ch*cw:
    print(maxh+maxw-1)
else:
  print(maxh+maxw)

Measured memory_bytes: 54176
//This disgusting code is wriiten by Juruo D0zingbear
//Please don't hack me! 0v0 <3
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}

// cf IO: I64d
// atcoder IO: £ì£ì£ä
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int Maxn=100005;
string s,t,tt;
int main(){
	cin>>s;
	for (int i=0;i<s.size();i++){
		if (s[i]!='x') t+=s[i];
	}
	tt=t;
	reverse(tt.begin(),tt.end());
	if (t!=tt){
		printf("-1\n");
		return 0;
	}
	if (t.empty()){
		printf("0\n");
		return 0;
	}
	int l=0,r=s.size()-1;
	int ans=0;
	while (1){
		int c1=0,c2=0;
		while (s[l]=='x') l++,c1++;
		while (s[r]=='x') r--,c2++;
		ans+=(abs(c1-c2));
		l++;
		r--;
		if (l>=r) break;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 512
w, a, b = map(int, input().split())
a_tail = a + w
b_tail = b + w

if (a >= b and a <= b_tail) or (a_tail >= b and a_tail <= b_tail):
    ans = 0
else:
    ans = min(abs(a + w -b), abs(b + w - a))

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

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

        int a1 = S[0] - '0';
        int a2 = S[1] - '0';
        int b1 = S[2] - '0';
        int b2 = S[3] - '0';

        int a = a1*10 + a2;
        int b = b1*10 + b2;

        bool ya = false;
        bool ma = false;
        bool yb = false;
        bool mb = false;

        if(a >= 0 and a <= 99) ya = true;
        if(b >= 0 and b <= 99) yb = true;
        if(a >= 1 and a <= 12) ma = true;
        if(b >= 1 and b <= 12) mb = true;

        if(ya == true and ma == true and yb == true and mb == true)
        {
                cout << "AMBIGUOUS" << endl;
        }
        else if(ya == true and mb == true)
        {
                cout << "YYMM" << endl;
        }
        else if(ma == true and yb == true)
        {
                cout << "MMYY" << endl;
        }
        else
        {
                cout << "NA" << endl;
        }

        return 0;
}

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

int main(){
  int N;
  int a[100];
  cin >> N;
  int sum=0;
  for(int i=0; i<N; i++){
    cin >> a[i];
    sum+=a[i];
  }
  int ave = round(sum/(double)N);
  int cost=0;
  for(int i=0; i<N; i++){
    cost += pow(a[i]-ave,2);
  }
  cout << cost << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	// your code goes here
	int h,n;
	cin>>h>>n;
	int a[n],i;

	
	for(i=0;i<n;i++){cin>>a[i];
	
	}
	sort(a,a+n);
	
int sum=0;
	sum+=accumulate(a,a+n,sum);
	//cout<<sum;
	if(sum>=h)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
int n;
int main()
{
    scanf("%d",&n);
    for(int i=0;i*4<=n;i++)
    {
        if((n-i*4)%7==0) {printf("Yes\n");return 0;}
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
key = [[] for _ in range(M)]
for i in range(M):
    a, _ = map(int, input().split())
    # 空けることができる宝箱をbitで表す
    c = 0
    for v in list(map(int, input().split())):
        c += pow(2, v-1)
    key[i] = [a, c]

status_count = pow(2, N)
INF = 10 ** 30
# keyの各要素の先頭が値段になってる
dp = [INF] * (status_count)
dp[0] = 0
for a, c in key:
    # 今対象の鍵を購入したときの最小値を求める
    for i in range(status_count):
        dp[i | c] = min(dp[i | c], dp[i] + a)

print(dp[-1] if dp[-1] < INF else -1)


Measured memory_bytes: 47448