akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

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

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

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        m: usize,
        py: [(usize1, usize); m],
    }
    let mut v = vec![vec![]; n];

    for &(p, y) in &py {
        v[p].push(y);
    }
    for i in 0..n {
        v[i].sort();
    }

    for &(p, y) in &py {
        println!("{:>06}{:>06}", p + 1, v[p].binary_search(&y).unwrap() + 1);
    }
}


Measured memory_bytes: 13820
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string c = Console.ReadLine();
            string[] v = { "a", "i", "o", "u", "e" };

            Console.WriteLine(v.Count(x => x == c) > 0 ? "vowel" : "consonant");

            Console.Out.Flush();
        }
    }
    


    public class Calculation
    {
        
    }

    public class Graph
    {

    }
}
    

Measured memory_bytes: 13268
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def rec(n: int, x: int, a: list, p: list) -> int:
    if x <= 0:
        raise ValueError

    elif n == 0:
        return 1

    elif x == 1:
        return 0

    elif 1 < x < a[n-1] + 2:
        return rec(n-1, x-1, a, p)

    elif x == a[n-1] + 2:
        return p[n-1] + 1

    elif a[n-1] + 2 < x < 2*a[n-1] + 3:
        return p[n-1] + 1 + rec(n-1, x - a[n-1] - 2, a, p)

    elif x == 2*a[n-1] + 3:
        return 2 * p[n-1] + 1

n,x = li()
a = [1]
p = [1]

for i in range(n):
    a.append(2*a[-1]+3)
    p.append(2*p[-1]+1)

print(rec(n, x, a, p))

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

signed main(){
	string s, t; cin >> s >> t;
	lint N = s.size(), M = t.size();
	vector<lint> cs(26, 0), ct(26, 0);
	vector<vector<lint> > alp(26);
	for(lint i = 0; i < N; i++){
		cs[s[i] - 'a']++;
		alp[s[i] - 'a'].push_back(i + 1);
	}
	for(lint i = 0; i < M; i++) ct[t[i] - 'a']++;
	for(lint i = 0; i < 26; i++){
		if(cs[i] == 0 && ct[i] != 0){
			cout << -1 << endl;
			return 0;
		}
	}
	lint ans = 0, index = 0;
	for(lint i = 0; i < M; i++){
		lint j = t[i] - 'a';
		int v = upper_bound(alp[j].begin(), alp[j].end(), index) - alp[j].begin();
		if(v == alp[j].size()){
			ans += (N - index);
			ans += alp[j][0];
			index = alp[j][0];
		}
		else{
			ans += (alp[j][v] - index);
			index  = alp[j][v];
		}
	}
	cout << ans << endl;
}

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

int N;
int C[510], S[510], F[510];

int solv(int p) {
	int ret = 0;
	for (int i = p; i < N - 1; i++) {
		if (ret <= S[i]) {
			ret = S[i] + C[i];
		}
		else {
			if (ret %F[i] == 0) {
				ret += C[i];
			}
			else {
				int k = (ret / F[i]) + 1;
				ret = F[i] * k + C[i];
			}
		}
	}
	return ret;
}

int main() {
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		cin >> C[i] >> S[i] >> F[i];
	}
	for (int i = 0; i < N; i++) {
		int ans;
		if (i == N - 1) ans = 0;
		else {
			ans = solv(i);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
if N ==1 and M == 1:
    print("1")
elif N == 1 or M == 1:
    print(max(N, M)-2)
else :
    print((N-2)*(M-2))
# 46664
# 69996
# 46664

# 2333332

#4666664
#4666664

Measured memory_bytes: 2940
#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>;

void Main()
{
  ll X,Y;
  cin >> X >> Y;
  int cnt = 0;
  while (true) {
    if (X > Y) break;
    cnt++; X *= (ll)2;
  }
  cout << cnt << endl;
}

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

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

using namespace std;

int N;
string S;

int main(void){
    
    cin >> N >> S;
    
    int result = 0;
    for(int i = 1; i < N; ++i){
        string left = S.substr(0, i);
        string right = S.substr(i);
        int sum = 0;
        bool flag = false;
        for(int j = 0; j < left.size(); ++j){
            for(int k = 0; k < right.size(); ++k){
                if(left[j] == right[k]){
                    right[k] = '0';
                    flag = true;
                }
            }
            if(flag) ++sum;
            flag = false;
        }
        result = max(result, sum);
    }
    
    cout << result << endl;

    return 0;
}


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

using namespace std;

int main() {

	string S; cin >> S;
	sort(S.begin(), S.end());
	map<char, int> letters;
	// for (int i = 0; i < 4; i++) {
	// 	letters[S[i]] = 0;
	// }
	for (int i = 0; i < 4; i++) {
		letters[S[i]] += 1;
	}
	for (const auto& letter : letters) {
		if (letter.second > 2 || letter.second < 2)  {
			cout << "No"; 
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

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

using namespace std;

int main()
{
    int n, m, a, b, e1, e2, el1, el2, eS=0, p=1, I=1;
    cin >> n >> m;
    int MD[n+1][n+1], g[n+1], C[n+1], Dp[250001]={0};
    vector <int> D[n+1], T, V2[n+1];
    Dp[0] = 1;
    for (int i = 0; i <= n; i++)
    {
        for (int y = 0; y <= n; y++)
        {
            MD[i][y] = 0;
        }
        g[i] = 1;
        C[i] = -1;
    }
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        V2[a].push_back(b);
        V2[b].push_back(a);
        MD[a][b] = 1;
        MD[b][a] = 1;
    }
    for (int i = 1; i <= n; i++)
    {
        for (int y = i+1; y <= n; y++)
        {
            if (i != y && MD[i][y] == 0)
            {
                D[i].push_back(y);
                D[y].push_back(i);
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if (g[i] == 1)
        {
            g[i] = 0;
            T.push_back(i);
            C[i] = 1;
            e1 = 1;
            e2 = 0;
            for (int y = 0; y < T.size(); y++)
            {
                a = T[y];
                for (int u = 0; u < D[a].size(); u++)
                {
                    b = D[a][u];
                    if (C[b] == C[a])
                    {
                        cout << -1;
                        return 0;
                    }
                    if (g[b] == 1)
                    {
                        g[b] = 0;
                        if (C[a] == 1)
                        {
                            C[b] = 0;
                            e2++;
                        }
                        else
                        {
                            C[b] = 1;
                            e1++;
                        }
                        T.push_back(b);
                    }
                }
            }
            eS += e1+e2;
            I++;
            for (int y = 250000; y >= 0; y--)
            {
                if (Dp[y] == p)
                {
                    Dp[y+e1] = I;
                    Dp[y+e2] = I;
                }
            }
            p = I;
            T.clear();
        }
    }
    for (int y = eS/2; y <= 250000; y++)
    {
        if (Dp[y] == I)
        {
            cout << y*(y-1)/2 + (n-y)*(n-y-1)/2;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 6272
data = []
tmp = []
for x in range(0,1000000):
    a,b = map(int, input().split())
    if a==0:
        if b==0:
            break
        pass
    data.append((a,b))
for x in range(0,len(data)):
    tmp = list(data.pop(0))
    for y in range(0,tmp[0]):
        for z in range(0,tmp[1]):
            if (y+z) % 2 ==0:
                print("#",end='')
            else:
                print(".",end='')
        print("")
    tmp.clear()
    print("")


Measured memory_bytes: 9096
#include <iostream>
#include <stdio.h>

using namespace std;
int main()
{
  int num,count1=0,count2=0,count3=0,count4=0;
  string temp;
  cin>> num;
  for(int i =0; i<num ; i++)
  {
    cin>>temp;
    if(temp =="AC"){
		count1 ++;
    }
    else if(temp =="WA")
    {
		count2 ++;
    }
    else if (temp =="TLE")
    {
      	count3++;
    }
    else 
      	count4 ++;
  }
  cout <<"AC x "<<count1<<endl;
  cout <<"WA x "<<count2<<endl;
  cout <<"TLE x "<<count3<<endl;
  cout <<"RE x "<<count4<<endl;
  return 0;
}

Measured memory_bytes: 3624
#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>;
// https://atcoder.jp/contests/abc165/tasks/abc165_d
int main() {
  // 除算の切り捨てfloor(x)
  // e.g. floor(a/b) = (a - a % b) / b 割り切れない分を先に引いておく感じ

  // (A*x - A*x % B) - (A * (x - x%B)) が最大となるx
  // = Ax - Ax % B - Ax + A(x%B)
  // = A(x%B) - Ax%B
  // = A(x % B)/B
  // x%B が最大となるx を求めればいい

  ll a, b, n;
  cin >> a >> b >> n;
  ll x = min(n, b - 1);
  ll ans = a * (x % b) / b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <functional>
#include <string>
#include <stack>
#include <map>

using namespace std;
using ll = long long;
ll mod = 1e9 + 7;


int main()
{
	int n, m, l;
	cin >> n >> m >> l;
	if ((n == m) && (m == l))
	{
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



class UnionFind {
public:
	vector<ll>rank, parent;
	//初期化
	UnionFind(ll size) {
		rank.resize(size, 0);
		parent.resize(size, 0);
		REP(i, size)parent[i] = i;
	}
	//木の根を求める
	ll find(ll x) {
		if (parent[x] == x)return x;
		else return parent[x] = find(parent[x]);
	}
	//xとyの属する集合を併合
	void unite(ll x, ll y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rank[x] < rank[y])
			parent[x] = y;
		else {
			parent[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
};




int main()
{
	ll N, M;
	cin >> N >> M;
	vector<ll> a(N);
	UnionFind uf(N);

	REP(i, N)cin >> a[i];
	REP(i, M) {
		ll x, y;
		cin >> x >> y;
		uf.unite(x, y);
	}

	map<ll, pair<ll, ll>> mp;
	REP(i, N) {
		ll par = uf.find(i);
		mp[par] = mp.find(par) == mp.end() || mp[par].first > a[i]
			? make_pair(a[i], i)
			: mp[par];
	}

	if (M == N - 1) {
		cout << 0 << endl;
		return 0;
	}

	ll res = 0;
	ll need = 2 * (N - 1 - M);
	if (need > N) {
		cout << "Impossible" << endl;
		return 0;
	}


	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		res += itr->second.first;
		a[itr->second.second] = INFL;
		need--;
	}
	if (need < 0)exit(1);

	sort(a.begin(), a.end());
	REP(i, need) {
		res += a[i];
		if (a[i] == INFL)exit(1);
	}
	cout << res << endl;
	return 0;
}


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

namespace agc017_b
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
            x[0]--;
            long sa = x[2] - x[1];
            bool ret = false;
            for (int i = 0; i <= x[0]; i++)//引き算する箇所の個数
            {
                long now = x[3] * (x[0] - i * 2);
                if (now - (x[4] - x[3]) * i <= sa &&
                    sa <= now + (x[4] - x[3]) * (x[0] - i)) ret = true;
            }
            Console.WriteLine(ret ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

int main(){
    int N;
    cin >> N;
    double A[N];
    double sum=0;
    rep(i,N){
        cin >> A[i];
        sum += 1/A[i];
    }
    double ans = 1/sum;
    cout << fixed << setprecision(6) << ans << endl;
    return 0;

}

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


int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];

    int minv = 2e9;
    for (int p = 1; p <= 100; p++) {
        int v = 0;
        for (int i = 0; i < n; i++) v += (x[i] - p) * (x[i] - p);
        minv = min(minv, v);
    }
    cout << minv << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int N,K,X,Y;
  cin>>N>>K>>X>>Y;
  if(N<K){
    cout<<N*X<<endl;
  }
  else{
    cout<<K*X+(N-K)*Y<<endl;
  }
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define fa(a,c) for(auto &a:c)
#define yes "YES"
#define no "NO"




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

int a,b;
cin>>a>>b;
cout<<6-a-b<<endl;



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(ll i = a; i <= (n); ++i)
#define repD(i, a, n) for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (long long) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define MAXN 5000000
const long double PI = 3.141592653589793238462643383;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<double> vd;
typedef vector<pii> vii;
const long long mod = 1000000007;
int Ceil(int a, int b){
    if(a%b==0) return a/b;
    else return (a/b)+1;
}
int main(){
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);   
    freopen("output.txt", "w", stdout);
    #endif
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n;
    cin>>n;
    vector<pair<ll,ll>> v(n);
    for(ll i = 0;i<n;i++){
        ll x;
        cin>>x;
        v.pb({x,i});
    }
    sort(v.rbegin(),v.rend());
    vector<vector<ll>> dp(n+2,vector<ll>(n+2,0));
    ll ans = 0;
    for(int i = 0;i<n;i++){
        for(int j = 0;j<=i;j++){
            dp[j+1][i-j] = max(dp[j+1][i-j],dp[j][i-j]+abs(v[i].second-j)*v[i].first);
            dp[j][i-j+1] = max(dp[j][i-j+1],dp[j][i-j]+abs(v[i].second-(n-i+j-1))*v[i].first);
            ans = max(ans,max(dp[j+1][i-j],dp[j][i-j+1]));
        }
    }
    cout<<ans;
    return 0;
}

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

int main() {
  int a[10];
  for (int i = 0; i < 10; i++) {
    cin >> a[i];
  }
  sort(a, a + 10);
  cout << a[9] << "\n" << a[8] << "\n" << a[7] << "\n";
  return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX



 
void solve()
{
    int n;
    cin >> n;
    set<string> q;
    while(n--)
    {
        string s;
        cin >> s;
        q.insert(s);
    }
    cout << q.size() << endl;
}


signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 19204
#include <bits/stdc++.h>
using namespace std;
long long n,m,k,sum,a[105],b[105],c[105],d[105];
vector<long long>v;
void dfs(int t) 
{
	if(t==n+1)
	{
		long long res=0;
		for(int i=1;i<=k;i++)
		{
			if(v[b[i]]-v[a[i]]==c[i])
				res+=d[i];
		}
		sum=max(sum,res);
		return;
	}
	for(int i=v[t-1];i<=m;i++)
	{
		v.push_back(i);
		dfs(t+1);
		v.pop_back();
	}
}
int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=k;i++)
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	v.push_back(1);
	dfs(1);
	cout<<sum;

	return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007
#define inf 1000000007
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
// ll power(ll x,ll y, ll md=inf){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;


#define endl '\n'
// #define int ll

signed main() {
	fast;

	int h,w;
	cin>>h>>w;

	pii v[200002];
	for(int i=0;i<h;i++) cin>>v[i].f>>v[i].s;

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

	map<int,int> mini = {{0,w}};

	for(int i=0;i<h;i++) {
		int r = v[i].s;

		auto it = mp.lower_bound(v[i].f);


		if(r==w) {
			while(it!=mp.end() && it->f <= r) {
				auto it1 = it++;
				auto it2 = mini.find(it1->s);
				if(it2->s==1) mini.erase(it2);
				else it2->s --;
				mp.erase(it1);
			}

			if(mini.size()) cout<<mini.begin()->f+i+1<<endl;
			else cout<<-1<<endl;
		}
		else {
			int mn = inf;

			while(it!=mp.end() && it->f <= r) {
				mn = min(mn, r+1-(it->f)+(it->s));
				auto it1 = it++;
				auto it2 = mini.find(it1->s);
				if(it2->s==1) mini.erase(it2);
				else it2->s --;
				mp.erase(it1);
			}

			if(mn<inf) {
				if(it!=mp.end() && it->f == r + 1) {
					if(it->s > mn) {
						auto it1 = mini.find(it->s);
						if(it1->s ==1) mini.erase(it1);
						else it1->s --;
						mini[mn]++;
						it->s = mn;
					}
				}
				else {
					mp.emplace_hint(it,r+1,mn);
					mini[mn]++;
				}
				cout<<mini.begin()->f+i+1<<endl;
			}
			else {
				if(mini.size()) cout<<mini.begin()->f+i+1<<endl;
				else cout<<-1<<endl;
			}

		}

	}
}

Measured memory_bytes: 14488
S=str(input())
Q=int(input())
which=0
front=""
back=""
for i in range(Q):
    a=list(map(str,input().split()))
    if a==["1"]:
        which+=1
        which%=2
        continue
    else:
        if which==0:
            if a[1]=="1":
                front=a[2]+front
            if a[1]=="2":
                back+=a[2]
        if which==1:
            if a[1]=="1":
                back+=a[2]
            if a[1]=="2":
                front=a[2]+front

S=front+S+back
if which==1:
    print(S[::-1])
if which==0:
    print(S)

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

int isPrime(int);
int count;
int find(int a,int d,int n){
	for(;;){
		if(isPrime(a))count++;
		if(count==n)return a;
		a+=d;
	}

}
int main(){
	int a,d,n;
	for(;;){
		cin >>a>>d>>n;
		if(!(a||d||n))break;
		count=0;
		cout<<find(a,d,n)<<endl;
	}
	return 0;
}
int isPrime(int n){
	int i;
	if(n==2)return 1;
	if(n==1||n%2==0)return 0;
	for(i=3;i*i<=n;i+=2){
		if(n%i==0)return 0;
	}
	return 1;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vll a(n); for(auto& e : a) cin >> e;

    vector<vll> dp(n+1, vll(2, -INF));
    dp[0][0] = 0LL;

    rep(i, n){
        rep(j, 2){
            ll cur = dp[i][j];
            if(cur == -INF) continue;

            // stay
            chmax(dp[i+1][j], cur + a[i]);

            // flip
            if(j == 0){
                chmax(dp[i+1][1], cur - a[i]);
            }
            else {
                chmax(dp[i+1][0], cur - a[i]);
            }
        }
    }

    cout << dp[n][0] << endl;

    return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
int main(void)
{
  int h, n, t=0;
  scanf("%d %d", &h, &n);
  while(n--)
  {
    int a;
    scanf("%d", &a);
    t+=a;
  }
  
  printf("%s\n", (t>=h) ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

int main(){
	int D;cin>>D;
  cout<<"Christmas";

  for(int i=0; i<25-D; i++)cout<<" Eve";
  cout<<endl;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m, v, p, a[N];
inline bool check(int mid) {
	int cur = a[mid] + m, cv = v - 1, rnk = 0, LL = 0, RR;
	for (int i = 1; i <= n; i++)
		if (a[i] <= cur) {
			i--;
			rnk = i;
			cv -= min(cv, i);
			LL = i + 1;
			break;
		}
	int cs = 0;
	RR = mid;
	for (int i = 1; i <= n; i++)
		if (i != mid && a[i] <= a[mid]) cs++, RR = min(RR, i);
	RR--;
	cv -= min(cv, cs);
	for (int i = LL; i <= RR && cv; i++) {
		if (rnk < p - 1) {
			cv--;
			rnk++;
		} else {
			long long sum = 0;
			for (int j = i; j <= RR; j++) {
				sum += cur - a[j];
			}
			if (1ll * cv * m > sum) return false;
			cv = 0;
			break;
		}
	}
	return rnk <= p - 1;
}
int main() {
	scanf("%d%d%d%d", &n, &m, &v, &p);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n, greater<int>());
	int lo = 1, hi = n;
	while (lo < hi) {
		int mid = (lo + hi + 1) >> 1;
		if (check(mid)) lo = mid;
		else hi = mid - 1;
	}
	printf("%d\n", lo);
	return 0;
}

Measured memory_bytes: 640
import java.util.HashMap;
import java.util.Iterator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long[] a = new long[n];
		HashMap<Long, Long>map = new HashMap<Long,Long>();

		for (int i=0; i<n; i++){
			a[i] = sc.nextLong();
			if (map.containsKey(a[i])){
				map.put(a[i], map.get(a[i]) + 1);
			} else {
				map.put(a[i], (long) 1);
			}
		}

		Iterator it = map.keySet().iterator();
		long total = 0;
		while (it.hasNext()){
			long key = (long) it.next();
			long tmp = map.get(key) -1;
			total += (tmp * (tmp+1)) / 2;
		}

		for (int i=0; i<n; i++){
			long tmp2 = map.get(a[i]);
			System.out.println(total - (tmp2 -1));
		}

	}
}

Measured memory_bytes: 110540
// Last Change: 03/24/2019 17:28:32.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  int X;
  cin >> X;

  int ans = 1;

  for (int i = 2; i <= X / 2; ++i) {
    int tmp = i;
    while (tmp <= X) {
      tmp *= i;
    }
    tmp /= i;
    ans = max(ans, tmp);
  }

  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
int main()
{
    int n,a,b;
    std::string text,mei,oki,str;
    std::cin >> text >> n;
    for (int tes=0;tes<n;tes++){
        std::cin >> mei;
        if(mei=="print"){
            std::cin >> a >> b;
            str=text.substr(a,b-a+1);
            std::cout << str << std::endl;
        }
        if(mei=="replace"){
            std::cin >> a >> b >> oki;
            text=text.replace(a,b-a+1,oki);
        }
        if(mei=="reverse"){
            std::cin >> a >> b;
            std::reverse(text.begin()+a,text.begin()+b+1);
        }
    }
    return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
using namespace std;
typedef pair<int, int> P;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  if (s.size() == 2) {
    if (s[0] == s[1])
      cout << 1 << " " << 2 << endl;
    else
      cout << -1 << " " << -1 << endl;
    return 0;
  }
  rep(i, s.size() - 2) {
    if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]) {
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
   SPEED;
   string str;
   cin>>str;
   if(str[1]=='R')
   {
       cout<<"ABC";
   }
   else
   {
       cout<<"ARC";
   }
}

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


int main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> work(N);

    for (int i = 0; i < N; ++i){
        int A, B;
        cin >> A >> B;
        work[i] = make_pair(B, A);
    }

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

    long long t = 0;
    for (int i = 0; i < N; ++i){
        t += work[i].second;
        if(t > work[i].first){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){
	int a,b; cin >> a >> b;
	int n; cin >> n;
	vector<bool> T(1001, false);
	for(int i = 0; i < n; i++){
		int s,t; cin >> s >> t;
		for(int j = s; j < t; j++){
			T[j] = true;
		}
	}
	for(int i = a; i < b; i++){
		if(T[i]){
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;

	return 0;
}




Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
void printVec(vector<vector<int>> v) {
    for (int i = 0 ; i < v.size(); i++) {
        for (int j = 0; j < v[0].size(); j++) {
            cout << v[i][j];
        }
        cout << '\n';
    }
}
/* main */
int main(){
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    vector<vector<int>> grid(H, vector<int>(W));
    for (int i = 0; i < B; i++) for (int j = A; j < W; j++) grid[i][j] = 1;
    for (int i = B; i < H; i++) for (int j = 0; j < A; j++) grid[i][j] = 1;
    printVec(grid);
}


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n, i, m, x;
	cin >> n >> m;
	map<ll,ll>mp;
	rep(i,0,m){
		cin >> x;
		mp[x] = 1;
	}
	ll mod = 1e9 + 7;
	vector<ll>ans(n+2);
	ans[0] = 1;
	if(mp[1] == 0)ans[1] = 1;
	rep(i,2,n+1){
		if(mp[i] == 1)continue;
		else ans[i] = (ans[i-1] + ans[i-2]) % mod;
	}
	cout << ans[n] << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 10300
n = int(input())
for i in range(n):
    a = list(map(int, input().split()))
    b = c = 0
    yes = True
    for j in range(10):
        if a[j] > b: b = a[j]
        elif a[j] > c: c = a[j]
        else: yes = False
    print('YES' if yes else 'NO')


Measured memory_bytes: 5592
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int gcd(int a, int b)
{
  if (b == 0)
    return a;

  return gcd(b, a % b);
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, X, x[111111], g = 0;

  std::cin >> N >> X;

  for (int i = 0; i < N; i ++) {
    std::cin >> x[i];

    x[i] = std::abs(x[i] - X);

    if (g == 0) {
      g = x[i];
    }
    else {
      g = gcd(x[i], g);
    }
  }

  std::cout << g << std::endl;

  return 0;
}


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

int main(){
  string S;
  long long int K;
  cin >> S >> K;
  size_t n = S.length();

  long long int count=0;
  long long int all_count = 0;
  for(int j=0; j<int(n); j++){
    if(S[j]==S[j+1]){
      count++;
    }else{
      all_count += (count+1)/2;
      count = 0;
    }
  }

  long long int count_s=0;
  long long int count_e=0;
  if(S[0]==S[n-1]){
    for(int j=0; j<int(n-1); j++){
      if(S[j]==S[j+1]){
        count_s++;
      }else{
        break;
      }
    }
    count_s+=1;

    for(int j=int(n-1); j>0; j--){
      if(S[j]==S[j-1]){
        count_e++;
      }else{
        break;
      }
    }
    count_e+=1;
  }

  long long int ALL_count = 0;
  if(count_s%2==1 && count_e%2==1){
    if(count_s==int(n) && count_s==int(n)){
      ALL_count = (n*K)/2;
    }else{
      ALL_count = all_count * K + (K-1);
    }
  }else{
    ALL_count = all_count * K;
  }
  cout << ALL_count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N =1e5+5;
const double INF=0x3f3f3f3f;
using namespace std;
typedef long long ll;
int fa[N],val[N],num[N],mi[N],vis[N],vis2[N],anss[N];
struct node
{
    ll x, y;
    friend bool operator < (node a, node b)
    {
        return a.x > b.x;
    }
};
priority_queue<node>q;
int find(int x)
{
    if(fa[x]!=x)
        fa[x]=find(fa[x]);
    return fa[x];
}
void join(int x,int y)
{
    int p,q;
    p=find(x),q=find(y);
    if(p!=q)
    {
        fa[p]=q;
        mi[q]=min(mi[p],mi[q]);
    }
    return ;
}
int main()
{
    int n,m;
    int x,y;
    int sum=0;
    int cnt=0;
    ll ans=0;
    int i;
    scanf("%d%d",&n,&m);
    for(int i=0; i<n; i++)
    {
        cin>>val[i];
    }
    for(i=0; i<n; i++)
    {
        fa[i]=i;
        mi[i]=val[i];
    }
    while(m--)
        scanf("%d%d",&x,&y),join(x,y);
    for(int i=0; i<n; i++)
    {
        int t=find(i);
        if(vis[t]==0)
        {
            vis[t]=1;
            anss[cnt++]=t;
        }
    }
    if(cnt==1)
    {
        cout<<0<<"\n";
        return 0;
    }
    for(int i=0; i<cnt; i++)
    {
        ans+=mi[anss[i]];
        sum++;
    }
    for(int i=0; i<n; i++)
    {
        int t=find(i);
        node pp;
        pp.x=val[i];
        pp.y=t;
        q.push(pp);
    }
    while(!q.empty())
    {
        ll a=q.top().x;
        int b=q.top().y;
        q.pop();
        if(vis2[b]==0)
        {
            vis2[b]=1;
            continue;
        }
        if(num[b]<cnt-1&&sum<(cnt-1)*2)
        {
            sum++;
            num[b]++;
            ans+=a;
        }
        if(sum==(cnt-1)*2)
            break;
    }
    if(sum<(cnt-1)*2)
        cout<<"Impossible"<<"\n";
    else
        cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 4720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,x,y;cin>>n>>m>>x>>y;
    int xm=-1000000, ym=100000;
    rep(i, n){
        int t; cin>>t;
        xm = max(xm, t);
    }
    rep(i, m){
        int t; cin>>t;
        ym = min(ym, t);
    }
    string ans = "War";
    for(int i=xm+1; i<=ym; i++){
        if(x<i && i<=y){
            ans = "No War";
            break;
        }
    }

    cout << ans<< endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


def rle(s):
    import itertools
    return list(map(lambda x: (x[0], len(list(x[1]))), itertools.groupby(s)))


n, k = ril()
s = rs()
s = rle(s)
m = len(s)
if m <= 2 * k:
    print(n - 1)
else:
    print(n - m + 2 * k)

Measured memory_bytes: 10408
#include <bits/stdc++.h>
int N, M, V, P, A[100005], ans;
int check(int x) {
	if (A[x] >= A[P]) return 1;
	if (A[x] + M < A[P]) return 0;
	long long v = V - (P - 1) - (N - x + 1);
	if (v <= 0) return 1;
	v *= M; int lim = A[x] + M;
	for (int i = P; i < x; ++i) {
		v -= lim - A[i];
		if (v <= 0) return 1;
	}
	return 0;
}
int main() {
	std::cin >> N >> M >> V >> P;
	for (int i = 1; i <= N; ++i) std::cin >> A[i];
	std::sort(A + 1, A + N + 1), std::reverse(A + 1, A + N + 1);
	int l = 1, r = N;
	while (l <= r) {
		int mid = l + r >> 1;
		if (check(mid)) ans = mid, l = mid + 1;
		else r = mid - 1;
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 640
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;
	if (a >= b) {
		while (a >= b) {
			b *= 2;
			k--;
		}
	}
	
	if (b >= c) {
		while (b >= c) {
			c *= 2;
			k--;
		}
	}
	
	if (k < 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N+1, 0), B(N+1, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        B[A[i]]++;
    }
    ll sum = 0;
    for (int i = 0; i <= N; i++) sum += B[i]*(B[i]-1)/2;
    for (int i = 0; i < N; i++) {
        int K = A[i];
        cout << sum - B[K]*(B[K]-1)/2 + (B[K]-1)*(B[K]-2)/2 << "\n"; 
    }
    return 0;
}

Measured memory_bytes: 5760
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        String[] a = Stream.generate(() -> null).limit(h)
                .map(b -> scanner.next())
                .filter(b -> b.contains("#"))
                .toArray(String[]::new);

        List<Integer> i = IntStream.range(0, w).boxed().collect(Collectors.toList());
        for (String s : a)
            i.removeIf(i2 -> s.charAt(i2) == '#');

        for (String s : a) {
            char[] c = s.toCharArray();
            for (int j = 0; j < c.length; j++)
                if (!i.contains(j))
                    System.out.print(c[j]);
            System.out.println();
        }
    }
}

Measured memory_bytes: 28588
#include <bits/stdc++.h>
using namespace std;
int par[10001];
int rank[10001];
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    rank[i]=1;
  }
}
int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}
void unit(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(rank[x]<rank[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}
bool same(int x,int y){
  return find(x)==find(y);
}
struct edge{int u,v,cost;};
bool comp(const edge& e1,const edge& e2){
  return e1.cost<e2.cost;
}
edge es[100001];
int V,E;
int kruskal(){
  sort(es,es+E,comp);
  init(V);
  int res=0;
  for(int i=0;i<E;i++){
    edge e=es[i];
    if(!same(e.u,e.v)){
      unit(e.u,e.v);
      res+=e.cost;
    }
  }
  return res;
}
int main(){
  cin>>V>>E;
  init(V);
  for(int i=0;i<E;i++)
    cin>>es[i].u>>es[i].v>>es[i].cost;
  cout<<kruskal()<<endl;
}

Measured memory_bytes: 4300
import functools

N = int(input())
march = ["M","A","R","C","H"]
S = {}
for m in march:
    S[m] = 0

for i in range(N):
    s = input()
    if s[0] in march:
        S[s[0]] += 1

aS = [s for s in S.values() if s != 0]

mul = functools.reduce(lambda a, x: a * x, aS, 1)
ans = 0
if len(aS) == 3:
    ans = mul
elif len(aS) == 4:
    ans = functools.reduce(lambda a, x: a + mul/x, aS, 0)
elif len(aS) == 5:
    for i in range(5):
        for j in range(i+1,5):
            ans = ans + mul / aS[i] / aS[j]
print(int(ans))

Measured memory_bytes: 3572
#include<stdio.h>
long long int dp[101][21];
int main(void)
{
	int n;
	int a[101];
	int i,j;
	
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n;i++){
		for(j=0;j<21;j++){
			dp[i][j]=0;
		}
	}
	dp[1][a[1]]=1;
	for(i=1;i<n;i++){
		for(j=0;j<21;j++){
			if(dp[i][j]!=0){
				if(j+a[i+1]<=20){
					dp[i+1][j+a[i+1]]+=dp[i][j];
				}
				if(j-a[i+1]>=0){
					dp[i+1][j-a[i+1]]+=dp[i][j];
				}
			}
		}
	}
	printf("%lld\n",dp[n-1][a[n]]);
	return 0;
}

Measured memory_bytes: 1044
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;

int main() {
    string X;
    cin >> X;
    int i, j, ct = 0, s2 = 0;

    // SSTSTT

    for (i = 0; i < X.size(); i = j) {
        int s1 = 0, t1 = 0;
        for (j = i; j < X.size() && X[j] == 'S'; ++j)
            ++s1;
        for (; j < X.size() && X[j] == 'T'; ++j)
            ++t1;
        if (s1 + s2 < t1) {
            ct += abs(s1 + s2 - t1);
            s2 = 0;
        } else {
            s2 = s1 + s2 - t1;
        }
    }
    cout << ct + s2 << endl;
    return 0;
}


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

long long int gcd(long long int a, long long int b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    
    if (b == 0) return a;
    else return gcd(b, a % b);
}

long long int lcm(long long int a, long long int b) {
    return a / gcd(a,b) * b;// divide first to avoid overflow
}

int main(){
    long long int n, m;
    string s, t;
    cin >> n >> m >> s >> t;

    long long int l = lcm(n,m);
    long long int x = lcm(n/gcd(n,m), m/gcd(n,m));
    for(int i=0; i<l/x; i++){
        //cout << i*x/(l/n) << " " << i*x/(l/m) << endl;
        if(s[i*x/(l/n)] != t[i*x/(l/m)]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 3760
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**8) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b, a%b)

def rec(a: int, b: int) -> int:
    mx = max(a,b)
    mn = min(a,b)
    if gcd(a,b) == mn:
        return (2 * (mx // mn) - 1) * mn
    
    else:
        return (2 * (mx // mn) * mn)  + rec(mn, mx - mn * (mx // mn))
    
n,x = li()
print(n + rec(x, n-x))
    

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"os"
	"sort"
	"strings"
)

var (
	a = []string{
		"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
	}
	s string
)

func main() {
	fmt.Scan(&s)
	x := strings.Split(s, "")
	sort.Strings(x)

	for _, v := range x {
		if v == a[0] {
			if len(a) == 1 {
				fmt.Println("None")
				os.Exit(0)
			}
			a = a[1:]
		}
	}

	fmt.Printf("%s\n", a[0])
}


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

#define int long long
#define fs first
#define sc second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define len(v) ((int)v.size())
#define vc vector
#define pr pair
#define endl "\n"
#define endd "\n"; return 0;
#define all(v) v.begin(), v.end()

using namespace std;

const int MAXN = 1e5;
const int INF = 1e10;
const int MOD = 1e9 + 7;

main() {
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<pr<int, int>> d;
    for (int i = 0; i < n; i++){
        pr<int, int> a;
        cin >> a.fs >> a.sc;
        d.pb(a);
    }
    sort(all(d));
    int tek = 0;
    for (auto v : d){
        tek += v.sc;
        if (tek >= k){
            cout << v.fs << endd;
        }
    }
}


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

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

    int n,y;cin>>n>>y;

    int sy=y-n*1000;
    int n1=-1,n5=-1,n10=-1;

    for(int i=0;i<=n;i++)
    {
        int bsy=sy-i*4000;
        if(bsy<0)break;
        if(bsy%9000==0)
        {
            if(bsy/9000+i<=n)
            {
                n10=bsy/9000;
                n5=i;
                n1=n-n10-n5;
                break;
            }
        }
    }

    cout<<n10<<" "<<n5<<" "<<n1<<"\n";

    return 0;
}


Measured memory_bytes: 3632
/*{{{*/
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORR(i,a,b) for(ll i=b-1;i>=a;i--)

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

using namespace std;
/*}}}*/

int main() {
  ll n;
  cin >> n;
  ll bf = 0;
  ll ans = 0;
  ll nx = 0;
  ll ma = 0;
  REP(i,n){
    cin >> nx;
    if(nx>=ma) ans++;
    ma = max(ma,nx);
  }
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 256