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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

map<ll, ll> calc(vector<ll>& s) {
    map<ll, ll> ret;
    rep(i, s.size()-1) {
        s[i+1] += s[i];
    }
    rep(i, s.size()) {
        rep(j, i) {
            ret[s[i]-s[j]]++;
        }
    }
    return ret;
}

int main() {
    int n, m;
    while (cin >> n >> m) {
        if (n == 0 && m == 0) break;
        vector<ll> s[2];
        s[0].assign(n+1, 0LL);
        s[1].assign(m+1, 0LL);
        rep(i, n) {
            cin >> s[0][i + 1];
        }
        rep(i, m) {
            cin >> s[1][i + 1];
        }
        auto x = calc(s[0]), y = calc(s[1]);
        ll ans = 0LL;
        for(auto& p : x) {
            ans += p.se * y[p.fi];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 44824
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,C = list(map(int, input().split()))
stc = [tuple(map(int, input().split())) for _ in range(n)]
T = max(item[1] for item in stc)
l = [[False]*(T+1) for _ in range(C)]
for s,t,c in stc:
    for i in range(s-1,t):
        l[c-1][i] = True
ans = max(sum(l[c][i] for c in range(C)) for i in range(T+1))
print(ans)

Measured memory_bytes: 112188
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int m_0 = S.at(5)- '0';
  int m_1 = S.at(6)- '0';
  if (m_0 == 0) {
    if (m_1 <= 4) {
      cout << "Heisei" << endl;
    }
    else if (m_1 >= 5) {
      cout << "TBD" << endl;
    }
  }
  else cout << "TBD" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include<limits>
#include<stack>
#include<queue>
#include<math.h>
#include <iomanip>

#define rep(i,n) for(auto i=0;i<(n);i++)
#define all(vs) (vs).begin(),(vs).end()
#define roundup(A,B) (A)/(B)+(A%B==0?0:1)
#define maximize(A,B) A=max((A),(B))
#define read(type,name) type name;cin>>name
#define ll long long

using namespace std;
template<typename T>
T MAX() { return numeric_limits<T>::max(); }

//二次元テーブル
template<typename T>
class Table {
public:
	Table(int height, int width, T value) {
		if (width < 0)throw out_of_range("Width should be >=0");
		if (height < 0)throw out_of_range("Height should be >=0");
		this->wid = width;
		this->hgt = height;
		vs = new T[width * height];
		for (auto i = 0; i < width * height; i++)vs[i] = value;
	}
	Table(const Table& table) {
		hgt = table.hgt;
		wid = table.wid;
		vs = new T[hgt * wid];
		for (size_t i = 0; i < table.size(); i++) {
			vs[i] = table.vs[i];
		}
	}
	Table(Table&& table) {
		hgt = table.hgt;
		wid = table.wid;
		swap(vs, table.vs);
	}
	~Table() {
		if (vs)delete[] vs;
	}
	Table& operator=(const Table& table) {
		if (table == *this)return *this;
		this->wid = table.wid;
		this->hgt = table.hgt;
		if (vs)delete[] vs;
		vs = new T[wid * hgt];
		for (auto i = 0; i < wid * hgt; i++)vs[i] = table.vs[i];
	}
	Table& operator=(Table&& table) {
		wid = table.wid;
		hgt = table.hgt;
		swap(vs, table.vs);
	}
	inline T& at(int y, int x) {
		if (wid > x)throw out_of_range("x>width.");
		if (hgt > y)throw out_of_range("y>height.");
		return vs[x + y * wid];
	}
	int size()const { return wid * hgt; }
	int width()const { return wid; };
	int height()const { return hgt; };
	T* begin() { return vs; }
	T* end() { return vs + wid * hgt; }
	T& operator()(int y, int x) { return vs[x + y * wid]; }
	const T& operator()(int y, int x)const { return vs[x + y * wid]; }
private:
	int wid, hgt;
	T* vs;
};
//周期的に変化する。ループは剰余の環でうまく表せる。
void A() {
	string weather[]{ "Sunny","Cloudy","Rainy" };
	read(string, s);
	for (auto i = 0; i < 3; i++) {
		if (weather[i] == s) {
			cout << weather[(i + 1) % 3] << endl;
			return;
		}
	}
}
//全てが満たさねばならない条件の検査は、
//間違いを探す方が簡潔になる。
void B() {
	read(string, s);
	for (auto i = 0; i < s.length(); i++) {
		if (i % 2 == 0 && s[i] == 'L') {
			cout << "No" << endl;
			return;
		}
		if (i % 2 != 0 && s[i] == 'R') {
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;
}
// 正解数だけペナルティを免れることができる。
// 問題数-正解数の減点がKを超えるかどうかで判定する。
void C() {
	read(int, N);
	read(int, K);
	read(int, Q);
	auto score = vector<int>(N, -Q + K);
	int win;
	for (auto i = 0; i < Q; i++) {
		cin >> win;
		score[win - 1]++;
	}
	for (auto s : score) cout << (s > 0 ? "Yes" : "No") << endl;
}
void D() {}
void E() {}
void F() {}

int main(){
	C();
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 1e6 + 10;

int Begin[N], Next[N], to[N], e = 1;

void add(int u, int v){
	to[++e] = v, Next[e] = Begin[u], Begin[u] = e;
	to[++e] = u, Next[e] = Begin[v], Begin[v] = e;
}

int cha[N], chb[N], ans[N], n;
bool vis[N];

void DFS(int o){
	for(int &i = Begin[o]; i; i = Next[i]){
		int u = to[i];
		if(vis[i]) continue;
		vis[i] = vis[i ^ 1] = true;
		if(u == o + n) ans[o] = 1;
		else if(u == o - n) ans[u] = -1;
		DFS(u);
	}
}

int main(){

	scanf("%d", &n);
	For(i, 1, n){
		int x;
		scanf("%d", &x);
		if(x > 0) ++cha[x], add(i, x);
		else add(0, i);
	}
	For(i, 1, n){
		int x;
		scanf("%d", &x);
		if(x > 0) ++chb[x], add(n + i, n + x);
		else add(0, n + i);
	}

	For(i, 1, n) 
		if(cha[i] % 2 != chb[i] % 2){
			puts("IMPOSSIBLE");
			return 0;
		}
		else if(cha[i] % 2 == 0) add(i, i + n);

	puts("POSSIBLE");
	DFS(0);
	For(i, 1, n) printf("%d%c", ans[i], i == n ? '\n' : ' ');

	return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
using ll = long long;

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

bool isprime(int i){
    if(i == 1){
        return false;
    }
    for(int j = 2; j*j <= i; j++){
        if(i % j == 0) return false;//割り切れる。
    }
    return true;
}

int main(){
    int q;
    cin >> q;
    int l=0,r=0;
    vector<int> query;
    query.resize(100001);

    reps(i,1,100001){
        query[i] = query[i-1];
        if(isprime(i) && isprime((i+1)/2)){
            query[i]++;
        }
    }

    // for(int i = 0; i < 100; i++){
    //     cout <<  i <<" "  << query[i] << endl;
    // }

    // cout << "----------" << endl;

    rep(i,q){
        cin >> l >> r;
        cout << query[r] - query[l-1] << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef vector<ll> vll;

#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define fin(ans) cout << (ans) << endl;

template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}

template <typename T>
void Sort(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b));
  }
}

void Main()
{
  ll p, q, r; cin >> p >> q >> r;
  ll a = p + q, b = p + r,c = q + r;
  fin(min(a, min(b, c)))
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

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

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();

        int r = b / a;
        System.out.println(Math.min(b /a, c));

    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 22228
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	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 main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	g := make([][]int, n)

	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		u := getNextInt(scanner)
		k := getNextInt(scanner)
		u--
		for ii := 0; ii < k; ii++ {
			v := getNextInt(scanner)
			v--
			g[u][v] = 1
		}
		fmt.Fprintln(writer, joinint(g[u], " "))
	}

	writer.Flush()
}

func joinint(a []int, sep string) string {
	n := len(a)
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		ss[i] = fmt.Sprintf("%d", a[i])
	}
	return strings.Join(ss, sep)
}



Measured memory_bytes: 1496
import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n];
        for (int i=0;i<n;i++)a[i]=sc.nextInt();
        long ans = 0;
        for (int i=1;i<n;i++){
            int need = a[i-1]+a[i]-x;
            if (need>0){
                ans+=need;
                if (a[i]>=need){
                    a[i]-=need;
                }else {
                    a[i-1]-=need-a[i];
                    a[i]=0;
                }
            }
        }
        System.out.println(ans);
    }
}


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

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

  long long ans=0LL; int blk=0, n=s.size();
  for(int i=n-1; i>=0; --i){
    if(s[i]=='B'){
      ans+=n-1-i-blk;
      ++blk;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 640
# ABC065c
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
MOD = 10**9+7

if not (n == m or n == m-1 or n == m+1):
    print(0)
    exit(0)


if n == m:
    print(math.factorial(n) % MOD * math.factorial(n) % MOD * 2 % MOD)
    exit(0)
print(math.factorial(n) % MOD*math.factorial(m) % MOD)


Measured memory_bytes: 4096
#!/usr/bin/python
# -*- coding: utf-8 -*-

def main():
    # 入力
    N = int(raw_input())

    inp = []
    for x in range(N):
        input_list = raw_input()
        inp.append(input_list)

    # 文字列置換
    for x in inp:
        replaced = x.replace("Hoshino", "Hoshina")
        print(replaced)

if __name__=='__main__':
    main()

Measured memory_bytes: 4196
word = input()
ans = 0

for i in range(len(word)):
  tmp = 0
  for j in range(len(word)-i):
    if word[j+i]=="A" or word[j+i]=="T" or word[j+i]=="C" or word[j+i]=="G":
      tmp += 1
    else: break
  if tmp>ans: ans = tmp

print(ans)

Measured memory_bytes: 3060
MOD = 1000000007

def prime_fact(n)
  #素因数分解
  i = 2
  while i ** 2 <= n do
    cnt = 0
    while n % i == 0
      cnt += 1
      n /= i
    end

    @map[i] = cnt if cnt > 0 && (@map[i] == nil || @map[i] < cnt)
    i += 1
  end

  @map[n] = 1 if n != 1 && @map[n] == nil
end

def power(n, a, m)
  res = 1

  if a > 0
    res = power(n, a / 2, m)
    if a % 2 == 0
      res = (res * res)
    else
      res = ((res * res) % m * n)
    end
  end
  
  return res
end

def main
  n = gets.chomp.to_i
  a = gets.chomp.split.map(&:to_i)

  @map = {}

  a.each do |v|
    prime_fact(v)
  end

  gcd = 1
  @map.map { |v, k|
    gcd *= power(v, k, MOD)
  }

  ans = 0
  a.each do |v|
    ans += (gcd / v)
  end

  puts ans % MOD
end

main

Measured memory_bytes: 191044
#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)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    int odd = n/2;
    int even = n/2;
    if(n%2==1) odd++;
    cout<<odd*even<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++ ){
			a[i] = scan.nextInt();
		}
		
		int length = max(a) - min(a);
		
		System.out.println(length);

	}
	public static int max(int[] a){
		int max=0;
		int kari=0;
		
		for( int hoge : a){
			if(hoge > kari) {
				max =hoge;
				kari = hoge;
			}
		}
		
		return max;
	}
	public static int min(int[] a){
		int min=0;
		int kari=1000;
		
		for( int hoge : a){
			if(hoge < kari){
				min =hoge;
				kari = hoge;
			}
		}
		
		return min;
	}

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 100;


int main(){
  int N, x;
  string y;
  cin >> N;
  pair<pair<string, int>, int> p[MAX];

  rep(i, N){
    cin >> y >> x;
    x = x * (-1);
    p[i] = make_pair(make_pair(y, x), i+1);
  }
  sort(p, p+N);

  rep(i, N){
    cout << p[i].second << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
const ll MOD = 1000000007;

ll sc[203][203];
ll dp[400][200][200];
map<pair<ll, ll>, ll> bef, aft;

void chmax(ll& x, ll y) {
	x = max(x, y);
}

int main() {
	for (ll i = 0;i < 203;i++)for (ll j = 0;j < 203;j++)sc[i][j] = INT64_MIN / 5;
	ll H, W;
	cin >> H >> W;
	for (ll i = 0;i < H;i++) {
		for (ll j = 0;j < W;j++) {
			cin >> sc[i][j];
		}
	}

	dp[0][0][0] = sc[0][0];

	for (int t = 0;t < H + W;t++) {
		for (int e8 = 0;e8 <= t;e8++) {
			if (e8 >= H)continue;
			if (t - e8 >= W)continue;
			for (int sq = 0;sq <= t;sq++) {
			if (sq >= H)continue;
			if (t - sq >= W)continue;
				if (e8 != sq) {
					chmax(dp[t + 1][e8][sq], dp[t][e8][sq] + sc[e8][t - e8 + 1] + sc[sq][t - sq + 1]);
					chmax(dp[t + 1][e8 + 1][sq + 1], dp[t][e8][sq] + sc[e8 + 1][t - e8] + sc[sq + 1][t - sq]);
				}
				else {
					chmax(dp[t + 1][e8][sq], dp[t][e8][sq] + sc[e8][t - e8 + 1]);
					chmax(dp[t + 1][e8 + 1][sq + 1], dp[t][e8][sq] + sc[e8 + 1][t - e8]);
				}

				if (e8 + 1 != sq) {
					chmax(dp[t + 1][e8 + 1][sq], dp[t][e8][sq] + sc[e8 + 1][t - e8] + sc[sq][t - sq + 1]);
				}
				else {
					chmax(dp[t + 1][e8 + 1][sq], dp[t][e8][sq] + sc[e8 + 1][t - e8]);
				}

				if (sq + 1 != e8) {
					chmax(dp[t + 1][e8][sq + 1], dp[t][e8][sq] + sc[e8][t - e8 + 1] + sc[sq + 1][t - sq]);
				}
				else {
					chmax(dp[t + 1][e8][sq + 1], dp[t][e8][sq] + sc[e8][t - e8 + 1]);
				}
			}
		}
	}
	cout << dp[H + W - 2][H - 1][H - 1] << endl;
}

Measured memory_bytes: 123520
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repn(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define lb lower_bound
#define mp make_pair
#define ite iterator
#define max2(x, y) ((x) > (y)) ? (x) : (y)
#define max3(x,y,z) max2((x), max2((y),(z)))
#define max4(v,w,x,y) max2(max2((v),(w)), max2((x),(y)))
#define min2(x, y) ((x) > (y)) ? (y) : (x)
#define min3(x,y,z) min2((x), min2((y),(z)))
#define min4(v,w,x,y) min2(min2((v),(w)), min2((x),(y)))
#define ul unsigned long
#define ull unsigned long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second

template<typename T>
bool elem(set<T> st, T val){
	return (st.find(val) != st.end());
}

template<typename T>
void printv(vector<T> vt){
    rep(i, vt.size() - 1)
        cout << vt[i] << " ";
    cout << vt[vt.size() - 1] << endl;
}

typedef vector<int> vint;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef pair<int, int> pii;


int ans[51];
int main(void){
    int n;
    rep(i, 51) ans[i] = -1;
    while(cin >> n){
        int ret = 0;
        if(ans[n] >= 0){
            cout << ans[n] << endl;
            continue;
        }
        rep(a,10){
            rep(b,10){
                rep(c,10){
                    rep(d,10)
                        if(a+b+c+d==n) ret++;
                }
            }
        }
        cout << ret << endl;
        ans[n] = ret;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979
using ll = long long;
using P = pair<int,int>;

ll divisor=1e9+7;
int main(){
	int n;
	cin>>n;
	ll a[n];
	ll mx=0,smx=0;
	rep(i,n){
		cin>>a[i];
	}
	ll fr[n]={};
	ll ba[n]={};
	rep(i,n){
		if(i+a[i]<n){
			fr[i+a[i]]++;
		}
		if(i-a[i]>=0){
			ba[i-a[i]]++;
		}
	}
	ll sum=0;
	rep(i,n){
		sum+=fr[i]*ba[i];
	}
	puts(sum);
}

Measured memory_bytes: 8324
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var sum int // nの各桁の和
	for x := n; x > 0; {
		sum += x % 10
		x /= 10
	}

	if n%sum == 0 {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <bits/stdc++.h> 
        #define ll long long
        #define F first
        #define S second
        #define FF first.first
        #define FS first.second
        #define pb push_back
        using namespace std;
        const ll N=1000006, INF=1e10, MOD=998244353;
             
        ll n, q=1, a[N], b[4][N], c[N], f[N], m, o=3, h, w, mx, mn, ans, Ans;
        string s, S;
        vector <ll> v[N];
        pair<ll, ll> p[N];
         
         
        main(){ios_base::sync_with_stdio(false), cin.tie(0);
                            
            cin>>n>>s;
            for(int i=0; i<n; i++){
            	if(s[i]=='R')a[i+1]=1;
            	else if(s[i]=='G')a[i+1]=2;
            	else a[i+1]=3;
        	}
        	for (int i=n; i>=1; i--){
        		b[1][i]=b[1][i+1];
        		b[2][i]=b[2][i+1];
        		b[3][i]=b[3][i+1];
        		b[a[i]][i]++;
        	}
        	for (int i=1; i<=n; i++){
        		for (int j=i+1; j<n; j++){
        			if(a[i]==a[j])continue;
        			if(j+j-i<=n&&a[j+j-i]!=a[i]&&a[j+j-i]!=a[j])ans--;
        			ans+=b[6-a[i]-a[j]][j+1];
        		}
        	}
        	cout<<ans;
        }

Measured memory_bytes: 27188
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N = ni()
s = ns()

mod = 10 ** 9 + 7
dp = [1] * N

for i, ss in enumerate(s):
    sdp = []
    ans = 0
    for d in dp:
        ans = (ans + d) % mod
        sdp.append(ans)
    dp = []
    if ss == "<":
        for j in range(N-1-i):
            dp.append(sdp[j])
    else:
        for j in range(N-1-i):
            dp.append((sdp[N-1-i] - sdp[j]) % mod)
    # print(dp)
print(dp[0])


Measured memory_bytes: 75392
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

constexpr ll mod = 1e9+7;
ll mpow(ll a,ll n){
    ll ans=1,x=a;
    while(n){
        if(n&1) ans=ans*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return ans;
}

ll nCr(ll n,ll r){
    ll res=1;
    for(int i=1;i<=r;++i){
        res=res*i%mod;
    }
    res=mpow(res,mod-2);
    for(int i=n;i>n-r;--i){
        res=res*i%mod;
    }
    return res;
}

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    
    ll ans=mpow(2,n);
    ans--;
    cout<<(ans-nCr(n,a)-nCr(n,b)+2*mod)%mod<<endl;
}


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

using namespace std;

const int maxn = 200010;

char s[maxn * 4];

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	scanf("%s", s);
	int l = 0;
	bool rev = false;
	for(int i = 0; i < min(k, 2*n); ++i) {
		if(!rev) {
			if(s[l]=='A') s[l]='B';
			else s[n+l++]='B', rev=true;
		} else {
			if(s[l]=='B') s[l]='A';
			else s[n+l++]='A', rev=false;
		}
	}
	if(rev) for(char*p=s+l;*p;++p)*p^='A'^'B';
	if(k > n * 2 && n % 2 == 1 && k % 2 == 1) s[l] ^= 'A'^'B';
	puts(s+l);
	return 0;
}


Measured memory_bytes: 896
/* author:hellojim */
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
ll x,y;
ll mx[4],mn[4];
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n;
	cin>>n;
	rep(i,4)
	{
		mx[i]=-1e18;
		mn[i]=1e18;
	 } 
	rep(i,n)
	{
		cin>>x>>y;
		mx[0]=max(mx[0],x+y);
		mx[1]=max(mx[1],x-y);
		mx[2]=max(mx[2],y-x);
		mx[3]=max(mx[3],-x-y);
		mn[0]=min(mn[0],x+y);
		mn[1]=min(mn[1],x-y);
		mn[2]=min(mn[2],y-x);
		mn[3]=min(mn[3],-x-y);
	}
	ll ans=-1e18;
	rep(i,4)
	{
		ans=max(ans,mx[i]-mn[i]);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3612
#author : dokueki

import sys


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n = int(sys.stdin.readline())
    print((n//500)*1000+(((n-(n//500)*500))//5)*5)


if __name__ == "__main__":
    #IOE()
    main()


Measured memory_bytes: 38692
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  unsigned ll x;
  cin>>x;
  unsigned ll y = 100;
  int c=1;
  while(true) {
    y *= 1.01;
    if(y>=x)
      break;
    c++;
  }
  cout << c << endl;
  return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
bool compare(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.second > b.second); 
}
int findmax(int arr[], int n){
	int curr_max = -1;
	for(int i=0;i<n;i++){
		curr_max = max(curr_max, arr[i]);
		}
	return curr_max;
	}
int findmin(int arr[], int n){
	int curr_max = INT_MAX;
	for(int i=0;i<n;i++){
		curr_max = min(curr_max, arr[i]);
		}
	return curr_max;
	}
bool help(int arr[], int mid, int n, int c){
	int last_pos = arr[0];
	int cows = 1;
	for(int i=1;i<n;i++){
		if(abs(arr[i]-last_pos) >= mid){
			last_pos = arr[i];
			if(++cows == c)
				return true;
			last_pos = arr[i];
		}
	}
	return false;
}
int main() 
{ 
	ll t;
	t=1;
	while(t--){
	ll n,c;
	cin>>n>>c;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<ll> dp(n, INT_MAX);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<=i+c and j<n;j++){
			dp[j]=min(dp[j], dp[i]+abs(a[j]-a[i]));
		}
	}
	cout<<dp[n-1]<<endl;		
	// your code goes here
	return 0;
	}
} 


Measured memory_bytes: 1792
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t N, A, B;
	uint64_t chunk_size, chunk_num, chunk_left;
	uint64_t answer;
	if (scanf("%" SCNu64 "%" SCNu64 "%" SCNu64, &N, &A, &B) != 3) return 1;
	chunk_size = A + B;
	if (chunk_size <= 0) {
		puts("uso tuki !!!!!");
		return 1;
	}
	chunk_num = N / chunk_size;
	chunk_left = N % chunk_size;

	answer = A * chunk_num;
	answer += chunk_left >= A ? A : chunk_left;
	printf("%" PRIu64 "\n", answer);
	return 0;
}


Measured memory_bytes: 128
import numpy as np

n = int(input())
a = np.array(input().split(), dtype=np.int32)
b = np.array(input().split(), dtype=np.int32)

ans = 0
mod = 1
for k in range(30):
    mod *= 2
    t = mod // 2
    cnt = 0
    bb = np.sort(b % mod)
    aa = a % mod
    l1, r1, l2, r2 = (np.searchsorted(bb, v - aa).sum() for v in (t, 2*t, 3*t, 4*t))
    cnt += r1 - l1
    cnt += r2 - l2

    if cnt % 2:
        ans += t

print(ans)


Measured memory_bytes: 35884
//1
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a,b,k;
    cin >> a >> b >> k;
    for(int i = 0;i < k;i++){
        b += a = a/2;
        swap(a, b);
    }
    if(k%2)swap(a,b);
    cout << a << " " << b << endl;
}

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

using namespace std;

int
main(int argc, char* argv[]) {
  int n, i;
  long long _a;
  vector<long long> a;

  cin >> n;

  for(i=0; i<n; i++) {
    cin >> _a;
    a.push_back(_a);
  }
  sort(a.begin(), a.end());

  long long int b = (a.back() - *a.begin());
  cout << b << endl;

  return 0;
}


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

int main(){
  int n, y=1; cin >>n;
  double x=0; cout <<fixed <<setprecision(10);
  vector<int>a(n); vector<int>b(n);
  for(int i=0; i<n; i++){cin >>a[i] >>b[i];}

  for(int i=0; i<n-1; i++){
  for(int j=i+1; j<n; j++)
  {x+=hypot((a[i]-a[j]),(b[i]-b[j]));}
  }

  cout <<2*x/n;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;
    bool q = false;
    for (int i = int(s.size() - t.size()); i >= 0; i--) {
        if (!q) {
            bool b = true;
            for (int j = 0; j < int(t.size()); j++) {
                if (!(s[i+j] == t[j] || s[i+j] == '?')) {
                    b = false;
                    break;
                }
            }
            if (b) {
                int j = 0;
                for (; j < int(t.size()); j++) {
                    s[i+j] = t[j];
                }
                for (; i+j < int(s.size()); j++) {
                    if (s[i+j] == '?') s[i+j] = 'a';
                }
                q = true;
            }
        } else {
            if (s[i] == '?') s[i] = 'a';
        }
    }
    if (q) {
        cout << s << endl;
    } else {
        cout << "UNRESTORABLE" << endl;
    }
}


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

int main ()
{
    int	N;
    while (cin >> N, N) {
	int n1, n2;
        int a =	0, b = 0;
        for (int i = 0; i < N; i++) {
            cin >> n1 >> n2;
            if (n1 > n2) a += n1 + n2;
            else if (n1 < n2) b	+= n1 +	n2;
            else {
                a += n1;
                b += n2;
            }
        }
        cout <<	a << " " << b << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
long long int mod = 1e9;

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

void solve(int n, int v, int w) {
  while(v != w) {
    if(v > w) {
      v = (v+n-2) / n;
    }else{
      w = (w+n-2) / n;
    }
  }
  cout << v << endl;
}

int main(){
  int n; cin >> n;
  int q; cin >> q;
  int v, w;
  for(int i=0; i<q; i++) {
    cin >> v >> w;
    if(n == 1) {
      cout << min(v, w) << endl;
      continue;
    }
    solve(n, v, w);
  }
  return 0;
}


// EOF


Measured memory_bytes: 1280
N, Y = map(int, input().split())
x, y, z = [-1]*3
for i in range(N+1):
  for j in range(N+1-i):
    k = N - i - j
    if 10000*i + 5000*j + 1000*k == Y:
      x, y, z = i, j, k
      break
  else :
    continue
  break
print("{0} {1} {2}".format(x, y, z))

Measured memory_bytes: 9196
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

do {

	c -= b;
	if(c <= 0)break;
	a -= d;
}while(a >0);

System.out.println(a>0? "Yes" : "No");
		scan.close();

	}

}


Measured memory_bytes: 27072
n=int(raw_input())
ab=[map(int,raw_input().split()) for _ in xrange(n)]
cnt=0
for i in xrange(n-1,-1,-1):
    a,b=ab[i][0],ab[i][1]
    if (a+cnt)%b==0:continue
    cnt+=b-(a+cnt)%b
print(cnt)

Measured memory_bytes: 18308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];
    vl sum(n+1);
    rep(i,n)sum[i+1]=sum[i]+a[i];
    ll ans=LINF;
    for(int k=2;k<=n-2;k++){
        ll L=sum[k]-sum[0];
        ll tmp=LINF;
        ll best_u=0;
        auto u=lower_bound(sum.begin(),sum.end(),L/2)-sum.begin();
        if(u>0&&u<k){
            if(tmp>abs((sum[k]-sum[u])-(sum[u]-sum[0]))){
                tmp=abs((sum[k]-sum[u])-(sum[u]-sum[0]));
                best_u=u;
            }
        }
        u--;
        if(u>0&&u<k){
            if(tmp>abs((sum[k]-sum[u])-(sum[u]-sum[0]))){
                tmp=abs((sum[k]-sum[u])-(sum[u]-sum[0]));
                best_u=u;
            }
        }

        ll R=sum[n]-sum[k];
        ll tmp2=LINF;
        ll best_v=0;
        auto v=lower_bound(sum.begin(),sum.end(),R/2+sum[k])-sum.begin();
        if(v>k&&v<n){
            if(tmp2>abs((sum[n]-sum[v])-(sum[v]-sum[k]))){
                tmp2=abs((sum[n]-sum[v])-(sum[v]-sum[k]));
                best_v=v;
            }
        }
        v--;
        if(v>k&&v<n){
            if(tmp2>abs((sum[n]-sum[v])-(sum[v]-sum[k]))){
                tmp2=abs((sum[n]-sum[v])-(sum[v]-sum[k]));
                best_v=v;
            }
        }
        vl A(4);
        A[0]=sum[best_u]-sum[0];A[1]=sum[k]-sum[best_u];
        A[2]=sum[best_v]-sum[k];A[3]=sum[n]-sum[best_v];
        sort(A.begin(),A.end());
        chmin(ans,A.back()-*A.begin());
    }
    cout<<ans<<endl;
    return 0;
}

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

N,M = map(int,input().split())

p = [0] + [int(x) for x in input().split()]
root = list(range(N+1))
depth = [0]*(N+1)

# 連結成分を作る
def find_root(x):
  y = root[x]
  if x == y:
    return y
  z = find_root(y)
  root[x] = z
  return z

def merge(x,y):
  xx = find_root(x)
  yy = find_root(y)
  if xx == yy:
    return
  if depth[xx] > depth[yy]:
    root[yy] = xx
  elif depth[xx] < depth[yy]:
    root[xx] = yy
  else:
    root[xx] = yy
    depth[xx] += 1
    
XY = [[int(x) for x in input().split()] for _ in range(M)]
for x,y in XY:
  merge(x,y)

# 連結成分内は自由に作れる
# p[i]とiが同じ連結成分にあると1点
answer = 0
for i,x in enumerate(p[1:],1):
  if find_root(i) == find_root(x):
    answer += 1

print(answer)

Measured memory_bytes: 30968
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] arr = reader.readLine().split(" ");
        int a = Integer.parseInt(arr[0]);
        int b = Integer.parseInt(arr[1]);
        System.out.println(a < 6 ? 0 : a < 13 ? b / 2 : b);
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <map>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int b, f, r, v;
    map<int, map<int, map<int, int> > > m;
    while (cin >> b >> f >> r >> v) {
        map<int, map<int, map<int, int> > >::iterator it = m.find(b);
        if (it == m.end()) {
            map<int, int> o; o.insert(make_pair(r, v));
            map<int, map<int, int> > n; n.insert(make_pair(f, o));
            m.insert(make_pair(b, n));
        }
        else {
            map<int, map<int, int> >::iterator it = m.at(b).find(f);
            if (it == m.at(b).end()) {
                map<int, int> o; o.insert(make_pair(r, v));
                m.at(b).insert(make_pair(f, o));
            }
            else {
                map<int, int>::iterator it = m.at(b).at(f).find(r);
                if (it == m.at(b).at(f).end()) {
                    m.at(b).at(f).insert(make_pair(r, v));
                }
                else {
                    it->second += v;
                }
            }
        }
    }
    for (int i = 1; i <= 4; i++) {
        for (int j = 1; j <= 3; j++) {
            for (int k = 1; k <= 10; k++) {
                try {
                    cout << " " << m.at(i).at(j).at(k);
                }
                catch(out_of_range&) {
                    cout << " " << 0;
                }
            }
            cout << "\n";
        }
        if (i < 4)
            cout << "####################" << "\n";
    }
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    vector<int> a (3);
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    sort(a.begin(),a.end());
    if(a.at(0) == 5 && a.at(1) == 5 && a.at(2) == 7){
    cout << "YES" << endl;
    }
    else{
    cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
  int people[4][3][10];
  int n;
  int b, f, r, v;
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 10; k++){
	people[i][j][k] = 0;
      }
    }
  }

  std::cin >> n;

  for(int i = 0; i < n; i++){
    std::cin >> b >> f >> r >> v;
    people[b -1 ][f -1][r - 1] += v;
  }

  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 10; k++){
	if(k != 10) std::cout << ' ';
	std::cout << people[i][j][k];
      }
      std::cout << std::endl;
    }
    if(i != 3) std::cout << "####################" << std::endl;
  }


  return 0;
}

Measured memory_bytes: 3096
import Data.Bits

f2::Int->Int
f2 a
   |a <1=0
   |a `mod` 4==3=0
   |a `mod` 4==1=1
   |a `mod` 4==0=a
   |a `mod` 4==2=((a `div` 4)+1)*4-1

main = do
       e1<-getLine
       let (a:b:[])=map read (words e1)::[Int]
       print (xor (f2 (a-1)) (f2 b))

Measured memory_bytes: 508
import math
N,M =map(int,input().split())
if N==1 :
    N1=0
elif N==0:
    N1=0
else:
    N1=(math.factorial(N))//(math.factorial(N-2)*2)
    
if M==1:    
    M1=0
    
elif M ==0:
    M1=0
else:
    M1=(math.factorial(M))//(math.factorial(M-2)*2)
    
print(str(N1+M1))

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

int main(){
    int n;
    cin >> n;
    bool moti[110]={};
    for(int i=0; i<n; i++) {
        int d;
        cin >> d;
        moti[d] = true;
    }
    int cnt = 0;
    for(int i=0; i<105; i++){
        if(moti[i])cnt++;
    }
    cout << cnt << '\n';
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int k = s.size();

  int win = 0;
  for (char c: s) {
    if (c == 'o') {
      win++;
    }
  }
  win += 15 - k;

  if (win >= 8) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

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

string solve(int a, int b, int c, int d, int e, int k){
    return (min({a-b,a-c,a-d,a-e,b-c,b-d,b-e,c-d,c-e,d-e}) * (-1)) > k ? ":(" : "Yay!";
    //multipliquei por -1 pro número sempre retornar positivo
}
int main(){
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    cout<<solve(a,b,c,d,e,k)<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

#define NIL -1
#define MAX 100005

struct Node{
  int p,l,r;
};


Node T[MAX];
int n,D[MAX],H[MAX];



void setDepth(int u, int d) {
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].r,d+1);
  setDepth(T[u].l,d+1);
}

int setHeight(int u) {
  int h1=0, h2=0;
  if(T[u].r != NIL) h1 = setHeight(T[u].r) + 1;
  if(T[u].l != NIL) h2 = setHeight(T[u].l) + 1;
  return H[u] = max(h1,h2);
}

int getSibling(int u) {
  if(T[u].p == NIL) return NIL;
  if(T[T[u].p].l != u && T[T[u].p].l != NIL) return T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != NIL) return T[T[u].p].r;
  return NIL;
}


void print(int u) {
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].r != NIL) deg++;
  if(T[u].l != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  
  if(T[u].p == NIL) printf("root\n");
  else if(T[u].r == NIL && T[u].l == NIL) printf("leaf\n");
  else printf("internal node\n");
}


int main() {
  int v,l,r;
  int N;
  cin >> N;
  rep(i,N) T[i].l = T[i].r = T[i].p = NIL;
  rep(i,N) {
    cin >> v >> l >> r;
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }
  
  rep(i,N) if(T[i].p == NIL) r = i;
  setDepth(r,0);
  setHeight(r);
  
  rep(i,N) print(i);

  return 0;
}






Measured memory_bytes: 3216
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
    int A[3][3];

    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            cin >> A[i][j];
        }
    }

    int N;
    cin >> N;

    vector<int> b;
    for (int i = 0; i < N; i++){
        int x;
        cin >> x;
        b.push_back(x);
    }
    
    int flag[3][3] = {{0}};
            
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < N; k++){
                if (A[i][j] == b[k]){
                    flag[i][j] = 1;
                    break;
                }
            }
        }
    }

    // for (int i = 0; i < 3; i++){
    //     for (int j = 0; j < 3; j++){
    //         cout << flag[i][j] << " " << ends;
    //     }
    //     printf("\n");
    // }

    int found = 0;
    for (int i = 0; i < 3; i++){
        int sum = 0;
        for (int j = 0; j < 3; j++){
            sum = sum + flag[i][j];
        }

        if (sum == 3){
            found = 1;
            break;
        }
    }

    for (int j = 0; j < 3; j++){
        int sum = 0;
        for (int i = 0; i < 3; i++){
            sum = sum + flag[i][j];
        }

        if (sum == 3){
            found = 1;
            break;
        }
    }

    if (flag[0][0] + flag[1][1] + flag[2][2] == 3){
        found = 1;
    }

    if (flag[0][2] + flag[1][1] + flag[2][0] == 3){
        found = 1;
    }

    if (found == 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    
    return 0;
}


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

class Myon
{
    //chokudaiさんのコードをコピペ
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        //Console.SetOut(new Printer(Console.OpenStandardOutput()));
        cin = new Scanner();
        new Myon().calc();
        Console.Read();

        return 0;
    }

    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
    public void calc()
    {
        long a = cin.nextLong();
        long b = cin.nextLong();

        long gcd2 = Gcd(a, b);
        int count = 0; //公約数のもつ素因数の数　ただし重複は数えない　12 なら 2(2^2 3 )だが3でない
        int temp = 1;
        long max = (long)Math.Sqrt(gcd2);
        
        while (gcd2 != 1)
        {
            temp++;
            if (gcd2 % temp == 0)
            {
                count++;
                while (gcd2 % temp == 0) gcd2 /= temp;
            }
            else if (temp > max) { count++; break; }
        }
        

        showL(count + 1);
    }


    

    public void backetSort(ref int[] a)
    {
        //max a << a.len に対して有効なソート
        //よってa = int[] とする
        long n = a.Length;
        var count = new int[n];
        var loc = new long[n];//loc[i] は i が終わる 位置 max index where c[index] = loc[i]
        for (long i = 0; i < n; i++) count[a[i]]++;
        loc[0] = count[0] - 1;
        for (long i = 0; i < n-1; i++) loc[i+1] = loc[i] + count[i+1]; 
        long index = 0;

        for(int i = 0; i < n; i++)
        {
            while (index <= loc[i]) a[index++] = i; //incex <= loc[i] == index < loc[i] + 1
        }
    }

    public static void showL(long n) { Console.WriteLine(n); }
    public static void showL(string s) { Console.WriteLine(s); }
}

class Printer : StreamWriter
{
    public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
    public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
    public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        while (i >= s.Length)
        {
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
        }
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 11220
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<sstream>
using namespace std;
int inf = 1000000000;

int main(){

  int a, b;
  cin >> a >> b;
  if( a <= 8 && b <= 8 ) cout << "Yay!" << endl;
  else cout << ":(" << endl;

  return 0;
}



//


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

void main_()
{
    ll N, K;
    cin >> N >> K;

    ll ans = ((N - 1) + (K - 2)) / (K - 1);
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


int main(){

    ll n;
    cin >> n;

    if (n%2 == 0) cout << n << endl;
    else cout << 2*n << endl;
}





//              g++ -std=c++1z

Measured memory_bytes: 256
s=input()
l=["dreamer","dream","erase","eraser"]
i=0
f=False
while True:
    s5=s[i:i+5]
    s6=s[i:i+6]
    s7=s[i:i+7]
    if i==len(s):f=True
    if s7=="dreamer" and s[i+7:i+8]!="a":
        i+=7
        continue
    if  s7=="dreamer" and s[i+7:i+8]=="a":
        i+=5
        continue
    if s6=="eraser":
        i+=6
        continue
    if s5=="dream":i+=5;continue
    if s5=="erase":i+=5;continue
    break
print("YES" if f else "NO")

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

int main() {
    int N, M; cin >> N >> M;
    if (N > M) {
        rep(i, N) cout << M;
        cout << endl;
    } else {
        rep(i, M) cout << N;
        cout << endl;
    }
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

    string s,t;
    cin >> s >> t;
    cout << t << s;

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    d =  defaultdict(int)
    for a in A:
        d[a] += 1

    for _ in range(M):
        B, C = map(int, input().split())
        d[C] += B

    ans = 0

    cand = list(d.keys())
    cand.sort(reverse=True)
    cnt = 0
    for c in cand:
        if cnt + d[c] <= N:
            ans += c * d[c]
            if cnt + d[c] == N:
                break
            cnt += d[c]
        else:
            ans += c * (N - cnt)
            break

    print(ans)
        


if __name__ == "__main__":
    main()

Measured memory_bytes: 89056
from sys import exit
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
ban = set(map(int, input().split()))
diff = 200
for i in range(102):
  if i in ban:
    continue
  if abs(x - i) < diff:
    diff = abs(x - i)
    ans = i
print(ans)

Measured memory_bytes: 9192
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<queue>
#include<cstring> 
using namespace std;
int main()
{int a,b,c;
 cin>>a>>b>>c;
 cout<<min(a*b,c)<<endl;
 system("pause");
 return 0;
}

Measured memory_bytes: 504