akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n, m;
    cin>>n>>m;
    vector<pair<int, int> > v(n);
    rep(i, n){
        int a, b;
        cin>>a>>b;
        v[i] = make_pair(b, m-a);//報酬, 働かなければならない日
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    set<int> canwork;
    rep(i, m) canwork.insert(-i);
    int res = 0;
    rep(i, n){
        int money = v[i].first;
        int day = v[i].second;
        if(canwork.find(-day) != canwork.end()) {
            canwork.erase(-day);
            res += money;
        }
        else{
            auto itr = canwork.lower_bound(-day);
            if(itr == canwork.end()) continue;
            int s = *itr;
            canwork.erase(s);
            res += money;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <iostream>
using namespace std;
long long A, B, result, temp;

int main()
{
    scanf("%lld %lld", &A, &B);
    result = (B - A + 1) / 2 % 2;
    temp = (B - A) / 2 % 2;
    if(A % 2 == 1 && B % 2 == 0)
    {
        result = A ^ B ^ temp;
    }
    else if(A % 2 == 1)
    {
        result = A ^ temp;
    }
    else if(B % 2 == 0)
    {
        result = B ^ temp;
    }
    printf("%lld", result);
}

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

int main() {
	
	string s; cin >> s;
	string ans = "AC";
	if (s[0] != 'A') ans = "WA";
	int cnt = 0;
	int index;
	for (int i = 2; i < s.size() - 1; i++) {
		if (s[i] == 'C') {
			cnt++;
			index = i;
		}
	}
	if (cnt != 1) ans = "WA";
	for (int i = 0; i < s.size(); i++) {
		if (i == 0 || i == index) continue;
		if (!islower(s[i])) ans = "WA";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3532
import Control.Applicative
import Control.Monad
import Data.List
import Data.Function (on, fix)

main :: IO ()
main = do
  [n, m] <- f
  solve n <$> replicateM m ((\[a, b] -> (a, b)) <$> f) >>= putStrLn
  where
    f = map read <$> words <$> getLine

solve :: Int -> [(Int,Int)] -> String
solve n ps = f 0 1
  where
    f ct i
      | i > n = show ct
      | otherwise = let ps' = filter (\(a, b) -> a <= i && i <= b) ps
                    in if null ps'
                       then "Impossible"
                       else f (ct + 1) (1 + maximum (map snd ps'))



Measured memory_bytes: 4216
fun main(args: Array<String>) {
    val (N, Y) = readLine()!!.split(" ").map(String::toInt)
    for (i in 0..Y / 10000) {
        val first = 10000 * i
        for (j in 0..Y / 5000) {
            val second = 5000 * j

            val k = (Y - first - second) / 1000
            if(k < 0){
                break
            }
            if (i + j + k == N) {
                println("$i $j $k")
                return
            }
        }
    }

    println("-1 -1 -1")
}





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

// マクロ
// forループ
#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--)
// xにはvectorなどのコンテナ
#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 PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair



int main() {
    int n, x;
    while(true) {
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        int ans = 0;
        FOR(i, 1, n) {
            FOR(j, i+1, n) {
                FOR(k, j+1, n) {
                    if (i + j + k == x) {
                        ans++;
                    }
                }
            }
        }
        PRINT(ans);
            
    }
    return 0;
}


Measured memory_bytes: 3092
#define DEBUGGING  // Enables DEBUG macro.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifndef DEBUGGING
#define debug(...)
#define DEBUG(...)
#else
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                     \
  do {                                 \
    cerr << " (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ": ";      \
    debug(__VA_ARGS__);                \
    cerr << endl;                      \
  } while (0)
#endif

int solve() {
  int N;
  cin >> N;
  vector<u64> A(N);
  for (auto& x : A) cin >> x;
  cin.ignore();
  string S;
  getline(cin, S);
  assert((int)S.size() == N);
  int p = N - 1;
  vector<bitset<64>> vecs(64);
  auto can_make = [&](u64 x) -> bool {
    bitset<64> b(x);
    REP(i, 64) {
      if (b[i]) {
        b ^= vecs[i];
      }
    }
    return b.to_ullong() == 0LL;
  };
  auto maybe_add = [&](u64 x) -> void {
    if (x == 0) return;
    if (can_make(x)) return;
    bitset<64> b(x);
    REP(i, 64) {
      if (b[i]) {
        b ^= vecs[i];
      }
    }
    int first = -1;
    REP(i, 64) {
      if (b[i]) {
        first = i;
        break;
      }
    }
    assert(first >= 0);
    vecs[first] = b;
    REP(i, 64) {
      if (i != first && vecs[i][first]) {
        vecs[i] ^= b;
      }
    }
  };
  while (p >= 0) {
    while (p >= 0 && S[p] == '0') {
      maybe_add(A[p]);
      --p;
    }
    while (p >= 0 && S[p] == '1') {
      if (!can_make(A[p])) return 1;
      --p;
    }
  }
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  REP(t, T) { cout << solve() << '\n'; }
}

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

using namespace std;
        
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
        
#define print(a) {for(auto xxxxx : (a)) cout << xxxxx << ' '; cout << '\n';}
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

ll next(){ll x; cin >> x; return x;}
const int maxn = 3e5 + 5, intf = 2e9;
const ll inf = 1e18, mod = 998244353;
const ld eps = 1e-9;


void solve(){
  ll a; ld b;
  cin >> a >> b;
  ll c = b*ld(100) + 0.5;
//  cout << c << '\n';
  cout << (a*c) / 100;  
}

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
  
  for (int t = 1; t--;) {
    solve();
  }
        
  return 0;
}
/*

*/


Measured memory_bytes: 3756
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
using namespace std;

class lr{
public:
  int l, r;
  lr() {l = r = 0;}
  lr(int left, int right) {l = left; r = right;}
};

int main(){
  int N; cin >> N;
  lr LR[N];
  for(int i = 0; i < N; i++) cin >> LR[i].l >> LR[i].r;
  int ans = 0;
  for(int i = 0; i < N; i++) ans += LR[i].r - LR[i].l + 1;
  cout << ans << endl;
}


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

// why am I so weak

int n, k;
int a[100055];
set<int> have;

int main() {
	scanf("%d %d", &n, &k);

	set<int> s;

	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		s.insert(x);
		have.insert(x);
	}

	while (!s.empty()) {
		int v = *s.rbegin(); s.erase(v);

		if (v == k || have.count(v + k)) {
			puts("POSSIBLE");
			return 0;
		}

		if (s.empty()) {
			break;
		}

		s.insert(v - *s.rbegin());
	}

	puts("IMPOSSIBLE");
	
	return 0;
}


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

int main() {
    

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    //Write code below
    
    int a, b;
    
    cin >> a >> b;
    
    for (int i = b - a + 1; i < a + b; i++) {
        cout << i << endl;
    }
}


Measured memory_bytes: 256
// AOJ 2149: Luck Manipulator
// 2017.11.9 bal4u@uu

#include <stdio.h>
#include <string.h>

int y[102];

int main()
{
	int n, a, b, c, x, i, j, ans;
	
	while (scanf("%d%d%d%d%d", &n, &a, &b, &c, &x) && n > 0) {
		for (i = 0; i < n; i++) scanf("%d", y+i);
		ans = -1, j = 0;
		i = 10001; while (i--) {
			if (y[j] == x) if (++j == n) { ans = 10000-i; break; }
			x = (a*x+b) % c;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1748
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int width = 0;
		int height = 0;
		Scanner sc = new Scanner(System.in);
		
		while (true){
			//マップの大きさを取得
			width = sc.nextInt();
			height = sc.nextInt();
			int count = 0;
			
			//終了条件の判定
			if (width == 0 && height == 0){
				break;	
			}
			
			//マップ用変数
			int[][] map = new int[height + 2][width + 2];
			
			//番兵を配置
			for (int i = 0; i < width + 2; i++){
				map[0][i] = 0;
				map[height + 1][i] = 0;
			}
			for (int i = 1; i < height + 1; i++){
				map[i][0] = 0;
				map[i][width + 1] = 0;
			}
			
			//データを入力
			for (int i = 1; i <= height; i++){
				for (int j = 1; j <= width; j++){
					map[i][j] = sc.nextInt();
				}
			}
			
			for (int i = 1; i <= height; i++){
				for (int j = 1; j <= width; j++){
					if (map[i][j] == 1){
						count++;
						map[i][j] = 0;
						remover(i,j,map);
					}
				}
			}
			
			System.out.println(count);
		}
		
	}
	private static void remover(int h, int w, int[][] map){
		int choice[][] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
			
		for (int i = 0; i < 8; i++){
			if (map[choice[i][0] + h][choice[i][1] + w] == 1){
				map[choice[i][0] + h][choice[i][1] + w] = 0;
				remover(choice[i][0] + h, choice[i][1] + w,map);
			}
		}
	}
}


Measured memory_bytes: 47132
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    l1 = [1,3,5,7,8,10,12]
    l2 = [4,6,9,11]
    x,y = map(int,input().split())
    if x==2 or y==2:
        print("No")
    elif x in l1 and y in l1:
        print("Yes")
    elif x in l2 and y in l2:
        print("Yes")
    else:
        print("No")
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38508
import math
a,b,x=map(int,input().split())
h = x/(a*a)
if b/2<=h:
  atan1 = math.degrees(math.atan(((a*a*b)-x)*2/(a*a*a)))
else:
  atan1 = math.degrees(math.atan((a*b*b)/(2*x)))
print(atan1)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline


def typical_stairs():
    n, m = map(int, input().split())
    dangerous = set(int(input()) for _ in range(m))
    mod = 1000000007
    dp = [0] * (n + 1)
    dp[0] = 1
    if 1 not in dangerous:
        dp[1] = 1
    for i in range(2, n + 1):
        if i not in dangerous:
            dp[i] = dp[i - 2] + dp[i - 1]
    print(dp[-1] % mod)


if __name__ == '__main__':
    typical_stairs()


Measured memory_bytes: 460020
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int i, n, m;
	int sum, array[1024];
	
	while (1){		
		scanf("%d %d", &n, &m);
		
		if (!n && !m){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		sort(array, array + n);
		reverse(array, array + n);
		
		for (i = 0, sum = 0; i < n; i++){
			if ((i + 1) % m != 0 || n - (i / m * m) < m){
				sum += array[i];
			}
		}
		
		printf("%d\n", sum);
	}
	
	return (0);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const int SIZE = 100005;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ll MOD = 1E9 + 7;
#define rep(i,n) for (long long i=0;i<(n);++i)
#define repp(i,a,b) for (long long i=(a);i<(b);++i)
#define per(i,x) for(long long i = (x) ; i >= 0 ; --i)
#define perr(i,x,y) for(long long i = (x) ; i >= (y) ; --i)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(a) (a).begin(),(a).end()
#define lla(a) (a).rbegin(),(a).rend()
#define p(x) cout<<x<<" "
#define pn(x) cout<<x<<"\n"
#define p2(x,y) cout<<x<<" "<<y<<"\n"
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define p4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"
#define p5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<"\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif


//template<class T>
//bool isPrime(T n){
//	if(n==1)return false;
//	T i = 2;
//	while(i*i<=n){
//	   if(n%i==0)return false;
//	   i+=1;
//	}
//    return true;
//}

// bool prime[100005];
// void seive()
// {
// 	memset(prime,true,sizeof(prime));
// 	prime[0]=0;
// 	prime[1]=0;
// 	for(ll p=2;p*p<=100000;p++)
// 	{
// 		if(prime[p]==true)
// 		{
// 			for(ll i=p*2;i<=100000;i+=p)
// 			prime[i]=false;
// 		}
// 	}	
// }

// ll power(ll n,ll k, ll mod){
// 	if(k==0)
// 		return 1;
// 	if(k==1)
// 		return n%mod;

// 	ll get=power(n,k/2,mod);
// 	ll ret = ((get%mod)*(get%mod))%mod;

// 	if(k%2)
// 		ret = ((ret%mod)*(n%mod))%mod;

// 	return ret%mod;
// }

ll dp[SIZE];

int main(){
    
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    FAST;
	
	ll n,W; cin>>n>>W;
	dp[0] = 0;
	repp(i,1,SIZE){
		dp[i]=INFL;
	}
	ll val[n], w[n];
	rep(i,n){
		cin>>w[i]>>val[i];
	}
	rep(i,n){
		per(j,SIZE-val[i]){
			dp[j+val[i]] = min(dp[j]+w[i],dp[j+val[i]]);
		}
		//trace(i,dp[i]);
	}

	ll ans = INT_MIN;

	repp(i,1,SIZE){
		if(dp[i]<=W){
			ans = i;
		}
	}
	pn(ans);
}

Measured memory_bytes: 1024
n = input()
k = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print k[n-1]

Measured memory_bytes: 2568
fun main() = Thread(null, ::abc174b, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc174b() {
    val (n, d) = readLine()!!.split(" ").map { it.toLong() }
    val xyList = List(n.toInt()) {
        val (x, y) = readLine()!!.split(" ").map { it.toLong() }
        x to y
    }

    val answer = xyList.count { (x, y) -> x * x + y * y <= d * d }

    println(answer)
}


Measured memory_bytes: 79832
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int A,B,K; cin>>A>>B>>K;
	for(int i=0;i<K;i++){
		if(i%2==0){
			if(A%2==1)A--;
			A/=2;
			B+=A;
		}
		else{
			if(B%2==1)B--;
			B/=2;
			A+=B;
		}
	}
	cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
  int a, b;
  if(scanf("%d %d", &a, &b) <= 0) {
    printf("fail");
  }
  int i = 0;
  while(i < 1101) {
    if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
      printf("%d", i);
      return 0;
    }
    i++;
  }
  printf("%d", -1);
  return 0;
}

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

namespace abc131_d
{
    class Program
    {
        static void Main(string[] args)
        {
            // 仕事の個数
            var n = long.Parse(Console.ReadLine());
            // それぞれにかかる時間と締め切り
            var t = new t[n];
            for (var i = 0L; i < n; i++)
            {
                var items = Console.ReadLine().Split(' ');
                t[i] = new t
                {
                    a = long.Parse(items[0]),
                    b = long.Parse(items[1])
                };
            }

            // 締め切りが同じ仕事が複数ある場合、どの仕事を優先しても結果は変わらない(結局やらなくてはならないので)
            // 締め切り：1 56 57 57 100
            // →どちらの57を先にやっても構わない。
            //  逆に、57を始める前に、それよりも締め切りが早いやつを全部片づけておかないとやばい
            // →1が間に合う→56も間に合う→57も間に合う→100も間に合う
            //  逆に、1と56だけで考えて間に合わなかったら、どうあがいても間に合わない
            var pattern = t.OrderBy(m => m.b).ToArray();

            var time = 0L;
            for (int i = 0; i < pattern.Length; i++)
            {
                var limit = pattern[i].b;
                time += pattern[i].a;
                if (limit < time)
                {
                    time = 0;
                    break;
                }
            }

            var answer = time > 0 ? "Yes" : "No";
            Console.WriteLine($"{answer}");
        }
    }

    struct t
    {
        public long a;
        public long b;
    }
}


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

public class Main {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();
        System.out.print((t / a) * b);
    }
}


Measured memory_bytes: 21588
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int X=sc.nextInt();
        int N=sc.nextInt();
        boolean p[]=new boolean[102];
        for(int i=0; i<N; i++){
            p[sc.nextInt()]=true;
         }
        
        for(int i=0; i<51; i++){
            if(p[X-i]==false){
                 System.out.println(X-i);
                break;
            }
            if(p[X+i]==false){
                System.out.println(X+i);
                break;
            }
        }
    }
}

Measured memory_bytes: 35932
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int testcase = scanner.nextInt();
        int seikai = scanner.nextInt();

        if (testcase==seikai){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }

    }
}


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

count_list = []
for i in range(10):
    count_list.append([0] * 10)

for i in range(1, n + 1):
    i_str = str(i)
    j = int(i_str[0])
    k = int(i_str[-1])
    count_list[j][k] += 1

ans = sum([count_list[i][j] * count_list[j][i] for i in range(1, 10) for j in range(1, 10)])
print(ans)

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


int main()
{
    int x;
    cin>>x;
    /*if(x<1000)
    {
        cout<<1000-x;
    }
    else{
            if(x%1000==0)
            {
                cout<<"0";
            }
            else{
                int h=x%1000;
    float b=(float)x/1000;
    cout<<floor(b)*1000-h;
            }

    }*/
    int h=x%1000;
    if(h==0){cout<<"0";}
    else{
        cout<<1000-h;
    }



}




Measured memory_bytes: 3628
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += B[A[i] - 1]
    # if 0 < i and A[i] == A[i - 1] + 1:
    #     ans += C[i - 2]
    if 0 < i and A[i] == A[i - 1] + 1:
        ans += C[A[i] - 2]

print(ans)

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

vector<int> even(100001);
vector<int> odd(100001);

int main() {
	int n;
	cin >> n;
	for (int i = 0, v; i * 2 < n; i++) {
		cin >> v;
		even[v]++;
		cin >> v;
		odd[v]++;
	}
	int ef = 0, es = 0, of = 0, os = 0;
	for (int i = 0; i < 100001; i++) {
		if (even[i] > even[ef]) {
			es = ef;
			ef = i;
		} else if (even[i] > even[es])
			es = i;

		if (odd[i] > odd[of]) {
			os = of;
			of = i;
		} else if (odd[i] > odd[os])
			os = i;
	}

	if (ef != of) {
		cout << n - even[ef] - odd[of] << endl;
	} else
		cout << min(n - even[es] - odd[of], n - even[ef] - odd[os]) << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int max(int a, int b){
    return a < b ? b:a;
}

int main(void)
{
    int P, Q, R;
    int M ;
    
    //printf("P Q R :");
    scanf("%d", &P);
    
    scanf("%d", &Q);
    
    scanf("%d", &R);
    
    M = max(P,max(Q,R));
    P=P+Q+R;
    P=P-M;
    printf("%d", P);
    
    return 0;
}


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

const int MAXN = 100100;
int arr[MAXN][3];
int dp[MAXN][3];
pair<int,int> nums(int x){
    if(x ==1 ){
        return make_pair(0,2);
    }
    if(x == 2){
        return make_pair(0,1);
    }
    if(x == 0){
        return make_pair(1,2);
    }
}
int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
	    for(int j=0;j<3;j++){
	        cin>>arr[i][j];
	    }
	}
    dp[0][1] = arr[0][1];
    dp[0][0] = arr[0][0];
    dp[0][2] = arr[0][2];

	for(int i=1;i<n;i++){
	   for(int j=0;j<3;j++){
	       auto hold = nums(j);
	       dp[i][j] = max(dp[i-1][hold.first]+arr[i][j],dp[i-1][hold.second]+arr[i][j]);
	      // cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
	   }
	    
	}
	std::cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<int>>;

vector<int> d, f;
vector<bool> seen;
void dfs(Graph &G, int v, int &ptr){
  seen[v] = true;
  d[v] = ptr++;
  for (auto next_v : G[v]){
    if (seen[next_v]) continue;
    dfs(G, next_v, ptr);
  }
  f[v] = ptr++;
}

int main() {
  int n;
  cin >> n;
  Graph G(n);
  rep(i, n){
    int u, k;
    cin >> u >> k;
    rep(j, k){
      int v;
      cin >> v;
      G[u-1].push_back(v-1);
    }
  }
  seen.assign(n, false);
  d.assign(n, 0);
  f.assign(n, 0);
  int ptr = 1;
  rep(i, n){
    if (seen[i]) continue;
    dfs(G, i, ptr);
  }
  rep(i, n){
    cout << i+1 << ' ' << d[i] << ' ' << f[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    string n; cin >> n;
    int ans=0;
    rep(i,n.length()){
        ans+=n[i]-'0';
    }
    if(ans%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll
#define MOD (1000*1000*1000+7)

int t, n, m, k, a[60][60], q, l, r;
void multip( int a[60][60], int b[60][60], int c[60][60] ){
int temp[60][60];
for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
        temp[i][j]=0;
        for(int g=1; g<=n; g++){
            temp[i][j]+=(a[i][g]*b[g][j])%MOD;
            temp[i][j]%=MOD;
        }
    }
}
for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
        c[i][j]=temp[i][j];
    }
}
return;
}
int res[60][60];


void exp(int e){

if(e<=1){
    return;
}
int temp[60][60];

for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
        temp[i][j]=res[i][j];
    }
}

if( (e%2)==1){
    multip(temp, temp, res);
    if( (e/2)>1){
        exp(e/2);
    }


    multip(res, temp, res);
}
else{
multip(temp, temp, res);
exp(e/2);
}



}






int32_t main(){
INIT
cin>>n>>k;
for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
        cin>>a[i][j];
        res[i][j]=a[i][j];
    }
}
exp(k);
int num=0;
for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
            //cout<<res[i][j]<<" ";
        num+=res[i][j];
        num%=MOD;
    }//cout<<"\n";
}
cout<<num;




return 0;
}





Measured memory_bytes: 5384
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, L, T, X[101010], W[101010];

void solve() {
    int tmp[101010] = {};
    for (int i = 0; i < N; i++) {
        if (W[i] == 1)
            tmp[i] = X[i] + T;
        else
            tmp[i] = X[i] - T;
        tmp[i] %= L;
        tmp[i] += L;
        tmp[i] %= L;
    }
    sort(tmp, tmp + N);

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (W[i] == 1) {
            cnt -= (X[i] + T) / L;
        } else {
            cnt += (T - X[i] + L - 1) / L;
        }
    }
    cnt %= N;
    cnt += N;
    cnt %= N;

    int ans[101010] = {};
    for (int i = 0; i < N; i++) {
        ans[(i + cnt) % N] = tmp[i];
    }

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

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> L >> T;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> W[i];
    }


    solve();
    return 0;
}


Measured memory_bytes: 6788
#include<iostream>
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define endl "\n"
#define MOD 1000000007
#define DEB(x) cout<<"##"<<x<<"##"<<endl;
void myfunc(int a,int b,int c,int d)
{
    c=c-b;
    if(c<=0)
    {
        cout<<"Yes";
        return;
    }
    a=a-d;
    if(a<=0)
    {
        cout<<"No";
        return;
    }
    myfunc(a,b,c,d);
}
void solve()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    myfunc(a,b,c,d);
    cout<<endl;
}
void solve1()
{
    int n;
    cin>>n;  
    string q;
    set<string>sl;
    for(int i=0;i<n;i++)
    {
        cin>>q;
        sl.insert(q);
        
    }
    cout<<sl.size();

}

int main() 
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    solve();
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> toppingSheet = Arrays.asList(br.readLine().split(""));

            int ramenPrice = 700;
            int toppingPrice = 100;
            for (String topping : toppingSheet) {
                if (topping.equals("o")) {
                    ramenPrice += toppingPrice;
                }
            }

            System.out.println(ramenPrice);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21588
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    r, g, b = map(int, read().split())

    n = 100 * r + 10 * g + b
    if n % 4 == 0:
        print('YES')
    else:
        print('NO')

    return


if __name__ == '__main__':
    main()


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

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

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

int main(void) {
  int N, Y;
  cin >> N >> Y;
  for (int x = 0; x <= N; x++) {
    for (int y = 0; y <= N; y++) {
      if (9000 * x + 4000 * y + 1000 * N == Y && (N - x - y) >= 0) {
        cout << x << " " << y << " " << N - x - y << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

string chara(string s)
{
  int i;
  int len = s.size();
  string upstr = s;
  for (i = 0; i < len; i++){
    upstr[i] = toupper(s[i]);
  }
  return upstr;
}

int main(void)
{
  int count = 0;
  string w, input;
  cin >> w;
  while (1) {
    cin >> input;
    if (input == "END_OF_TEXT") break;
    if (chara(input) == chara(w)) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1196
import sys


def resolve(in_):
    a, b, c, d = map(int, next(in_).split())
    while True:
        c -= b
        if c <= 0:
            return 'Yes'
        a -= d
        if a <= 0:
            return 'No'


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

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

int eval(stack<string> &formula)
{
    string str = formula.top();
    formula.pop();
    if (str == "+" || str == "-" || str == "*")
    {
        int right = eval(formula);
        int left = eval(formula);
        if (str == "+")
        {
            return right + left;
        }
        else if (str == "-")
        {
            return left - right;
        }
        else if (str == "*")
        {
            return right * left;
        }
    }

    return stoi(str);
}

int main()
{
    stack<string> formula;
    string s;
    getline(cin, s);

    stringstream ss;
    ss << s;
    string str;
    while (ss >> str)
    {
        formula.push(str);
    }
    cout << eval(formula) << endl;
    return 0;
}


Measured memory_bytes: 3224
#include <stdio.h>

int main(){
	int S;
	scanf("%d", &S);

	int h = S / 3600;
		int H = S - 3600 * h;
		int m = H / 60;
		int s = H - 60 * m;

	printf("%d", h);
	printf(":%d", m);
	printf(":%d\n", s);

	return 0;
}

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

int main(){
    int64_t A,B,result;

    cin >> A >> B;
    
    
    if(B > A){
        swap(A,B);
    }
    result = A;

    while (result % B != 0){
        // cout << result << endl;
        result += A;
    }

    cout << result;
}

Measured memory_bytes: 256
#include <cstdio>
#include <unordered_map>

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);

    std::unordered_map<long long, int> mp;
    long long a, ans = 0, sum = 0;
    ++mp[0];
    for (int i = 0; i < n; ++i) {
        scanf("%lld", &a);
        sum += a;
        ans += mp[sum];
        ++mp[sum];
    }
    printf("%lld\n", ans);
}
/*
累積和が等しい2点間の、連続する部分列の和は０になる。
ある累積和がn個存在するとき、n個の中から2点を選ぶ組み合わせはnC2通り。

累積和１が３回現れる場合。
1回目：
    sum += a;  // sum = 1
    ans += mp[sum];  // mp[1] = 0 <- 初回の累積和はカウントされない
    ++mp[sum];  // mp[1] = 1

2回目：
    sum += a;  // sum = 1
    ans += mp[sum];  // mp[1] = 1 <- 累積和１が２回出たのでansがカウントされる。2C2=1通り
    ++mp[sum];  // mp[1] = 2 <- 累積和１が２点に存在する

3回目：
    sum += a;  // sum = 1
    ans += mp[sum];  // mp[1] = 2 <- 累積和１が３回出たのでansがカウントされる。3C2=3通り
    ++mp[sum];  // mp[1] = 3 <- 累積和１が３点に存在する
*/


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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define pi acos(-1.0)
#define eps 1e-8
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

lli n, W, ans, dp[105][1000005], w[105], v[105] ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    memset(dp, inf, sizeof dp) ;
    dp[0][0]=0 ;
    cin>> n >> W ;
    for(int i=1 ; i<=n ; i++) cin>> w[i] >> v[i] ;
    for(int j=0 ; j<=100000 ; j++)
      for(int i=1 ; i<=n ; i++)
        {
          dp[i][j]=min(dp[i-1][j], dp[i][j]) ;
          if(j-v[i]>=0) dp[i][j]=min({dp[i][j], dp[i-1][j-v[i]]+w[i]}) ;
        }
    for(int i=1 ; i<=100000 ; i++) if(dp[n][i]<=W) ans=i ;
    cout<< ans ;
  }


Measured memory_bytes: 820608
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;

int main(){
    double t,d,t1,t2,d1,d2,m=999;
    cin>>t>>d>>t1>>t2>>d1>>d2;
    for(int i=0;i<=d;i+=d1)
        for(int j=0;i+j<=d;j+=d2)
            if(abs((t1*i+t2*j)/(i+j)-t)<m&&(i>0||j>0))
                m=abs((t1*i+t2*j)/(i+j)-t);
    printf("%.6f\n",m);
    
}

Measured memory_bytes: 1240
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll a, b, c, k;
    cin>>a>>b>>c>>k;
    if(abs(a-b)>1000000000000000000){
        cout<<"Unfair"<<endl;
        return 0;
    }
    if(k%2==0){
        cout<<a-b<<endl;
    }
    else{
        cout<<-a+b<<endl;
    }





    return 0;
}


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

double x1,y1,x2,y2;
int main(){
	scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
	x2-=x1;
	y2-=y1;
	double len=hypot(x2,y2);
	x2/=len;
	y2/=len;
	int q;
	scanf("%d",&q);
	while(q--){
		double x,y;
		scanf("%lf%lf",&x,&y);
		x-=x1;
		y-=y1;
		double r=(x*x2+y*y2);
		printf("%.9f %.9f\n",x1+r*x2,y1+r*y2);
	}
}


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


int main() {
  ll n, k, q, tmp;
  cin >> n >> k >> q;
  vector<int>a(n, k-q);
  rep(i,q) {
    cin >> tmp;
    a[tmp-1]++;
  }
  
  rep(i,n) {
    if(a[i]<=0) {
      cout << "No" << endl;
    }else {
      cout << "Yes" << endl;
    }
  }
  return 0;
}
  
  
  
  

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

int main(){
 int h,n;
 cin >> h >> n;
 int a[1011111];
 for (int i = 0; i<n;++i) cin>>a[i];

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

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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int N = nextInt();
		int K = nextInt();
		int S = nextInt();

		int dummy;
		if(S==1){
			dummy=2;
		}else{
			dummy=S-1;
		}
		StringBuffer sb = new StringBuffer();
		for(int i=0;i<N;i++){
			if(i<K){
				sb.append(S);
			}else{
				sb.append(dummy);
			}
			sb.append(" ");
		}
		sb.delete(sb.length()-1, sb.length());
		System.out.println(sb.toString());
	}



	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 31040
#include <bits/stdc++.h>
using namespace std;
int n,a,b,c;
string str[200000];
int cnt[3][200000];
vector<char> ans;

int main()
{
	/* start code */
    cin>>n>>a>>b>>c;
    for(int i = 0; i < n; i++) {
    	cin>>str[i];
	} 
	for(int i = n - 1; i >= 0; i--) {
		if(str[i] == "AB") {
			cnt[0][i] = cnt[0][i + 1] + 1;
			cnt[1][i] = cnt[1][i + 1] + 1;
		}else if(str[i] == "AC") {
			cnt[0][i] = cnt[0][i + 1] + 1;
			cnt[2][i] = cnt[2][i + 1] + 1;
		}else {
			cnt[1][i] = cnt[1][i + 1] + 1;
			cnt[2][i] = cnt[2][i + 1] + 1;
		}
	}
    for(int i = 0; i < n; i++) {
    	string s = str[i];
    	if(s == "AB") {
    		if(a == 0 && b == 0) {
    			cout<<"No"<<endl;
    			return 0;
			}else {
				if((a < b) || (a == b && cnt[0][i] > cnt[1][i])) {
					++a, --b;
					ans.push_back('A');
				}else {
					--a, ++b;
					ans.push_back('B');
				}
			}
		}else if(s == "AC") {
    		if(a == 0 && c == 0) {
    			cout<<"No"<<endl;
    			return 0;
			}else {
				if((a < c) || (a == c && cnt[0][i] > cnt[2][i])) {
					++a, --c;
					ans.push_back('A');
				}else {
					--a, ++c;
					ans.push_back('C');
				}
			}
		}else {
    		if(b == 0 && c == 0) {
    			cout<<"No"<<endl;
    			return 0;
			}else {
				if((b < c) || (b == c && cnt[1][i] > cnt[2][i])) {
					++b, --c;
					ans.push_back('B');
				}else {
					--b, ++c;
					ans.push_back('C');
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i = 0; i < ans.size(); i++) {
		cout<<ans[i]<<endl;
	}
    /* end code */
	return 0;
}

Measured memory_bytes: 11180
a,b,c,k=io.read("*n","*n","*n","*n")
if k%2==0 then
    if a-b>=10^18 then
        print("Unfair")
    else
        print(a-b)
    end
else
    if b-a>=10^18 then
        print("Unfair")
    else
        print(b-a)
    end
end

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

int main() {
    int s;
    int a[1000000];
    cin >> s;

    a[0] = s;
    int i = 0;

    while (true){
        if(s % 2 == 0)
            s = s / 2;
        else
            s = 3 * s + 1;
        a[++i] = s;
        for(int j = 0; j < i; j++) {
            if (a[j] == s) {
                cout << i + 1 << endl;
                return 0;
            }
        }
    }    
}


Measured memory_bytes: 256
let () =
    let main () =
        let n = int_of_string (read_line ()) in
        let s = read_line () in

        let rec loop_l l acc =
            if l = n then acc else (
                let nn = n - l in
                let a = Array.make nn 0 in
                let rec loop_i i j =
                    if i < nn then (
                        let rec loop_j j =
                            if i + j = nn || s.[j + l] != s.[i + j + l] then j else loop_j (j + 1)
                        in
                        let j = loop_j j in
                        a.(i) <- j;
                        if j = 0 then loop_i (i + 1) j else
                            let rec loop_k k =
                                if i + k = nn || k + a.(k) >= j then k else
                                    let () = a.(i + k) <- a.(k) in
                                    loop_k (k + 1)
                            in
                            let k = loop_k 1 in
                            loop_i (i + k) (j - k)
                    )
                in
                loop_i 1 0;
                let rec loop i acc =
                    if i = nn then acc else loop (i + 1) (max acc (min i a.(i)))
                in
                let acc = loop 1 acc in
                loop_l (l + 1) acc
            )
        in
        let r = loop_l 0 0 in
        Printf.printf "%d\n" r
    in
    main ()

Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  ll n, m;
  cin >> n >> m;
  if (abs(n-m) > 1) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  rep(i,n) (ans *= i+1) %= MOD;
  rep(i,m) (ans *= i+1) %= MOD;
  if (n == m) (ans *= 2) %= MOD;
  cout << ans << endl;
}


Measured memory_bytes: 256
/// by ztx
/// blog.csdn.net/hzoi_ztx
/// for c++11, using google c++ style
#include <bits/stdc++.h>
#define rep(i, l, r) for (i = (l); i <= (r); i++)
#define rep_(i, l, r) for (i = (l); i < (r); i++)
#define rev(i, r, l) for (i = (r); i >= (l); i--)
#define rev_(i, r, l) for (i = (r); i > (l); i--)
#define Rep(i, l, r) for (int i = (l); i <= (r); i++)
#define Rep_(i, l, r) for (int i = (l); i < (r); i++)
#define Rev(i, r, l) for (int i = (r); i >= (l); i--)
#define Rev_(i, r, l) for (int i = (r); i > (l); i--)
#define each(e, s) for (e : s)
#define Each(e, s) for (auto e : s)
#define r(args...) read(args)
typedef long long ll;
typedef double lf;
typedef long double llf;
typedef unsigned uint;
typedef std::pair<int, int> pii;
int g_ch, g_neg, g_eof;
template <typename ret_t>
inline void read(ret_t& ret) {
    ret = g_ch = g_neg = g_eof = 0;
    while (g_ch < '!') g_ch = getchar();
    if (g_ch == '-') g_neg = true, g_ch = getchar();
    while (g_ch > '!') ret = ret * 10 + g_ch - '0', g_ch = getchar();
    if (g_neg) ret = -ret;
    g_eof = g_ch == EOF;
}
template <typename ret_t, typename... args_t>
inline void read(ret_t& x, args_t&... args) {
    read(x), read(args...);
}

#define kN 100010LL

int n, m;
ll ans;

std::priority_queue<int> h;

int main() {
    int i, x;
    r(n, m);
    rep(i, 1, n) {
        r(x);
        h.push(x);
    }
    while (m && !h.empty()) {
        x = h.top();
        h.pop();
        x >>= 1;
        if (x) h.push(x);
        m--;
    }
    while (!h.empty()) {
        ans += h.top();
        h.pop();
    }
    printf("%lld\n", ans);
    // END:
    getchar(), getchar();
    return 0;
}

Measured memory_bytes: 892
/**
 *   author: malviyanshiv
 *   created: 12 March 2019  07:47:16
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define FORE(a) for(auto ele : a )
#define ALL(a) begin(a), end(a)
#define RPB(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define F first
#define S second
#define TC int t; cin >> t; while(t--)
#define SET(a,b) memset(a,b,sizeof(a))

#define TRACE

#ifdef TRACE
#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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

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


void optimizeIO(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

ll get(ll a){
    if( a%4 == 0 )
        return a;
    if( a%4 == 1 )
        return 1;
    if( a%4 == 2 )
        return a+1;
    return 0;
}

int main(){
    optimizeIO();

    ll a, b;
    cin >> a >> b;
    ll xb = get(b), xa;
    if( a != 0 )
        xa = get(a-1);
    else
        xa = 0;
    cout << (xa^xb) << endl;
    
    return 0;
}

Measured memory_bytes: 256