akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[5];
    a[1] = 9;
    a[3] = 1000;
    a[5] = 100000;
    if(n <= 9) cout << n << endl;
    else if(n <= 99) cout << 9 << endl;
    else if(n < 1000) cout << 9 + (n - 99) << endl;
    else if(n < 10000) cout << 909 << endl;
    else if(n < 100000) cout << 909 + (n - 9999) << endl;
    else cout << 90909 << endl;
}

Measured memory_bytes: 256
H, W, A, B = map(int, input().split())

class Combin(object):
    def __init__(self, max_n, mod = 10**9 + 7):
        self.max_n = max_n
        self.mod = mod
        self.fac = self._init_factorials()
        self.inv = self._init_inv()
        
    def _init_factorials(self):
        N = self.max_n
        mod = self.mod
        f = 1
        fac = [1] * (N + 1)
        for i in range(1, N + 1):
            f *= i
            f %= mod
            fac[i] = f
        return fac

    def _init_inv(self):
        N = self.max_n
        mod = self.mod
        ret = pow(self.fac[N], mod - 2, mod)
        inv = [1] * (N + 1)
        inv[N] = ret
        for i in range(N-1, 0, -1):
            ret *= i + 1
            ret %= mod
            inv[i] = ret
        return inv

    def nCb(self, n, b):
        return (self.fac[n] * self.inv[b] * self.inv[n-b]) % self.mod


def solve(H, W, A, B):
    mod = 10 ** 9 + 7
    cb = Combin(H + W)
    ans = cb.nCb(H + W - 2, H - 1)
    t1 = B + H - 1
    t2 = B - 1
    t3 = W - B - 2
    t4 = W - B - 1
    for a in range(1, A + 1):
        d = cb.nCb(t1 - a, t2) * cb.nCb(t3 + a, t4)
        ans -= d
        ans %= mod
    return ans

print(solve(H, W, A, B))

Measured memory_bytes: 18932
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%I64d",&x)
#define ss(s)	scanf("%s",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;
const int N = 3e5;
vi g[N];
int a[N];
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int no, int par);
int cnt[N], dis[N];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,n,k,j, u, v;
	cin>>n>>k;
	vpii E;
	fo(i, n-1){
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
		E.pb({v, u});
	}
	dis[0] = -1;
	int ans = n;
	fo(j, n-1){
		u = E[j].F, v = E[j].S;
		if (k&1){
			dfs(u, v, 0);
			dfs(v, u, 0);
		}
		int cur = 0;
		Fo(i, 1, n+1)
			cur += dis[i] > k/2;
		ans = min(ans, cur);
	}
	if (k&1){
		cout<<ans<<endl;
		return 0;
	}
	ans = n;
	Fo(j, 1, n+1){
		dfs(j, j, 0);
		int cur = 0;
		Fo(i, 1, n+1)
			cur += dis[i] > k/2;
		ans = min(ans, cur);
	}
	cout<<ans<<endl;

	return 0;
} 

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
	if (exp & 1) result = ((ll)result * base) % mod;
	base = ((ll)base * base) % mod;
	exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int no, int par){
	dis[u] = 1 + dis[par];
	for(int v:g[u]){
		if (v == par or v == no) continue;
		dfs(v, no, u);
	}
}

Measured memory_bytes: 7552
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include<vector>
#include<iostream>
#include<set>
#include<map>
#include<algorithm>
using namespace std;




int main() {
	int n;
	cin >>n ;
	set<long long int> se;
	long long int tmp;
	for(int i=0;i<n;++i){
		cin >> tmp;
		se.insert(tmp);
	}
	
	if(se.size() == n) cout << "YES" <<endl;
	else cout << "NO" <<endl;
	
    return 0;
}


Measured memory_bytes: 9600
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)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        n:usize,
        an:[i64;n],
    }
    let mut ans = vec![0;n];
    let mut count = 0;
    for i in (1..n+1).rev() {
        let mut sum = 0;
        let mut index = i;
        while index <= n {
            sum += ans[index-1];
            index += i;
        }
        if sum % 2 != an[i-1] {
            ans[i-1] = 1;
        }
    }
    let mut sub = vec![];
    for i in 0..ans.len() {
        if ans[i] != 0 {
            sub.push(i+1);
        }
    }
    println!("{}",sub.len());
    for i in 0..sub.len(){
        if i > 0 {
            print!(" ");
        }
        print!("{}",sub[i]);
    }
    println!();
}


fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}


Measured memory_bytes: 9340
#include <stdio.h>
#include <vector>
using namespace std;

const int N = 100010;

vector<int> graph[N];
int dep[N], p[20][N];

void go(int now) {
	for (int i = 0; i < graph[now].size(); i++) {
		dep[graph[now][i]] = dep[now] + 1;
		p[0][graph[now][i]] = now;
		go(graph[now][i]);
	}
	return ;
}

int LCA(int l, int r) {
	if (dep[l] < dep[r]) swap(l, r);
	for (int i = 19; i >= 0; i--) {
		if (dep[p[i][l]] >= dep[r]) {
			l = p[i][l];
		}
	}
	for (int i = 19; i >= 0; i--) {
		if (p[i][l] != p[i][r]) {
			l = p[i][l];
			r = p[i][r];
		}
	}
	if (l != r) return p[0][l];
	else return l;
}

int main() {
	int n, k, temp, q, l, r;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &k);
		for (int j = 0; j < k; j++) {
			scanf("%d", &temp);
			graph[i].push_back(temp);
		}
	}
	go(0);
	for (int i = 1; i < 20; i++) {
		for (int j = 0; j < n; j++) {
			p[i][j] = p[i - 1][p[i - 1][j]];
		}
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d%d", &l, &r);
		printf("%d\n", LCA(l, r));
	}
}



Measured memory_bytes: 21044
#include<iostream>
using namespace std;
int main(){
  int p[5];
  while(1){
    int g=0,tyo=0,pa=0;
    cin >> p[0];
    if(p[0]==1){
      g++;
    }
    else if(p[0]==2){
      tyo++;
    }
    else if(p[0]==3){
      pa++;
    }
    if(p[0]==0){
      break;
    }
    for(int i=1;i<5;i++){
      cin >> p[i];
      if(p[i]==1){
	g++;
      }
      else if(p[i]==2){
	tyo++;
      }
      else if(p[i]==3){
	pa++;
      }
    }

    if(g>0 && tyo>0 && pa>0){
      for(int i=0;i<5;i++){
	p[i]=3;
      }
    }
    else if(g==5 || tyo==5 || pa==5){
      for(int i=0;i<5;i++){
	p[i]=3;
      }
    }
    else if(g<=0 && tyo>0 && pa>0){
      for(int i=0;i<5;i++){
	if(p[i]==2){
	  p[i]=1;
	}
	else if(p[i]==3){
	  p[i]=2;
	}
      }
    }
    else if(g>0 && tyo>0 && pa<=0){
      for(int i=0;i<5;i++){
	if(p[i]==1){
	  p[i]=1;
	}
	else if(p[i]==2){
	  p[i]=2;
	}
      }
    }
    else if(g>0 && tyo<=0 && pa>0){
      for(int i=0;i<5;i++){
	if(p[i]==1){
	  p[i]=2;
	}
	else if(p[i]==3){
	  p[i]=1;
	}
      }
    }

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

  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
    /*
    奇数要素と偶数要素でそれぞれ最頻出の数字(p1, p1)と次点で頻出の数字(q1, q2)を記録する。
    p1とp2が異なる場合、それぞれの最頻出数字以外の要素を書き換えれば良い
    p1とp2が同じ場合、q1とq2のうち出現数の少ない側は最頻出数字以外を書き換え、
    多い側は次点の要素以外の数字を書き換える。
    */
    int N; cin >> N;
    vector<int> odd(100010, 0);
    vector<int> even(100010, 0);
    for (int i = 0; i < N; ++i) {
        int x; cin >> x;
        if(i%2) ++odd[x];
        else    ++even[x];
    }
    int p1 = distance(odd.begin(), max_element(odd.begin(), odd.end()));
    int p1c = odd[p1];
    odd[p1] = 0;
    int q1c = *max_element(odd.begin(), odd.end());

    int p2 = distance(even.begin(), max_element(even.begin(), even.end()));
    int p2c = even[p2];
    even[p2] = 0;
    int q2c = *max_element(even.begin(), even.end());

    if (p1 != p2) cout << (N - p1c - p2c) << endl;
    else if (q1c <= q2c) cout << (N - p1c - q2c) << endl;
    else cout << (N - q1c - p2c) << endl;;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll N, M; cin >> N >> M;
    vector<pair<ll, ll>> AB(N);
    rep(i, N) {
        ll x, y; cin >> x >> y;
        AB[i] = make_pair(x, y);
    }
    sort(ALL(AB));

    ll cnt = 0, money = 0;
    for (auto ab : AB) {
        cnt += ab.second; money += (ab.second * ab.first);
        if (M < cnt) {
            ll diff = cnt - M;
            cnt -= diff; money -= (diff * ab.first);
            break;
        }
    }
    cout << money << endl;
}

Measured memory_bytes: 4832
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll n,b,r;
  cin>>n>>b>>r;
   ll p=(b+r);
   ll k=(n%p);
   ll ans=0;
  if(k==0)
    ans=0;
  else if(k<=b)
     ans=k;
  else
     ans=b;
  ll res=0;
   res=b*(n/p) + ans;
   cout<<res<<endl;
}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		_a, _ := strconv.Atoi(buf[0])
		_b, _ := strconv.Atoi(buf[1])
		a := strings.Split(buf[0], "")
		b := strings.Split(buf[1], "")
		if _a == 0 && _b == 0 {
			break
		}
		hit := 0
		blow := 0
		for i, av := range a {
			for j, bv := range b {
				if i == j && av == bv {
					hit++
				}
				if i != j && av == bv {
					blow++
				}
			}
		}
		fmt.Println(hit, blow)
	}
}


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

int main(){
	int x;
	cin >> x;
	int q,r;
	r = x % 500;
	q = (x-r) / 500;
	cout << q * 1000 +((r-r%5)/5)*5 << endl;
	return 0;
}


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

int main() {
  int num_query; cin >> num_query;
  map<string, int> dictionary;
  
  for (int i = 0; i < num_query; i++) {
    int command; scanf("%d", &command);
    char key[20]; scanf("%s", key);
    
    switch (command) {
      case 0:
        int value; scanf("%d", &value);
        if (dictionary.count(key)) {
          dictionary.at(key) = value;
        } else {
          dictionary.insert(make_pair(key, value));
        }
        break;
        
      case 1:
        printf("%d\n", dictionary.at(key));
        break;
    }
  }
}


Measured memory_bytes: 25956
#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>;
#include <math.h>
const int INF = 1001001001;
main(){
  double A,B,H,M;
  cin>>A>>B>>H>>M;
  double rad=(min(abs(5*(H+M/60)-M),60-abs(5*(H+M/60)-M))*2/60*M_PI);
  double ans=sqrt(A*A+B*B-2*A*B*cos(rad));
  cout << fixed << setprecision(9);
  cout<<ans<<endl;
  return 0;
  }

Measured memory_bytes: 4112
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int a,b;
int main() {
  ios::sync_with_stdio(false);
  cin>>a>>b;
  for(int i=1;i<=1000000;i++){
    if(i*8/100==a&&i/10==b)return cout<<i,0;
  }
  cout<<-1;
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a), end(a)

int main(void) {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = INF;
    int lim = max(X, Y) * 2 + 1;
    REP(c, lim) {
        int a = X - c / 2;
        a = max(a, 0);
        int b = Y - c / 2;
        b = max(b, 0);
        // cout << a << " " << b << " " << c << endl;
        ans = min(ans, (ll)(A * a + B * b + C * c));
    }
    cout << ans << endl;
    return 0;
}

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

bool D[100][100];

int main() {
  int A, B; cin >> A >> B;
  for (int i = 0; i < 100; i++)
    for (int j = 0; j < 100; j++)
      D[i][j] = (i >= 50);
  for (int i = 0; i < A-1; i++) {
    D[i/50*2][i%50*2] = true;
  }
  for (int i = 0; i < B-1; i++) {
    D[99-i/50*2][i%50*2] = false;
  }
  cout << "100 100" << endl;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++)
      cout << (D[i][j] ? "." : "#");
    cout << endl;
  }
}

Measured memory_bytes: 3636
fun main(args: Array<String>) {
    arc068d()
}

fun arc068d() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toInt() }

    val remain = aList.groupBy { it }.size

    val answer = if (remain % 2 == 0) remain - 1 else remain

    println(answer)
}


Measured memory_bytes: 57960
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

lst1 = []
lstN = []

for i in range(M):
    if AB[i][0] == 1:
        lst1.append(AB[i][1])
    if AB[i][1] == N:
        lstN.append(AB[i][0])

if list(set(lst1) & set(lstN)) == []:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Measured memory_bytes: 54684
#ifdef _MSC_VER
#  define _CRT_SECURE_NO_WARNINGS
#  define _USE_MATH_DEFINES
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double;
using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
template <typename T> using vec = vector<T>; void in() { }
template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
template <typename T> void out(T &&x) { cout << x << "\n"; }
template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t x; cin >> x; return x; }()
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define bisect_left lower_bound
#define bisect_right upper_bound
#define bound(a, x, b) (a <= x && x <= b)
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;

i32 n, m;
queue<i32> a[300];

i32 solve() {
    in(n, m);
    times(n, i) {
        times(m, j) {
            indef(i32, ai);
            a[i].push(ai);
        }
    }
    
    i32 ans = INT_MAX;
    set<i32> u;
    while (true) {
        i32 t[301] = {};
        bool ok = true;
        times(n, ni) {
            while (u.find(a[ni].front()) != u.end()) {
                a[ni].pop();
                if (a[ni].size() < 1) {
                    ok = false;
                    break;
                }
            }
            if (!ok) break;
            t[a[ni].front()]++;
        }
        if (!ok) break;
        i32 max_t = 0;
        upto(1, m, mj) {
            max_t = max(max_t, t[mj]);
        }
        upto(1, m, mj) {
            if (t[mj] == max_t) {
                u.insert(mj);
            }
        }
        ans = min(ans, max_t);
    }

    return ans;
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    cout << fixed << setprecision(9);
    out(solve());

    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}


int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> v(n);cin >> v;
  for(auto&e:v)e--;
  vector<ll> dist(n,-1);
  ll now = 0;
  for(ll i = 0; i < k; ++i){
    if(dist[now] == -1)dist[now] = i;
    ll next = v[now];
    if(dist[next] != -1){
      int p = i+1-dist[next];
      k = (k-dist[next])%p + dist[next];
      break;
    }
    now = next;
  }
  now = 0;
  for(int i = 0; i < k; ++i){
    now = v[now];
  }
  cout << now+1 << endl;
  return 0;
}


Measured memory_bytes: 6420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

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

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const int N = 200200;
int n;
int a[N][2];
pii ord[N];
int st[N];
int m;
vector<int> g[N];
bool used[N];
int ans[N];
vector<int> comp;

void addEdge(int v, int u) {
	g[v].push_back(u);
	g[u].push_back(v);
}

void dfs(int v) {
	used[v] = 1;
	comp.push_back(v);
	for (int u : g[v])
		if (!used[u])
			dfs(u);
}

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

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &a[i][0], &a[i][1]);
		ord[i] = mp(a[i][0], i);
	}
	sort(ord, ord + n);
	for (int i = 0; i < n; i++) {
		int p = ord[i].second;
		int y = a[p][1];
		if (m == 0 || a[st[m - 1]][1] > y) {
			st[m++] = p;
		} else {
			int q = st[m - 1];
			while(m > 0 && a[st[m - 1]][1] < y) {
				m--;
				addEdge(p, st[m]);
			}
			st[m++] = q;
		}
	}
	for (int v = 0; v < n; v++) {
		if (used[v]) continue;
		comp.clear();
		dfs(v);
		for (int u : comp)
			ans[u] = (int)comp.size();
	}
	for (int i = 0; i < n; i++)
		printf("%d\n", ans[i]);

	return 0;
}


Measured memory_bytes: 19428
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    # sys.stdin = open("Sample.txt")
    N, C = Scanner.map_int()
    D = Scanner.int_list_list(C)
    colors = Scanner.int_list_list(N)
    for i in range(N):
        for j in range(N):
            colors[i][j] -= 1
    T = [[0 for _ in range(C)] for _ in range(3)]
    for h in range(N):
        for w in range(N):
            T[(h+w) % 3][colors[h][w]] += 1
    ans = INF
    for a in range(C):
        for b in range(C):
            for c in range(C):
                if a == b or a == c or b == c:
                    continue
                now = 0
                for d in range(C):
                    now += T[0][d] * D[d][a]
                    now += T[1][d] * D[d][b]
                    now += T[2][d] * D[d][c]
                ans = min(ans, now)
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 45784
#include <iostream>
using namespace std;
 
int main(){
	/*input*/
	int n, m, c; cin >> n >> m >> c;
	int* b = new int [m]; 
	int** a = new int* [n];
	for(int i = 0; i < n; i++){
		a[i] = new int[m];
	}
	for(int i = 0; i < m; i++){
		cin >> b[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	/*calculation*/
	int o = 0;
	for(int i = 0; i < n; i++){
		int wa = 0;
		for(int j = 0; j < m; j++){
			wa+=a[i][j]*b[j];
		}
		wa+=c;
		if(wa > 0){
			o++;
		}
	} 
	/*output*/
	cout << o << endl;
    return 0;
}


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

int main(){
  int N,A,B,C;
  cin >> N >> A >> B >> C;
  vector<int> l(N);
  for (int i=0;i<N;i++){
    cin >> l[i];
  }
  int ans=10000000;
  for (int bit1=0;bit1<(1<<N);bit1++){
    for (int bit2=0;bit2<(1<<N);bit2++){
      int sumA=0,sumB=0,sumC=0,a=-1,b=-1,c=-1;
      for (int i=0;i<N;i++){
        if (bit1&(1<<i)&&(!(bit2&(1<<i)))){
          sumA+=l[i];
          a++;
        }
        else if (bit2&(1<<i)&&(!(bit1&(1<<i)))){
          sumB+=l[i];
          b++;
        }
        else if (bit1&(1<<i)&&bit2&(1<<i)){
          sumC+=l[i];
          c++;
        }
      }
      if (sumA==0||sumB==0||sumC==0){
        continue;
      }
      int cost=abs(A-sumA)+abs(B-sumB)+abs(C-sumC)+10*(a+b+c);
      ans=min(ans,cost);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define newline ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define MOD 1000000007


int main()
{
    ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);
    //cout.tie(nullptr);

    // Pikachu, I choose you
    int n,k;
    cin >> n >> k;
    n = (n+1)/2;
    if(n >= k)
    cout << "YES" ;
    else
    cout << "NO";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (){
	
	int i,a,sum=0;
	
	for(i=1;i<=3;i++){
		scanf("%d", &a);
		sum=sum + a;
}
		
	if (sum>=22){
			printf("bust\n");
		}else {
			printf("win\n");
		}
	


return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define w(e) int e ; cin >> e ; while (e--)  
#define ll long long 
#define endl "\n"
#define mod  10000000007
#define pi 3.1415926535897932384626433
#define setbit(x) __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)  
/*
*/
int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n , m ; cin >> n >> m;
    int a ; int sum=0;
    while (m--)
    {
    	cin >> a ;
    	sum += a ;
    }
    if (sum<=n)
    {
    	cout << n-sum << endl; 
    }
    else 
    	cout << -1 << endl;
	return  0;
}

Measured memory_bytes: 3664
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

count1 = 0
count2 = 0
for i in range(0,X):
    if i in A:
        count1+=1

for i in range(X+1,N+1):
    if i in A:
        count2+=1

print(min(count1, count2))

Measured memory_bytes: 38256
#include <stdio.h>
#include <stdlib.h>

int main() {
  int n, i, j, count = 0, num, flag;

  scanf("%d", &n);


  for (i = 0; i < n; i++) {
    scanf("%d", &num);
    flag = 1;
    if (num == 2) count++;

    else if (num < 2 || num % 2 == 0) continue;

    else {
      for (j = 3; j*j <= num; j+=2) {
	if (num % j == 0) {
	  flag = 0;
	  break;
	}
      }
      if (flag == 1) count++;
    } 
  }

  printf("%d\n", count);
  return 0;
}



Measured memory_bytes: 2108
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val A, B, N = in.nextLong
  val x = (N + 1) / B * B - 1 match {
    case x if x > 0 => x
    case _ => N
  }
  println(A * x / B - A * (x / B))
}

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

using namespace std;

void hawawa()
{
  string str, AKIHABARA = "AKIHABARA";
  cin >> str;
  for (int i = 0; i < 9; i++) {
    switch (i) {
    case 0:
    case 4:
    case 6:
    case 8:
      if (str[i] == 'A') {
        break;
      } else {
        str = str.substr(0, i) + 'A' + str.substr(i, str.size() - i);
        break;
      }
    default:
      if (str[i] == AKIHABARA[i]) {
        break;
      } else {
        cout << "NO\n";
        return;
      }
    }
  }
  if (str == AKIHABARA) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;
 
#define REP(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define RREP(i, a, n) for(ll i = n-1; i >= (ll)(a); i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007
#define _SPLIT " "
 
template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T,class ...Args> void read(T& a, Args&... args){cin >> a; read(args...);} 
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<class T> void write(T a){cout << setprecision(24) << a << endl;}
template<class T,class ...Args> void write(T a, Args... args){cout << setprecision(24) << a << _SPLIT; write(args...);}
template<class T> void warr(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}
ll comb(ll n, ll m){ll p=1;m=min(m,n-m);for(ll i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
    string s[3];
    int it[3]={0};
    rarr(s,3);
    int k=0;
    while(it[k]<(int)s[k].size()){
        it[k]++;
        k=s[k][it[k]-1]-'a';
    }
    string res="ABC";
    write(res[k]);
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int k = n % 100;
    int s = n / 100;
    if((s > 12 || s == 0)&& k <= 12 && 0 < k){
        cout << "YYMM" << endl;
    }else if(0 < s && s <= 12 && (k == 0 || 12 < k)){
        cout << "MMYY" << endl;
    }else if(0 < s && s <= 12 && 0 < k && k <= 12){
        cout << "AMBIGUOUS" << endl;
    }else{
        cout << "NA" << endl;
    }

}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    string s;
    cin >> s;

    int min_diff = INF;
    REP(i, s.length() - 2) {
        int num = stoi(s.substr(i, 3));
        min_diff = min(min_diff, abs(753 - num));
    }
    P(min_diff);

    return 0;
}


Measured memory_bytes: 256
/*問題文
joisinoお姉ちゃんは、劇場の受付を担当しています。

この劇場には、席 1 から席 100000 までの、100000 個の席があります。
彼女のメモ書きによると、今までの間に N 組の団体が来て、i 組目の団体は席 li から席 ri までの連続した席に座っています。
今、劇場の席には何人座っているか求めてください。

制約
1≦N≦1000
1≦li≦ri≦100000
同じ席に複数の人が座ることはない。
入力は全て整数である。
入力
入力は以下の形式で標準入力から与えられる。

N
l1 r1
:
lN rN
出力
劇場の席に座っている人数を出力せよ。
*/

#include <stdio.h>
//#include <stdlib.h>


int main(){
  int N;
  int l[1000],r[1000];
  int i;
  int sum = 0;

  scanf("%d", &N);
  for(i = 0; i < N; i++){
    scanf("%d%d", &l[i], &r[i]);
    sum = sum + r[i] - l[i] + 1;
  }
printf("%d\n", sum);


  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int h, w;
char maze[21][21];
int dist[20][20];
int qx[100000], qy[100000], head, tail;
int vx[4] = {0, 1, 0, -1};
int vy[4] = {1, 0, -1, 0};
void bfs(int stx, int sty) {
	dist[sty][stx] = 0;
	head = tail = 0;
	qx[tail] = stx;
	qy[tail] = sty;
	tail++;
	while (head != tail) {
		for (int i = 0; i < 4; i++) {
			int nx = qx[head] + vx[i];
			int ny = qy[head] + vy[i];
			if (0 <= nx && nx < w && 0 <= ny && ny <= h && dist[ny][nx] == -1 &&
				maze[ny][nx] == '.') {
				dist[ny][nx] = dist[qy[head]][qx[head]] + 1;
				qx[tail] = nx;
				qy[tail] = ny;
				tail++;
			}
		}
		head++;
	}
}

int main() {
	int max = 0, cnt = 0;
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++) {
		scanf("%s", maze[i]);
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (maze[i][j] == '#')
				continue;
			for (int k = 0; k < h; k++) {
				for (int l = 0; l < w; l++) {
					dist[k][l] = -1;
				}
			}
			bfs(j, i);
			for (int k = 0; k < h; k++) {
				for (int l = 0; l < w; l++) {
					if (maze[k][l] == '#')
						continue;
					cnt = dist[k][l];
					if (cnt > max) {
						max = cnt;
					}
				}
			}
		}
	}
	printf("%d\n", max);
	return 0;
}

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

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <map>

using namespace std;

typedef pair<int,int> Paint;

bool Pairsecond(const Paint& pf,Paint&ps){//sortCompare
  return pf.second < ps.second;
}

#define anyfill(n,s) setw(n) << setfill(s)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define pb push_back
#define MAX 1000000000
#define MOD 1000000007


/*
確認ポイント
to_string() はC++11以降の実装;
cout<< (char)数値 //数値にあった文字に置き換えられる
cout<< (double)int型/(2など)//小数になる
length(),size()に括弧をつけ忘れてないか;
sort()が使える型//vector,string...
大文字小文字間違えてないか
cout << fixed << 小数計算//正しい小数表記になる(基本6桁)(e記法回避にも使える)
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
sqrt(数値型)でrootが取れる
vector.unique()は隣接した同じ要素を削除するので先にソートをする
*/
int main() { 
  int n,m;cin>>n>>m;
  vector<Paint> k;
  for(int i = 0; n > i; i++){
    int tmp;cin>>tmp;
    k.push_back(make_pair(tmp,1));
  }
  for(int i = 0; m > i; i++){
    int b,c;cin>>c>>b;
    k.push_back(make_pair(b,c));
  }
  sort(k.begin(),k.end());
  long long ret = 0;
  int ko = 0;
  for(int i = k.size()-1; 0 <= i; i--){
    if(k[i].second+ko > n)ret += (long long)(n-ko)*k[i].first,ko=n;
    else ret += (long long)k[i].first*k[i].second,ko+=k[i].second;
    if(ko == n)break;
  }
  cout << ret << endl;
}




Measured memory_bytes: 2420
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    vi v;
    int l = 0;
    rep(r,n-1){
        if(a[r] == a[r+1]){
            v.push_back(r+1-l);
            l = r+1;
        }
    }
    v.push_back(n-l);
    //rep(i,v.size())cout << " " << v[i];cout << endl;
    n = v.size();
    if(n == 1)cout << v[0] << endl;
    if(n == 2)cout << v[0] + v[1] << endl;
    if(n >= 3){
        int ans = 0;
        rep(i,n-2)ans = max(ans, v[i]+v[i+1]+v[i+2]);
        cout << ans << endl;
    }
}



Measured memory_bytes: 4224
N, x = map(int, input().split())
a_list = list(map(int, input().split()))
ex_list = a_list.copy()
ex_list.extend(a_list)

ans = float("inf")
cost_list = [float("inf") for _ in range(N)]
for i in range(N):
    cost = 0
    for j in range(N):
        if i == 0:
            cost += ex_list[N + j]
            cost_list[j] = ex_list[N + j]
        else:
            tmp = cost_list[j]
            if tmp > ex_list[N - i + j]:
                cost_list[j] = ex_list[N - i + j]
                cost += ex_list[N - i + j]
            else:
                cost += tmp

    cost += x * i
    ans = min(ans, cost)
print(ans)


Measured memory_bytes: 3188
#include <stdio.h>

int main(void){
  int n, i, j, view, flag;
  view=1;
  scanf("%d", &n);
  int height[n];
  for(i=1;i<n;i++){
    scanf("%d ", &height[i]);
  }
  scanf("%d", &height[n]);
  for(i=2;i<=n;i++){
    flag=1;
    for(j=1;j<i;j++){
      if(height[j]>height[i]){
	flag=0;
      }
    }
    if(flag){
      view+=1;
    }
  }
  printf("%d\n", view);
  return 0;
}


Measured memory_bytes: 128
N, W = [int(x) for x in input().split()]

dp = [0] * (W + 1)

for i in range(1, N + 1):
    v, w = [int(x) for x in input().split()]
    for j in range(w, W + 1):
        dp[j] = max(dp[j], dp[j - w] + v)

print(dp[W])



Measured memory_bytes: 5916
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
    long long n,r;
    scanf("%lld",&n);
    r=sqrt(n);
    long long ans=2*n;
    for(long long i=1;i<=r;i++){
        if(n%i==0){
            ans=min(ans,i+n/i-2);
        }
    }
    printf("%lld\n",ans);
}

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

int main() {
	//a<b<c
	int a,b,c,k,count = 0;
	cin >> a >> b >> c >> k;
	while(a>=b || b>=c){
		if(a>=b) {
			b *= 2;
			count++;
		}
		if(b>=c) {
			c *= 2;
			count++;
		}
	}
	if(count > k) cout << "No" <<endl;
	else cout << "Yes" <<endl;
	return 0;
}


Measured memory_bytes: 3632
from sys  import stdin,stdout

from collections import Counter

st=lambda:list(stdin.readline().strip())
li=lambda:list(map(int,stdin.readline().split()))
mp=lambda:map(int,stdin.readline().split())
inp=lambda:int(stdin.readline())
pr=lambda n: stdout.write(str(n)+"\n")

from bisect import bisect_left,bisect_right

mod=1000000007
INF=float('inf')
def DFS(n,d,v):
    v[n]=False
    stack=[n]
    while stack:
        a=stack.pop()
        for i in d[a]:
            if not v[i]:
                stack.append(i)
                v[i]=True
                
def solve():
    n,m=mp()
    d={i:[] for i in range(n+1)}
    for i in range(m):
        a,b=mp()
        d[a].append(b)
        d[b].append(a)
    ans=0
    v=[False for  i in range(n+1)]
    for i in range(1,n+1):
        if not v[i]:
            ans+=1
            DFS(i,d,v)
    pr(ans-1)
    
    
for _ in range(1):

    solve()


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i]--;
    }
    int b[n];
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    int c[n-1];
    for (int i = 0; i < n-1; i++)
    {
        cin >> c[i];
    }
    int r = 0;
    for (int i = 0; i < n; i++)
    {
        r += b[a[i]];
        if(i > 0 && a[i] == a[i-1] + 1)
        {
            r += c[a[i-1]];
        }
    }
    cout << r;
    return 0;
}


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

class Program
{
  public static void Main(string[] args)
  {
    int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int n = s[0];
    int y = s[1];
    for (int i = 0; i <= n; i ++) {
      for (int j = 0; j <= n-i; j ++) {
        if (y == 10000 * i + 5000 * j + 1000 * (n-i-j) && n-i-j >= 0) {
          Console.WriteLine("{0} {1} {2}", i, j, n-i-j);
          goto end;
        }
        if (i == n && j == n-i) Console.WriteLine("-1 -1 -1");
      }
    }
    end:;
  }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846  



int main() {
	int m1, m2, d1, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if (m1 != m2) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector <int>
#define vl vector <long long>
#define pb push_back
#define mk make_pair
#define pi pair <int,int>
#define pl pair <ll,ll>
#define rep(i,a,n) for(int i=a;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define rep_(i,a,n) for(int i=(n-1);i>=a;i--)
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    rep(i,0,n)
    	cin>>a[i];
    if(a[0]>0)
    	a[0]--;
    int f=0;
    rep(i,1,n)
    {
    	if(a[i]<a[i-1])
    	{
    		f=1;
    		break;
		}
		if(a[i]>a[i-1])
			a[i]--;
	}
	cout<<((f)?"No":"Yes")<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int MAX = 10000000;
ll 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;
    }
}

ll 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(){
    COMinit();
    int n,k;
    cin >> n >> k;
    int mx = min(k,n-1);
    ll ans = 0;
    for(int i = 0;i <= mx;i++){
        ans += COM(n,i) * COM(n-1,i);
        ans %= MOD;
    }

    cout << ans << endl;
}


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



int main() {
  ll N,K;
  cin >> N>>K;
  vector<ll> h(N);
  rep(i,N)
  {
    cin>>h.at(i);
  }
  vector<ll> ans(N);//最低コスト
  if(K<N)
  {
    rep(i,K)
    {
      ans.at(i)=abs(h.at(i)-h.at(0));
    }
    rep(i,N-K)
    {
      vector<ll> ans2(K);//K+i番目の最低コスト
      rep(j,K)
      {
        ans2.at(j)=ans.at(i+j)+abs(h.at(K+i)-h.at(i+j));
      }
      sort(ans2.begin(), ans2.end());
      ans.at(K+i)=ans2.at(0);
    }
  }
  else
  {
    ans.at(N-1)=abs(h.at(N-1)-h.at(0));
  }  
  cout<<ans.at(N-1)<<endl;
  return 0;
}

Measured memory_bytes: 1792
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1e9+7;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N;
    cin >> N;
    vector<ll> v(N);
    rep(i, N) cin >> v[i];
    //
    sort(v);
    //
    double ans = v[0];
    for (ll i = 1; i < v.size(); ++i)
    {
        ans += v[i];
        ans *= 0.5f;
    }
    printf("%.6f", ans);
    //
    return 0;
}

Measured memory_bytes: 3188
n = int(input())
k = int(input())

def calc(tmp, kk):
    s1 = 2 * tmp
    s2 = tmp + kk
    if s1 < s2:
        tmp = s1
    else:
        tmp = s2
    return tmp

temp = 1
for i in range(n):
    temp = calc(temp, k)
print(temp)

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

string s, t;

void input() {
    cin >> s >> t;
}

void solve() {

    int count = 0;
    for(auto itr = s.begin(), itr2 = t.begin(); itr != s.end(); itr++, itr2++){
        if(*itr == *itr2) {
            count++;
        }
    }
    cout << count << endl;
}

int main() {
    input();
    solve();

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b;
  cin >> k >> a >> b;
  int flag=0;
  for(int i=a;i<b+1;i++){
    if(i%k==0){
      flag += 1;
    }
  }
  if(flag>0){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
}
    


Measured memory_bytes: 3664
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n;
    cin >> n;
    vector<int> ans(1, 1);
    for (int i = 2; i*i <= n; i++) {
        int a = i;
        while (a <= n) {
            ans.emplace_back(a);
            a *= i;
        }
    }
    
    cout << *max_element(ans.begin(), ans.end()) << endl;
    return 0;
}

Measured memory_bytes: 256