akhauriyash/Code-Regression huggingface dataset:
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod


x, y = map(int, input().split())
mod = 10 ** 9 + 7
ans_comb = []
for i in range(x // 2 + 1):
    j = x - 2 * i
    if 2 * i + j == x and 2 * j + i == y:
        ans_comb = [i, j]
if len(ans_comb) == 0:
    print(0)
else:
    print(comb(ans_comb[0] + ans_comb[1], ans_comb[1], 10 ** 9 + 7))


Measured memory_bytes: 40044
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <iomanip>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
set <int> vec;


int main()
{
	ios::sync_with_stdio(false);

#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;

	for (int i = 0; i < n; ++i) {
		int temp;
		cin >> temp;
		vec.insert(temp);
	}

	cout << vec.size();

	return 0;
}

Measured memory_bytes: 256
use std::vec::Vec;
use std::cmp::*;
use std::collections::HashSet;
use std::cmp::Ordering;

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

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

fn main() {
    let s: String = read();
    let k: usize = read();
    let n: usize = s.len();
    let slice: &str = &s;
    let mut hs = HashSet::new();
    for i in 1..min(k+1, 6) {
      for j in 0..n+1-i {
        hs.insert(&slice[j..j+i]);
      }
    }

    let mut v: Vec<&str> = hs.into_iter().collect();
    // let compare = |a: &&str, b: &&str| -> Ordering {
    //   if a.len() > b.len() {
    //     Ordering::Greater
    //   } else if a.len() < b.len() {
    //     Ordering::Less
    //   } else {
    //     a.cmp(&b)
    //   }
    // };
    // v.sort_by(compare);
    v.sort();
    println!("{}", v[k - 1]);
}


Measured memory_bytes: 6396
//Name-Deepesh Bhatt
//Institute-IIT Dhanbad

#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a ,ll b)
{
    return a/gcd(a,b)*b;
}
ll power(ll a, ll n)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2);
    p = (p * p);
    if (n % 2)
        return (p * a);
    else
        return p;
}

int main()
{
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(NULL);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    map<char,vector<ll>>m;
    for(ll i=0;i<n;i++){
        m[s[i]].push_back(i+1);
    }
    ll r=m['R'].size();
    ll g=m['G'].size();
    ll b=m['B'].size();
    ll ans=r*g*b;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            ll k=j+(j-i);
            if(k<n){
                if(s[i]!=s[j]&&s[j]!=s[k]&&s[i]!=s[k])
                    ans--;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> P;
#define mk make_pair
int main(){
    int h,w;
    while(cin>>h>>w,h||w){
        P in=mk(w*w+h*h,pii(h,w));
        P ans=mk(1e9,pii(1e9,1e9));
        for(int i=1;i<1000;++i){
            for(int j=i+1;j<1000;++j){
                P tmp=mk(i*i+j*j,pii(i,j));
                if(tmp>in){
                    ans=min(ans,tmp);
                }
            }
        }
        cout<<ans.second.first<<" "<<ans.second.second<<endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, l, r, total = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    total += r - l + 1;
  }

  cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  priority_queue<ll, vector<ll>, greater<ll>> front, back;
  vector<ll> lsum(n + 1), rsum(n + 1), m(n);
  REP(i, n) {
    ll po;
    cin >> po;
    lsum[0] += po;
    front.push(po);
  }

  REP(i, n) { cin >> m[i]; }

  REP(i, n) {
    ll po;
    cin >> po;
    rsum[0] -= po;
    back.push(-po);
  }

  REP(i, n) {
    auto top = front.top();
    if (top < m[i]) {
      lsum[i + 1] = lsum[i] - top + m[i];
      front.pop();
      front.push(m[i]);
    } else {
      lsum[i + 1] = lsum[i];
    }
  }

  REP(i, n) {
    auto top = back.top();
    if (top < -m[n - 1 - i]) {
      rsum[i + 1] = rsum[i] - top - m[n - 1 - i];
      back.pop();
      back.push(-m[n - 1 - i]);
    } else {
      rsum[i + 1] = rsum[i];
    }
  }

  ll ans = lsum[0] + rsum[n];
  REP(i, n + 1) { ans = max(ans, lsum[i] + rsum[n - i]); }
  cout << ans << endl;
}


Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

int n;

bool b[15];
void t(int x){
    int tmp = x;
    int count=0;
    while(count<=n){
        
        if(x%2==1) {
            b[count] = true;
        }
        else{
            b[count] = false;
        }
        x /= 2;
        count++;
    }
    
}


void solve(){

    rep(i,15){
        b[i]=true;
    }

    cin >> n;
    vector<vector<pair<int,int>>> v;
    rep(i,n){
        vector<pair<int,int>> vp;
        int a;
        cin >> a;
        rep(j,a){
            int x,y;
            cin >> x >> y;
            x--;
            vp.emplace_back(make_pair(x,y));
        }
        v.emplace_back(vp);
    }


    int ans = 0;
    for(int bit=0; bit<(1<<n); bit++){
        int tmpans = 0;
        t(bit);
        
        /*
        rep(i,n){
            if(b[i]) cout << 1;
            else cout << 0;
        }
        cout << endl;
        */
        
        //b[j]:j番目の人が正直か嘘つきか
        bool is = true;
        rep(j,n){
            if(b[j]==false) continue;
            auto vtmp = v[j];
            rep(k,vtmp.size()){
                int x,y;
                x = vtmp[k].first;
                y = vtmp[k].second;

                if(b[j]==false){
                    y = abs(y-1);
                }
                
                if(b[x]!=(y==1?true:false)){
                    //cout << bit << "の状態で" << j << "+1番目の人の証言、" << x << "+1番目の人は" << y << "であるというのが矛盾" << endl;
                    is = false;
                    break;
                }
            }
            if(!is){
                break;
            }
        }
        if(!is){
            //cout << "NO" << endl;
            continue;
        }
        rep(i,n){
            if(b[i]) tmpans++;
        }
        ans = max(ans, tmpans);
    }


    cout << ans << endl;

}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;



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

  ll n;
  cin >> n;

  ll a[n];
  ll rec = 0;
  REP(i, n){
    cin >> a[i];
    if(a[i] % 2) rec++;
  }

  if(rec) cout << "first" << endl;
  else cout << "second" << endl;

  return 0;
}


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

class MainClass
{
    static void Main()
    {
        string N = Console.ReadLine();
        if (N[0] == N[1] && N[1] == N[2])
        {
            Console.WriteLine("Yes");
        }
        else if (N[1] == N[2] && N[2] == N[3])
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 25616
import std.stdio,
       std.range,
       std.string,
       std.conv,
       std.math,
       std.algorithm;

void main(){
  int base = 100000;
  real p = 1.05;
  int n = readln.chomp.to!int;

  n.iota.each!((e){
      base *= p;
      base += (base % 1000) ? 1000 - base % 1000 : 0;
    });

  writeln(base);
}

Measured memory_bytes: 2392
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        // int T;
        // T=in.nextInt();
        // while((T--)>0)
        // {
        //     //code comes here

        // }   
        int N;
        N=in.nextInt();
        in.nextLine();
        Set<String> set=new HashSet<>();
        for(int i=0;i<N;i++)
        {
            set.add(in.nextLine());
        }
        System.out.println(set.size());

    }

}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


int main() {
    string s; cin >> s;
    bool N = 0;
    bool W = 0;
    bool S = 0;
    bool E = 0;
    rep(i, s.size()) {
        if (s[i] == 'N') N = 1;
        else if (s[i] == 'W') W = 1;
        else if (s[i] == 'S') S = 1;
        else if (s[i] == 'E') E = 1;
    }
    if (!(N^S) && !(E^W)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


    


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#pragma warning(disable: 4996)
#define INF (1e9)
#define mod (ll(1e9)+7)

using namespace std;
typedef long long ll;
typedef long double ld;

struct dat { ll p, y, idx; } V[100005];
string Ans[100005];
ll n, m;

bool comp(dat a, dat b)
{
	if (a.p == b.p)
		return a.y < b.y;
	return a.p < b.p;
}

string solve(int x)
{
	string ans = "";
	int cx = x, len=0, ras=0;
	while (cx)
	{
		len++;
		ras = ras * 10 + cx % 10;
		cx /= 10;
	}
	for (int i = 1; i <= 6-len; i++)
		ans += '0';
	char add[10];
	sprintf(add, "%d", x);
	ans += add;
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		cin >> V[i].p >> V[i].y;
		V[i].idx = i;
	}
	sort(V + 1, V + m + 1, comp);
	int c = 1, pr = 0;
	for (int i = 1; i <= m; i++)
	{
		if (V[i].p != pr)
		{
			pr = V[i].p;
			c = 1;
		}
		else
		{
			c++;
		}
		Ans[V[i].idx] = solve(V[i].p) + solve(c);
	}
	for (int i = 1; i <= m; i++)
	{
		cout << Ans[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353 
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll cost[400][400];
ll a[400];
ll b[401];
ll solve(ll i,ll j){
    if(cost[i][j]!=-1)
        return cost[i][j];
    else{
        cost[i][j]=1e18;
        for(ll k=i;k<j;k++)
            cost[i][j]=min(solve(i,k)+solve(k+1,j)+b[j+1]-b[i],cost[i][j]);
        return cost[i][j];
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        b[0]=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            b[i+1]=a[i];
            b[i+1]+=b[i];
        }
        for(ll i=0;i<n;i++){
            cost[i][i]=0;
            for(ll j=i+1;j<n;j++)
                cost[i][j]=-1;
        }
        cout<<solve(0ll,n-1)<<"\n";
    }
    return 0;
}

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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N; cin >> N;
    vector<int> a(N);
    int Q; cin >> Q;
    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < N; ++i) cin >> a[i];
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21712
#include<iostream>
using namespace std;
int main() {
    int N,M;cin>>N>>M;
    int A[N],sum=0,cnt=0;
    for (int i=0; i<N; i++) {
        cin>>A[i];
        sum+=A[i];
    }
    double T = sum / 4.0 / M;
    for (int i=0; i<N; i++) {
        if (A[i]>=T) cnt++;
    }
    if (cnt>=M) cout<<"Yes"<<endl;
    else  cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long n = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int[,] countA = new int[s.Length, 2];
			int[,] countC = new int[s.Length, 2];
			int c1 = 0, c2 = 0;
			for (int i = 0; i < s.Length; i++) {
				if (s[i] == 'A') {
					c1++;
				}
				if (s[i] == '?') {
					c2++;
				}
				countA[i, 0] = c1;
				countA[i, 1] = c2;
			}
			c1 = 0;
			c2 = 0;
			for (int i = s.Length - 1; i >= 0; i--) {
				if (s[i] == 'C') {
					c1++;
				}
				if (s[i] == '?') {
					c2++;
				}
				countC[i, 0] = c1;
				countC[i, 1] = c2;
			}

			long ans = 0;
			for (int i = 1; i < s.Length - 1; i++) {
				if (s[i] == 'B' || s[i] == '?') {
					//  a*3^q + q*3^(q-1)
					long a = countA[i - 1, 0];
					long q = countA[i - 1, 1];
					a *= Power3((int)q);
					a %= mod;
					a += q * Power3((int)q - 1) % mod;

					long c = countC[i + 1, 0];
					q = countC[i + 1, 1];
					c *= Power3((int)q);
					c %= mod;
					c += q * Power3((int)q - 1) % mod;

					ans += a * c % mod;
					ans %= mod;
				}
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}

		static List<int> _Power3 = new List<int>();
		static int Power3(int x)
		{
			if (x < 0) {
				return 0;
			}
			if (x < _Power3.Count) {
				return _Power3[x];
			}
			if (_Power3.Count == 0) {
				_Power3.Add(1);
			}
			int i = _Power3.Count;
			long result = _Power3[i - 1];
			while (i <= x) {
				result *= 3;
				result %= mod;
				_Power3.Add((int)result);
				i++;
			}
			return (int)result;
		}

	}
}


Measured memory_bytes: 13848
input = gets.chomp
last = (input.rindex('/')||0)+1
height = 0
$heightArr = []
$areaArr = []
$same = -1
$down = 0
def whatArea
    area = 0
    for i in $down+1..$same do
        area += $heightArr[$down] - $heightArr[i]
    end
    $areaArr << area
end
input.each_char {|c|
    $heightArr << height
    if c == '\\'
        height -= 1
    elsif c == '/'
        height += 1
    end
}
$heightArr << height
loop{
    nextDown = input[$same+1..last].index('\\')
    if nextDown == nil
        break
    else
        $down = $same + nextDown + 1
    end
    nextSame = $heightArr[$down+1..last].index($heightArr[$down])
    if nextSame == nil
        $same = $same+1
    else
        $same = $down + nextSame
        whatArea
    end
}
puts $areaArr.inject(:+)||0
puts $areaArr.size.to_s+$areaArr.map{|e|' '+e.to_s}*''

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int N, K;
    cin >> N >> K;
    if (N % K == 0)
        cout << 0 << endl;
    else
        cout << 1 << endl;
    return 0;
}

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

evidences = [[] for _ in range(N)]
for i in range(N): # i:人の番号
    A = int(input())
    for _ in range(A): #  x:人の番号, y:正直者か見破る番号
        x, y = map(int, input().split())
        evidences[i].append((x - 1, y))
        
# 全通り試す(最大は2**15だから問題ない)
result = 0
for i in range(1, 2 ** N): # iのビットは正直者と不親切な人の割合
    consistent = True# 全通り試して矛盾がなければtrue
    for j in range(N):# ビット演算で一人ずつ見ていく
        if (i >> j) & 1 == 0: # 選んだ一人が不親切なら
            continue
        for x, y in evidences[j]: # x:人の番号, y:正直者か見破る番号
            if (i >> x) & 1 != y: # xで一人を選んで,yの証言と一致してなかったら矛盾
                consistent = False
    if consistent:
        result = max(result, bin(i).count('1'))
print(result)

Measured memory_bytes: 3064
n = int(input())
a = sorted(list(map(int, input().split())))
ans = 0
if n % 2 == 1:
    if a[0] == 0:
        for i in range(1, n, 2):
            if a[i] != a[i + 1]:
                break
        else:
            ans = 2 ** ((n - 1) // 2) % (10 ** 9 + 7)
else:
    for i in range(0, n, 2):
        if a[i] != a[i + 1]:
                break
    else:
        ans = 2 ** (n // 2) % (10 ** 9 + 7)
print(ans)


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

using ld = long double;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    ld mx = 0.0;
    int ans1, ans2;
    for (int a = 0; a <= F; a += 100 * A) {
        for (int b = 0; a + b <= F; b += 100 * B) {
            int dissolve = (a + b) / 100 * E;
            for (int c = 0; a + b + c <= F && c <= dissolve; c += C) {
                for (int d = 0; a + b + c + d <= F && c + d <= dissolve; d += D) {
                    ld pct = (ld) (c + d) / (ld) (a + b + c + d);
                    if (pct >= mx) {
                        ans1 = a + b + c + d;
                        ans2 = c + d;
                        mx = pct;
                    }
                }
            }
        }
    }
    cout << ans1 << " " << ans2 << '\n';
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0040
{
    class Program
    {
        static void Main(string[] args)
        {
            var St = Console.ReadLine();

            long N = long.Parse(St);

            var S = Console.ReadLine().ToArray<char>();

            if (S.Length == 1)
            {
                Console.WriteLine(1);
                return;
            }

            int va = 1;

            for (long i = 0; i < N - 1; i++)
            {
                if (S[i] == S[i + 1])
                {
                    continue;
                }
                va++;
            }

            Console.WriteLine(va);

        }
    }
}


Measured memory_bytes: 28596
import numpy as np


def solve():
    N, K, *A = map(int, open(0).read().split())
    A = np.array(A)
    
    X = 0
    for i in range(40, -1, -1):
        ones = np.sum((A >> i) & 1)
        zeros = N - ones
        if ones < zeros:
            if X + 2 ** i <= K:
                X += 2 ** i
        else:
            continue
    
    ans = np.sum(X ^ A)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 26508
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N;
    cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    int ans=INF;
    for(int i=-100;i<=100;i++){
        int sum=0;
        rep(j,N) sum+=pow(abs(A[j]-i),2);
        ans=min(ans,sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <queue>
#include <string>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include  <vector>
#define clr(a, b) memset(a, b, sizeof(a))
#define inf 0x3f3f3f3f

using namespace std;

typedef long long ll;
int a;
int main() {
    // freopen("test.in", "r", stdin);
    // freopen("test.out", "w", stdout);
    cin >> a;
    cout << a + a * a + a * a * a;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define ctoi(x) (x - '0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int n, ans;
vi v(200010);
unordered_map<int, int> M;

int main() {
	fastio;
	cin >> n;
	FOR(i, n) {
		cin >> v[i + 1];
		M[v[i + 1]]++;
	}
	for (int i = 1; i <= n; i++) {
		int flag = 1;
		for (ll j = 1; j * j <= v[i]; j++) {
			if (v[i] % j == 0) {
				//v[i]/j, j
				if (j == v[i] && M[j] >= 2 || j != v[i] && M[j] >= 1 || v[i]/j == v[i] && M[v[i]/j] >= 2 || v[i]/j != v[i] && M[v[i]/j] >= 1) {
					flag = 0;
					break;
				}
			}
		}
		if (flag) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 32488
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define SET(A,VAL) memset(A, VAL, sizeof(A))
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int MAX = 1e6+8;
const int sz = 1e5+5;
void f_io(){
    IOS;
    #ifndef ONLINE_JUDGE
    FRE
    #endif
}
int32_t main(){
    
    int t = 1;

    while(t--){
        int n; cin >> n;
        n = n % 10;
        set<int> s1 = {2, 4, 5, 7, 9};
        set<int> s2 = {0,1,6,8};
        set<int> s3 = {3};
        if(s1.count(n)) cout << "hon";
        else if(s2.count(n)) cout << "pon";
        else cout << "bon";
        cout << endl;

    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pown(ll fi,ll se){
  ll ans=1;
  rep(i,se){
    ans*=fi;
  }
  return ans;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
ll n,k;
cin>>n>>k;
vec(a,n);
a=getv<ll>(n);
ll now=0;
vec(b,41);
ll cmp=0b1;
for(int now=0;now<=40;now++){
  ll cnt=0;
  rep(i,n){
    if(a[i]&cmp){cnt++;}
  }
  if(cnt>(n/2))b[now]=0;
  else {b[now]=1;}
  cmp<<=1;

}
ll sum=0;
cout<<endl;
for (ll i = 40; i>=0; i--){
  
  if(b[i]==1){
    if((sum+pown(2,i))<=k){
      sum+=pown(2,i);
    }else{
      b[i]=0;
    }
  }
 
}
ll ans=0;
rep(i,41){
  rep(j,n){
    if((b[i]&(1))^((a[j]>>i)&1)){ans+=pown(2,i);/*cout<<i<<" "<<j<<endl;*/}
  }
  
}
op(ans);
return 0;
}

Measured memory_bytes: 2168
#include "bits/stdc++.h"
using namespace std;

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

struct segtree{
	int size;
	vector<ll> mx;

	void init(int n){
		size=1;
		while(size<n) size*=2;
		mx.assign(2*size, 0);
	}

	void set(int i, ll v, int x, int lx, int rx){
		if(rx-lx==1){
			mx[x]=v; 
			return;
		}
		int m=(lx+rx)/2;
		if(i<m) set(i, v, 2*x+1, lx, m);
		else set(i, v, 2*x+2, m, rx);
		mx[x]=max(mx[2*x+1], mx[2*x+2]);
	}

	void set(int i, ll val){
		set(i, val, 0, 0, size);
	}

	ll calc(int l, int r, int x, int lx, int rx){
		if(lx>=r || rx<=l) return 0;
		if(lx>=l && rx<=r) return mx[x];
		int m=(lx+rx)/2;
		return max(calc(l, r, 2*x+1, lx, m), calc(l, r, 2*x+2, m, rx));
	}

	ll calc(int l, int r){
		return calc(l, r, 0, 0, size);
	}
};

ll n, x;
vector<ll> h, a;

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> n;
  rep(i, 1, n){
  	cin >> x; h.pb(x);
  }
  rep(i, 1, n){
  	cin >> x; a.pb(x);
  }

  segtree st;
  st.init(n+1);

  ll ans=0;
  rep(i, 0, n-1){
  	ll best=st.calc(1, h[i])+a[i];
  	ans=max(ans, best);
  	st.set(h[i], best);
  }
  cout << ans;
}

Measured memory_bytes: 10660
#include <iostream>
#include <string>

using namespace std;

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

  int min = 99999999;
  for(int i=1; i<n; i++){
    int a = i;
    int b = n - i;
    string aStr = to_string(a);
    string bStr = to_string(b);
    int aSum = 0;
    int bSum = 0;
    for(int j=0; j<aStr.size(); j++){
      char temp = aStr.at(j);
      aSum += atoi( &temp );
    }
    for(int k=0; k<bStr.size(); k++){
      char temp = bStr.at(k);
      bSum += atoi( &temp );
    }

    if(min > aSum + bSum){
      min = aSum + bSum;
    }
  }

  cout << min;

  return 0;
}


Measured memory_bytes: 256
S=str(input())
Q=int(input())
which=0
front=""
back=""
for i in range(Q):
    a=list(map(str,input().split()))
    if a==["1"]:
        which+=1
        which%=2
        continue
    else:
        if which==0:
            if a[1]=="1":
                front=a[2]+front
            if a[1]=="2":
                back+=a[2]
        if which==1:
            if a[1]=="1":
                back+=a[2]
            if a[1]=="2":
                front=a[2]+front

S=front+S+back
if which==1:
    print(S[::-1])
if which==0:
    print(S)


Measured memory_bytes: 4644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var firstLine = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = firstLine[0];
            var B = firstLine[1];
            if (Math.Abs(A - B) > 1)
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine("Yay!");
            }
        }
    }
}

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

typedef long long ll;
typedef pair<int,int> ii;

const int mx=1e5+777;
const int mod=1e9+7;

vector<ll> fact(mx);

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	fact[0]=1;
	for (int i=1; i<mx; i++)
		fact[i]=(fact[i-1]*i)%mod;
	int n,m; cin>>n>>m;
	if(n>m) swap(n,m);
	if(m>n+1) { cout<<0<<"\n"; return 0; }
	ll ret=(fact[n]*fact[m])%mod;
	if(n==m) ret=(ret*2)%mod;
	cout<<ret<<"\n";
	return 0;
}

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

int main(){
    vector<vector <char>> c(3,vector<char>(3));
    
    for(int i = 0;i < 3;i++)
        for(int j = 0;j < 3;j++){
            cin >> c.at(i).at(j);
        }

    cout << c.at(0).at(0) << c.at(1).at(1) << c.at(2).at(2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



ll N,A,B;

int main(){

	scanf("%lld %lld %lld",&N,&A,&B);

	ll pre,current;
	scanf("%lld",&pre);

	ll ans = 0;
	for(int i = 1; i < N; i++){
		scanf("%lld",&current);
		if(A*(current-pre) < B){

			ans += A*(current-pre);
		}else{

			ans += B;
		}
		pre = current;
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        String S = sc.next();	
	        if(S.equals("ABC")) {
	        	System.out.println("ARC");
	        } else {
	        	System.out.println("ABC");
	        }
	        
	        
	        long ans=0;
	        
	    }
	}

Measured memory_bytes: 35616
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	int n;
	cin >> n;
	if(n == 1){
		cout << "Hello World" << endl;
	}else{
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, k, mida, midb;
    cin >> a >> b >> k;
    if((a+b)%2==0) mida = min((a+b)/2, a+k-1);//aからk番目と中間どっちが小さいか
    else mida = min((a+b+1)/2, a+k-1);

    if((a+b)%2==0) midb = max((a+b)/2, b-k+1);//aからk番目と中間どっちが小さいか
    else midb = max((a+b+1)/2, b-k+1);

    if(mida == midb) midb ++;
    FOR(i, a, mida){
        cout << i <<"\n";
    }
    FOR(i, midb, b){
        cout << i <<"\n";
    }
    
}


Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const ll MOD = 1e9+7;
//}}}

int a[100];
int main(){
  int N;
  cin >> N;

  rep(i, N){
    cin >> a[i];
  }
  int ans = 0;
  rep(i, 1, N){
    if(a[i] == a[i - 1]){
      ans++;
      i++;
    }
  }
  cout << ans << endl;
  return 0;
} 


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,cnt=0;
  cin >> a >> b >> c;
  while(c!=0&&(a+b!=0)){
    c--;
    cnt++;
    if(b>=1){
      b--;
      cnt++;
    }else{
      a--;
    }
  }
  if(c>=1) cnt++;
  if(b>=0) cnt+=b;
  cout << cnt <<"\n";

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

bool can(const vector<int> &H, int i)
{
	for (int j = 0; j < i; ++j) {
		if (H[j] > H[i]) {
			return false;
		}
	}
	return true;
}

int main()
{
	int N;
	cin >> N;
	vector<int> H(N);
	for (auto &x : H) {
		cin >> x;
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (can(H, i)) {
			++ans;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import re
import itertools

N,Q = list(map(int, input().split()))
s = input()

pos = [m.end() for m in re.finditer(r'AC', s)]

dp = [0] * (N+1)
for p in pos:
    dp[p] = 1
dp = list(itertools.accumulate(dp))

ans=[]    
for _ in range(Q):
    l,r = list(map(int, input().split()))
    ans.append(dp[r]-dp[l])

print(*ans, sep='\n')

Measured memory_bytes: 21320
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	ll n; cin>>n;
	ll ans = n+1-2;
	reps(i,pow(n,0.5)){
		ll j = n/i;
		if(i*j==n){
			if(ans>i+j-2) ans = i+j-2;
		}
	}
	cout << ans << endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    std::vector<int> seq(N);
    for(int i=0; i < N; i++){
        cin >> seq.at(i);
    }
    std::vector<int> record;
    int rec = 0;
    for(int i=0; i < N-1; i++){
        if(seq.at(i)>=seq.at(i+1)){
            rec ++;
        }else{
            record.push_back(rec);
            rec = 0;
        }
    }
    record.push_back(rec);
    int max = *std::max_element(record.begin(), record.end());
    cout << max << endl;
}


Measured memory_bytes: 1276
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int N;
   cin >> N;
   int A[3];
   cin >> A[0] >> A[1] >> A[2];
   vector<pair<int,int>> qs;
   for(int i=0;i<N;i++){
      string s;
      cin >> s;
      if(s=="AB") qs.emplace_back(make_pair(0,1));
      if(s=="BC") qs.emplace_back(make_pair(1,2));
      if(s=="AC") qs.emplace_back(make_pair(0,2));
   }
   vector<int> ans; 
   for(int i=0;i<N;i++){
      int f=qs[i].first;
      int s=qs[i].second;
      if(A[f]==0&&A[s]==0){
         cout << "No" << endl;
         return 0;
      }
      else if(A[f]>1||A[s]>1){
         if(A[f]>A[s]) swap(f,s);
         ans.emplace_back(f);
         A[f]++;
         A[s]--;
      }
      else if(A[f]==0||A[s]==0){
         if(A[s]==0) swap(f,s);
         ans.emplace_back(f);
         A[f]++;
         A[s]--;
      }
      else{
         if(i+1<N&&qs[i+1].first!=f&&qs[i+1].second!=f){
            swap(f,s);
         }
         ans.emplace_back(f);
         A[f]++;
         A[s]--;
      }
   }
   string S="ABC";
   cout << "Yes" << endl;
   for(int i=0;i<N;i++){
      cout << S[ans[i]] << endl;
   }
   return 0;
}


Measured memory_bytes: 4840
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
      break
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(a//b)


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

static const int N = 100;

int main(){
  int n,p[N+1],m[N+1][N+1];
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> p[i-1] >> p[i];
  }

  // M[i][j] i=j ならばその掛け算の回数は0回
  for(int i=1;i<=n;i++) m[i][i] = 0;

  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j = i + l -1;
      m[i][j] = (1 << 21);
      for(int k=i;k<=j-1;k++){
        m[i][j] = min(m[i][j],m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }
  cout << m[1][n] << endl;
  return 0;
}


Measured memory_bytes: 3128
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int N, K;
	cin >> N >> K;
	vector<int> p( N );
	for( auto& v: p ) { cin >> v; }

	vector<double> x( N+1 );
	for( int i = 0; i < N; ++i ) {
		x[i+1] = (p[i] * (p[i]+1) / 2) / (double)p[i];
		x[i+1] += x[i];
	}

	double ans = 0;
	for( int i = K; i <= N; ++i ) {
		ans = max( ans, x[i] - x[i-K] );
	}

	cout << fixed << setprecision( 12 );
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define maxn 100005
using namespace std;
ll n;
ll a[maxn];
bool compare(ll x,ll y)
{
    return x>y;
}
int main()
{
    while(~scanf("%lld",&n))
    {
        ll i;
        for(i=0;i<n;i++)
            scanf("%lld",&a[i]);
        sort(a,a+n,compare);
        ll b[3];int step=0;
        b[0]=0;b[1]=0;b[2]=0;
        for(i=0;i<n-1;i++)
        {
            if(a[i]==a[i+1])
            {
                b[++step]=a[i];
                i++;
                if(step==2) break;
            }
        }
        printf("%lld\n",b[1]*b[2]);
    }
}


Measured memory_bytes: 1152
#include<stdio.h>

int main(){
  int A,B,C;
  scanf("%d%d%d",&A,&B,&C);

  int ans=0;
  for (int i = 1; i <= 100; i++)
  {
    if(A*i%B==C){
      ans=1;
      break;
    }
  }

  ans > 0?  puts("YES"):puts("NO"); 
  
  return 0;
}

Measured memory_bytes: 1660
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

vector<bool> sieve(ll n){
  vector<bool> is_prime(n+1);
  fill(is_prime.begin(),is_prime.end(),true);
  for(ll i = 0; i<=n; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for(ll i=2; i<=n; i++){
    if(is_prime[i]){
      for(ll j = 2*i; j<=n; j+=i){
        is_prime[j] = false;
      }
    }
  }
  return is_prime;
}

int main(){
  vector<bool> is_prime = sieve(100000);
  ll cnt[100001];
  cnt[0] = 0;
  for(ll i = 1; i <= 100000; i++){
    if(is_prime[i] == true&&is_prime[(i+1)/2]==true){
      cnt[i] = cnt[i-1]+1;
    }else{
      cnt[i] = cnt[i-1];
    }
  }
  ll q;
  cin >> q;
  REP(i,q){
    ll l,r;
    cin >> l >> r;
    cout << cnt[r]-cnt[l-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()


int main(){
  ll H,W,N;
  cin >> H >> W >> N;
  priority_queue<P> A;
  rep(i,N){
    ll a,b;
    cin >> a >> b;
    if(a-3>=0&&b-3>=0&&a<=H&&b<=W){
      A.push(P(a-3,b-3));
    }
    if(a-3>=0&&b-2>=0&&a<=H&&b+1<=W){
      A.push(P(a-3,b-2));
    }
    if(a-3>=0&&b-1>=0&&a<=H&&b+2<=W){
      A.push(P(a-3,b-1));
    }
    if(a-2>=0&&b-3>=0&&a+1<=H&&b<=W){
      A.push(P(a-2,b-3));
    }
    if(a-2>=0&&b-2>=0&&a+1<=H&&b+1<=W){
      A.push(P(a-2,b-2));
    }
    if(a-2>=0&&b-1>=0&&a+1<=H&&b+2<=W){
      A.push(P(a-2,b-1));
    }
    if(a-1>=0&&b-3>=0&&a+2<=H&&b<=W){
      A.push(P(a-1,b-3));
    }
    if(a-1>=0&&b-2>=0&&a+2<=H&&b+1<=W){
      A.push(P(a-1,b-2));
    }
    if(a-1>=0&&b-1>=0&&a+2<=H&&b+2<=W){
      A.push(P(a-1,b-1));
    }
  }
  vector<ll> B(10,0);
  B.at(0)=(H-2)*(W-2);
  while(!A.empty()){
    ll k=1;
    P a=A.top();
    A.pop();
    while(!A.empty()&&a==A.top()){
      A.pop();
      k++;
    }
    B.at(k)++;
    B.at(0)--;
  }
  rep(i,10){
    cout << B.at(i) << endl;
  }
}


Measured memory_bytes: 19764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int MAX = 4e5;
const ll mod = 998244353;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * (ll)i % mod;
        inv[i] = mod - inv[mod%i] * (mod/(ll)i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}


int main(){
  ll n, a, b, k;
  cin >> n >> a >> b >> k;
  COMinit(); 
  ll ans = 0;
  for(ll c = 0; c <= n; c++) {
    if(c*a <= k && (k-a*c) % b == 0 && (k-a*c)/b <= n) {
      ll d = (k-a*c)/b;
      (ans += COM(n,c)*COM(n,d)) %= mod; 
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


vector<string> field(55);
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
ll H, W;

ll bfs(int h, int w){
  Vs fi = field;
  int d[55][55];
  rep(i, 0, 55) rep(j, 0, 55) d[i][j] = -1;
  d[h][w] = 0;
  queue<pair<int, int>> qu;
  qu.push(make_pair(h, w));
  while(!qu.empty()){
    pair<int, int> u = qu.front(); qu.pop();
    fi[u.first][u.second] = '#';
    rep(i, 0, 4){
      int y = u.first+dy[i], x = u.second+dx[i];
      if(y<0 || y>=H || x<0 || x>=W) continue;
      if(fi[y][x] == '#') continue;
      d[y][x] = d[u.first][u.second] + 1;
      fi[y][x] = '#';
      qu.push(make_pair(y, x));
    }
  }
  if(d[H-1][W-1] == -1){
    cout << -1 << endl;
    return -1;
  }
  return d[H-1][W-1];
}

int main() {
  cin >> H >> W;
  rep(i, 0, H){
    cin >> field[i];
  }

  ll white = 0;
  rep(i, 0, H) rep(j, 0, W) if(field[i][j] == '.') white++;

  ll m = bfs(0, 0);
  if(m == -1) return 0;
  cout << white - m -1 << endl;

  return 0;
}


Measured memory_bytes: 256