akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


int main(){
  int h,n;
  cin>>h>>n;
  int arr[n];
  int suma = 0;
  for(int i=0;i<n;i++){
   cin>>arr[i]; 
    suma += arr[i];
  }
  if(suma >= h){
    cout<<"Yes"<<endl;
  }
  else
    cout<<"No"<<endl;
 return 0; 
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		List<Integer> diffList = new ArrayList<>();
		for (int i = 0; i < m; i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);
		// System.out.println(list);

		for (int i = 0; i < m-1; i++) {
			diffList.add(Math.abs(list.get(i)-list.get(i+1)));
		}
		Collections.sort(diffList);
		// System.out.println(diffList);

		int sum = 0;
		for (int i = 0; i < m-1-(n-1); i++) {
			sum += diffList.get(i);
		}
		System.out.println(sum);



	}
}


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

class Program
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var H = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int ans = 0;
        int max = 0;

        for (int i = 0; i < N; i++)
        {
            if(i == 0)
            {
                ans = ans + 1;
                max = H[i];
            }
            else
            {
                if(max <= H[i])
                {
                    ans = ans + 1;
                    max = H[i];
                }
            }
        }

            Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, Q;
    cin >> N >> Q;
    vector<priority_queue<int>> v(N);
    while (Q--) {
        int q, t; cin >> q >> t;
        if (q == 0) {
            int x;
            cin >> x;
            v[t].push(x);
        } else if (q == 1) {
            if (v[t].size()) cout << v[t].top() << endl;
        } else {
            if (v[t].size()) v[t].pop();
        }
    }
}


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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define double long double
#define tt tuple<int, int, int>
#define endl '\n'

double dp[303][303][303];

int n;

double f(int cnt1, int cnt2, int cnt3) {

	if(cnt1 + cnt2 + cnt3 == 0)
		return 0;

	double &ret = dp[cnt1][cnt2][cnt3];

	if(ret > -1)
		return ret;

  ret = 0;
  if(cnt1)
    ret += (cnt1) * f(cnt1 - 1, cnt2, cnt3);
  if(cnt2)
    ret += (cnt2) * f(cnt1 + 1, cnt2 - 1, cnt3);
  if(cnt3)
    ret += (cnt3) * f(cnt1, cnt2 + 1, cnt3 - 1);

  ret /= n;

  ret += 1;

  ret *= n * 1.0 / (cnt1 + cnt2 + cnt3);
  return ret;
}

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

  for(int i = 0; i < 303; i++)
  	for(int j = 0; j < 303; j++)
  		for(int k = 0; k < 303; k++)
  			dp[i][j][k] = -INF;

  cin >> n;

  int cnt1, cnt2, cnt3;

  cnt3 = cnt2 = cnt1 = 0;
  for(int i = 0; i < n; i++) {
    int x;
    cin >> x;

    cnt1 += (x == 1);
    cnt2 += (x == 2);
    cnt3 += (x == 3);
  }

  cout << fixed << setprecision(10);
  cout << f(cnt1, cnt2, cnt3) << endl;

}

Measured memory_bytes: 434944
#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;

int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	vector<vector<LL>> A(N,vector<LL>(N));
	int i,j,k;
	for (i=0;i<N;i++){
		for (j=0;j<N;j++){
			cin>>A[i][j];
		}
	}
	vector<pair<int,int>> point;
	for (i=0;i<N-1;i++){
		for (j=i+1;j<N;j++){
			for (k=0;k<N;k++){
				if (i==j || i==k || k==j){
					continue;
				}
				if (A[i][j]>A[i][k]+A[k][j]){
					cout<<-1<<endl;
					return 0;
				}else if (A[i][j]==A[i][k]+A[k][j]){
					point.push_back(make_pair(i,j));
				}
			}
		}
	}
	for (k=0;k<point.size();k++){
		i=point[k].first;
		j=point[k].second;
		A[i][j]=0;
		A[j][i]=0;
	}
	LL minDist=0;
	for (i=0;i<N;i++){
		for (j=0;j<N;j++){
			minDist+=A[i][j];
		}
	}
	cout<<minDist/2<<endl;
	return 0;
}

Measured memory_bytes: 18928
#include<iostream>
#include<string>
 
using namespace std;
 
typedef long long ll;
 
ll N;
 
int main() {
	cin >> N;
 
	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 3 == 0 || i % 5 == 0)continue;
		ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
def main():
    a = [int(i) for i in input().split()]

    a.sort()

    op0 = (a[2] - a[0])//2
    a[0] += 2 * op0

    op1 = (a[2] - a[1])//2
    a[1] += 2 * op1

    if a[0] == a[2] and a[1] == a[2]:
        print(op0+op1)
    elif a[0] < a[2] and a[1] == a[2]:
        print(op0+op1+2)
    elif a[0] == a[2] and a[1] < a[2]:
        print(op0+op1+2)
    elif a[0] < a[2] and a[1] < a[2]:
        print(op0+op1+1)


if __name__ == '__main__':
    main()


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int t = 0;
  vector<int> v{t};
  for (char c : s) {
    if (c == 'R') {
      ++t;
    } else {
      --t;
    }
    if ((t & 3) == 0) {
      v.push_back(t);
    }
  }
  int res = 0;
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    res += v[i + 1] - v[i] == 4;
  }
  cout << res << '\n';
}



Measured memory_bytes: 3232
package main

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

func main() {
	N := nextInt()
	S := nextBytes()
	T := nextBytes()

	for i := 0; i < N; i++ {
		fmt.Printf("%c", S[i])
		fmt.Printf("%c", T[i])
	}
	fmt.Println()
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<ctype.h>
using namespace std;
#define f(i,n) for(ll i=0;i<n;i++)
#define fasti ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
int main()
{
fasti;
ll n;
cin>>n;
ll a[n];
map<ll,ll>x;
for(ll i=1;i<n;i++)
{
    cin>>a[i];
    x[a[i]]++;
}
for(ll i=0;i<n;i++)
    cout<<x[i+1]<<' ';
return 0;
}

Measured memory_bytes: 17724
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long pow=1;

        for(int i=1; i<=n; i++) {
            pow = (pow * i)% 1000000007;
        };
        System.out.println(pow);
    }
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

string solve_y(int n) {
    if (n>0) return "U";
    else return "D";
}

string solve_x(int n) {
    if (n>0) return "R";
    else return "L";
}

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx;
    int dy = ty - sy;

    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx, 'L');
    cout << "L" << string(dy+1, 'U') << string(dx+1, 'R') << "D";
    cout << "R" << string(dy+1, 'D') << string(dx+1, 'L') << "U"<< endl;

    return 0;
}



Measured memory_bytes: 256
class Triangle
  def initialize(array)
    @lengths = array.sort!
  end

  attr_accessor :lengths

  def right_triangle?
    (@lengths[0] ** 2) + (@lengths[1] ** 2) == @lengths[2] ** 2
  end
end

case_num = gets.to_i
case_num.times do
  puts Triangle.new(gets.split(" ").map(&:to_i)).right_triangle? ? "YES" : "NO"
end

Measured memory_bytes: 6112
#include<iostream>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<vector>
using namespace std;
const int INF = 2000000005;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 1; i < n; i++) {
		int kans = 0;
		bool abc[26] = { false };
		for (int k = 0; k < i; k++) {
			abc[(int)(s[k])-97] = true;
		}
		for (int k = i; k < n; k++) {
			if (abc[(int)(s[k]) - 97]) {
				kans++;
				abc[(int)(s[k]) - 97] = false;
			}
		}
		ans = max(ans, kans);
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

// int N = 2018;
// int A = 218;
int N, A;
int main() {
    cin >> N >> A;
    int mod = N % 500;
    if (mod <= A) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long n = 0;
  long k = 0;
  long hoge = 0;
  int i = 0;
  scanf("%lu %lu",&n,&k);
  hoge = k;
  for(i=0;i<n-1;i++){
    hoge *= k-1;
  }
  printf("%lu",hoge);
  return 0;
}
         
    

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

void PrimeFact(ll n,map<ll,ll>& mp){
    while(n!=1){
        if(n == 2 || n == 3){
            mp[n]++; n/=n;
            continue;
        }
        bool prime_flag = false;
        for(ll i = 2;i*i <= n;i++){
            if(n%i==0){
                mp[i]++; n/=i;
                prime_flag = true;
                break;
            }
        }
        if(!prime_flag){mp[n]++; n/= n;}
    }
}

const ll MOD = 1e9+7;
template<class Type>
Type solve(Type res = Type()){
    map<ll,ll> mp;
    ll N; cin >> N;
    for(int i = 1; i <= N;i++){
        PrimeFact(i,mp);
    }
    res = 1;
    for(auto p:mp){
        res = res * (p.second+1) % MOD;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<ll>() << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    int n, k, q ;
    string ans[] = {"Yes", "No"};
    int flag = 0;
    cin>>n>>k>>q;
    int a[q];
    int sa[n];
    int tnp;
        
    for (int i = 0; i < n; i++){
        sa[i] = k - q;
    }
    for (int i = 0; i < q; i++){
        cin>>tnp;
        sa[tnp-1]++; 
    }
    for (int i = 0; i < n; i++){
        if (sa[i] <= 0){
            cout<<ans[1]<<endl;
        }else{
            cout<<ans[0]<<endl;
        }
    }
}

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

#define OK 0
#define INIT 0

void compared(int*, int*);

int main(void) {

    int a   =INIT;
    int b   =INIT;
    int c   =INIT;

    //data input
    cin >> a;
    cin >> b;
    cin >> c;
    
    if (a > b) {
        compared(&a,&b);
    }

    if (a > c) {
        compared(&a,&c);
    }

    if (b > c) {
        compared(&b,&c);
    }
    
    cout << a << " " << b << " " << c << endl;

    return OK;
}

void compared(int* data1, int* data2)
{
    int tmp = INIT;

    tmp     = *data1;
    *data1  = *data2;
    *data2  = tmp;
}

Measured memory_bytes: 1168
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  string n;
  cin >> n;
  if(n.length() == 2) cout << n << endl;
  else {
    cout << n[2] << n[1] << n[0] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys, re

N = input()
S = input()
# pattern = re.compile(r'\)\(')
sentence = ''
left, right = 0, 0
# lit = []
for s in S:
    sentence += s
    if s == '(':
        left += 1
    else:
        right += 1
    if left - right < 0:
        sentence = '(' + sentence
        left += 1
if left - right > 0:
    sentence = sentence + ')' * (left - right)
print(sentence)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

const long long INF = 1e18; 
const long long mod = 998244353;//200003;786433;1e9 + 7;
const double Pi = acos(-1);
  
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int k;
int dp[100005];

signed main()
{
	cin >> k;
	for(int i = 0; i < k; i++)
	{
		dp[i] = 1e9;
	}
	dp[1] = 1;
	queue <int> BFS;
	BFS.push(1);
	while(BFS.empty() == false)
	{
		int node = BFS.front();
		BFS.pop();
		if(dp[node * 10 % k] > dp[node])
		{
			dp[node * 10 % k] = dp[node];
			BFS.push(node * 10 % k);
		}
		if(dp[(node * 10 + 1) % k] > dp[node] + 1)
		{
			dp[(node * 10 + 1) % k] = dp[node] + 1;
			BFS.push((node * 10 + 1) % k);
		}
	}
	cout << dp[0];
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

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

	ll N, K;
	string S;

	cin >> N >> K >> S;

	vector<P> v;
	vector<ll> ss;
	ll cnt = 0;
	ll sum = 0;
	char color;

	color = S[0];
	// base
	ss.push_back(0);
	if (S[0] == '0') {
		// start from '1' by insterting size 0 of 1
		ss.push_back(0);
	}
	rep(i, N) {
		if (S[i] == color) {
			cnt++;
		}
		else {
			sum += cnt;
			cnt = 0;
			ss.push_back(sum);
			color = S[i];
			cnt++;
		}
	}
	if (cnt > 0) {
		sum += cnt;
		ss.push_back(sum);
	}
	
	ll ans = -1;
	ll len = -1;
	for (int i = 0; i < ss.size(); i += 2) {
		len = min(i + 2 * K+1, (ll)ss.size() - 1);
		ans = max(ans, ss[len] - ss[i]);
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1528
import numpy as np

N = int(input())

MAP = np.zeros((9,9))
for i in range(1,N+1):
    a = i%10
    b = int(str(i)[0])
    if a != 0 and b != 0:
        MAP[a-1,b-1] += 1

cnt = 0
for i in range(9):
    for j in range(9):
        cnt += MAP[i,j] * MAP[j,i]

print(int(cnt))

Measured memory_bytes: 14408
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        aaa: [usize; n - 1],
    }
    let mut ans = vec![0usize; n];

    for a in aaa {
        ans[a - 1] += 1;
    }

    for a in ans {
        println!("{}", a);
    }
}


Measured memory_bytes: 6360
# 幅優先探索 Breadth first search: BFS

n = int(input())
A = [[0 for i in range(n)] for i in range(n)]
for i in range(n):
    dat = [int(i) for i in input().split()]
    for v in dat[2:]:
        A[dat[0]-1][v-1] = 1

for i in range(n):
    for j in range(n-1):
        print(A[i][j], end=" ")
    print(A[i][n-1])



Measured memory_bytes: 6384
class Factorial():
    def __init__(self, mod=10**9 + 7):
        self.mod = mod
        self._factorial = [1]
        self._size = 1
        self._factorial_inv = [1]
        self._size_inv = 1

    def __call__(self, n):
        return self.fact(n)

    def fact(self, n):
        ''' n! % mod '''
        if n >= self.mod:
            return 0
        self._make(n)
        return self._factorial[n]
    
    def _make(self, n):
        if n >= self.mod:
            n = self.mod
        if self._size < n+1:
            for i in range(self._size, n+1):
                self._factorial.append(self._factorial[i-1]*i % self.mod)
            self._size = n+1

    def fact_inv(self, n):
        ''' n!^-1 % mod '''
        if n >= self.mod:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        self._make(n)
        if self._size_inv < n+1:
            self._factorial_inv += [-1] * (n+1-self._size_inv)
            self._size_inv = n+1
        if self._factorial_inv[n] == -1:
            self._factorial_inv[n] = self.modinv(self._factorial[n])
        return self._factorial_inv[n]
    
    @staticmethod
    def xgcd(a, b):
        '''
        Return (gcd(a, b), x, y) such that a*x + b*y = gcd(a, b)
        '''
        x0, x1, y0, y1 = 0, 1, 1, 0
        while a != 0:
            (q, a), b = divmod(b, a), a
            y0, y1 = y1, y0 - q * y1
            x0, x1 = x1, x0 - q * x1
        return b, x0, y0

    def modinv(self, n):
        g, x, _ = self.xgcd(n, self.mod)
        if g != 1:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        return x % self.mod

    def comb(self, n, r):
        ''' nCr % mod '''
        if r > n:
            return 0
        t = self(n)*self.fact_inv(n-r) % self.mod
        return t*self.fact_inv(r) % self.mod

    def comb_with_repetition(self, n, r):
        ''' nHr % mod '''
        t = self(n+r-1)*self.fact_inv(n-1) % self.mod
        return t*self.fact_inv(r) % self.mod

    def perm(self, n, r):
        ''' nPr % mod '''
        if r > n:
            return 0
        return self(n)*self.fact_inv(n-r) % self.mod

x, y = sorted(map(int, input().split()))
q, r = divmod(x+y, 3)
if r != 0:
    print(0)
else:
    comb = Factorial().comb
    print(comb(q, y-q))


Measured memory_bytes: 40684
#include <bits/stdc++.h> 
using namespace std;
#define INF INT_MAX
#define N 100005
#define K 3
int n, k;
int arr[N][K];
int dp[N][K];
int solve(int idx, int last_k){
    int res;
    if(idx == n)
        return 0;
    if(~last_k && ~dp[idx][last_k])
        return dp[idx][last_k];
    for(int i=0; i<K; ++i){
        if(last_k != i){
            dp[idx][last_k] = max(dp[idx][last_k], arr[idx][i]+solve(idx+1, i));
        }
    }
    return dp[idx][last_k];
}
int main()
{
    cin >> n;
    memset(dp, -1, sizeof(dp[0][0]) * N * K);
    for(int i=0; i<n; ++i)
        for(int j=0; j<3; ++j)
            cin >> arr[i][j];
    cout << solve(0, -1);
    return 0;
}



Measured memory_bytes: 10368
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846
#define FF first
#define SS second

int main(){
	FASTIO;
	ll h, w, n; cin >> h >> w >> n;
	ll x[333333], y[333333]; memset(x, 0, sizeof x); memset(y, 0, sizeof y);
	vector<ll> M[333333];
	set<pair<ll, ll>> sorted;
	for ( int k = 0; k < n; k++ ){ 
		ll a, b; cin >> a >> b;
		x[a]++, y[b]++;
		M[a].pb(b);
	}
	for ( int k = 0; k < 333333; k++ ){
		if (y[k])
			sorted.insert(mp(y[k], k));
	}
	ll ans = 0;
	ll cur = 3333333;
	for ( int k = 0; k < 333333; k++ ){
		if (M[k].empty()) {
			ans = max(ans, x[k]);
			continue;
		}
		map<ll, ll> cnt;
		for (ll e: M[k]) {
			cnt[e]++;
		}
		for (const auto &it: cnt) {
			sorted.erase(sorted.lower_bound(mp(y[it.first], 0)));
			sorted.insert(mp(y[it.first] - it.second, cur++));
		}
		ans = max(ans, x[k] + sorted.rbegin()->first);
		for (const auto &it: cnt) {
			sorted.erase(sorted.lower_bound(mp(y[it.first] - it.second, 0)));
			sorted.insert(mp(y[it.first], cur++));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 56044
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}


signed main(){
  int n,A,B;
  cin>>n>>A>>B;
  
  int a = (n-1) * A + B;
  int b = (n-1) * B + A;
  cout<<max(b-a+1,0LL)<<endl;

  return 0;
}


Measured memory_bytes: 256
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion

signed main() {
    int n;cin >> n;
    string S;cin >> S;
    string s = S.substr(0,n),t = S.substr(n);
    map<pair<string,string>,int> mp;
    // cout << s << ' ' << t << endl;//確認済
    rep(bit,(1<<n)) {
        string k = "";
        string l = "";
        rep(i, n) {
            if(1&(bit>>i)) k+=s[i];
            else l+=s[i];
        }
        mp[{k,l}]++;
    }
    int count = 0;
    rep(bit,(1<<n)) {
        string k = "";
        string l = "";
        rev(i, n) {
            if(1&(bit>>i)) k+=t[i];
            else l+=t[i];
        }
        count+=mp[{l,k}];
        // cout << l << ' ' << k << ' ' << mp[{l,k}] << endl;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 60836
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 200000, MD = 1000000007;

int ff[N + 1], gg[N + 1];

int power(long long a, int k) {
	long long p = 1;
	while (k) {
		if (k & 1)
			p = p * a % MD;
		a = a * a % MD;
		k >>= 1;
	}
	return p;
}

void init(int n) {
	for (int f = 1, i = 0; i <= n; i++) {
		gg[i] = power(ff[i] = f, MD - 2);
		f = (long long) f * (i + 1) % MD;
	}
}

long long ch(int n, int k) {
	return (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

int main() {
	int n, k; cin >> n >> k;
	init(n);
	k = min(k, n - 1);
	long long ans = 0;
	for (int i = 0; i <= k; i++)
		ans = (ans + ch(n, i) * ch(n - 1, i)) % MD;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 5140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int K = (N + 1) / 2;
	int A[200000];
	rep(i, N) A[i] = getint() - i - 1;
	int L = -200000;
	int R = 1000000000;
	while (L + 1 < R) {
		int H = (L + R) / 2;
		int k = 0;
		rep(i, N) if (A[i] <= H) k++;
		if (k < K) L = H;
		else R = H;
	}
	ll kotae = 0;
	rep(i, N) kotae += abs(A[i] - R);
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

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

  ll n, a, b, c, d, e; cin >> n >> a >> b >> c >> d >> e;
  // ボトルネック
  ll minCost = min({a, b, c, d, e});
  ll costA = (n+minCost-1)/minCost;
  cout << costA + 4 << '\n';
  return 0;
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, K; cin >> N >> K;
  VI cnt(26);
  REP(i,N){
	string s; cin >> s;
	cnt[s[0]-'A']++;
  }

  priority_queue<int> pq;
  REP(i,26) pq.push(cnt[i]);
  int ans = 0;
  while(true){
	bool ok = true;
	VI mem;
	REP(_,K){
	  if(pq.top() == 0){
		ok = false;
		break;
	  }
	  mem.PB(pq.top()-1);
	  pq.pop();
	}
	if(!ok) break;
	++ans;
	for(auto&& x: mem)
	  pq.push(x);
  }
  cout<< ans << endl;

  return 0;
}


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

int main() {
    string s; cin >> s;
    if (s.length() < 26) {
        char c = 'a';
        while (s.find(c) != string::npos) c++;
        return !(cout << s + c << endl);
    }
    string t(s);
    if (next_permutation(begin(s), end(s))) {
        int pref = 0;
        while (s[pref] == t[pref]) pref++;
        cout << s.substr(0, pref + 1) << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


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

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	
	vector<ll> p(a), q(b), r(c);
	for(int i = 0; i < a; ++i) {
		cin >> p[i];
	}
	
	for(int i = 0; i < b; ++i) {
		cin >> q[i];
	}
	
	for(int i = 0; i < c; ++i) {
		cin >> r[i];
	}
	
	sort(p.begin(), p.end());
	sort(q.begin(), q.end());
	sort(r.begin(), r.end());
	
	priority_queue<ll, vector<ll>, greater<ll>> pq;
	
	for(int i = a - 1; i > a - x - 1; i--) {
		pq.push(p[i]);
	}
	
	for(int i = b - 1; i > b - y - 1; i--) {
		pq.push(q[i]);
	}
	
	while( r.size() && r.back() > pq.top() ) {
		pq.pop();
		pq.push(r.back());
		r.pop_back();
	}
	
	
	ll ans = 0LL;
	while( !pq.empty() ) {
		ans += pq.top();
		pq.pop();
	}

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


Measured memory_bytes: 4724
#include<stdio.h>
int main(void){
  	int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a == b && a != c){
    printf("Yes");
  }else if(a == c && a != b){
    printf("Yes");
  }else if(b == c && b != a){
    printf("Yes");
  }else{
	printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
int main() {
	ll x,k,d;cin>>x>>k>>d;
	if(x<0) x=-x;
	if(x/d>=k) return cout<<x-k*d<<endl,0;
	if((k-x/d)%2==0) cout<<x%d<<endl;
	else cout<<abs(x%d-d)<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    ll ans = 0;
    if (n == m) {
        ans = 2;
        for (int i = 2; i <= n; ++i) {
            ans = ans * i % M;
        }
        for (int i = 2; i <= m; ++i) {
            ans = ans * i % M;
        }
    }
    if (abs(n - m) == 1) {
        ans = 1;
        for (int i = 2; i <= n; ++i) {
            ans = ans * i % M;
        }
        for (int i = 2; i <= m; ++i) {
            ans = ans * i % M;
        }
    }
    cout << ans;
    return 0;
}

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

using namespace std;

int main () {

	int K;
	cin >> K;

	set<pair<int, int> > vp;

	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			if (((i % 2 == 0 and j % 2 == 1) or (i % 2 == 1 and j % 2 == 0)) and i != j)
				vp.insert({i, j});
		}
	}

	cout << vp.size() / 2 << '\n';	
	return 0;
}


Measured memory_bytes: 512
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    char ac, bc, cc, dc;
    cin >> ac >> bc >> cc >> dc;
    int a = ac - 48; int b = bc - 48; int c = cc - 48; int d = dc - 48;
    vector<char> ops = {'+', '-'};
    for (char op1: ops) {
        for (char op2: ops) {
            for (char op3: ops) {
                int res = a;
                res += (op1 == '+') ? b : -b;
                res += (op2 == '+') ? c : -c;
                res += (op3 == '+') ? d : -d;
                if (res == 7) {
                    cout << a << op1 << b << op2 << c << op3 << d << "=7" << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

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

int main(int argc,char** argv){
  	int a,b,c,k;
  	cin>>a>>b>>c>>k;
  	int sum=0;
    if(k<=a){
         cout<<k<<endl;
         return 0;
    }
    sum+=a;
    k-=a;
    k-=b;
    sum-=k;
	cout<<sum<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
bool chmin(ll&a,ll b){if(a>b){a=b;return true;}return false;}
bool chmax(ll&a,ll b){if(a<b){a=b;return true;}return false;}
#define debg cout<<"debg"<<endl
#define out(a) cout<<(a)<<endl
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
signed main(){
  
  ll d,g;
  cin>>d>>g;
  vector<ll> p(d),c(d);
  rep(i,d)cin>>p[i]>>c[i];

  const ll INF=(1LL<<62);
  ll ans=INF;
  for(int bit=0;bit<(1<<d);++bit){
    ll solve=0,point=0,mx=0;
    for(int i=0;i<d;++i){
      if(bit&(1<<i)){
        solve+=p[i];
        point+=c[i]+p[i]*100*(i+1);
      }
      else mx=i;
    }
    if(point<g){
      ll dif=g-point,tmp;
      tmp=dif/((mx+1)*100);
      if(dif%((mx+1)*100)!=0)tmp++;
      if(tmp>p[mx])continue;
      solve+=tmp;
      point+=p[mx]*tmp;
    }
    chmin(ans,solve);
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
import sys
 
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
 
 
H=int(input())

cnt=0
p=0

while H>0:
	H=H//2
	cnt+=1
	

for i in range(cnt):
	p=1+p*2
	
print(p)
	

Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

typedef long double ld;

const int mod = 998244353;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}

int mul(int a, int b) {
  return (a * (ll) b) % mod;
}

const int N = 3007;

int a[N];
int p[N][N];
int cnt[N][N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, s;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cnt[0][0] = 1;
  cnt[0][a[0]] = 1;
  p[0][a[0]] = 1;
  ll ans = p[0][s];
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= s; j++) {
      p[i][j] = p[i - 1][j];
      cnt[i][j] = cnt[i - 1][j];
    }
    for (int j = s; j >= a[i] + 1; j--) {
      add(p[i][j], p[i][j - a[i]]);
      add(cnt[i][j], cnt[i][j - a[i]]);
    }
    add(p[i][a[i]], i + 1);
    ans += p[i][s];
    ans %= mod;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 70784
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int h,n;

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
using namespace std;
ll expo(ll b,ll e,ll mod)
{
  if(e==0ll)
    return 1;
  if(e%2==0)
    return expo((b*b)%mod,e/2,mod);
  else
    return (b*expo((b*b)%mod,e/2,mod))%mod;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;

   // cin>>t;
    while(t--)
    {
       ll n,i,j,c,x;
       cin>>n;
       ll arr[n+1];
       for(i=0;i<n;i++)
        cin>>arr[i];
       sort(arr,arr+n);
       x=1;
       c=1;
       ll ans=0;
       for(i=1;i<n;i++)
       {
           x=(x*2)%hell+c%hell;
           c*=2;
           c%=hell;
           x%=hell;
       }
       //cout<<x<<" "<<c<<"\n";
       ll inv=expo(2,hell-2,hell);
      c=(c*inv)%hell;
       for(i=0;i<n;i++)
       {
           ans=(ans+x*arr[i])%hell;
           x=(x-c+hell)%hell;
       }
       for(i=0;i<n;i++)
        ans=(ans*2)%hell;
       cout<<ans;
    }
}


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

int main() {
	string Sa, Sb, Sc;
	cin >> Sa >> Sb >> Sc;
	int a = 0, b = 0, c = 0;
	int flaga = true, flagb = false, flagc = false;
	int x;
	while (1) {
		if (flaga) {
			x = Sa[a];
			a++;
			flaga = false;
		}
		if (flagb) {
			x = Sb[b];
			b++;
			flagb = false;
		}
		if (flagc) {
			x = Sc[c];
			c++;
			flagc = false;
		}
		if (x == 'a') {
			flaga = true;
			if (a == Sa.size()) {
				cout << "A" << endl;
				break;
			}
		}
		else if (x == 'b') {
			flagb = true;
			if (b == Sb.size()) {
				cout << "B" << endl;
				break;
			}
		}
		else if (x == 'c') {
			flagc = true;
			if (c == Sc.size()) {
				cout << "C" << endl;
				break;
			}
		}
	}
		return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

typedef struct{
  double x,y;
}POINT;

void koch(int,POINT,POINT);

int main(){
  int n;
  POINT p1,p2;

  scanf("%d",&n);

  p1.y=p1.x=0;
  p2.x=100;
  p2.y=0;
  
  printf("%.8f %.8f\n",p1.x,p1.y);
  koch(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);

  return 0;
}


void koch(int n, POINT p1,POINT p2){
  if(n==0)return;  
  POINT s,t,u;
  double theta;

  theta=M_PI*60.0/180.0;
 
  s.x=(2*p1.x+1*p2.x)/3.0;
  s.y=(2*p1.y+1*p2.y)/3.0;

  t.x=(1*p1.x+2*p2.x)/3.0;
  t.y=(1*p1.y+2*p2.y)/3.0;

  u.x=(t.x-s.x)*cos(theta)-(t.y-s.y)*sin(theta)+s.x;
  u.y=(t.x-s.x)*sin(theta)+(t.y-s.y)*cos(theta)+s.y;

  koch(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);

  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);

  koch(n-1,t,p2);
}



Measured memory_bytes: 2104
#include <iostream>

using namespace std;

typedef long long int ll;
#define REP(i, I, N) for (int i = I; i < N; ++i)
#define rep(i, N) REP(i, 0, N)

int main() {
    int r, D, x;
    cin >> r >> D >> x;
    for (int i = 1; i < 11; i++) {
        x = x * r - D;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	string s;
	cin >> s;

	int f=0;
	if(s=="KIHBR")f=1;
	if(s=="AKIHBR")f=1;
	if(s=="AKIHABR")f=1;
	if(s=="AKIHBAR")f=1;
	if(s=="AKIHBRA")f=1;
	if(s=="KIHABR")f=1;
	if(s=="KIHABAR")f=1;
	if(s=="KIHABARA")f=1;
	if(s=="KIHBAR")f=1;
	if(s=="KIHBARA")f=1;
	if(s=="KIHBRA")f=1;
	if(s=="AKIHABAR")f=1;
	if(s=="AKIHABRA")f=1;
	if(s=="KIHABARA")f=1;
	if(s=="AKIHABARA")f=1;
	if(f)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include<string.h>
#include <math.h>
#include <stack>
#define ll long long
using namespace std;
int a[100010];
int b[100010];
int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++)
		scanf("%d %d", a + i, b + i);
	int start = a[0];
	int end = b[0];
	for (int i = 1; i < m; i++) {
		if (a[i] > start)
			start = a[i];
		if (b[i] < end)
			end = b[i];
	}
	if (end < start)
		printf("0\n");
	else
		printf("%d\n", end - start + 1);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int number(char s) {
  if(s == 'A')
    return 10;
  if(s == 'B')
    return 11;
  if(s == 'C')
    return 12;
  if(s == 'D')
    return 13;
  if(s == 'E')
    return 14;
  if(s == 'F')
    return 15;
}

int main() {
  char X, Y;
  cin >> X >> Y;

  if(number(X) < number(Y))
    cout << '<' << endl;
  else if(number(X) > number(Y))
    cout << '>' << endl;
  else
    cout << '=' << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		String[] flCd = new String[]{
			"S 1", "S 2", "S 3", "S 4", "S 5", "S 6", "S 7", "S 8",  "S 9", "S 10", "S 11", "S 12", "S 13",
			"H 1", "H 2", "H 3", "H 4", "H 5", "H 6", "H 7", "H 8",  "H 9", "H 10", "H 11", "H 12", "H 13",
			"C 1", "C 2", "C 3", "C 4", "C 5", "C 6", "C 7", "C 8",  "C 9", "C 10", "C 11", "C 12", "C 13",
			"D 1", "D 2", "D 3", "D 4", "D 5", "D 6", "D 7", "D 8",  "D 9", "D 10", "D 11", "D 12", "D 13"
		};
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		String[] hvCd = new String[n];
		//sc.useDelimiter("\\r\\n");
		for (int i=0; i < n; i++) {
			hvCd[i] = sc.nextLine();
		}
		for (int i = 0; i < 52; i++) {
			if (!Arrays.asList(hvCd).contains(flCd[i])) {
				System.out.println(flCd[i]);
			}
		}
	}
}

Measured memory_bytes: 26316
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
int a,b,c,A,B,C,ans;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	if(a==b&&b==c)
	{
		if(a&1)
			printf("0");
		else
			printf("-1");
		return 0;
	}
	while(a%2==0&&b%2==0&&c%2==0)
	{
		A=(b+c)/2,B=(a+c)/2,C=(a+b)/2;
		a=A,b=B,c=C;
		++ans;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
int a[300010],num2[300010],num[300010],sum_num[300010],sum_tot[300010];

int check(int m,int n)
{
    int p=0;
    p+= sum_num[n]-sum_num[m-1];
    p+= sum_tot[m-1]/m;
    return p;
}


int main()
{
    int n;scanf("%d",&n);
    for(int i=0;i<n;++i) scanf("%d",&a[i]);
    for(int i=0;i<n;++i) ++num2[a[i]];
    for (int i=0;i<=n;++i) num[ num2[i] ]++;
    sum_num[0]=sum_tot[0]=0;
    for (int i=1;i<=n;++i)
    {
        sum_tot[i]=sum_tot[i-1]+num[i]*i;
        sum_num[i]=sum_num[i-1]+num[i];
    }
    int ll=1;int rr=n;int ans=n;
    for (int k=1;k<=n;++k)
    {
        ll=1;rr=ans;ans=0;
        while (ll<=rr)
        {
            int mid=(ll+rr)/2;
            if ( check(mid,n)>=k ){
                ans=mid;ll=mid+1;
            }
            else rr=mid-1;
        }
        printf("%d\n",ans);
    }

}







Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }

    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
    
    
  int main(){

    string s;
    cin>>s;
    sort(all(s));
    if(s=="abc")cout<<"Yes";
    else cout<<"No";
  }
     
  


Measured memory_bytes: 256
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
from fractions import Fraction
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9+7

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

B.reverse()

for i in range(N):
    if A[i] == B[i]:
        k = A[i]
        break
else:
    print("Yes")
    print(*B)
    exit()

possible = []
impossible = []
for i in range(N):
    if A[i] != k and B[i] != k:
        possible.append(i)
    elif A[i] == k and B[i] == k:
        impossible.append(i)

for i in impossible:
    if not possible:
        print("No")
        exit()
    j = possible.pop()
    B[i],B[j] = B[j],B[i]

print("Yes")
print(*B)

Measured memory_bytes: 129580
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	string s;
	cin >> s;
	string ans = "ABC" + s;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] A = new int[210];
		int N = Integer.parseInt(sc.next());
		for (int i = 0; i < N; i++) {
			A[i] = Integer.parseInt(sc.next());
		}
		int result = 0;
		boolean flg = false;
		while (true) {
			for (int i = 0; i < A.length; i++) {
				if (A[i] % 2 != 0) {
					flg = true;
					break;
				}
			}

			if (flg) {
				break;
			}

			for (int i = 0; i < A.length; i++) {
				A[i] /= 2;
			}

			result++;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 35672