akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int n, m;
vector<vector<int>> g;
// u-v間のパスの集合
vector<ll> S_edge;

vector<ll> bfs(int root) {
    // par[i] := 頂点iの親
    vector<int> par(n, -1);
    // path[i] := 根(root)から頂点iまでのパスをbitで管理
    vector<ll> paths(n, 0);
    queue<int> que;
    que.push(root);
    par[root] = root;
    while(que.size()) {
        int now = que.front();
        que.pop();
        for(auto next : g[now]) {
            if(par[next] >= 0) {
                continue;
            }
            par[next] = now;
            paths[next] = (paths[now] | (1LL << next));
            que.push(next);
        }
    }
    return paths;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    g.resize(n);
    for(int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        g[a - 1].emplace_back(b - 1);
        g[b - 1].emplace_back(a - 1);
    }
    cin >> m;
    S_edge.resize(m, 0);
    auto paths = bfs(n - 1);
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        S_edge[i] = (paths[u - 1] ^ paths[v - 1]);
    }

    ll ans = 0;
    for(int bit = 0; bit < (1 << m); bit++) {
        int sgn = (__builtin_popcount(bit) % 2 == 0 ? 1 : -1);
        // 白で塗る辺の集合
        ll S = 0;
        for(int i = 0; i < m; i++) {
            if(bit & (1 << i)) {
                S |= S_edge[i];
            }
        }
        // 白で塗らない辺の本数
        int cnt = (n - 1) - __builtin_popcountll(S);
        ans += sgn * (1LL << cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var max = -1;
        var mo = 0;
        for(var i = 0; i < 3; i++)
        {
            var num = Max(ToInt32(input[i % 3] + input[(i + 1) % 3]),ToInt32(input[(i+1)%3]+input[i%3]));
            if (num > max) { max = num; mo = ToInt32(input[(i + 2) % 3]); }
        }
            WriteLine(max + mo);
    }
}


Measured memory_bytes: 11348
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        A: [u64; N],
    }
    let mut Amax = 0;
    let mut Amin = 9999;
    for i in 0..N{
        Amax = max(Amax,A[i]);
        Amin = min(Amin,A[i]);
    }
    println!("{}", Amax-Amin);
}

Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i++)

#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>


using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

ll n, x, res, re;
ll a[200007];
ll b[200007];
set<ll> near;


ll clear(ll i)
{
	return 5 * a[i] + 2 * x;
}

ll count(ll prec)
{
	if (prec < 1 || prec > n)
		return 1e18;

	ll ret = 0;
	forn(i, 0, 200007)
		b[i] = 0;
	b[2] = prec;
	ll mi = 2;
	forn(i, n - prec, n)
		ret += clear(i);
	for (ll i = n - prec - 1; i >= 0; i--)
	{
		if (b[mi] == 0)
			mi++;
		b[mi]--;
		b[mi + 1]++;
		ret += (mi * 2 + 1)*a[i] + x;
	}
	return ret;
}

ll bin()
{
	ll le, ri;
	le = 1;
	ri = n;
	while (ri - le > 1)
	{
		ll m = (ri + le) / 2;
		ll f, s, t;
		f = count(m - 1);
		s = count(m);
		t = count(m + 1);
		if (s < f && s < t)
			return s;
		if (f < s)
			ri = m;
		else
			le = m;
	}

	ll q, w, e, r, t;
	q = count(le - 1);
	w = count(le);
	e = count(le + 1);
	r = count(ri);
	t = count(ri + 1);
	q = min(q, w);
	e = min(e, r);
	q = min(q, e);
	q = min(q, t);
	return q;
}


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


	cin >> n >> x;
	forn(i, 0, n)
		cin >> a[i];
	res = bin();
	cout << res;
	return 0;
}

Measured memory_bytes: 3328
makeSquare :: [Int] -> String
makeSquare [h,w] = unlines $ replicate h ws
  where
    ws = foldr1 (++) $ replicate w "#"

main :: IO ()
main = do
  s' <- getLine
  let s = (map read . words) s'

  if s == [0,0] then return ()
  else do
    putStrLn $ makeSquare s
    main

Measured memory_bytes: 3928
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    string s; cin >> s;
    int n=s.size();
    ll ans=0;
    bool sum=0;
    rrep(i,n){
        int x=s[i]-'0';
        x+=sum;
        if(x==5){
            ans+=5;
            if(i>0&&s[i-1]-'0'>4) sum=1;
            else sum=0;
        }
        else if((x%10)<5){
            ans+=x%10;
            sum=x/10;
        }
        else{
            ans+=10-x;
            sum=1;
        }
        //cout << ans << endl;
    }
    ans+=sum;
    cout << ans << endl;
}


Measured memory_bytes: 1412
X, N = map(int, input().split())
if N!=0:
  p = list(map(int, input().split()))
else:
  p =[]

p = set(p)
i=0
while i<101:
  n = X-i
  if not(n in p):
    ans = n
    break
  n = X+i
  if not(n in p):
    ans = n
    break
  i+=1

print(ans)

Measured memory_bytes: 9132
n = int(input())
b = list(map(int, input().split()))

lst = []
for i in range(n, 0, -1):
    for j in range(i - 1, -1, -1):
        if b[j] == j + 1:
            lst.append(j + 1)
            b.pop(j)
            break
    else:
        print(-1)
        exit()

for num in lst[::-1]:
    print(num)

Measured memory_bytes: 3064
use std::io::stdin;

fn main() {
    let mut s = String::new();

    stdin().read_line(&mut s).ok();
    let n: i32 = s.trim().parse().unwrap();
    s.clear();

    let mut former_t = 0;
    let mut former_travel_plan = vec![0, 0, 0];
    let mut travel_plan: Vec<i32>;

    let mut res = "Yes";

    for _i in 0..n {
        stdin().read_line(&mut s).ok();
        travel_plan = s
            .trim()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect();

        let t_diff = travel_plan[0] - former_t;
        let place_diff = (travel_plan[1] - former_travel_plan[1]).abs()
            + (travel_plan[2] - former_travel_plan[2]).abs();
        if (t_diff >= place_diff) & ((t_diff - place_diff) % 2 == 0){
            former_t = travel_plan[0];
            former_travel_plan = travel_plan;
            s.clear();
        } else {
            res = "No";
            break;
        }
    }

    println!("{}", res);
//     let mut travel_plan = Vec::<(i32, i32, i32)>::new();
//     travel_plan.push((0, 0, 0));
// 
//     for _i in 0..n {
//         stdin().read_line(&mut s).ok();
//         let travel_plan_unit: Vec<i32> = s
//             .trim()
//             .split_whitespace()
//             .map(|x| x.parse().unwrap())
//             .collect();
//         travel_plan.push((
//             travel_plan_unit[0],
//             travel_plan_unit[1],
//             travel_plan_unit[2],
//         ));
//         s.clear();
//     }
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
    Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        new Main().run();
    }
    void run() {
        int[] points = new int[2];
		for(int i = 0; i < points.length; ++i) {
    		points[i] = sc.nextInt();
		}
      	double result = ((double)points[0] / (double)points[1]);
      	System.out.println(result);
    }
}


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

int main() {
 	int N;
	cin >> N;
 	int RC = 0;
	int BC = 0;
	
	vector<char> s(N,0);
	
	for (int i = 0; i < N; i++) {
		cin >> s.at(i);
	}

	for (int i = 0; i < N; i++) {
		if (s.at(i) == 'R') {
			RC++;
		} else if (s.at(i) == 'B') {
			BC++;
		}
	}
	if (RC > BC) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
using System.Text;
public partial class IntroductionToProgramming{
	public static void Main(){
		string[] line = System.Console.ReadLine().Split(' ');
		int r = int.Parse(line[0]);
		int c = int.Parse(line[1]);

		int[,] cell = new int[r + 1, c + 1];
		int sum = 0;

		for (int i = 0; i < r; i++)
		{
			string[] line2 = System.Console.ReadLine().Split(' ');
			for (int j = 0; j < c; j++)
			{
				int n = int.Parse(line2[j]);
				cell[i, j] = n;
				cell[r, j] += n;
				cell[i, c] += n;
				sum += n;
			}
		}
		cell[r, c] = sum;

		for (int i = 0; i < r + 1; i++)
		{
			StringBuilder sb = new StringBuilder();
			for (int j = 0; j < c + 1; j++)
			{
				sb.Append(cell[i, j].ToString() + " ");
			}
			System.Console.WriteLine(sb.ToString().Trim());
		}
	}
}

Measured memory_bytes: 5864
from sys import setrecursionlimit

setrecursionlimit(10 ** 6)

s = input() + "T"
x, y = map(int, input().split())

stepx = []
stepy = []

headx = True
step = 0
for c in s:
    if c == "F":
        step += 1
    else:
        if headx:
            stepx.append(step)
        else:
            stepy.append(step)
        headx = not headx
        step = 0

x -= stepx[0]
stepx = stepx[1:]


class Reachable:
    def __init__(self, steps):
        self.steps = steps

        self.maxs = sum(steps)
        self.r = [{} for _ in range(len(steps))]

    def __call__(self, i, s):
        if i == -1:
            return s == 0
        elif not -self.maxs <= s <= self.maxs:
            return False
        elif self.r[i].get(s, None) is not None:
            return self.r[i][s]
        else:
            step = self.steps[i]
            r = self(i - 1, s - step) or self(i - 1, s + step)
            self.r[i][s] = r
            return r


answer = Reachable(stepx)(len(stepx) - 1, x) and Reachable(stepy)(len(stepy) - 1, y)

if answer:
    print("Yes")
else:
    print("No")


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

int main(){
	int n, m, x, a[100];
	cin >> n >> m >> x;
	for(int i = 0; i < m; i++) cin >> a[i];

	int k1 = 0, k2 = 0;
	for(int i = 0; i < m; i++){
		if(a[i] > 0 && a[i] < x) k1++;
		if(a[i] > x && a[i] < n) k2++;
	}

	cout << min(k1, k2) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iterator>
#include <functional>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define sz(a)  int((a).size())
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define CLR(a) memset((a), 0, sizeof(a))
#define INF (1 << 31) - 1
const int dh[8] = {-1, 1, 0, 0,1,1,-1,-1};
const int dw[8] = {0, 0, 1, -1,1,-1,1,-1};
typedef long long ll;
typedef pair<int, int> p;
typedef vector <int> VI;
typedef vector <string> VS;

vector <int> his;

int main(){

	int n;
	cin >> n;

	VI a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}	
	sort(all(a));
	
	int ans = 1;
	if(a[0] * 2 >= a[1]) ans++;
	
	ll sum = a[0] + a[1];
	for(int i = 2; i < n; i++){
		if(sum * 2 >= a[i]) ans++;
		else ans = 1;

		sum += a[i];
	}

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=2e9;

int main(){
    int h,w;
    cin>>h>>w;
    for(int i=0;i<w+2;i++)cout<<"#";
    cout<<endl;
    for(int i=0;i<h;i++){
        cout<<"#";
        string s; cin>>s;
        cout<<s<<"#"<<endl;
    }
    for(int i=0;i<w+2;i++)cout<<"#";
    cout<<endl;
}


Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder.abc111 {

    class Program {
        /**
         * ins
         *  119
         * out
         *  991
         */
        main(inp: string): void {

            const x: string[] = inp.split('').map(n => {
                if (n === '1') {
                    return '9';
                } else {
                    return '1';
                }
            });
            console.log(x.join(''));
        }
    }

    const prg = new Program();
    prg.main(fs.readFileSync('/dev/stdin', 'utf8').trim());
}

Measured memory_bytes: 7500
#include <cstdint>
#include <vector>
#include <iostream>
#include <algorithm>
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#endif

#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = uint16_t; using ld = long double; using namespace std;

int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	ll N; cin >> N;
	vector<ll> P(N), q(N);
	rep(n, N) { cin >> P[n]; }
	rep(n, N) { cin >> q[n]; }
	long long sa{0};
	if (P > q) swap(P, q);
	do {
		if (P == q) break;
		++sa;
	} while (next_permutation(begin(P), end(P)));
	p(sa);
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define speedhack ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fromfile freopen("input.txt", "r", stdin);  freopen("output.txt", "w", stdout); 
#define mod int (1e9+7)
#define MAXN int (1e9)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
 
double pi = 3.14159265358979323846;

double a,b,h,m;
int main() {
    speedhack;
    //fromfile;
    cin >> a >> b >> h >> m;
    double t = h + double(m/60.000000);
    double omega1 = 2 * pi / 12;
    double omega2 = 2 * pi;
    double y1 = a * cos(omega1 * t);
    double y2 = b * cos(omega2 * t);
    double x1 = a * sin(omega1 * t);
    double x2 = b * sin(omega2 * t);
    double l = sqrt((y1-y2) * (y1-y2) + (x1-x2) * (x1-x2));
    cout << setprecision(15) << l;
}
 
 
    

Measured memory_bytes: 4144
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int l[200000+5],r[200000+5],n,m,q,ret[200000+5],sz,p,num1[200000+5],num[200000];
int l1[200000+5],r1[200000+5],vec[600000+5],c[600000+5];
void Add( int x)  //树状数组加入
{
    for(;x<=sz;x+=(x&-x))
        c[x]++;  //因为这里只需要1，所以我就写出c[x]++了
}
int Sum( int x)  //树状数组求和，同上面的sum(x)
{
     int s=0;  //计数的变量
    for(;x>0;x-=(x&-x))  //累计
        s+=c[x];
    return s;  //返回结果
}
bool cmp1(int a,int b){
	return r1[a]<r1[b];
}
bool cmp(int a,int b){
	return r[a]<r[b];
}
int main()
{
    cin>>n>>m>>q;
    for(int i=1;i<=m;i++){
    	cin>>l[i]>>r[i];
    	vec[p++]=l[i];
    	vec[p++]=r[i];
    	num[i]=i;
	}
	for(int i=1;i<=q;i++){
		cin>>l1[i]>>r1[i];
		vec[p++]=l1[i];
		vec[p++]=r1[i];
		num1[i]=i;
	}
	sort(vec,vec+p);
	sz=unique(vec,vec+p)-vec;
	for(int i=1;i<=m;i++){
		l[i]=lower_bound(vec,vec+sz,l[i])-vec+1;
		r[i]=lower_bound(vec,vec+sz,r[i])-vec+1;
	}
	for(int i=1;i<=q;i++){
		l1[i]=lower_bound(vec,vec+sz,l1[i])-vec+1;
		r1[i]=lower_bound(vec,vec+sz,r1[i])-vec+1;
	}
	sort(num1+1,num1+q+1,cmp1);
	sort(num+1,num+m+1,cmp);
	
	int j=1;
	for(int k=1;k<=q;k++){
		int i=num1[k];
		while(j<=m&&r[num[j]]<=r1[i]){
		Add(l[num[j++]]);	
		} 
		ret[i]=j-Sum(l1[i]-1)-1;
	
	}
	for(int i=1;i<=q;i++){
		cout<<ret[i]<<endl;
	}
}

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

int main() {
    int A, B; cin >> A >> B;
    for (int i = 1; i < 100000; i++) {
        if ((int)(i * 0.08) == A && (int)(i * 0.1) == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
if s < t:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9092
#include<bits/stdc++.h>
using namespace std;
long long Cnt[1010];
int main()
{
	int N;
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		int Tmp=i;
		for(int j=2;j<=i;j++)
			while(Tmp%j==0)
			{
				Tmp/=j;
				Cnt[j]++;
				//cout<<i<<":"<<j<<"->"<<Cnt[j]<<endl;
			}
	}
	long long Ans=1ll;
	for(int i=2;i<=N;i++)
		Ans=Ans*(Cnt[i]+1ll)%1000000007;
	cout<<Ans<<endl;
	return 0;
}


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

#define ll long long
#define ull unsigned long long
#define vii vector<int>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define pldld pair<long long double, long long double>
#define ff first
#define ss second
#define pb push_back
#define read freopen("alu.txt","r",stdin);
#define write freopen("vorta.txt","w",stdout);
#define fastio ios::sync_with_stdio(false); cin.tie(NULL);
#define PI 2*acos(0.0)
#define DEBUG(x) cerr << #x << " = " << x << endl

const int MAX = 2e6 + 5, MOD = 1e9 + 7  , MAXLG = log2(MAX)+1;
const ll inf = 1e18 + 5;

int arr[MAX];
vii g[MAX];
bool vis[MAX];
int dis[2005][2005];

void bfs(int u, int root, int n){
    for(int i=1; i<=n; i++){
        vis[i] = false;
    }
    queue<int>q;
    q.push(u);
    dis[root][u] = 0;
    vis[u] = true;
    while(!q.empty()){
        u = q.front();
        q.pop();
        for(int v: g[u]){
            if(!vis[v]){
                q.push(v);
                vis[v] = true;
                dis[root][v] = dis[root][u] + 1;
            }
        }
    }
}

map<int,int>mp;
int main(){

    fastio;
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=2; i<=n; i++){
        g[i-1].pb(i);
        g[i].pb(i-1);
    }
    g[x].pb(y);
    g[y].pb(x);
    for(int i=1; i<=n; i++){
        fill(vis,vis+n+1,false);
        bfs(i,0,i);
    }
    for(int i=1; i<=n; i++){
        bfs(i,i,n);
    }
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            int d = dis[i][j];
            if(d < n) mp[d]++;
        }
    }
    for(int i=1; i<n; i++) cout<<mp[i]<<"\n";
}


Measured memory_bytes: 65920
A,B,C = list(map(int,input().split()))
count = 0
if A%2 == 1 or B%2 == 1 or C%2 == 1:
    print(0)
    exit()
if A == B == C:
    print(-1)
    exit()
while True:
    if A%2 == 1 or B%2 == 1 or C%2 == 1:
        break
    A_half = A//2
    B_half = B//2
    C_half = C//2
    A = B_half+C_half
    B = A_half+C_half
    C = A_half+B_half
    count += 1
print(count)

Measured memory_bytes: 3064
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val k, s = sc.nextInt
  var res = 0
  for (x <- 0 to k;
       y <- ((s - x + 1) / 2) to x;
       z = s - x - y)
  {
    if (0 <= z && z <= k) {
           if (x == y && y == z) res += 1
      else if (x == y || y == z) res += 3
      else res += 6
    }
  }
  println(res)
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<string,int>Psi;

int main(){
  int n,k;
  cin>>n>>k;
  double p=1.0/(double)n;
  double ans=0.0;
  for(int i=1;i<=n;i++){
    if(k>i){
      int tmp=i;
      double tmp_p=1.0;
      while(tmp<k){
        tmp=tmp<<1;
        tmp_p*=0.5;
      }
    ans+=p*tmp_p;
    }else{
      ans+=(n-i+1)*p;
      break;
    }
  }
  cout<<fixed <<setprecision(9)<< ans<<endl;
}

Measured memory_bytes: 256
"use strict";
    
// 約数列挙
const calcDivisor = N => {
  let result = [];

  for(let i=1; i*i<=N; i++) {
    if(N % i === 0) {
      result.push(i);
      const j = N / i;
      if(j !== i) result.push(j);
    }
  }

  return result.sort((a,b)=>a-b);
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    const divides = calcDivisor(M);
    
    let answer = 1;
    
    for(let i=0; i<divides.length; i++) {
        if(N * divides[i] <= M) {
            answer = divides[i];
        } else {
            break;
        }
    }
    
    console.log(answer)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
#define N 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
void AIA() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
//cout<<fixed<<setprecision(20);
// freopen("stand.in","r",stdin);
// freopen("stand.out","w",stdout);

/*
 _____________              __                ___        ___       ___________________________     ____        ____
|             |            /\ \              |   |      |   |     |                           |    \   \      /   /
|   __________|           / /\ \             |   |      |   |     |      _____      _____     |     \   \    /   /
|  |                     / /  \ \            |   |      |   |     |     |     |    |     |    |      \   \  /   /
|  |                    / /    \ \           |   |      |   |     |     |     |    |     |    |       \   \/   /
|  |______             / /      \ \          |   |______|   |     |     |     |    |     |    |        \      /
|         |           / /        \ \         |              |     |     |     |    |     |    |         \    /
|   ______|          / /          \ \        |    ______    |     |     |     |    |     |    |          |  |
|  |                / /============\ \       |   |      |   |     |     |     |    |     |    |          |  |
|  |               / /==============\ \      |   |      |   |     |     |     |    |     |    |          |  |
|  |              / /                \ \     |   |      |   |     |     |     |    |     |    |          |  |
|  |             / /                  \ \    |   |      |   |     |     |     |    |     |    |          |  |
|__|            /_/                    \_\   |___|      |___|     |_____|     |____|     |____|          |__|

								  <<<<<<<<<<< NEVER GIVE UP !! >>>>>>>>>>>
								<<<<<<<< YOU CAN DO IT IF YOU WANT !! >>>>>>>>
								 <<<<<<<<< BELIEVE IN YOURSELF !! >>>>>>>>>

*/

int main()
{
	//cout<<fixed<<setprecision(20);
	//freopen("stand.in","r",stdin);
	//freopen("stand.out","w",stdout);
	AIA();	
	ll a , b;
	cin>>a>>b;
	int n = a ,m = a*4;
	if(m == b){
		cout<<"Yes";
		return 0;
	}
	while(n--){
		m-=4;
		m+=2;
		if(m==b){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3668
N,M=map(int,input().split())
AC=[0]*(N+1)
WA=[0]*(N+1)
W=0
A=0
for i in range(M):
    p,s=input().split()
    p=int(p)
    if AC[p]==0:

        if s=='WA':
            WA[p]+=1

        else:
            AC[p]=1
            A+=1

for i in range(N+1):
    if AC[i]==1:
        W+=WA[i]
print(A,W)


Measured memory_bytes: 4596
#include <iostream>

using namespace std;

int num_digits(int x) {
  int n = 0;
  while (x > 0) {
    x /= 10;
    n++;
  }
  return n;
}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (num_digits(i) % 2 == 1) {
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce
import sys
sys.setrecursionlimit(4100000)

INF = 1 << 60

# ここから書き始める
n = int(input())
s = [int(input()) for i in range(n)]
if sum(s) % 10 != 0:
    print(sum(s))
else:
    s.sort()
    for i in s:
        if i % 10 != 0:
            print(sum(s) - i)
            break
    else:
        print(0)


Measured memory_bytes: 63980
#include<bits/stdc++.h>
using namespace std;
int main()
{
	map<string,int>m1;
	m1["SUN"]=7;
	m1["MON"]=6;
	m1["TUE"]=5;
	m1["WED"]=4;
	m1["THU"]=3;
	m1["FRI"]=2;
	m1["SAT"]=1;
	string s;
	cin>>s;
	cout<<m1[s];
	return 0;
 } 

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

int n, k;

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

	int ans = 1;
	cin >> n >> k;
	for(int i = 1; i <=n; i++) {
		if (ans*2 <= ans+k) {
			ans *= 2;
		} else {
			ans += k;
		}
		//cout << ans << "\n";
	}

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

Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long n, k;
    scan(n, k);
    writeln(k * (k - 1) ^^ (n - 1));

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>

int main(void){
    char s[11], t[12];

//入力
    scanf("%s %s", s, t);

    for(int i=0 ; i < strlen(s) ; i++){
        if(s[i] != t[i]){
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");

    return 0;
}

Measured memory_bytes: 1616
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
put = []

for i in reversed(range(N)):
    if A[i]:
        put.append(i+1)
        # iを素因数分解して、約数に1をxorしていく
        tmp = 1
        n = i+1
        while tmp*tmp <= n:
            if n % tmp == 0:
                A[tmp-1] ^= 1
                if tmp != n//tmp:
                    A[n//tmp-1] ^= 1
            tmp += 1


if len(put) > 0:
    print(len(put))
    print(*put)
else:
    print(0)


Measured memory_bytes: 69112
import math
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    cnt = 0
    for i in range(N):
        for j in range(A[i]):
            if A[i] % 2 == 0:
                A[i] = A[i]//2
                cnt += 1
            else:
                break
    print(cnt)
if __name__ == "__main__":
    main()

Measured memory_bytes: 4148
#include <iostream>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using namespace std;

using ll = long long;

signed main() {
	cin.sync_with_stdio(false); cin.tie(nullptr);
	cin.exceptions(cin.failbit);

	int n; cin >> n;
	pair<string, int> p[n];
	int ans = 0;
	rep(i, 0, n) cin >> p[i].first >> p[i].second;
	string s; cin >> s;
	bool flag = false;
	rep(i, 0, n) {
		if (flag) ans += p[i].second;
		if (s == p[i].first) flag = true;
	}
	cout << ans;
}

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

int sumstring(string n){
	int sum = 0;
	for(int i = 0; i < n.size(); i++){
		sum += (int(n[i]) - 48);
	}
	return sum;
}

void Main()
{
	while(1){
		string n;
		cin >> n;
		if(n != "0"){
			cout << sumstring(n) << endl;
		}else{
			break;
		}
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3200
package main

import (
	"fmt"
)

func main() {
	var n, y int
	fmt.Scan(&n, &y)
	ans1, ans2, ans3 := exec(n, y)
	fmt.Println(ans1, ans2, ans3)
}

func exec(n, y int) (int, int, int) {
	for i := 0; i <= n; i++ {
		if i*10000 > y {
			break
		}
		for j := 0; j <= n-i; j++ {
			k := (y - i*10000 - j*5000) / 1000
			if i+j+k == n {
				return i, j, k
			}
		}
	}
	return -1, -1, -1
}


Measured memory_bytes: 512
N=int(input())
S=[input() for _ in range(N)]
a=S.count("AC")
b=S.count("WA")
c=S.count("TLE")
d=S.count("RE")

print("AC","x",a)
print("WA","x",b)
print("TLE","x",c)
print("RE","x",d)


Measured memory_bytes: 16152
#include<algorithm>
#include<cstdio>
#include<set>
#include<utility>
using namespace std;

struct vertex {
    int cnt = 0, bcnt = 0;
    double prob = 0.0, weight = 0.0;
    set<int> from, to;
};

int n, m;
pair<int, int> p[180000];
bool jdg[600];
vertex ver[600];

void dfs(int x) {
    if (++ver[x].cnt < ver[x].from.size()) return;
    for (auto &i : ver[x].to) {
        ver[i].prob += ver[x].prob / ver[x].to.size();
        dfs(i);
    }
}

void bdfs(int x) {
    if (++ver[x].bcnt < ver[x].to.size()) return;
    if (x != n - 1) ver[x].weight /= ver[x].to.size();
    for (auto &i : ver[x].from) {
        ver[i].weight += ver[x].weight + 1.0; 
        bdfs(i);
    }
}

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) scanf("%d %d", &p[i].first, &p[i].second);
    sort(p, p + m);
    jdg[0] = true;
    for (int i = 0; i < m; i++) {
        if (jdg[p[i].first - 1]) {
            jdg[p[i].second - 1] = true;
            ver[p[i].first - 1].to.emplace(p[i].second - 1);
            ver[p[i].second - 1].from.emplace(p[i].first - 1);
        }
    }

    ver[0].prob = 1.0; 
    dfs(0);
    bdfs(n - 1);
    
    double rdc = 0.0;
    for (int i = 0; i < m; i++) {
        if (!jdg[p[i].first - 1] || ver[p[i].first - 1].to.size() == 1) continue;
        double a = (ver[p[i].first - 1].weight - 1.0
                 - ver[p[i].second - 1].weight) / (ver[p[i].first - 1].to.size() - 1);
        rdc = min(rdc, a * ver[p[i].first - 1].prob);
    }
   
    printf("%5.15lf\n", ver[0].weight + rdc);
    return 0;
}



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll D, N;
ll i, j, k;
int main(){
    scanf("%lld%lld", &D, &N);
    i = 0;
    j = 0;
    while(j<N){
        ++i;
        ll a = i;
        k = 0;
        while(a%100==0){
            a /= 100;
            ++k;
        }
        if(k==D)
            ++j;
    }
    printf("%lld\n", i);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <set>

using namespace std;
set<int> s; 
int main()
{
	int x, t;
	t = 0;
	scanf("%d", &x);
	for (int i = 0; i < x; i++)
	{
		int l;
		scanf("%d ", &l);
		if (s.find(l) != s.end()) s.erase(l);
		else s.insert(l);
	}
	printf("%d", s.size());
} 

Measured memory_bytes: 4864
#include <iostream>
#include <cmath>

using namespace std;

int gcd(int a,int b){
    int x = max(a,b);
    int y = min(a,b);
    while(x % y != 0){
        int z = x % y;
        x = y;
        y = z;
    }
    return y;
}

int N;
int a[100000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> a[i];
    int m = a[0];
    for(int i=1;i<N;i++) m = gcd(m,a[i]);
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 640
n = int(input())
sl = [input() for _ in [0]*n]
count = 0
dict = {}
for s_raw in sl:
  s = ''.join(sorted(s_raw))
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1
print(count)


Measured memory_bytes: 24976
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    elif m==-1 or f==-1:
        grade="F"
    elif m+f>=80:
        grade="A"
    elif m+f<80 and m+f>=65:
        grade="B"
    elif m+f<65 and m+f>=50:
        grade="C"
    elif m+f<50 and m+f>=30:
        if r>=50:
            grade="C"
        else:
            grade="D"
    elif m+f<30:
        grade="F"
    print(grade)

Measured memory_bytes: 5596
#include <stdio.h>
#include <string.h>

char *inputStr(char *str, size_t len) {
	char *rtn = fgets(str, len, stdin);
	if (str[(len = (strnlen(str, len) - 1))] == '\n') {
		str[len] = '\0';
	} else {
		fflush(stdin);
	}
	return rtn;
}

int caesarEncDec(int ch, int key) {
	if (ch < 'a' || ch > 'z') { return ch; }
	if (key < 0) { key += (((-key) + ('z' - 'a')) / ('z' - 'a' + 1)) * ('z' - 'a' + 1); }
	key %= 'z' - 'a' + 1;
	ch += key;
	if (ch > 'z') { ch -= 'z' - 'a' + 1; }
	return ch;
}

int main(int argc, char *argv[]) {
	static const char *keyword[] = {"the", "this", "that"};
	static const int wordNum = 3;
	char enc[96], dec[96], key;
	int len, i;
	while (inputStr(enc, sizeof(enc) / sizeof(enc[0])) != NULL) {
		len = strnlen(enc, sizeof(enc) / sizeof(enc[0]));
		memset(dec, '\0', sizeof(dec) / sizeof(dec[0]));
		for (key = 0; key < 'z' - 'a' + 1; ++key) {
			for (i = 0; i < len; ++i) {
				dec[i] = (char)caesarEncDec((int)enc[i], -(int)key);
			}
			for (i = 0; i < 3; ++i) {
				if (strstr(dec, keyword[i])) { goto nuke1; }
			}
		}
		nuke1:
		puts(dec);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define REVERSE(c) reverse((c).begin(), (c).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort((c).begin(),(c).end())
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
	LL K, S;
	cin >> K >> S;

	LL count = 0;
	REP(i, K + 1) {
		REP(j, K + 1) {
			if (0 <= S - i - j && S - i - j <= K) {
				count++;
			}
		}
	}

	cout << count << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include<set> 
#include<map> 
#include<stack> 
#include<cmath> 
#include<cstdio> 
#include<queue> 
#include<vector> 
#include<climits> 
#include<cstring> 
#include<iostream> 
#include<algorithm> 
using namespace std; 
#define MAXC 30
#define MAXN 500
#define LL long long 
#define INF INT_MAX 
int read(){ 
    int f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x; 
}
int c,d[MAXC+5][MAXC+5],cnt[3][MAXC+5],S[3][MAXC+5];
int change(int t,int x){
    int ret=0;
    for(int i=1;i<=c;i++)
        ret+=cnt[t][i]*d[i][x];
    return ret;
}
int main(){
    int n=read(),ans=INF;
    c=read();
    for(int i=1;i<=c;i++)
        for(int j=1;j<=c;j++)
            d[i][j]=read();
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cnt[(i+j)%3][read()]++;
    for(int t=0;t<=2;t++)
        for(int i=1;i<=c;i++) 
            S[t][i]=change(t,i);
    for(int i=1;i<=c;i++)
        for(int j=1;j<=c;j++)
            for(int k=1;k<=c;k++)
                if(i!=j&&j!=k&&i!=k){
                    int tmp=S[0][i]+S[1][j]+S[2][k];
                    if(tmp<ans) ans=tmp;
                }
    printf("%d\n",ans);
    return 0;
} 

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(x,y);
  int m1[205] = {300000,200000,100000};
  if(x==1 && y==1) z += 400000;
  z += m1[x-1] + m1[y-1];
  OUT(z);
}

Measured memory_bytes: 256
s = int(input())
a = []
a.append(s)
ans = 0
while True:
    if a[ans]%2==0:
        if a[ans]//2 in a:
            print(ans+2)
            break
        a.append(a[ans]//2)
    else :
        if 3*a[ans]+1 in a:
            print(ans+2)
            break
        a.append(3*a[ans]+1)
    ans+=1

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;
 
int main(){
    int a,b;
    cin >> a >> b;
    for(int i=0; i<1001; i++){
        if(a==floor(i*0.08) and b==floor(i*0.1)){
            cout << i << endl;
            exit(0);
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

constexpr int64_t MOD = 1'000'000'007;
constexpr int     MAX =       200'005;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int64_t COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
    int64_t H, W, A, B;
    cin >> H >> W >> A >> B;

    int64_t ans = 0;
    COMinit();
    for(int i=0; i<H-A; i++) {
        ans += COM(B-1+i, B-1) * COM(W-B-1+H-1-i, H-1-i);
        ans %= MOD;
    }

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


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<vector<lli> > Graph;
const lli mod = 1000000007LL;
const lli MAXN = 100005;

lli N, M;
Graph G;
lli vis[MAXN];

void dfs(lli v) {
  vis[v] = true;
  for(lli i = 0; i < G[v].size(); ++i) {
    lli nv = G[v][i];
    if(!vis[nv]) dfs(nv);
  }
}

int main() {
  while(cin >> N >> M && (N|M)) {
    G = Graph(N);
    for(lli i = 0; i < M; ++i) {
      lli a, b; cin >> a >> b;
      --a; --b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    memset(vis, 0, sizeof(vis));
    lli cnt = 0, res = 1;
    for(lli i = 0; i < N; ++i) {
      if(!vis[i]) {
        dfs(i);
        ++cnt;
        res = res * 2LL % mod;
      }
    }
    cout << res + (cnt != N) << endl;
  }
  return 0;
}

Measured memory_bytes: 12180
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <sstream>
#include <string>
#include <climits>
#include <set>
#include <array>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <map>
#include <utility>
using namespace std;

int main()
{
    string str;
    cin >> str;
    if (str == "ABC")
        cout << "ARC";
    else cout << "ABC";
}

Measured memory_bytes: 3580
N = int(input())
a = list(map(int, input().split()))
seta = list(set(a))

if len(seta) == 3 and a.count(seta[0]) == a.count(seta[1]) and a.count(seta[1]) == a.count(seta[2]) and a.count(seta[2]) == a.count(seta[0]):
  if seta[0]^seta[1] == seta[2] and seta[1]^seta[2] == seta[0] and seta[0]^seta[2] == seta[1]:
    print("Yes")
  else:
    print("No")
elif len(seta) == 2:
  sseta = sorted(seta)
  if sseta[0] == 0 and a.count(sseta[1]) == a.count(sseta[0])*2:
    print("Yes")
  else:
    print("No")
elif len(seta) == 1 and seta[0] == 0:
  print("Yes")
else:
  print("No")

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

int main(void){
  long int N;

long int count=0;

scanf("%ld", &N);

while(N!=0){
    if(N%3 != 0 && N%5!=0){
count += N;
    }
    N -= 1;
}
  
  printf("%ld\n", count);
  return 0;
}


Measured memory_bytes: 1736
//#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(uniqu7e(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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;}

void END(){cout << "Yes" << endl; exit(0);}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x, y;
	cin >> x >> y;
	int ans = 0;
	ans += max(0, 300000 - 100000*(x-1));
	ans += max(0, 300000 - 100000*(y-1));
	if (x == 1 && y == 1) ans += 400000;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
<?php

$input = function() {return trim(fgets(STDIN));};
list($n, $m) = explode(' ', $input());
for($i = 0; $i < $n; $i++) {
    $a[] = explode(' ', $input());
}

for($i = 0; $i < $m; $i++) {
    $b[] = $input();
}

foreach ($a as $v) {
    $sum = 0;
    for ($i = 0; $i < $m; $i++) {
        $sum += ($v[$i] * $b[$i]);
    }
    echo $sum .PHP_EOL;
}

Measured memory_bytes: 10968
import java.util.Scanner;
import java.util.Set;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[][] ratio = new int[n][2];
        for(int i=0;i<n;i++){
            ratio[i][0] = Integer.parseInt(sc.next());
            ratio[i][1] = Integer.parseInt(sc.next());
        }

        long t = 1;
        long a = 1;
        for(int i=0;i<n;i++){
            int rt = ratio[i][0];
            int ra = ratio[i][1];
            long bia = Math.max(((t+rt-1)/rt), ((a+ra-1)/ra));
            t = rt * bia;
            a = ra * bia;
        }
        System.out.println(a+t);
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int A = in(),B = in(),K = in();
    REP(i,K)if(A + i <= B)cout << A + i << "\n";
    REP(i,K)if(B - K + i + 1 > A + K - 1)cout << B - K + i + 1 << "\n";
}

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

using namespace std;

int main(void) {
    int H, W, D;
    cin >> H >> W >> D;
    vector<int> I(H*W+1);
    vector<int> J(H*W+1);
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            int A;
            cin >> A;
            I[A] = i;
            J[A] = j;
        }
    }

    vector<int> distance(H*W+1);
    for(int k=D; k<=H*W; k++) {
        distance[k] = distance[k-D] + abs(I[k] - I[k-D]) + abs(J[k] - J[k-D]);
    }

    int Q;
    cin >> Q;
    while(Q--) {
        int L, R;
        cin >> L >> R;
        cout << distance[R] - distance[L] << endl;
    }
    return 0;
}


Measured memory_bytes: 2176