akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long A;
    double B;
    cin >> A >> B;
    long long C = (long long) (B*(1e2+1e-7));

    C=(A*C)/100ll;
    cout << C  << endl;
 
    return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <map>
#include <stack>
#include <vector>
using namespace std;
#define D

#ifdef D
int main(void) {
	int N;
	cin >> N;
	//vector<int> arr(N);
	int int_in;
	int cunt = 0;
	bool flag = false;
	for (size_t i = 1; i <= N; i++)
	{
		cin >> int_in;
		if (int_in == i)
			if (flag)
			{
				//cunt++;
				flag = false;
			}
			else {
				cunt++;
				flag = true;
			}
		else
		{
			flag = false;
		}
	}
	cout << cunt << endl;
	return 0;
}

#endif // D

Measured memory_bytes: 256
from operator import itemgetter
n, m = map(int, input().split())
ab = sorted([ list(map(int, input().split())) for _ in range(m)], key=itemgetter(1) )
x = 0
ans = 0
for a, b in ab:
  if a > x:
    ans += 1
    x = b-1
print(ans)

Measured memory_bytes: 29920
def Schedule(schedule):
    """
    :return: 複数の区間が与えられた時の重複の無い区間の選び方の最大数
    """
    schedule = sorted(schedule, key=lambda x: x[1])
    N = len(schedule)
    res = 0
    end = -float("inf")

    for i in range(N):
        if end <= schedule[i][0]:  # 重複がダメならば等号を消す
            end = schedule[i][1]  # 終点でソートされているので、自動的に可能な中で最速の終点が選ばれている
            res += 1
    return res

################################################################################

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
schedule = []
for i in range(M):
    start, end = map(int, input().split())
    schedule.append((start, end))               # schedule = (始点、終点)

print(Schedule(schedule))

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

int main() {
  int n, r;
  cin >> n >> r;
  int internal;
  if (n >= 10) {
    internal = r;
  }
  else {
    internal = r + 100 * (10-n);
  }

  cout << internal << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int E = sc.nextInt();
		int F = sc.nextInt();
		sc.close();
		int[]dp = new int[F + 1];
		if(100 * A <= F) {
			dp[100 * A] = 1;
		}
		if(100 * B <= F) {
			dp[100 * B] = 1;
		}
		for(int i = A; i <= F; i++) {
			if(dp[i] == 1) {
				int da = i + 100 * A;
				int db = i + 100 * B;
				if(da <= F) {
					dp[da] = 1;
				}
				if(db <= F){
					dp[db] = 1;
				}
			}
		}
//		for(int i = 100 * A; i <= F; i += 100) {
//			if(dp[i] == 1) {
//				System.out.print(i + " ");
//			}
//		}
//		System.out.println();
		int m = ((F + 99) / 100) * E;
		int[]dp2 = new int[m + 1];
		if(C <= m) {
			dp2[C] = 1;
		}
		if(D <= m) {
			dp2[D] = 1;
		}
		for(int i = C; i <= m; i++) {
			if(dp2[i] == 1) {
				int dc = i + C;
				int dd = i + D;
				if(dc <= m) {
					dp2[dc] = 1;
				}
				if(dd <= m){
					dp2[dd] = 1;
				}
			}
		}
//		for(int i = C; i <= m; i++) {
//			if(dp2[i] == 1) {
//				System.out.print(i + " ");
//			}
//		}
//		System.out.println();
		int w = 0;
		int s = 0;
		double max = 0;
		for(int i = 100 * A; i <= F; i += 100) {
			if(dp[i] == 1) {
				int k = (i / 100) * E;
				//System.out.println(k);
				for(int j = k; j >= C; j--) {

					if(dp2[j] == 1) {
						double t = (double)100 * j / (j + i);
						//System.out.println((i+j) + " " + s);
						if(max < t && i + j <= F) {
							max = t;
							w = i + j;
							s = j;
							break;
						}
					}
				}
			}
		}
		if(s == 0) {
			System.out.println(100 * A + " 0");
		}else {
			System.out.println(w + " " + s);
		}
	}
}

Measured memory_bytes: 21844
def f(a, m):
  if a % m == 0:
    return m
  else:
    return a % m

def solve():
  N = int(input())
  A = list(map(int, input().split()))
  while True:
    m = min(A)
    A = list(map(lambda a: f(a, m), A))
    if all([a == m for a in A]): return m

print(solve())


Measured memory_bytes: 15020
val = input()
if(val == 'SUN'):
    print(7)
elif(val == 'MON'):
    print(6)
elif(val == 'TUE'):
    print(5)
elif(val == 'WED'):
    print(4)
elif(val == 'THU'):
    print(3)
elif(val == 'FRI'):
    print(2)
elif(val == 'SAT'):
    print(1)


Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <numeric>
#include <cassert>
#include <cmath>
#include <map>
#include <set>
#include <iostream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
typedef vector<PII > VPII;
typedef vector<VPII> VVPII;

#define FOR(k,a,b) for(int k(a); k < (b); ++k)
#define REP(k,a) for(int k=0; k < (a); ++k)
#define ABS(a) ((a)>0?(a):-(a))

int main(int argc, char** argv) {
#ifdef HOME
	freopen("in.txt", "rb", stdin);
	freopen("out.txt", "wb", stdout);
#endif
	string s;
	cin >> s;
	int N = s.length();
	vector<int> v(30);
	REP(i, N)
		v[s[i] - 'a']++;
	int mx = 0;
	REP(i, 30)
		if (v[i] > mx)
		{
			mx = v[i];
		}
	string ans;
	if (N & 1)
	{
		ans = (s[0] == s.back() ? "Second" : "First");//(2 * mx == N + 1 ? "first" : "second");
	}
	else
	{
		ans = (s[0]!=s.back()? "Second" : "First");
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
use std::io::{self, BufRead};

const MOD: i64 = 1_000_000_007;

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let nab = lines.next().unwrap().unwrap();
    let mut nab = nab.split_whitespace();
    let n: i64 = nab.next().unwrap().parse().unwrap();
    let a: i64 = nab.next().unwrap().parse().unwrap();
    let b: i64 = nab.next().unwrap().parse().unwrap();

    let mut ans = pow_mod(2, n, MOD);
    ans -= comb_mod(n, a, MOD);
    ans -= comb_mod(n, b, MOD);
    ans -= 1;
    ans %= MOD;
    if ans < 0 {
        ans += MOD
    };

    println!("{}", ans);
}

fn mul_mod(a: i64, b: i64, m: i64) -> i64 {
    ((a % m) * (b % m)) % m
}

fn div_mod(a: i64, b: i64, m: i64) -> i64 {
    let b_inv = pow_mod(b, m - 2, m);
    mul_mod(a, b_inv, m)
}

fn pow_mod(a: i64, b: i64, m: i64) -> i64 {
    let (mut a, mut b, mut result) = (a % m, b, 1);
    while b > 0 {
        if b % 2 == 1 {
            result = (result * a) % m;
        }
        a = (a * a) % m;
        b /= 2;
    }
    result
}

fn comb_mod(a: i64, b: i64, m: i64) -> i64 {
    let b = std::cmp::min(b, a - b);
    let num = (a - b + 1..a + 1).fold(1, |acc, x| mul_mod(acc, x, m));
    let den = (1..b + 1).fold(1, |acc, x| mul_mod(acc, x, m));
    div_mod(num, den, m)
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#define lli long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
using Graph = vector<vector<int>>;
int main()
{
	int n, x, y;
	cin >> n >> x >> y;
	x -= 1;
	y -= 1;

	Graph G(n);
	rep(i,n-1){
		G[i].push_back(i+1);
		G[i+1].push_back(i);
	}

	G[x].push_back(y);
	G[y].push_back(x);

	queue<int> que;
	vector<int> Dist(n, 0);

	rep(i,n){
		vector<int> dist(n, -1);
		dist[i] = 0;
		que.push(i);

		while(!que.empty()){
			int v = que.front();
			que.pop();

			for(int nv : G[v]){
				if(dist[nv] != -1) continue;

				dist[nv] = dist[v] + 1;
				que.push(nv);
			}
		}
		rep(j,n) Dist[dist[j]]++;
	}

	loop(i, 1, n){
		cout << Dist[i]/2 <<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <map>

using namespace std;

typedef long long ll;

int main() {
    ll n, m, a, b, c, ans = 0, cnt = 0;
    scanf("%lld%lld", &n, &m);
    map<ll, ll> d;
    for (ll i = 0; i < n; ++i) scanf("%lld", &a), ++d[a];
    for (ll i = 0; i < m; ++i) {
        scanf("%lld%lld", &b, &c);
        d[c] += b;
    }
    for (auto i = d.rbegin(); i != d.rend(); ++i) {
        if (cnt + (*i).second <= n) {
            ans += (*i).first * (*i).second;
            cnt += (*i).second;
        } else if (cnt < n) {
            ans += (*i).first * (n - cnt);
            cnt = n;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 12800
package main

import (
	"fmt"
	"log"
	"math/rand"
)

const D = 365
const T = 26

const isTest = false

func main() {
	if !isTest {
		var d int
		var c [T]int
		var s [D][T]int
		fmt.Scanf("%d", &d)
		for i := 0; i < T; i++ {
			fmt.Scanf("%d", &c[i])
		}
		for i := 0; i < d; i++ {
			for j := 0; j < T; j++ {
				fmt.Scanf("%d", &s[i][j])
			}
		}

		ans := solve(d, c[:], s[:])
		for i := 0; i < d; i++ {
			fmt.Printf("%d\n", ans[i]+1)
		}
	} else {
		maxscore := 0
		for p := 0; p < 50; p++ {
			c, s := makeproblem(D)
			ans := solve(D, c, s)
			sc := score(ans, D, c, s)
			fmt.Printf("score:%d\n", sc)
			fmt.Printf("ans:%+v\n", ans)
			fmt.Printf("c:%+v, s:%+v\n", c, s[0])
			if sc > maxscore {
				maxscore = sc
			}
			fmt.Printf("maxscore:%d\n", maxscore)
		}
	}
}

func makeproblem(d int) ([]int, [][T]int) {
	var c [T]int
	var s [D][T]int
	for i := 0; i < T; i++ {
		c[i] = rand.Intn(101)
	}
	for i := 0; i < d; i++ {
		for j := 0; j < T; j++ {
			s[i][j] = rand.Intn(20001)
		}
	}
	return c[:], s[:]
}

func solve(d int, c []int, s [][T]int) []int {
	//return random(d, c, s)
	return donyoku(d, c, s)
}

func random(d int, c []int, s [][T]int) []int {
	var ans [D]int
	for i := 0; i < d; i++ {
		ans[i] = rand.Intn(T)
	}
	return ans[:]
}

func donyoku(d int, c []int, s [][T]int) []int {
	var ans [D]int
	var sc int
	var max int
	var maxtype int
	for i := 0; i < d; i++ {
		max = -1
		maxtype = -1
		for j := 0; j < T; j++ {
			ans[i] = j
			sc = score(ans[:], i+1, c, s)
			if sc > max {
				max = sc
				maxtype = j
			}
		}
		if maxtype == -1 {
			log.Fatalf("ERROR i:%d max:%d", i, max)
		}
		ans[i] = maxtype
	}
	return ans[:]
}

func score(ans []int, d int, c []int, s [][T]int) int {
	var ret int
	var delta int
	var last [T]int
	for i := 0; i < d; i++ {
		last[ans[i]] = i + 1
		delta = s[i][ans[i]]
		for j := 0; j < T; j++ {
			delta -= c[j] * (i + 1 - last[j])
		}
		ret += delta
	}
	ret += 1000000
	if ret < 0 {
		return 0
	}
	//log.Printf("ret:%d", ret)
	return ret
}


Measured memory_bytes: 2644
pi = 3.14159265358979
a,b,c = gets.split.map(&:to_f)
r = pi*c/180.0

t = Math.sqrt(a*a+b*b-2*a*b*Math.cos(r))

puts a*b*Math.sin(r)/2.0.round(6)
puts (a+b+t).round(6)
puts b*Math.sin(r).round(6)



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

int main() {
    char a[5];
    cin>>a;
    for(int i=0; i<4; i++) a[i] -= '0';
    for(int i=0; i<2; i++) {
        for(int j=0; j<2; j++) {
            for(int k=0; k<2; k++) {
                if(a[0]+(2*i-1)*a[1]+(2*j-1)*a[2]+(2*k-1)*a[3] == 7) {
                    char op[3] = {'-','-','-'};
                    if(i) op[0]='+';
                    if(j) op[1]='+';
                    if(k) op[2]='+';
                    cout<<(int)a[0]<<op[0]<<(int)a[1]<<op[1]<<(int)a[2]<<op[2]<<(int)a[3]<<"=7"<<endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
import math

a, b, c, d = map(int, input().split())
cd = (c * d) // math.gcd(c, d)
u = b//c + b//d - b//cd
l = (a-1)//c + (a-1)//d - (a-1)//cd

print(b - a + 1 - u + l)


Measured memory_bytes: 9004
#include <cstring>
#include <bits/stdc++.h>
#define re register
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define MAXN 4000007
using namespace std;
const int inf = 0x3f3f3f3f;
int n,pre[MAXN],nxt[MAXN],a[MAXN],flag;
int main()
{
    cin>>n;
    for(re int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]%2!=i%2) flag=1;
    }
    
    for(re int i=1;i<=n;i++) pre[i]=max(pre[i-1],a[i]);
    memset(nxt,100,sizeof(nxt));
    for(re int i=n;i>=1;i--) nxt[i]=min(nxt[i+1],a[i]);
    for(re int i=2;i<=n-1;i++)
        if(a[i]!=i&&nxt[i+1]<a[i]&&pre[i-1]>a[i])
            flag=1;
    for(re int i=1;i<=n-1;i++)
        if(((a[i]==i)==(a[i+1]==i+1))&&pre[i]!=i)
            flag=1;
    if(flag) cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 19840
#include<stdio.h>
int main()
{
	int n,h[101],a;
	while(1){
		scanf("%d",&n);
		if(n==0)
			break;
		for(int i=0;i<n+1;i++)
			scanf("%d",&h[i]);
		if(h[1]-h[0]==h[2]-h[1]&&h[3]-h[2]==h[2]-h[1]){
			a=h[1]-h[0];
			for(int i=2;i<n+1;i++){
				if(h[i+1]-h[i]!=a){
					printf("%d\n",h[i+1]);
					break;
				}
			}
		}
		else{
			if(h[4]-h[2]==h[1]-h[0])
				printf("%d\n",h[3]);
			else if(h[4]-h[3]==h[1]-h[0])
				printf("%d\n",h[2]);
			else if(h[4]-h[3]==h[2]-h[0])
				printf("%d\n",h[1]);
			else
				printf("%d\n",h[0]);
		}
	}
	return 0;
}

Measured memory_bytes: 1032
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

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

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::vector<std::pair<double, std::string>> XU;
	std::cin >> N;
	XU.resize(N);
	for (auto& xu : XU) {
		std::cin >> xu.first >> xu.second;
	}
	
	double result = 0;
	for (const auto& xu : XU) {
		if (xu.second == "JPY") {
			result += xu.first;
		} else {
			result += xu.first * 380000.0;
		}
	}
	printf("%.12f\n", result);
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
const int maxn = 1e5 + 5;
int a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    string a ; cin >>a;
    int n = a.size();
    string b = "dream";
    string c = "dreamer";
    string d = "erase";
    string e = "eraser";
    bool ok = true;
    string x , y , z , w;
    for (int i = n - 1 ; i >= 0 ; ){
        if (i - (int)b.size() + 1 >= 0)
            x = a.substr(i - b.size() + 1 , b.size());
        else x = "";
        if (i - (int)c.size() + 1 >= 0)
            y = a.substr(i - c.size() + 1 , c.size());
        else y = "";
        if (i - (int)d.size() + 1 >= 0)
            z = a.substr(i - d.size() + 1 , d.size());
        else z = "";
        if (i - (int)e.size() + 1 >= 0)
            w = a.substr(i - e.size() + 1 , e.size());
        else w = "";
       // cout << x << " " << y << " " << z << " " << w << endl;
        if (x == b) i -= b.size();
        else if (y == c) i -= c.size();
        else if (z == d) i -= d.size();
        else if (w == e) i -= e.size();
        else {
            ok = false;
            break;
        }
    }
    if (ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3768
#include <iostream>
using namespace std;
int main(){
    int YJ,MUR,KMR;
    cin>>YJ>>MUR>>KMR;
    if(YJ<MUR && MUR<KMR){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
    
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define MAX 100007
int r[MAX];
int a[MAX];
int b[MAX];
int k1[MAX];

int main(){
	int x,k,q;
	cin >> x >> k;
	for(int i=1; i<=k; i++)cin >> r[i];
	r[k+1]=INT_MAX;
	a[0]=0;
	b[0]=x;
	k1[0]=1;
	// printf("%d %d %d\n",a[0],b[0],k1[0]);
	for(int i=1; i<=k; i++){
		int dt=r[i]-r[i-1];
		if(i&1){
			a[i]=max(a[i-1]-dt,0);
			b[i]=max(b[i-1]-dt,0);
			if(a[i]==b[i])k1[i]=(x+1);
			else k1[i]=min(k1[i-1]+max(dt-a[i-1],0),x);
		}
		else{
			a[i]=min(a[i-1]+dt,x);
			b[i]=min(b[i-1]+dt,x);
			if(a[i]==b[i])k1[i]=(x+1);
			else k1[i]=max(k1[i-1]-max(dt-x+a[i-1]+1,0),0);
		}
		// printf("%d %d %d\n",a[i],b[i],k1[i]);
	}
	cin >> q; 
	for(int i=1; i<=q; i++){
		int tq, aq;
		cin >> tq >> aq;
		if(tq==0){cout << aq << endl; continue;}
		int p=lower_bound(r,r+k+2,tq)-r-1;
		int dt=tq-r[p];
		int	res=min(a[p]+max(aq-k1[p]+1,0),b[p]);
		// cout << dt << " " << res << " ";
		res= (p&1) ? min(res+dt,x) :max(res-dt,0);
		// cout << p << " " << res << endl;
		cout << res << endl;
	}
}

Measured memory_bytes: 2816
S = input()
N = len(S)


def generator(length, prev):
    start = prev
    dic = {'0':'1', '1':'0'}
    while len(start) < length:
        next = dic[prev]
        start += next
        prev = next

    return start

first_zero = generator(N, '0')
first_one = generator(N, '1')

cnt_zero = 0
for i in range(N):
    if first_zero[i] == S[i]:
        cnt_zero += 1


cnt_one = 0
for i in range(N):
    if first_one[i] == S[i]:
        cnt_one += 1

print(min(cnt_zero, cnt_one))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,a,b;scanf("%lld%lld%lld",&n,&a,&b);
    if((b&1)==(a&1)) cout<<(max(a,b)-min(a,b)>>1)<<endl;
    else
    {
        if(a>b) swap(a,b);
        ll ans=min(a+(b-a-1>>1),(n-b+1)+((n-(a+n-b+1))>>1));
        cout<<ans;
    }
}


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

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	for(int i = 0; i < n; ++i){ cin >> b[i]; }
	vector<vector<ll>> g(51, vector<ll>(51, 0));
	for(int i = 0; i <= 50; ++i){
		for(int j = 0; j <= i; ++j){
			for(int s = 0; s <= 51; ++s){
				if(i == j){
					g[i][j] |= (1ll << s);
				}else if(s > 0 && g[i % s][j] & ((1ll << s) - 1)){
					g[i][j] |= (1ll << s);
				}else if(g[i][j] & ((1ll << s) - 1)){
					g[i][j] |= (1ll << s);
				}
			}
		}
	}
	bool possible = true;
	for(int i = 0; i < n; ++i){
		if(g[a[i]][b[i]] == 0){ possible = false; }
	}
	if(!possible){
		cout << -1 << endl;
		return 0;
	}
	vector<ll> h(n);
	for(int i = 0; i < n; ++i){ h[i] = (1ll << a[i]); }
	ll answer = 0;
	for(int s = 51; s > 0; --s){
		bool required = false;
		for(int i = 0; i < n; ++i){
			bool flag = false;
			for(int j = 0; j <= 50; ++j){
				if((h[i] & (1ll << j)) && (g[j][b[i]] & ((1ll << s) - 1))){
					flag = true;
				}
			}
			if(!flag){ required = true; }
		}
		if(required){
			answer |= (1ll << s);
			for(int i = 0; i < n; ++i){
				for(int j = 0; j <= 50; ++j){
					if(h[i] & (1ll << j)){ h[i] |= (1ll << (j % s)); }
				}
			}
		}
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        long[] as = new long[n];
        for (int i = 0; i < n; i++) {
            as[i] = std.nextInt();
        }

        int nextleft = 0;
        int nextRight = n - 1;
        BigDecimal leftLen = BigDecimal.ZERO;
        BigDecimal rightLen = BigDecimal.ZERO;
        while (nextleft <= nextRight) {
            if (leftLen.compareTo(rightLen) <= 0) {
                leftLen = leftLen.add(BigDecimal.valueOf(as[nextleft]));
                nextleft++;
            } else {
                rightLen = rightLen.add(BigDecimal.valueOf(as[nextRight]));
                nextRight--;
            }
        }

        System.out.println(leftLen.subtract(rightLen).abs());
    }
}


Measured memory_bytes: 92092
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components
import numpy as np
from collections import defaultdict

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

if M == 0:
    print(-1)
    exit()

AB = [tuple(int(x) for x in line.split()) for line in readlines()]

A,B = zip(*AB)
graph = csr_matrix(([1]*M,(A,B)),(N+1,N+1))
_,comp = connected_components(graph,connection='strong')

size = np.bincount(comp)

if size.max() == 1:
    print(-1)
    exit()

n = np.where(size > 1)[0][0]

V = set(np.where(comp == n)[0])

graph = [[] for _ in range(N+1)]
for a,b in AB:
    if a in V and b in V:
        graph[a].append(b)

# とりあえず1つサイクルを見つける
order = defaultdict(int)
x = V.pop()
V.add(x)
q = [x]
order[x] = 1
path = [x]
flag = False
while True:
    y = graph[x][0]
    if order[y] != 0:
        path = path[order[y]-1:]
        break
    path.append(y)
    order[y] = order[x] + 1
    x = y

V = set(path)
next_v = {u:v for u,v in zip(path,path[1:])}; next_v[path[-1]] = path[0]

# 辺を1つ追加しながら、小さいサイクルを見つける
for a,b in AB:
    if not (a in V and b in V):
        continue
    # 間の頂点を削除
    x = next_v[a]
    while x != b:
        V.remove(x)
        x = next_v[x]
    next_v[a] = b

print(len(V))
print(*V,sep='\n')



Measured memory_bytes: 17168
N = int(input())
s = input()
countR= 0
countB= 0
for i in range(N):
    if s[i] == 'R':
        countR += 1
    elif s[i] == 'B':
        countB += 1
        
if countR > countB:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
import sys
def input():
    return sys.stdin.readline()[:-1]
    
n = int(input())
A = []

for i in range(n):
    a,num = input().split()
    A.append([a,int(num),i])
    
def partition(A,p,r):
    #import random
    #rand = 1+int(p+(r-p)*random.random())
    #A[rand],A[r] = A[r],A[rand]    
    x = A[r][1]
    i = p-1
    for j in range(p,r):
        if A[j][1]<= x:
            i += 1
            A[i],A[j] = A[j],A[i]
    A[i+1],A[r] = A[r],A[i+1]
    return i+1

def quickSort(A,p,r):
    if p<r:
        q = partition(A,p,r)
        quickSort(A,p,q-1)
        quickSort(A,q+1,r)
        
quickSort(A,0,n-1)

def check_stable(A):
    for i in range(n-1):
        if (A[i][1] == A[i+1][1]) & (A[i][2]>A[i+1][2]):
            return "Not stable"
    return "Stable"

print(check_stable(A))

for a,num,_ in A:
    print(*[a, num])


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


int main() {
  string s;
  cin >> s;
  s[5]=' ',s[13]=' ';
  cout << s << endl;
  return 0;
}

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

int main()
{
    int arr[3];
    int a, b; cin >> a >> b;
    arr[0]= a + b; arr[1] = a - b; arr[2] = a * b;
    int max = arr[0];
    for (int i = 0; i < 3; i ++)
    {
        if (arr[i] > max)
            max = arr[i];
    }
    cout << max;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while(true) {
        	int x = sc.nextInt();
        	int y = sc.nextInt();
        	int s = sc.nextInt();
        	if(x + y + s == 0) break;
        	int max = 0;
        	for(int i=1;i<s;i++) {
        		for(int j=1;j<=s-i;j++) {
        			int a = i*(100+x)/100;
        			int b = j*(100+x)/100;
        			if(a + b != s) continue;
            		int ay = i*(100+y)/100;
            		int by = j*(100+y)/100;
            		max = Math.max(ay+by, max);
        		}
        	}
        	System.out.println(max);
         }
       
    }
}


Measured memory_bytes: 28908
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 998244353
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
int main()
{
       ios::sync_with_stdio(0) ;
       cin.tie(0); 
       string s;
       cin>>s;
       int n=s.size();int flag=1;
       for(int i=0,j=(n/2)-1;i<(n/2);i++,j--)
       {
           if(s[i]!=s[j])
           flag=0;
       }
       for(int i=0,j=(n/2)-1;i<(n/2);i++,j--)
       {
           if(s[i]!=s[j])
           flag=0;
       }
       int i=n/2;
       i++;
       int j=n-1;
       for(;i<n;i++,j--)
       {
           if(s[i]!=s[j])
           flag=0;
       }
       i=0;j=n-1;
        for(;i<n;i++,j--)
       {
           if(s[i]!=s[j])
           flag=0;
       }
       if(flag==0)
       cout<<"No"<<endl;
       else
       cout<<"Yes"<<endl;
  return 0 ;
}
//make all values ll



Measured memory_bytes: 256
def dfs(fld, check, sy, depth)
  ok = true
  ny = -1
  (sy...fld.size).each do |y|
    (0...fld[y].size).each do |x|
      if check[y][x] == depth && fld[y][x] == '*'
        ny = y if ny == -1
        l = r = x
        loop do
          check[y][r] = depth + 1
          break if fld[y][r+1] != '*'
          r += 1
        end
        ml, mr = fld[y+1][l-1..r+1].map.with_index(l-1){ |e, i| i if e == '*' }.compact
        ml -= l; mr -= r

        yy = y + 1; xl = l + ml; xr = r + mr
        loop do
          check[yy][xl] = check[yy][xr] = depth + 1
          (xl+1...xr).each{ |k| check[yy][k] = depth + 2 }
          if fld[yy + 1][xl + ml] != '*'
            (xl+1...xr).each{ |k| check[yy][k] = depth + 1 }
            break
          end
          yy += 1; xl += ml; xr += mr
        end

        s = ((r - l + 1) + (xr - xl + 1)) * (yy - y + 1) / 2
        $ret[s] ||= 0
        $ret[s] += 1
        ok = false
      end
    end
  end
  return true if ok
  return true if dfs(fld, check, ny, depth + 2)
end

l = false
while n = gets.to_i
  break if n == 0
  if l
    10.times{ print '-' }
    puts
  end
  l = true
  fld = [*n.times.map{ [' ', *gets.chomp.split(''), ' '] }, [' '] * 100]
  $ret = {}
  check = (n+1).times.map{ [0] * 100 }
  dfs(fld, check, 0, 0)
  $ret.sort.each{ |k, v| puts "#{k} #{v}" }
end

Measured memory_bytes: 10272
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n = int(readline())
#C = [0]*n
#D = [0]*n

"""
dp[i][j] = 2,5で何回割れるか
"""
dp = [[0]*20 for _ in range(50)]

M = 10**9
for i in range(n):
    bi = float(readline())
    ai = int(round(bi*M))
    
    c2=c5=0    
    x = ai
    while x%2==0:
        c2 += 1
        x//=2
    
    x = ai
    while x%5==0:
        c5 += 1
        x//=5
    #C[i] = c2
    #D[i] = c5
    dp[c2][c5] += 1
    #print(c2,c5)

"""
dp[i][j] = 2,5で何回割れるか(50*20)
"""
acc = [dp[i][:] for i in range(50)]
for i in range(49,-1,-1):
    for j in range(19,-1,-1):
        if i != 49:
            acc[i][j] += acc[i+1][j] 
        if j != 19:
            acc[i][j] += acc[i][j+1] 
        if i != 49 and j != 19:
            acc[i][j] -= acc[i+1][j+1] 
            
ans = 0
for i in range(50):
    for j in range(20):
        ans += dp[i][j] * acc[max(0,18-i)][max(0,18-j)]
        if i >= 9 and j >= 9: ans -= dp[i][j]

#print(ans)
print(ans//2)











Measured memory_bytes: 68732
/*
* @Author: kabbo
* @Date:   2020-06-24 08:40:07
* @Last Modified by:   kabbo
* @Last Modified time: 2020-06-24 08:49:58
*/
#include<bits/stdc++.h>
using namespace std;
#define pii pair<long long,long long>
#define endl '\n'
#define ull unsigned long long
#define ll long long
const int mod = 1e9 + 7;
using u64 = uint64_t;
using u128 = __uint128_t;
#define sc1(x) scanf("%lld",&(x));
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
void solve() {
	int n;
	cin >> n;
	map<string, int>mp;
	mp["AC"] = 0, mp["TLE"] = 0, mp["WA"] = 0, mp["RE"] = 0;
	while (n--) {
		string str;
		cin >> str;
		mp[str]++;
	}
	cout << "AC" << " x " << mp["AC"] << endl;
	cout << "WA" << " x " << mp["WA"] << endl;
	cout << "TLE" << " x " << mp["TLE"] << endl;
	cout << "RE" << " x " << mp["RE"] <<endl;



}
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//int t;
	////cin >> t;
	//for (int i(1); i <= t; ++i) {
	//printf("Case %d:\n", i);
	solve();
	//}
#ifndef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
	return 0;
}

Measured memory_bytes: 3884
s = input()
for i in range(len(s)):
  if i%2==0 and s[i] not in ['R', 'U', 'D']:
    print('No')
    exit()
  elif i%2==1 and s[i] not in ['L', 'U', 'D']:
    print('No')
    exit()


print('Yes')

Measured memory_bytes: 3060
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] h = new int[n];
		
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		
		int ans = 0;
		while(true) {
			int min = 101;
			int mini = -1;
			for(int i = 0; i < n; i++) {
				if(h[i] != 0) {
					min = Math.min(min, h[i]);
					mini = i;
				}
			}
			
			if(min == 101) {
				break;
			}
			int left = mini;
			int right = mini;
			for(int i = mini - 1; i >= 0; i--) {
				if(h[i] == 0) {
					break;
				}
				left--;
			}
			for(int i = mini + 1; i < n; i++) {
				if(h[i] == 0) {
					break;
				}
				right++;
			}
			
			for(int i = left; i <= right; i++) {
				h[i] -= min;
			}
			ans += min;
		}
		
		System.out.println(ans);
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++)cin >> A[i];
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    
    long long n = A[0];
    long long m = n / 2;
    long long r, d = abs(m - A[0]);
    for(int i = 0; i < N; i++){
        long long dis = abs(m - A[i]);
        if(d > dis){
            d = dis;
            r = A[i];
        }
    }
    cout << n << " " << r << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
const static int INF = 10000000.0;
using namespace std;
int main() {
	double n,t,a;
	cin >> n >> t >> a;
	double h;

	double mn = INF;
	int H = -1;

	for (int i = 1; i < n+1; i++) {
		cin >> h;
		double s = t - (h * 0.006);
		double d = a - s;
		if (d < 0) d = d * (-1.0);

		mn = min(mn, d);
		if (mn == d) H = i;

	}
	cout << H << endl;
	return 0;
}

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

int main(){
string S;
  cin>>S;
  int sum=0;
  int max=0;



  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A'||S.at(i)=='T'||S.at(i)=='G'||S.at(i)=='C'){
      sum++;
      if(sum>max){


      max=sum;

  }
}

    else if(sum!=0&&(S.at(i)!='A'&&S.at(i)!='T'&&S.at(i)!='G'&&S.at(i)!='C')){
      sum=0;

  }

}
cout<<max<<endl;
}

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;
int INF = 1000000009;
const int mod = 2019;
struct mint
{
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
  mint inv() const
  {

    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
int main()
{
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  mint pre = 0;
  mint k = 1;
  map<ll, ll> mp;
  rep(i, s.size())
  {
    pre += (k * (int)(s[i] - '0'));
    mp[pre.x]++;
    k *= 10;
  }
  ll ans = 0;
  rep(i, 2019)
  {
    if(i==0)
      ans += mp[i];
    ans += mp[i] * (mp[i] - 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3724
import numpy as np
n = int(input())
x = np.array(input().split(),dtype=int)

ave = 0
for i in range(n):
    ave += x[i]
ave /= n
ave = int(ave+0.5)

ans = 0
for i in range(n):
    ans += (x[i]-ave)**2

print(ans)


Measured memory_bytes: 12496
/*
读题不规范，爆零两行泪。
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
const int N=10,S=50;
int n,m,s;
int a[S+1],b[S+1],c[S+1],d[S+1];
int lis[N+1];
int ans;
void dfs(int x=1,int now=1){
	if(x==n+1){
		int res=0;
		for(int i=1;i<=s;i++)if(lis[b[i]]-lis[a[i]]==c[i])res+=d[i];
		ans=max(ans,res);
		return;
	}
	lis[x]=now;
	for(int i=now;i<=m;i++)dfs(x+1,i);
}
int main(){
	cin>>n>>m>>s;
	for(int i=1;i<=s;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];
	dfs();
	cout<<ans;
	return 0;
}

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

int gcd(int a, int b)
{
  if (a < b) {
    swap(a, b);
  }
  for (int r; (r = a % b) != 0;) {
    a = b;
    b = r;
  }
  return b;
}

int main()
{
  int x, y;
  while (cin >> x >> y && x != 0) {
    const int g = gcd(x, y);
    x /= g; y /= g;
    vector<int> seen(y, -1);
    seen[x] = 0;
    for (int c = 1;; c++) {
      x = (10*x) % y;
      if (x == 0) {
        cout << c << " 0" << endl;
        break;
      } else if (seen[x] != -1) {
        cout << seen[x] << ' ' << c-seen[x] << endl;
        break;
      }
      seen[x] = c;
    }
  }
  return 0;
}

Measured memory_bytes: 4848
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	k := iScan()
	s := iScan()
	if s != mod-7 {
		ans := make([]int, n)
		for i := 0; i < k; i++ {
			ans[i] = s
		}
		for i := k; i < n; i++ {
			ans[i] = mod - 7
		}
		fmt.Println(strings.Trim(fmt.Sprint(ans), "[]"))
	} else {
		ans := make([]int, n)
		for i := 0; i < k; i++ {
			ans[i] = s
		}
		for i := k; i < n; i++ {
			ans[i] = 1
		}
		fmt.Println(strings.Trim(fmt.Sprint(ans), "[]"))
	}
}


Measured memory_bytes: 9372
function main(input) {
    var inputs = input.split("\n");
    var HW = inputs.shift().split(" ");
    var H = HW.shift();
    var W = HW.shift();
    var hw = inputs.shift().split(" ");
    var h = hw.shift();
    var w = hw.shift();
    console.log((H - h) * (W - w));
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n, 0), b(n, 0), p(n, 0);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }

    for (int i = 0; i < n; ++i) {
        a[i] = 1 + n * i;
        b[n - 1 - i] = a[i];
    }

    for (int i = 0; i < n; ++i) {
        a[p[i] - 1] += i;
    }

    for (int i = 0; i < n; ++i) {
        if (i != 0) cout << " ";
        cout << a[i];
    }
    cout << endl;

    for (int i = 0; i < n; ++i) {
        if (i != 0) cout << " ";
        cout << b[i];
    }
    cout << endl;
}

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

#define REP(i,n) for(int i =0; i <n; ++i)

#define REPR(i,n) for(int i =n; i >=0; --i)

#define REP_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

//const ll MOD = 1000000007;

//const  long double PI=(acos(-1));

//const  long double EPS=0.0000000001;

int main(){
    int a,b,c;
    cin >> a >> b >> c;

    int d = a + b + c;

    if(d >= 22)cout << "bust" << endl;
    else cout << "win" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, i, num = 0;
	
	scanf("%d %d %d", &a, &b, &c);
	
	for (i = a; i <= b; i++) {
		if (c % i == 0) {
			num++;
		}
	}
	
	printf("%d\n", num);
	
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a,b,c,k;
  cin>>a>>b>>c;
  cin>>k;

  ll cnt=0;
  while(a>=b){
    b*=2;
    cnt++;
  }

  while(b>=c){
    c*=2;
    cnt++;
  }
  if(cnt<=k)
    yes;
  else
    no;



}



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

string s;
int n;

bool check(string &t)
{
	bool ok = true;
	for (int i = 0; i < n; i++)
	{
		int prv = (i - 1 + n) % n;
		int nxt = (i + 1) % n;
		ok &= t[i] == 'S' && (s[i] == 'o' ^ t[prv] != t[nxt]) || t[i] == 'W' && (s[i] == 'o' ^ t[prv] == t[nxt]);
	}
	return ok;
}

void gen(string t)
{
	t.resize(n);

	for (int i = 2; i < n; i++)
	{
		if (t[i - 1] == 'S')
		{
			if (s[i - 1] == 'o')
				t[i] = t[i - 2];
			else
				t[i] = t[i - 2] ^ 'S' ^ 'W';
		}
		if (t[i - 1] == 'W')
		{
			if (s[i - 1] != 'o')
				t[i] = t[i - 2];
			else
				t[i] = t[i - 2] ^ 'S' ^ 'W';
		
		}
	}

	if (check(t))
	{
		cout << t << '\n';
		exit(0);
	}
}

int main()
{
	cin >> n >> s;
	s += s[0];

	gen("SS");
	gen("SW");
	gen("WS");
	gen("WW");

	cout << -1 << '\n';
	return 0;
}


Measured memory_bytes: 512
import fractions
import math
def pFactorize(num):
    factor_list = []
    for i in range(2, math.floor(math.sqrt(num))+ 1):
        if num % i == 0:
            factor_list.append([i,1])
            num //= i
        while num % i == 0:
            factor_list[-1][1] += 1
            num //= i
    if not num == 1:
        factor_list.append([num,1])
    return factor_list
a,b=[int(_) for _ in input().split()]
c=pFactorize(fractions.gcd(a,b))
print(len(c)+1)


Measured memory_bytes: 64108
import math
from decimal import *
def solve():
  getcontext().prec = 99
  a,b,c = (int(i) for i in input().split())
  if Decimal(a)**Decimal("0.5") + Decimal(b)**Decimal("0.5") < Decimal(c)**Decimal("0.5"):
    print("Yes")
  else:
    print("No")
    
solve()

Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i=j;i<=k;i++)
set<string> st;
void init(){
	string s1="KIH",s2="B",s3="R",s4="A";
	rep(i,0,1)
		rep(j,0,1)
			rep(k,0,1)
				rep(l,0,1){
					string s_ok;
					if(i==1) s_ok+=s4;
					s_ok+=s1;
					if(j==1)s_ok+=s4;
					s_ok+=s2;
					if(k==1)s_ok+=s4;
					s_ok+=s3;
					if(l==1)s_ok+=s4;
					st.insert(s_ok);
				}
	return;
		
}
string s;
int main(){
	init();
	cin>>s;
	if(s.size()>9){puts("NO");return 0;}
	if(st.count(s)!=0) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
def calc(n):
    if n == 2:
        return [[1], [1]], 1
    lis, val = calc(n - 1)
    for i, l in enumerate(lis):
        l.append(val + 1 + i)
    lis.append(list(range(val + 1, val + n)))
    return lis, val + n - 1

N = int(input())
base = 1
n = 4
while ((base // 2) < N) and (N != 1):
    base = (n - 1) * (n - 2)
    n += 1
if base == (N * 2) or (N == 1):
    lis,_ = calc(n - 2)
    length = len(lis[0])
    k = len(lis)
    print('Yes')
    print(k)
    [print(length, ' '.join(map(str, l))) for l in lis] 
else:
    print('No')

Measured memory_bytes: 12404
A,B = gets.split.map(&:to_i)
P = [2,3,4,5,6,7,8,9,10,11,12,13,1]
if P.index(A) > P.index(B)
  puts 'Alice'
elsif P.index(A) < P.index(B)
  puts 'Bob'
else
  puts 'Draw'
end

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = l[0], T = l[1];
            var human = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var before = human[0];
            var ans = 0L;
            for (var i = 1; i < N; i++)
            {
                var diff = human[i] - before;
                if (diff >= T)
                    ans += T;
                else
                    ans += diff;

                before = human[i];
            }

            ans += T; 
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28704
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
    string s;
    string t;

    cin >> s;
    for (int i = 0; i < s.size(); i += 2) {
        t += s[i];
    }
    cout << t << endl;

    return 0;
}

Measured memory_bytes: 512
"use strict";
const Main = (input) =>{
    let xs = input.trim().split('\n').map(v=>parseInt(v,10));
    let A =[];
    let B =[]; 
    let ans = 0;
    for(let i=0; i<xs.length; i++){
    A.push(Math.ceil(xs[i]/10)*10);
    B.push(Math.ceil(xs[i]/10)*10-xs[i])
    ans+=A[i];
    }
    const compare = (a, b)=>{ 
    return b - a;      
    }
    B.sort(compare); 
    console.log(ans-B[0]);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl
#define printV(v) for(int zxc=0;zxc<v.size()-1;zxc++){cout << v[zxc] << " ";} cout << v.back() << endl;

int main() {
    string s;
    cin >> s;
    int c = -1, f = -1;
    bool ok = false;
    REP(i,s.size()) {
        if (s[i] == 'C') {
            c = i;
            break;
        }
    }
    if (c == -1) {
        cout << "No" << endl;
        return 0;
    }
    REP(i,s.size()) {
        if (s[i] == 'F') {
            f = i;
            if (f > c) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
point=[list(map(int,input().split())) for i in range(N)]
distance=0
for i in range(N-1):
    for j in range(i+1,N):
        try:
            a,b=tuple(point[i])
            c,d=tuple(point[j])
            a-=c
            b-=d
            distance+=(a**2+b**2)**(1/2)
        except:
            continue
print(2*distance/N)

Measured memory_bytes: 3064
use std::str::FromStr;
fn main() {
    let mut ab = String::new();
    std::io::stdin().read_line(&mut ab).ok();
    let mut it = ab.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let a : i64 = it.next().unwrap();
    let b : i64 = it.next().unwrap();
    if a <= 0 && b >= 0 {
        println!("Zero");
    } else if a > 0 {
        println!("Positive");
    } else {
        if (b - a + 1) % 2 == 0 {
            println!("Positive");
        } else {
            println!("Negative");
        }
    }
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main() {
  long long int X,K,D;
  cin >> X >> K >> D;
  long long int ax = X;
  if (X < 0ll) ax = -X;
  long long int b = ax / D;
  long long int ans = 0ll;
  if (b > K) {
    ans = ax - K * D;
  } else {
    if ((K-b)%2 == 0) {
      ans = ax - b * D;
    } else {
      ans = D - (ax - b * D);
    }
  }
  cout << ans;
  return 0;
}

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

using namespace std;

int n;
vector<int> A(20);

bool solve(int i, int m)
{
	if (!m)
		return true;

	if (i >= n)
		return false;

	return solve(i + 1, m) || solve(i + 1, m - A[i]);
}

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

	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> A[i];

	int q, m;
	cin >> q;
	while (q--)
	{
		cin >> m;
		if (solve(0, m))
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}

	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }
 
 
const long long MAXN = 1e9 + 9;
const long long SIZE = 3e5 + 5;
const long long MOD = 1e9 + 7;

int H, W, N, mH, mW;
vector<int> CH[SIZE], CW[SIZE], rows, cols;
unordered_map<int, bool> was[SIZE];
long long res;


int main() { speedhack()

	cin >> H >> W >> N;

	forn (i, N) {
		int I, J;
		cin >> I >> J;
		CH[I].push_back(J);
		CW[J].push_back(I);
		mH = max(mH, (int)CH[I].size());
		mW = max(mW, (int)CW[J].size());
		was[I][J] = true;
	}

	forn (i, W) {
		if (CW[i].size() == mW)
			cols.push_back(i);
	}

	forn (i, H) {
		if (CH[i].size() == mH)
			rows.push_back(i);
	}

	res = mH + mW;
	bool ok = false;

	for (int r : rows) { 
		if (ok) break;
		for (int c : cols) {
			if (!was[r][c]) {
				ok = true;
				break;
			}
		}
	}

	if (!ok) --res;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 75344