akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;
double pi=3.1415926535;

ll power(ll x,ll n){
    if(n==0) return 1;
    ll res=power(x*x%mod,n/2);
    if(n&1) res=res*x%mod;
    return res;
}

int main(){
  int n;
  cin>>n;
  ll a[n];
  ll b[n];
  rep(i,0,n){
    cin>>a[i]>>b[i];
  }
  map<P,int> sei,fu;
  int zero=0;
  int c=0;
  int d=0;
  rep(i,0,n){
    if(a[i]==0 && b[i]==0){
      zero++;
    }
    else if(a[i]==0 && b[i]!=0){
      c++;
    }
    else if(a[i]!=0 && b[i]==0){
      d++;
    }
    else{
      if((a[i]>0 && b[i]>0) || (a[i]<0 && b[i]<0)){
        ll e=gcd(a[i],b[i]);
        sei[P(abs(a[i]/e),abs(b[i]/e))]++;
      }
      else{
        ll e=gcd(a[i],b[i]);
        fu[P(abs(a[i]/e),abs(b[i]/e))]++;
      }
    }
  }
  
  ll ans=1;
  for(auto p:sei){
    if(fu.count(P(p.first.second,p.first.first))){
      ll cur=power(2,p.second)+power(2,fu[P(p.first.second,p.first.first)])-1;
      if(cur<0) cur+=mod;
      cur%=mod;
      ans*=cur;
      ans%=mod;
    }
    else{
      ans*=power(2,p.second);
      ans%=mod;
    }
  }
  for(auto p:fu){
    if(sei.count(P(p.first.second,p.first.first))){
    }
    else{
      ans*=power(2,p.second);
      ans%=mod;
    }
  }
  
  ll now=power(2,c)+power(2,d)-1;
  if(now<0) now+=mod;
  ans*=now;
  ans%=mod;
  ans+=zero;
  ans--;
  if(ans<0) ans+=mod;
  cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  set<int> freqs;
  int a = 0, extra = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a);
    if (a >= 3200) { ++extra; }
    else { freqs.insert(a / 400); }
  }
  int ans_max = freqs.size() + extra;
  int ans_min = max(1, (int)freqs.size());
  printf("%d %d\n", ans_min, ans_max);
  return 0;
}


Measured memory_bytes: 256
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val x = readI()
  println(if (30 <= x) "Yes" else "No")
}


Measured memory_bytes: 34512
#include<iostream>
#include<map>
#include<set>
#include<vector>
using namespace std;

map<string, int> check;
map<string, set<string>> mem;

void dfs(string s){
    if(check.count(s))    return;

    vector<string> groups;
    for(string member : mem[s]){
        if(mem.count(member)){
            dfs(member);
            groups.push_back(member);
        }
    }

    for(string member : groups){
        mem[s].erase(member);
        mem[s].insert(mem[member].begin(), mem[member].end());
    }

    check[s] = 1;
    return;
}

int main(){
    int n;
    while(cin >> n, n){
        string first = "";
        while(n-- > 0){
            string s;
            cin >> s;
            int cur = 0;
            while(s[cur] != ':')    cur++;
            string name = s.substr(0, cur);
            if(first == "") first = name;
            cur++;
            while(cur < s.length()){
                int next = cur;
                while(s[next] != '.' && s[next] != ',') next++;
                mem[name].insert(s.substr(cur, next-cur));
                cur = next+1;
            }
        }
        dfs(first);
        cout << mem[first].size() << endl;
        mem.clear();
        check.clear();
    }
    return 0;
}


Measured memory_bytes: 3444
H,W = (gets).split(" ").map{ |i| i.to_i }
$arr = []
$blks = []
$arr[0] = Array.new(W+2) {1}
1.upto(H) do |h|
    $arr[h] = Array.new(W+2) {0}
    ta = (gets).delete("\n").chars.map{ |c| c=='#' ? 1 : 0 }
    ta.each_with_index do |t,w|
        if t==1 then
            $arr[h][w+1] = 1
            $blks << [w+1,h]
        end
    end
    $arr[h][0] = 1;
    $arr[h][W+1] = 1;
end
$arr[H+1] = Array.new(W+2) {1}
#p $arr

# blks基準で仲間を増やしていく
# 仲間を増やせなければ終わる
def add_black(w,h)
    if $arr[h][w-1]==0 then
        $blks << [w-1,h]
        $arr[h][w-1] = 1
    end
    if $arr[h][w+1]==0  then
        $blks << [w+1,h]
        $arr[h][w+1] = 1
    end
    if $arr[h-1][w]==0 then
        $blks << [w,h-1]
        $arr[h-1][w] = 1
    end
    if $arr[h+1][w]==0 then
        $blks << [w,h+1]
        $arr[h+1][w] = 1
    end
end

count = 0
while true
    #p $blks
    bs = $blks.shift($blks.length)
    bs.each do |black|
        add_black(black[0], black[1])
    end
    if $blks.length>0 then
        count = count + 1
    else
        break
    end
end

puts count


Measured memory_bytes: 78588
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

template <class T>
map<T, int> prime_factor(T n) {
    map<T, int> ret;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, p; cin >> n >> p;
    ll ans = 1;
    for (auto q : prime_factor(p)) {
        rep (i, q.second / n) ans *= q.first;
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0) {
        cout << (a + b) / 2 << endl;
    } else {
        cout << (a + b) / 2 + 1 << endl;
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i, n) cin >> v[i];

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

    //    cout << v[0] << endl;
    
    double ans = v[0];

    for(int i=1;i<n;i++){
        ans += v[i];
        ans /= 2;
    }

    printf("%.7lf", ans);

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;
ll mod = 1000000007;
int flag[200010]; 

void divisor(int n) {
    for(int i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            flag[i]++;
            if(i * i != n) flag[n / i]++;
        }
    }
} 

int main() {
    int n;
    scanf("%d",&n);
    vector<int> a(n,0),b;
    for (int i = 0; i < n; i++) scanf("%d",&a[i]);
    int sum = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (a[i] == 0) {
            if (flag[i+1] % 2 == 1) {
                b.push_back(i+1);
                sum++;
                divisor(i+1);
            } 
        } else {
            if (flag[i+1] % 2 == 0) {
                b.push_back(i+1);
                sum++;
                divisor(i+1);
            }
        }
    }
    printf("%d\n",sum);
    reverse(b.begin(),b.end());
    if(!b.empty()) {
        for (const auto& x : b) printf("%d ",x);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3064
nm=input().split()
NM_list = list(map(int,nm))

A_list=[]
B_list=[]
for m in range(NM_list[1]):
	ab=input().split()
	AB_list = list(map(int,ab))
	A_list.append(AB_list[0])
	B_list.append(AB_list[1])

n_list=[]
for n in range(1,NM_list[0]+1):
	n_list.append(0)


for i in range(1,len(A_list)+1):
	for n_len in range(1,len(n_list)+1):
		if(n_len == A_list[i-1]):
			n_list[n_len-1] += 1
			break

for i in range(1,len(B_list)+1):
	for n_len in range(1,len(n_list)+1):
		if(n_len == B_list[i-1]):
			n_list[n_len-1] += 1
			break

for p in range(1,NM_list[0]+1):
	print(n_list[p-1])

Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

ll pow_mod(ll x,ll y)
{
    return 
    (
        y==0?1
        :y%2==0?pow_mod((x%MOD)*(x%MOD)%MOD,y/2)
        :x%MOD*pow_mod(x%MOD,y-1)
    )%MOD;
}
const ll sz=200000;
array<ll,sz>fac_mod;
array<ll,sz>fac_inv;
ll stare(ll n)
{
    ll ret=0;
    for(ll a=n,b=0;a>=0;a-=2,b+=1){
        ret+=(fac_mod[a+b]*fac_inv[a]%MOD)*fac_inv[b]%MOD;
        ret%=MOD;
    }
    return ret;
}
int main()
{
    fac_mod[0]=1;
    REP1(i,sz-1)fac_mod[i]=fac_mod[i-1]%MOD*i%MOD;
    REP(i,sz)fac_inv[i]=pow_mod(fac_mod[i],MOD-2);

    ll n=in(),m=in();
    vector<ll>a(m);REP(i,m)a[i]=in();
    ll now=0,ans=1;
    REP(i,m){
        ans%=MOD;
        ans=ans*stare(a[i]-now-1)%MOD;
        now=a[i]+1;
    }
    ans%=MOD;
    cout<<ans*stare(n-now)%MOD<<endl;
}

Measured memory_bytes: 4096
#include <iostream>

int n, S[100000];

int search(int T){
  int l=0, r=n;
  int mid;

  while( l < r ){
    mid = ( l+r )/2;
    if( T==S[mid] ) return 1;
    if( T>S[mid] ) l=mid+1;
    else if( T<S[mid] ) r=mid;
  }
  return 0;
}

int main(){
  int i, q;
  int T[50000];
  int count=0;

  std::cin >> n;
  for(int i=0; i<n; i++){
    std::cin >> S[i];
  }
  std::cin >> q;
  for(int i=0; i<q; i++){
    std::cin >> T[i];
    if(search(T[i])) { count++; }
  }
  std::cout << count << std::endl;
  return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

using namespace std;

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int n;
    cin >> n;
    int y;
    cin >> y;
    if (y < 1000)
    {
        cout << -1 << -1 << -1 << endl;
        return 0;
    }

    for (int i = n; i >= 0; i--)
    {
        for (int j = n - i; j >= 0; j--)
        {
            if (10000 * i + 5000 * j + 1000 * (n - i - j) == y)
            {
                cout << i << " " << j << " " << n - i - j << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int t[8][3]={0,1,2,
	     3,4,5,
	     6,7,8,
	     0,3,6,
	     1,4,7,
	     2,5,8,
	     0,4,8,
	     2,4,6};

main(){
  int i;
  string str;
  char c;
  while(cin >> str){
    c=0;
    for(i=0;i<8;i++){
      if(str[t[i][0]]==str[t[i][1]] && str[t[i][1]]==str[t[i][2]] && str[t[i][2]]!='s'){
	c=str[t[i][0]];
	break;
      }
    }
    if(c==0) c='d';
    cout << c << endl;
  }
}

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

li = [[0 for _ in range(N+1)] for _ in range(W+1)]

for n in range(1,N+1):
    for w in range(W+1):
        if w>=w_li[n-1][0]:
            li[w][n] = max(li[w][n-1] , li[w-w_li[n-1][0]][n-1]+w_li[n-1][1])
        else:
            li[w][n] = li[w][n-1]
print(li[W][N])

Measured memory_bytes: 130140
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

typedef long long ll, lint;
typedef long double ldouble;

#define sz(v) ((int) (v).size())
#define FOR(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define For(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()

#define mp make_pair
#define pb push_back
#define fst first
#define snd second

template<class T>
string to_string(T arr, int len = 1e9) {
    stringstream ss;
    int i = 0;
    for (auto item : arr) {
        ss << item << ' ';
        if (++i == len)
            break;
    }
    return ss.str();
}

#ifdef LOCAL
    #define dbg(expr) cout << "[line " << __LINE__ << "] " << (#expr) << ": " << (expr) << endl;
#else
    #define dbg(expr) (void) 0;
#endif


int main() {
#ifndef LOCAL
    cin.tie(0);
    ios_base::sync_with_stdio(false);
#endif

    int n;
    cin >> n;
    vector<vector<int>> field(2);
    For (i, 2) {
        field[i].resize(n);
        For (j, n)
            cin >> field[i][j];
    }
    lint s = 0;
    lint max_value = 0;
    For (i, n) {
        s += field[0][i];
        lint cur = s;
        for (int j = i; j < n; j++)
            cur += field[1][j];
        max_value = max(max_value, cur);
    }
    cout << max_value << endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.string, std.conv, std.array, std.algorithm;
import std.uni, std.math, std.container;
import core.bitop, std.datetime;

void main(){
    auto s = readln.chomp;
    auto stack = new Stack!(char)(s.length.to!int);

    foreach(c;s){
        if(c == 'B'){
            if(!stack.isEmpty) stack.pop();
        } else{
            stack.push(c);
        }
    }

    stack.print;
}

class Stack(T){
    private T[] stack;
    private int top, size;

    this(int N){
        stack = new T[](N + 1);
        size = N + 1;
    }

    bool isEmpty(){
        return top == 0;
    }

    bool isFull(){
        return top >= size;
    }

    void push(T stuff){
        ++top;
        if(isFull) throw new Exception("Stack is Full.");
        stack[top] = stuff;
    }

    auto pop(){
        if(isEmpty) throw new Exception("Stack is Empty.");
        auto ret = stack[top];
        --top;
        return ret;
    }

    auto print(){
        foreach(i ; 1 .. top + 1){
            write(stack[i]);
        }
        writeln;
    }
}

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

using namespace std;

int main(){
        int a,b,c,d,e;

        cin >> a >> b;

        c = b-a;

        d = (1+c)*c/2;

        e = d-b;

        printf("%d\n",e);

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
ll N;
int M,Q;
const int MAX_M=1e5;
bool a[MAX_M];
bool flg[MAX_M*14];
void bfs(int s,int n){
	queue<int> que;
	que.push(s);
	flg[s]=true;
	while(!que.empty()){
		int v=que.front();
		que.pop();
		REP(dir,4){
			int v2=-1;
			switch(dir){
				case 0:
				if(v%7>0){
					v2=v-1;
				}
				break;
				case 1:
				if(v%7<6 && v+1<n){
					v2=v+1;
				}
				break;
				case 2:
				if(v>=7){
					v2=v-7;
				}
				break;
				case 3:
				if(v+7<n){
					v2=v+7;
				}
				break;
			}
			if(v!=-1 && !flg[v2] && !a[v2%M]){
				flg[v2]=true;
				que.push(v2);
			}
		}
	}
}
ll cntcon(int n){
	ll ret=0;
	memset(flg,false,sizeof(flg));
//	cout<<"cntcon "<<n<<endl;
	REP(i,n){
//		cout<<i<<" ";
		if(!flg[i] && !a[i%M]){
			ret++;
			bfs(i,n);
		}
	}
//	cout<<endl;
	return ret;
}

int main(){
	cin>>N>>M>>Q;
	REP(i,Q){
		int ta;
		cin>>ta;
		a[ta]=true;
	}
	if(N<M){
		cout<<cntcon(7*N)<<endl;
	}else{
		ll k=N/M;
		ll c1=cntcon(7*M),c2=cntcon(14*M);
		cout<<c1+(k-1)*(c2-c1)+cntcon((int)(7*N-7*k*M+7*M))-c1<<endl;
	}
}

Measured memory_bytes: 1664
import Data.Char

main = do
    w <- getLine
    ans <- countLine $ map toLower w
    putStrLn $ show ans

countLine w = do
    l <- getLine
    if (l=="END_OF_TEXT")
        then return 0
        else do
            let c1 = count w $ words $ map toLower l
            c2 <- countLine w
            return (c1 + c2)


count :: String -> [String] -> Int
count w t = length $ filter (==w) t


Measured memory_bytes: 3784
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	max := 1

	var ans int64
	for i := 0; i < n; i++ {
		a := getNextInt(scanner)
		if i == 1 {
			max = 2
		}
		if a < max {
			continue
		}
		if a == max {
			max = a + 1
		}
		ans += int64((a - 1) / max)
	}
	fmt.Fprintln(writer, ans)
}

func maxint(a, b int) int {
	if a < b {
		return b
	}
	return a
}


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

using namespace std;


class disjoint_set {
    public:
        vector<long long> parent, rank, tree_size;

        disjoint_set();
        disjoint_set(long long size);

        void make_set(long long x);
        long long find_set(long long x);
        void unite(long long x, long long y);
        void resize(long long size);
};


disjoint_set::disjoint_set(long long size)
{
    parent.resize(size);
    rank.resize(size);
    tree_size.resize(size);

    for (long long i = 0; i < size; i++) {
        make_set(i);
    }
}


disjoint_set::disjoint_set()
    : disjoint_set(0)
{
}


void disjoint_set::resize(long long size)
{
    parent.resize(size);
    rank.resize(size);

    for (long long i = 0; i < size; i++) {
        make_set(i);
    }
}


void disjoint_set::make_set(long long x)
{
    parent[x] = x;
    rank[x] = 0;
    tree_size[x] = 1;
}


long long disjoint_set::find_set(long long x)
{
    if (x != parent[x]) {
        parent[x] = find_set(parent[x]);
    }
    return parent[x];
}


void disjoint_set::unite(long long x, long long y)
{
    long long rx, ry;
    rx = find_set(x);
    ry = find_set(y);
    if (rank[rx] == rank[ry]) {
        parent[rx] = ry;
        // when the rank (height) of the trees are the same
        // uniting trees will increase the rank.
        rank[ry]++;
        tree_size[ry] += tree_size[rx];
    } else if (rank[rx] < rank[ry]) {
        // uniting a shorter tree under a higher tree
        // won't change the rank (height) of the united tree.
        parent[rx] = ry;
        tree_size[ry] += tree_size[rx];
    } else {
        parent[ry] = rx;
        tree_size[rx] += tree_size[ry];
    }
}


int main() {
    int N, M, K;
    cin >> N >> M >> K;

    vector<set<int>> friends;
    vector<set<int>> block;
    friends.resize(N + 1);
    block.resize(N + 1);

    disjoint_set sns(N + 1);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        friends[a].insert(b);
        friends[b].insert(a);

        if (sns.find_set(a) != sns.find_set(b))
            sns.unite(a, b);
    }

    for (int i = 0; i < K; i++) {
        int c, d;
        cin >> c >> d;
        block[c].insert(d);
        block[d].insert(c);
    }

    map<int, int> cnt;
    for (int i = 0; i < N + 1; i++)
        cnt[i] = 0;

    for (int i = 1; i < N + 1; i++) {
        cnt[i] += friends[i].size() + 1; // don't forget yourself
        for (auto e : block[i]) {
            if (sns.find_set(i) == sns.find_set(e)) {
                cnt[i]++;
            }
        }
    }

    for (int i = 1; i < N + 1; i++) {
        int set_size = sns.tree_size[sns.find_set(i)];
        cout << set_size - cnt[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 35968
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int count=1;
  for(int i=1;i<n;i++){
    if(s.at(i-1)!=s.at(i)) count++;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // 1 2 10 12 14
    // 1 8 2 4
    // 8 4 2 1
    // 8
    int n, m, ans = 0;
    cin >> n >> m;
    vector<int> v(m);
    vector<int> diff;
    for (int i = 0; i < m; ++i) cin >> v[i];
    if (n >= m) { cout << 0 << '\n'; return 0; }
    sort(v.begin(), v.end());
    for (int i = 0; i + 1 < m; ++i) diff.push_back(v[i+1]-v[i]);
    sort(diff.rbegin(), diff.rend());
    int sum = 0;
    for (int i = 0; i < n - 1 && i < diff.size(); ++i) sum += diff[i];
    cout << v[m-1] - v[0] - sum << '\n';
    return 0;
}



Measured memory_bytes: 1276
n = int(input())
ts, tt = list(input().split())
s = [ts]
t = [int(tt)]
for i in range(1, n):
    ts, tt = list(input().split())
    s.append(ts)
    t.append(t[i-1] + int(tt))
x = input()

ans = 0
for i in range(n-1):
    if s[i] == x:
        ans = t[n-1] - t[i]
        break

print(ans)


Measured memory_bytes: 38472
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(ll (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

ll mod = 1e9+7;

ll pow_mod(ll x, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n,k;
    cin >> n  >> k;
    ll ans = 0;
    vector<ll> vec(k+1,0);
    for(ll i = k;i > 0; i--){
        vec[i] = pow_mod(k/i,n);

        ll sum = 0;
        for(ll j = 2; j*i <= k; j++){
            sum = (sum + vec[j*i]) % mod;
        }
        vec[i] = (vec[i] - sum + mod) % mod;
    }

    rep(i,k+1){
        ll tmp = (i * vec[i]) % mod;
        ans = (ans+tmp) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4032
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define all(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int x ;
  cin >> x ;
  
  if(x<1200){
    cout <<"ABC"<<endl ;
  }
  else if(x>=1200 && x<2800){
    cout <<"ARC"<<endl ;
  }
  else{
    cout <<"AGC"<<endl ;
  }
    return 0 ;
}


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

using namespace std;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vint a(3);
    REP(i,3) cin >> a[i];
    sort(ALL(a));
    if((a[0]==a[1]&&a[1]!=a[2])||(a[0]!=a[1]&&a[1]==a[2])){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    A, B, X = map(int, input().split())

    s1 = X / (A * A) * A
    h1 = (2 * s1) / B
    ans1 = math.degrees(math.atan2(B, h1))

    s2 = A * B - s1
    h2 = (2 * s2) / A
    ans2 = math.degrees(math.atan2(h2, A))

    if X / (A * A) <= B / 2:
        print(ans1)
    else:
        print(ans2)


main()


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const Int max_N = 4005;

Int N,K;

Int fact[max_N];
Int invfact[max_N];
Int inv[max_N];

void init(void) {
    fact[0] = fact[1] = 1;
    invfact[0] = invfact[1] = 1;
    inv[0] = inv[1] = 1;

    for(int i = 2;i < max_N;i++) {
        fact[i] = fact[i-1]*i%MOD;
        inv[i] = MOD - (MOD/i)*inv[MOD%i] % MOD;
        invfact[i] = inv[i]*invfact[i-1]%MOD;
    }

    return;
}

Int comb(Int n,Int k) {
    if(n < k)
        return 0;

    return (fact[n]*invfact[n-k]%MOD)*invfact[k]%MOD;
}

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

    init();
    for(int i = 1;i <= K;i++) {
        cout<<comb(N-K+1,i)*comb(K-1,i-1)%MOD<<endl;
    }

    return 0;
}


Measured memory_bytes: 512
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
	return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
	return a * a;
}

template <typename T>
T gcd(T a, T b) {
	if (a > b) return gcd(b, a);
	return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
	if (n == 0) return 1;
	if (n == 1) return b /* % MOD */;
	if (n % 2 == 0) {
		return mypow(b * b /* % MOD */, n / 2);
	}
	else {
		return mypow(b, n - 1) * b /* % MOD */;
	}
}

ll pcnt(ll b) {
	return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
int main() {
	ll N;
	cin >> N;
	map<ll,ll>  sum_cnt;
	sum_cnt[0] = 1;
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		ll A;
		cin >> A;
		sum += A;
		if (sum_cnt.find(sum) != sum_cnt.end()) {
			sum_cnt[sum]++;
		}
		else {
			sum_cnt[sum] = 1;
		}
	}
	ll ans = 0;
	for (auto itr = sum_cnt.begin(); itr != sum_cnt.end(); itr++) {
		ll num = itr->second;
		if (num > 1) {
			ans += num * (num - 1) / 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int X = in.nextInt();
			int time = 0;
			int ans = 0;
			do {
				time++;
				ans = (ans + time);
			} while (ans < X);
			out.println(time);
		}
	}

	static boolean permutation_2(String s, String t) {
		if (s.length() != t.length()) {
			return false;
		}

		int[] letters = new int[256];

		char[] s_array = s.toCharArray();
		for (char c : s_array) {
			letters[c]++;
		}

		for (int i = 0; i < t.length(); i++) {
			int c = (int) t.charAt(i);
			if (--letters[c] < 0) {
				return false;
			}
		}
		return true;
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


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


int main(){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int dp[n]={};
	dp[0]=0;dp[1]=abs(arr[0]-arr[1]);
	for(int i=2;i<n;i++)
	{
	
			dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i]-arr[i-1]));
		
	}
	cout<<dp[n-1]<<endl;
}

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

using namespace std;

typedef long long ll;
#define SWAP(x,y,z) {if ( y > z ) swap(y,z); if ( x > y ) swap(x,y); if (y > z) swap(y,z);}


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

    int k,s;
    int t = 0;
    cin >> k >> s;
    for ( int x = 0; x <= k; x++ )
    {
        for ( int y = 0; y <= k; y++ )
        {
            int z = s-x-y;
            if ( z >= 0 && z <= k) t++;
        }
    }

    cout <<t;
    // 274751WM
}


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

const int N = 1e5 + 100, inF = N;

int n, k, ans, out[N], dis[N];
bool mark[N];
vector<int> in[N];

void dfs(int v, bool change = false) {
	mark[v] = change;
	for (int u: in[v]) 
		if(mark[u] == false) {
			dis[u] = dis[v] + 1;
			dfs(u, change);
		}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;
	cin >> out[0];
	ans += (out[0] != 1);
	
	for (int i = 1; i < n; i++) {
		cin >> out[i];
		in[--out[i]].push_back(i);
	}
	dfs(0);
	vector<int> vec(n);
	iota(vec.begin(), vec.end(), 0);
	sort(vec.begin(), vec.end(), [](int a, int b) {
		return dis[a] > dis[b];
	});
	for (int u: vec) {
		if(mark[u] || dis[u] <= k)
			continue;
		for (int i = 0; i < k - 1; i++)
			u = out[u];
		ans++;
		dfs(u, true);
	}
	cout << ans;
	return 0;
}////

Measured memory_bytes: 11648
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	line = input[0].split(" ");
	tmp = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var H = parseInt(line[0], 10);
	var W = parseInt(line[1], 10);
	var h = parseInt(tmp[0], 10);
	var w = parseInt(tmp[1], 10);
	//console.log(H,W,h,w);
	ans = H*W-(h*W+H*w-h*w)
	
	
	
	
	//出力
    console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
 
  string s;
  cin >> s;
  rep(i, s.length()) {
    cout << 'x';
  }
  cout << endl;
  return 0;
}


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

ans = 0

for i in range(N) :
    if B[i] < A[i] :
        ans += B[i]
    elif A[i] <= B[i] < A[i]+A[i+1] :
        ans += B[i]
        A[i+1] -= B[i]-A[i]
    else :
        ans += A[i]+A[i+1]
        A[i] = 0
        A[i+1] = 0
print(ans)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;

int a, b, c;
string s;

int main(){
  cin >> a >> b >> c;
  bool flag = false;
  for(int i = 1; i < 10000; i++){
    if(b <= a * i && a*i <= c){
      flag = true;
    }
  }
  if(flag) cout << "OK"<<endl;
  else cout <<"NG"<<endl;
}



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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int n,m,v,p;
vector<LL> A;

bool P(const int i, int v)
{
    if (n-i <= p)
        return true;
    const LL x = A[i]+m;
    int j = n - min(p,v);
    if (x < A[n-p])
        return false;
    v -= n-(j+1)+1;
    v -= i;
    if (v > 0) {
        while (A[j] > x)
            j--;
        const int y = j-i;
        LL vol = x*y;
        FOR(k,i+1,j+1)
            vol -= A[k];
        return vol >= 1LL * v*m;
    }
    return true;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> n >> m >> v >> p) {
        A.resize(n);
        FOR(i,0,n)
            cin >> A[i];
        sort(ALL(A));
        int lo = 0, hi = n-p;
        while (lo < hi) {
            const int mid = (lo+hi)/2;
            if (P(mid,v))
                hi = mid;
            else
                lo = mid+1;
        }
        cout << n-lo << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compare_char1(const void *a, const void *b)
{
    return *(char*)a > *(char*)b;
}

int compare_char2(const void *a, const void *b)
{
    return *(char*)a < *(char*)b;
}

int main(int argc, char *argv[])
{
    char s[101] = {};
    char t[101] = {};
    scanf("%s", s);
    scanf("%s", t);
    qsort(s, strlen(s), sizeof(char), compare_char1);
    qsort(t, strlen(t), sizeof(char), compare_char2);
    printf("%s\n", strcmp(s, t) < 0 ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	n=(n+1)/2;
	YN(m<=n);
	return 0;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"3 1"# => r#"2"#,
r#"1 2"# => r#"3"#,
r#"2 3"# => r#"1"#,
}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        a: usize,
        b: usize,
    }

    let ans:Vec<usize> = (1..4).filter(|&x| x != a && x != b).collect();

    ans[0].to_string()
}

Measured memory_bytes: 4352
#include<iostream>
using namespace::std;
int main() {
  int A,B;
  cin >> A >> B;
  if (A >= 0 && A <= 5){
    cout << 0 << endl;
  }else if(A >= 6 && A <= 12){
    cout << B/2 << endl;
  }else if(A > 12 && A <= 100){
    cout << B << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long ll;
#define pb push_back
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
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 f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e9 + 100 ;
int mod = MOD;
int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int power(int a, int b){
	if(b < 0)return 0;
	int re = 1;
	while(b){
		if(b&1){
			re = mul(re, a);
		}
		a = mul(a, a);
		b >>= 1;
	}
	return re;
}
int const N = 100000 + 5;
int fact[N], inverse[N];
void FAC(){
 	fact[0] = 1;
	for(int x = 1; x< N; x++){
		fact[x] = mul(fact[x-1], x);
	}
	inverse[N-1] = power(fact[N-1], mod -2);
	for(int x = N-2; x>= 0; x--){
		inverse[x] = mul(x + 1, inverse[x+1]);
	}

 }

int ncr(int a, int b){
	if(a < b)return 0;
	return mul(fact[a], mul(inverse[a-b], inverse[b]));
}


/******************************************************/
struct dealer{
    int l, r, c;
    bool operator < (struct dealer b){
        if(b.l != l)return l < b.l;
        if(b.r != r)return r > b.r;
        return c < b.c;
    }
};
void solve(){
   int a , b ,m;
   cin >> a >> b >> m;
   vector<int> v1(a), v2(b);
   for(int &a1: v1)cin >> a1;
   for(int &a1 : v2)cin >> a1;
   int ans = 1e9;
   for(int x =0; x<m; x++){
   	int i, j, c;
   	cin >> i >> j >> c;
   	ans = min(ans, v1[i-1] + v2[j-1] - c);
   }
   sort(ALL(v1));
   sort(ALL(v2));
   ans = min(ans, v1[0] + v2[0]);
   cout << ans ;
}


/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}

}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	long long N, K;

	cin >> N >> K;

	int d = 0;
	for(long long x = K; x>0; x/=2){
		d++;
	}

	long long c[d], A[N];
	for(int i=0; i < d ; i++){
		c[i] = 0;
	}

	for(long long ll = 0; ll < N; ll++){
		cin >> A[ll];
		for(long long i = 0; i<d; i++){
			if((A[ll] & 1ll << i) != 0){
				c[i]++;
			}
		}
	 }

	long long X = 0;
	for(int i = d-1; i>=0; i--){
		if((c[i] < (N+1)/2) && ((X|1ll<<i) <= K)){
			X |= (1ll<<i);
		}
	}

	long long ans = 0;
	for(long long ll = 0; ll < N; ll++){
		ans += X ^ A[ll];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024