akhauriyash/Code-Regression huggingface dataset:
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define tt ll t;cin >> t;while(t--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


bool cmp(pair<string,int>p1,pair<string,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 5 * 100000 + 10;

#define int long long

int32_t main() {
    fio
    int n;
    cin >> n;
    int x = n%10;
    if(x == 2 || x == 4 || x== 5 || x == 7 || x == 9 ) {
        cout << "hon" << endl;
    }
    else if(x == 0 || x == 1 || x== 6 || x == 8) {
        cout << "pon" << endl;
    }
    else {
        cout << "bon" << endl;
    }

}






Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int max(long long a,long long b)
{
    if(a>=b)
    return 1;
    else
    return 0;
}
int main()
{
    long long x,y,t,gcd,lcm,a,b;
    while(scanf("%lld%lld",&x,&y)!=EOF)
    {
        if(!max(x,y))
        {
            t=x;x=y;y=t;
        }
        a=x;
        b=y;
        while(x%y)
        {
            x=x%y;
            if(!max(x,y))
        {
            t=x;x=y;y=t;
        }
        }
        gcd=y;
        lcm=a/gcd;
        lcm=lcm*b;
        cout<<gcd<<' '<<lcm<<endl;
    }
    return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    
    int m = min(X, Y);
    int M = max(X, Y);
    
    int cost = A * X + B * Y;
    cost = min(cost, A * (X - m) + B * (Y - m) + C * m * 2);
    cost = min(cost, C * M * 2);
    
    cout << cost << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
signed main(){
    int e,y;
    cin>>e>>y;
    if(e==0){
        if(1868<=y && y<=1911){
            cout<<"M"<<(y+1)-1868<<"\n";
        }
        if(1912<=y && y<=1925){
            cout<<"T"<<(y+1)-1912<<"\n";
        }
        if(1926<=y && y<=1988){
            cout<<"S"<<(y+1)-1926<<"\n";
        }
        if(1989<=y && y<=2016){
            cout<<"H"<<(y+1)-1989<<"\n";
        }
    }
    if(e==1){
        cout<<(y-1)+1868<<"\n";
    }
    if(e==2){
        cout<<(y-1)+1912<<"\n";
    }
    if(e==3){
        cout<<(y-1)+1926<<"\n";
    }
    if(e==4){
        cout<<(y-1)+1989<<"\n";
    }
    return(0);   
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

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

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin>>N;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    sort(all(A));
    ll ans = 0;
    vector<pair<ll,ll>> ansv;
    rep1(i,N-1){
        if(A[i] >= 0){
            ansv.push_back(make_pair(A[0],A[i]));
            A[0]-=A[i];
        }
        else{
            ansv.push_back(make_pair(A[N-1],A[i]));
            A[N-1]-=A[i];
        }
    }
    ansv.push_back(make_pair(A[N-1],A[0]));
    A[N-1] -= A[0];
    cout<<A[N-1]<<endl;
    for(auto p:ansv){
        cout<<p.first<<" "<<p.second<<endl;
    }
}

Measured memory_bytes: 4336
import java.util.Scanner;
public class Main {
	Scanner sc = new Scanner(System.in);
	int N;	//要素数
	int v=0;	//保存用変数
	int j=0;	//添字のための変数
	int[] A;
	
	public void input() {
		N = sc.nextInt();
		A = new int[N];
		for(int i=0; i<N; i++) { A[i] = sc.nextInt(); }
	}
	
	//ソート部分
	public void conpute() {
		output();
		for(int i=1; i<=N-1; i++) {
			v = A[i];
			j = i-1;
			while(j>=0 && A[j] > v) {
				A[j+1] = A[j];
				j--;
			}
			A[j+1] = v;
			output();
		}
	}
	
	public void output() {
		System.out.print(A[0]);
		for(int i=1; i<N; i++) {
			System.out.print(" "+A[i]);
		}
		System.out.println();
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.conpute();
	}
}




Measured memory_bytes: 30256
n = gets.to_i
arr = gets.split.map(&:to_i)
last = n-1
swap_count = 0

for i in 0..last
  minJ = i
  for j in i..last
    if arr[minJ] > arr[j]
      minJ = j
    end
  end
  arr[i], arr[minJ] = arr[minJ], arr[i]
  swap_count += 1 if minJ != i
end

s = ""
arr.each{|a| s += a.to_s; s += " "}
puts s.chop
puts swap_count

Measured memory_bytes: 8716
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
const int N = 407;
int n;
 
int v[N];
ll memo[N][N];
 
ll solve(int l, int r) {
  	if(l == r) return 0;
	ll & st = memo[l][r];
  
 	if(st == -1) {
      
      	st = 1e15;
      	ll sum = 0;
      	for(int i = l; i <= r; ++i) sum += v[i];
    	for(int i = l; i < r; ++i) {
        	st = min(st, sum + solve(l, i) + solve(i+1, r));
        }
    }
  	return st;
}
 
int main() {
	memset(memo, -1, sizeof memo);
	ios::sync_with_stdio(0); cin.tie(0); 
 	cin >> n;
  	for(int i = 0; i < n; ++i) {
     	cin >> v[i]; 
    }
  
 	cout << solve(0, n-1) << endl;
}

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

int main() {
  long long A,B,K;
  cin >> A >> B >> K;
  for(int i =0;i<=K;i++){
    if(A >= 1 && A>=K){
      A=A-K;
      break;
    }else if(A >= 1 && A<K){
      K=K-A;
      A=0;
    }else if(B >= 1 && B>= K){
      B=B-K;
      break;
    }else if(B >= 1 && B < K){
      K=K-B;
      B=0;
    }else{
      break;
    }
  }
  cout << A << " " << B;
}


Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int N, W;
    cin >> N >> W;
    vector<Int> w(N), v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i] >> w[i];
    }

    vector<vector<Int>> dp(N + 1, vector<Int>(W + 1));

    for (Int i = 0; i < N; i++) {
        for (Int weight = 0; weight <= W; weight++) {
            if (weight >= w[i]) {
                dp[i + 1][weight] = max(dp[i][weight - w[i]] + v[i], dp[i][weight]);
            } else {
                dp[i + 1][weight] = dp[i][weight];
            }
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}



Measured memory_bytes: 10800
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl


#
void func() {
  LL N;
  cin >> N;
  LL K;
  cin >> K;
  vector<LL> H(N);
  REP(i, N) {
    cin >> H[i];
  }
  vector<LL> C(N);
  C[0] = 0;
  for (LL i = 1; i < N; i++) {
    vector<LL> costs;
    for (LL k = 1; k <= K; ++k) {
      if (i - k >= 0) {
        LL cost = C[i - k] + abs(H[i] - H[i - k]);
        costs.push_back(cost);
      }
    }
    C[i] = *min_element(ALL(costs));
  }
  cout << C[N - 1];

}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
    int N;

    scanf("%d", &N);
    
    if (65 <= N && N <= 90){
        printf("1\n");
    }
    else if (97 <= N && N <= 122){
        printf("2\n");
    }
    else {
        printf("0\n");
    }
    
    return (0);
}


Measured memory_bytes: 2104
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <cstdio>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  vector<int> list(3);
  for (int i = 0; i < 3; i++) {
    cin >> list[i];
  }
  sort(all(list));
  cout << list[2] * 10 + list[1] + list[0];
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
package main

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

func main() {
	scanInit()

	n := nextInt()
	x := nextInt()
	t := nextInt()

	if n%x == 0 {
		fmt.Println(t * (n / x))
		return
	}
	fmt.Println(t + t*(n/x))

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
# coding: utf-8
# Your code here!

input_num = input()
input_len = len(input_num)
input_lis = list(input_num)
rvrsd_lis = list(reversed(input_lis))
flag = 0

#print(input_lis)
#print(rvrsd_lis)

for i in range(input_len):
    #print(input_lis[i])
    #print(rvrsd_lis[i])
    if input_lis[i] != rvrsd_lis[i]:
        flag = 1
        print("No")
        break

if flag == 0:
    print("Yes")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
long long int AB(long long int x){return x>0?x:-x;}
int main(){
	long long int N,A,B,C,D;
	cin >> N >> A >> B >> C >> D;
	C = D - C;
	B -= A;
	--N;
	bool flag = false;
	long long int L = 0, R = C * N;
	for(int i = -N; i <= N; i+=2){
		long long int base = i*D;
		if(L + base <= B && B <= R + base)flag = true;
//		cout << L << " " << R << " " << base << endl;
		L -= C;
		R -= C;
	}
	puts(flag ? "YES" :"NO");
	return 0;
}


Measured memory_bytes: 256
$N,$A,$B,$C = gets.split.map(&:to_i)
$L = Array.new($N) {gets.to_i}
$INF = 10**9
$min = $INF
 
class Node
  attr_accessor :depth, :array
 
  def initialize(depth, array)
    @depth = depth
    @array = array
  end
end
 
def calc(array)
  mp = -30
  a = 0
  b = 0
  c = 0
 
  array.each_with_index do |v, i|
    case v
    when 0 then
      a+=$L[i];mp+=10
    when 1 then
      b+=$L[i];mp+=10
    when 2 then
      c+=$L[i];mp+=10
    end
  end
 
  if [a,b,c].min == 0 then
    return $INF
  else
    return mp + (a-$A).abs + (b-$B).abs + (c-$C).abs
  end
end
 
def dfs()
  stack = [Node.new(0,[])]
  while !stack.empty?
 
    v = stack.pop()
 
    if v.depth > $N-1 then
      c = calc(v.array)
      $min = c if $min > c
    else
      childs = Array.new(4) do |i|
        Node.new(v.depth+1, v.array+[i])
      end
 
      childs.each do |child|
        stack.push(child)
      end
    end
  end
end
 
dfs()
puts $min

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;
const long long MODMOD = 998244353;

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

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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

int main() {
  string s;
  cin >> s;
  bool yes = true;
  long long ans = 0;
  vector<int> position;
  rep(i, s.size()) {
    if(s[i] == 'x') continue;
    position.emplace_back(i);
  }
  int left = 0, right = 0;
  if(position.size() == 0) {
    cout << 0 << endl;
    return 0;
  }
  else if(position.size() % 2 == 1) {
    left = position[position.size()/2] - 1;
    right = position[position.size()/2] + 1;
  }
  else {
    left = position[position.size()/2-1];
    right = position[position.size()/2];
  }
  while(left >= 0 || right <= s.size()-1) {
    if(right == s.size()) {
      for(int i=left;i>=0;i--) {
        if(s[i] == 'x') ans++;
        else {
          yes = false;
          break;
        }
      }
      break;
    }
    else if(left == -1) {
      for(int i=right;i<s.size();i++) {
        if(s[i] == 'x') ans++;
        else {
          yes = false;
          break;
        }
      }
      break;
    }
    if(s[left] == s[right]) {
      left--;right++;
      continue;
    }
    else if(s[left] == 'x') {
      left--;
      ans++;
    }
    else if(s[right] == 'x') {
      right++;
      ans++;
    }
    else {
      yes = false;
      break;
    }
  }
  if(yes) cout << ans << endl;
  else cout << -1 << endl;
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct unionFind{

    vector<int> par, rank;

    void init(int n){
        par.resize(n);
        rank.resize(n, 0);
        rep(i, n){
            par[i] = i;
        }
        return;
    }

    int root(int x){
        if(par[x] == x){
            return x;
        }else{
            par[x] = root(par[x]);
            return par[x];
        }
    }

    bool unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return false;
        }
        if(rank[rx] < rank[ry]){
            par[rx] = ry;
        }else if(rank[rx] == rank[ry]){
            par[rx] = ry;
            rank[ry]++;
        }else{
            par[ry] = rx;
        }
        return true;
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

};

struct edge{
    int from, to;
    lint cost;

    bool operator<(const edge & right) const {
        return cost < right.cost;
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<edge> edges;
    rep(i, m){
        edge e;
        cin >> e.from >> e.to;
        e.from--;
        e.to--;
        edges.push_back(e);
    }
    int ans = 0;
    rep(i, m){
        unionFind uf;
        uf.init(n);
        rep(j, m){
            if(i == j){
                continue;
            }
            uf.unite(edges[j].from, edges[j].to);
        }
        rep(j, n-1){
            if(!uf.same(j, j+1)){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n, x, i;
  int *l;
  int bound=0;
  int cnt=1;
  
  scanf("%d%d", &n, &x);
  l = malloc(sizeof(int) * n);
  for(i=0; i<n; i++){
    scanf("%d", &l[i]);
  }
  
  for(i=0; i<n; i++){
    bound += l[i];
    if(bound > x) break;
    cnt ++;
  }
  printf("%d\n", cnt);
  free(l);
  return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 10000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

int x, y, a, b, c;
vector<pair<int,int>> inp;
int fin;
//edge cases when n=1 , m=1. wrong variable in loop. if<->while
signed main()
{
	speed
	//global var
	cin>>x>>y>>a>>b>>c;
	vector<int> red(a), green(b),colorless(c);
	for (int i = 0; i < a; ++i)
	{
		cin>>red[i];
		inp.push_back({red[i],0});
	}
	for(int i=0;i<b;++i)
	{
		cin>>green[i];
		inp.push_back({green[i],1});
	}
	for (int i = 0; i < c; ++i)
	{
		cin>>colorless[i];
		inp.push_back({colorless[i],2});
	}
	sort(inp.begin(),inp.end(),greater<pair<int,int>>());
	int r=0,g=0,tot=0;;
	for(int i=0;i<x+y;++i)
	{
		if(inp[i].y==0){++r;}
		else if (inp[i].y==1){++g;}
		tot+=inp[i].x;
	}
	if(r<=x and g<=y)
	{
		cout<<tot<<"\n";return 0;
	}
	if(r>x)
	{

		tot=0;
		r=0;
		g=0;
		for(int i=0;i<x+y;++i)
		{
			if(inp[i].y==0 and r<x)
			{
				tot+=inp[i].x;
				++r;
			}
			else if(inp[i].y!=0)
			{
				tot+=inp[i].x;
				++g;
			}
		}
		for(int i=x+y;i<inp.size(); ++i)
		{
			if(inp[i].y!=0 and g<y)
			{
				tot+=inp[i].x;
				++g;
			}
		}
	}
	else
	{
		tot=0;
		r=0;
		g=0;
		for(int i=0;i<x+y;++i)
		{
			if(inp[i].y==1 and g<y)
			{
				tot+=inp[i].x;
				++g;
			}
			else if(inp[i].y!=1)
			{
				tot+=inp[i].x;
				++r;
			}
		}
		for(int i=x+y;i<inp.size(); ++i)
		{
			if(inp[i].y!=1 and r<x)
			{
				tot+=inp[i].x;
				++r;
			}
		}
	}
	
	cout<<tot<<"\n";
}


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

int main() {
    using P = pair<string, int>;

    int n, q;
    cin >> n >> q;
    queue<P> que;
    for(int i=0; i<n; ++i) {
        string name;
        int time;
        cin >> name >> time;
        que.push(make_pair(name, time));
    }
    int now = 0;
    while(!que.empty()) {
        P p = que.front();
        que.pop();
        if(p.second <= q) {
            now += p.second;
            cout << p.first << " " << now << endl;
        } else {
            p.second -= q;
            now += q;
            que.push(p);
        }
    }
}


Measured memory_bytes: 6328
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn count(a: &Vec<u32>, b: &Vec<u32>, v: u32) -> usize {
    let mut res = 0;
    let mut i = 0;
    let mut j = b.len() - 1;
    while i < a.len() && j < b.len() {
        if a[i] + b[j] >= v {
            res ^= a.len() - i;
            j -= 1;
        } else {
            i += 1;
        }
    }
    res
}

fn clear_and_sort(mut a: Vec<u32>, shift: usize) -> Vec<u32> {
    let mut m = 0;
    while m < a.len() && a[m] < (1 << shift) {
        m += 1;
    }
    if m >= a.len() {
        return a;
    }
    let mask = (1 << shift) - 1;
    for a in a[m..].iter_mut() {
        *a &= mask;
    }
    let mut b = Vec::with_capacity(a.len());
    let mut i = 0;
    let mut j = m;
    while i < m && j < a.len() {
        if a[i] <= a[j] {
            b.push(a[i]);
            i += 1;
        } else {
            b.push(a[j]);
            j += 1;
        }
    }
    while i < m {
        b.push(a[i]);
        i += 1;
    }
    while j < a.len() {
        b.push(a[j]);
        j += 1;
    }
    b
}

fn run() {
    input! {
        n: usize,
        a: [u32; n],
        b: [u32; n],
    }
    let mut a = a;
    let mut b = b;
    a.sort();
    b.sort();
    let mut ans = 0;
    for shift in (0..29).rev() {
        let cnt = count(&a, &b, 1 << shift) ^ count(&a, &b, 2 << shift) ^ count(&a, &b, 3 << shift);
        if (cnt & 1) == 1 {
            ans |= 1 << shift;
        }
        a = clear_and_sort(a, shift);
        b = clear_and_sort(b, shift);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 13080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		OperationExec op = new OperationExec();
		String str = op.inputWord();
		int q = op.inputNum();
		char[] array = new char[str.length()];
		op.divide(str, array);
		String operation = "";
		short[] viewLength = new short[100];
		short count = 0;
		char[][] stock = new char[100][1000];
		for (int i = 0; i < q; i++) {
			operation = op.inputWord();
			if (operation.equals("replace")) {
				op.replace(array);
			} else if (operation.equals("reverse")) {
				op.reverse(array);
			} else if (operation.equals("print")) {
				op.print(array, stock, count++, viewLength);
			}
		}
		op.print(stock, count, viewLength);
	}
}

class OperationExec {
	Scanner sc;

	public OperationExec() {
		sc = new Scanner(System.in);
	}

	public void print(char[] array, char[][] stockArray, short count, short[] viewLength) {
		short[] q = {sc.nextShort(), sc.nextShort()};
		short i, j;
		for (i = q[0], j = 0; i <= q[1]; i++, j++) {
			stockArray[count][j] = array[i];
		}
		viewLength[count] = j;
	}

	public void print(char[][] stockArray, short count, short[] viewLength) {
		for (int i = 0; i < count; i++) {
			for (int j = 0; j < viewLength[i]; j++) {
				try {
					System.out.print(stockArray[i][j]);
				} catch (Exception e) {
					break;
				}
			}
			System.out.println();
		}
	}

	public void replace(char[] array) {
		short[] q = {sc.nextShort(), sc.nextShort()};
		String p = sc.next();
		for (int i = q[0], j = 0; i <= q[1]; i++, j++) {
			array[i] = p.charAt(j);
		}
	}

	public void reverse(char[] array) {
		short[] q = {sc.nextShort(), sc.nextShort()};
		char tmp;
		for (int i = q[0]; i <= (q[0] + q[1]) / 2; i++) {
			tmp = array[i];
			array[i] = array[q[0] + q[1] - i];
			array[q[0] + q[1] - i] = tmp;
		}
	}

	public void divide(String str, char[] array) {
		for (int i = 0; i < str.length(); i++) {
			array[i] = str.charAt(i);
		}
	}

	public short inputNum() {
		return sc.nextShort();
	}

	public String inputWord() {
		return sc.next();
	}
}



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

typedef long long ll;

using S = long long;
using F = long long;

const S INF = 8e18;
const F ID = 8e18;

S op(S a, S b){ return std::max(a, b); }
S e(){ return -INF; }
S mapping(F f, S x){ return (f == ID ? x : f); }
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    std::vector<S> v(300001, 0);
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
    rep(i, N) {
        S x = seg.prod(max(0, A[i] - K), min(300001, A[i] + K + 1));
        seg.set(A[i], x + 1);
    }
    S ans = seg.all_prod();
    cout << ans << "\n";
    //rep(i, 10) cout << seg.get(i);
}

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

int n, m;

int main() {
    cin >> n >> m;
    int offset = 0;
    vector<pair<int, int>> cand(m);
    if (n % 2 != 0) {
        for (int i = 0; i < m; i++) {
            cout << i + 1 << ' ' << n - i << endl;
        }
        return 0;
    } else {
        set<int> match;
        for (int i = 0; i < m; i++) {
            int left = i + 1, right = n - i - offset;
            if (right - left == n / 2) {
                offset += 1;
                right--;
            }
            int now = min(right - left, left + n - right);
            if (match.count(now)) {
                offset += 1;
                right--;
            }
            int now2 = min(right - left, left + n - right);
            match.insert(now2);
            cout << left << ' ' << right << endl;
        }
    }
}

Measured memory_bytes: 6892
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
   input! {
      a:isize,v:isize,
      b:isize,w:isize,
      t:isize
   }
   let dist = (a - b).abs();
   let vdelta = (v - w).abs();
   if a == b {
      println!("YES");
      return;
   }
   if v < w {
      println!("NO");
      return;
   }

   let r = vdelta * t;
   if r >= dist {
      println!("YES");
   } else {
      println!("NO");
   }
}


Measured memory_bytes: 2172
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int n, max = 0;
  vector<int> v(101, 0);
  while(cin >> n) {
    v[n]++;
  }
    for(int i = 0; i < 100; i++) if(max < v[i]) max = v[i];
    for(int i = 0; i < 100; i++) if(max == v[i]) cout << i << endl;
    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define ll int
#define ld long double 
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace :: std;

const ll maxn=2010;


char jad[maxn][maxn];
ll ava[maxn];
ll l[maxn];
ll r[maxn];

ll finds(ll n){
	stack<ll> stk;
	for(ll i=0;i<n;i++){
		while(!stk.empty() && ava[stk.top()]>=ava[i]){
			stk.pop();
		}
		if(stk.empty()){
			l[i]=-1;
		}else{
			l[i]=stk.top();
		}
		stk.push(i);
	}
	while(!stk.empty()){
		stk.pop();
	}
	for(ll i=n-1;i>=0;i--){
		while(!stk.empty() && ava[stk.top()]>=ava[i]){
			stk.pop();
		}
		if(stk.empty()){
			r[i]=n;
		}else{
			r[i]=stk.top();
		}
		stk.push(i);
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		ans=max(ans,(ava[i]+1)*(r[i]-l[i]));
	}
	return ans;
}
bool good(ll i,ll j){
	int t=0;
	if(jad[i][j]=='#'){
		t^=1;
	}
	if(jad[i+1][j]=='#'){
		t^=1;
	}
	if(jad[i][j+1]=='#'){
		t^=1;
	}
	if(jad[i+1][j+1]=='#'){
		t^=1;
	}
	if(t&1){
		return 0;
	}
	return 1;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll w,h;
	cin>>w>>h;
	for(ll i=0;i<w;i++){
		for(ll j=0;j<h;j++){
			cin>>jad[i][j];
		}
	}	
	ll ans=w;
	for(ll i=0;i<w-1;i++){
		for(ll j=0;j<h-1;j++){
			if(good(i,j)){
				ava[j]++;
			}else{
				ava[j]=0;
			}
		}
		ans=max(ans,finds(h-1));
	}




	cout<<ans;

}


Measured memory_bytes: 4224
n, a, b, c = gets.split.map(&:to_i)
l = n.times.map { gets.to_i }
ans = 100000

[0, 1, 2, 3].repeated_permutation(n) do |array|
  a_ = a
  b_ = b
  c_ = c
  next if array.count(0) == 0 || array.count(1) == 0 || array.count(2) == 0
  array.each_with_index do |item, i|
    case item
    when 0
      a_ -= l[i]
    when 1
      b_ -= l[i]
    when 2
      c_ -= l[i]
    end
  end
  mp = 10 * (n - array.count(3) - 3)
  mp += a_.abs + b_.abs + c_.abs
  ans = mp if ans > mp
end

puts ans

Measured memory_bytes: 1916
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

A,B=mint()
g=gcd(A,B)
print(len(pf(g))+1)

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

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

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

signed main() {
    int N;
    cin >> N;
    vector<P> sts(N);
    rep(i, 0, N) {
        int s, t;
        cin >> s >> t;
        sts[i] = (P(s, t));
    }
    sort(all(sts), [](P x, P y) { return x.second < y.second; });

    int ans = 0, l = 0;
    rep(i, 0, N) {
        int s = sts[i].first;
        int t = sts[i].second;
        if (l < s) {
            ans++;
            l = t;
        }
    }
    cout << ans << "\n";
}



Measured memory_bytes: 3624
#include <stdio.h> 

int main(void)
{
	int a, b, c, i, ans;

	scanf("%d %d %d", &a, &b, &c);

	for(i=a; i<=b; i++)
	{
		if(c%i == 0)
		{
			ans++;
		}
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 596
# モンスターの体力は H
# アライグマの必殺技は N 種類
# アライグマが同じ必殺技を 2 度以上使うことなく
# モンスターに勝つことができるなら Yes を、
# できないなら No を出力。

H, N = map(int,input().split())
A = list(map(int,input().split()))
answer = sum(A)

if H <= answer :
    print( "Yes" )
else:
    print( "No" )

Measured memory_bytes: 20512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <ctype.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

using namespace std;
int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());

	map<char, int>mp;
	for (char i = 'a'; i <= 'z'; i++) {
		mp[i]++;
	}
	int n = s.size();
	for (int i = 0; i < n; i++) {
		mp[s[i]]++;
	}
	bool exist = false;
	for (char i = 'a'; i <= 'z'; i++) {
		if (mp[i] == 1) {
			cout << i << endl;
			exist = true;
			break;
		}
	}
	if (exist == false) {
		cout << "None" << endl;
	}
}

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

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;
  string s;cin>>s;
  vector<int> e(n), w(n);
  for(int i=0;i<n;i++){
    if(i!=0)e[i]=e[i-1];
    if(s[i]=='W')e[i]++;
  }
  for(int i=n-1;i>=0;i--){
    if(i!=n-1)w[i]=w[i+1];
    if(s[i]=='E')w[i]++;
  }
  int ans=min(e[n-2], w[1]);
  for(int i=1;i<n-1;i++){
    ans=min(ans, e[i-1]+w[i+1]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n, m, r = 0;
  cin >> n >> m;
  vector<int> f(n, -1);
  REP(i, m) {
    int s, c;
    cin >> s >> c;
    if(f[s - 1] != -1 && c != f[s - 1]) {
      cout << -1 << endl;
      return 0;
    }
    f[s - 1] = c;
  }

  if(f[0] == 0 && n > 1) {
    cout << -1 << endl;
    return 0;
  }

  REP(i, n) {
    if(f[i] == -1) {
      cout << ((i == 0 && n != 1) ? 1 : 0);
    } else {
      cout << f[i];
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int n, m;
V a[200000];

bool dfs(int x, int depth) {
  if (x == n) return true;
  if (depth == 2) return false;
  for (int i = 0; i < (int)a[x].size(); i++) {
    if (dfs(a[x][i], depth+1)) return true;
  }
  return false;
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    pi tmp;
    cin >> tmp.first >> tmp.second;
    a[tmp.first].push_back(tmp.second);
  }
  dfs(1, 0) ? dump("POSSIBLE") : dump("IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 8576
using System;

public class hello
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine().Trim());
        if (n == 0) { Console.WriteLine(0); goto exit; }
        getAns(n);
    exit:;
    }
    static void getAns(long n)
    {
        var t = 1L;
        var count = 1;
        while (true)
        {
            t *= 2;
            if (t - 1 >= n) { Console.WriteLine(count); break; }
            count++;
        }
    }
}



Measured memory_bytes: 18024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    string s, t;
    cin >> s;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == t[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int a , b , c , d; cin>>a>>b>>c>>d;
    for(int i = 0 ; i < 100; ++i){
        c -= b;
        if(c <= 0){
            cout<<"Yes\n";
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout<<"No\n";
            return 0;
        }
    }
}

Measured memory_bytes: 3656
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

bool vis[10010];
vector<int> g[10010];
int ind[10010], outd[10010], fa[10010], p[10010];

int Ask(int x) {
	return x == fa[x] ? x : fa[x] = Ask(fa[x]);
}

int main() {
	int n, h;
	scanf("%d%d", &n, &h);
	for(int i = 0; i <= h + h; i++)
		fa[i] = i;
	for(int i = 1; i <= n; i++) {
		int a, b, c, d, p, q;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		p = !c ? a : -c;
		q = !d ? -b : d;
		int fp = Ask(p + h), fq = Ask(q + h);
		if(fp != fq) 
			fa[fp] = fq;
		ind[q + h]++;
		outd[p + h]++;
	}
	for(int i = 0; i <= h + h; i++) {
		if(i < h && outd[i] > ind[i]) {
			printf("NO\n");
			return 0;
		}
		if(i > h && outd[i] < ind[i]) {
			printf("NO\n");
			return 0;
		}
	}
	for(int i = 0; i <= h + h; i++) {
		if(!ind[i] && !outd[i]) continue;
		int fx = Ask(i);
		p[fx] |= (ind[i] != outd[i]);
	}
	for(int i = 0; i <= h + h; i++) {
		if(!ind[i] && !outd[i]) continue;
		if(Ask(i) != i) continue;
		if(!p[i]) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 640
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define int long long

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 int A,B,C,D;
 cin>>A>>B>>C>>D;
while(true){
	C=C-B;
	if (C<=0)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	A=A-D;

	if (A<=0)
	{
		cout<<"No"<<endl;
		return 0;
	}
	

}
 
return 0;





}

Measured memory_bytes: 3588
#include<stdio.h>
int main(void){
    int d,n,ans=1,i;
    scanf("%d %d",&d,&n);
    for(i=0;i<d;i++){
        ans*=100;
    }
    if(n==100){
        printf("%d\n",ans*n+ans);
    }else{
        printf("%d\n",ans*n);
    }
    return 0;
}


Measured memory_bytes: 128
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = []
order = [-1 for i in range(n+1)]

c = 1
l = 0
v = 1
while order[v] == -1:
    order[v] = len(s)
    s.append(v)
    v = a[v - 1]

c = len(s) - order[v]
l = order[v]

if k < l:
    print(s[k])
else:
    k -= l
    k %= c
    print(s[l+k])



Measured memory_bytes: 32260
N,M=map(int, input().split())

sc = []
for i in range(M):
    sc.append(list(map(int, input().split())))
for i in range(10**N):
    ans = str(i)
    if len(ans) == N and all(ans[s-1] == str(c) for s,c in sc):
        print(ans)
        quit()
print(-1)


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

int main(){
    int m1,d1,m2,d2; cin >> m1 >> d1 >> m2 >> d2;

    if(d2==1){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (int i = 1; i <= N; i++)
#define repr(i, N) for (int i = N-1; i >= 0; i--)
#define repr1(i, N) for (int i = N; i > 0; i--)

using ll = long long;
using namespace std;

int main(){
    int N,index;
    //char S[4010];
    int ans=0;
    //char s[200];
    //vector<int> a(N,0);

    cin >> N;
    vector<int> A(N+1,0),left(N+1,0),right(N+2,0);
    rep1(i,N) cin >> A[i];

    /*最大値とそのindexを取得*/
    /*
    vector<int>::iterator It = max_element(A.begin(),A.end());
    ans = *It;
    index = distance(A.begin(),It);

    sort(A.begin(),A.end(),std::greater<int>());

    rep(i,N){
        if(i!=index) cout << ans << endl;
        else cout << A.at(1) << endl;
    }
    */

    rep1(i, N) left[i] = max(A[i], left[i-1]);
    repr1(i, N) right[i] = max(A[i], right[i+1]);

    rep1(i, N) cout << max(left[i-1], right[i+1]) << endl;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll  N,K;
    cin >> N >> K;
    if  (N % K == 0) cout << 0 << endl;
    else{
        ll  maximum = (N / K + 1) * K;
        ll  minimum = (N / K) * K;
        cout << min(maximum - N, N - minimum) << endl;
    }
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
using namespace std;
typedef long long ll;
typedef string str;
int main(){
    int n;
    ll ans=1;
    cin >> n;
    for(long long i=1; i<=n; i++){
        ans*=i;
        ans%=1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
int main()
{
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> v(N);
  vector<pair<int, int>> w(M);
  for (int i=0; i<N; ++i)
  {
    cin >> v[i].first >> v[i].second;
  }
  for (int i=0; i<M; ++i)
  {
    cin >> w[i].first >> w[i].second;
  }
  int m, n, a;
  for (int i=0; i<N; ++i)
  {
    m = 1000000000;
    n = -1;
    for (int j=0; j<M; ++j)
    {
      a = abs(v[i].first - w[j].first) + abs(v[i].second - w[j].second);
      if (m > a)
      {
        m = a;
        n = j;
      }
    }
    cout << n + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


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

using namespace std;
int n;
int a[60][30];

int main(){
  cin >> n;
  REP(i,n){
    string s;
    cin >> s;
    REP(j,s.size()){
      a[i][s[j]-'a'] ++;
    }
  }
  REP(i,'z'-'a'+1){
    int k = 1000;
    REP(j,n){
      k = min(k,a[j][i]);
    }
    char t = (int)((int)'a'+i);
    REP(j,k) cout << t;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256