akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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; }

int main () {
  int h, a;
  cin >> h >> a;
  cout << dup(h,a) << endl;
  return 0;
}

Measured memory_bytes: 256
import std.cstream;
import std.stdio;
import std.conv;
import std.string;

void main(){
string op,s,convLine;
char[] insteadOfn = din.readLine();
int n = to!(int)(insteadOfn);
int[string] hash;

  while(n-- > 0){
    convLine = readln();
    if(convLine[0] == 'i'){
      hash[convLine[7..convLine.length-1]]=1;   
    }else{
      auto val = convLine[5..convLine.length-1] in hash;
      if(val != null){
        writeln("yes");
      }
      else{
        writeln("no");
      }
    }
  } 
}

Measured memory_bytes: 34256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    ll n=s.length();
    ll ans=n*(n-1)/2;
    map<char,ll>m;
    for(int i=0;i<n;i++){
        m[s[i]]++;
    }
    for(char i='a';i<='z';i++){
        ans-=m[i]*(m[i]-1)/2;
    }
    cout<<ans+1<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 720
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
		Scanner scanner = new Scanner(System.in);
		int cases = scanner.nextInt();
		BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
		int ac = 0;
		int wa = 0;
		int tle = 0;
		int re = 0;
		for(int i = 0; i < cases; i++) {
			String temp = scanner.next();
			if(temp.equals("AC"))
				ac++;
			else if(temp.equals("WA"))
				wa++;
			else if(temp.equals("TLE"))
				tle++;
			else
				re++;
		}
		log.write("AC x " + ac + "\n");
		log.write("WA x " + wa + "\n");
		log.write("TLE x " + tle + "\n");
		log.write("RE x " + re + "\n");
		log.flush();
	}
}


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

using namespace std;

int main()
{
  int n;
  while(cin >> n, n){    
    string signal[1002];
    signal[0] = to_string(1e9);
    for(int i = 1; i <= n; i++) cin >> signal[i];
    if(n % 2) signal[n + 1] = to_string(1e9);
    else signal[n + 1] = to_string(-(1e9));
    int less = -(1e9)-3, more = 1e9+3;    
    for(int i = 1; i <= n; i++){
      if(signal[i] == "x"){
	if(signal[i-1] == "x" || signal[i+1] == "x"){
	  less = 1e9+3, more = -(1e9)-3;
	  break;
	}
	if(i % 2) more = min(more, min(stoi(signal[i-1]), stoi(signal[i+1]))-1);
	else less = max(less, max(stoi(signal[i-1]), stoi(signal[i+1]))+1);
      } else if(signal[i-1] != "x" && signal[i+1] != "x"){
	if(i%2 == 0 && (stoi(signal[i]) <= stoi(signal[i-1]) || stoi(signal[i]) <= stoi(signal[i+1])) ||
	   i%2 == 1 && (stoi(signal[i]) >= stoi(signal[i-1]) || stoi(signal[i]) >= stoi(signal[i+1]))){
	  less = 1e9+3, more = -(1e9)-3;
	  break;
	}
      }
    }
    if(less == more) cout << more << endl;
    else if(more > less) cout << "ambiguous" << endl;
    else if(more < less) cout << "none" << endl;
  }  
  return 0;
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int n,k;
  cin >> n >> k;
  vi p(n,0);
  rep(i,n) cin >> p.at(i);

  sort(rng(p));
  int ans = 0;
  rep(i,k) ans+=p.at(i);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
// https://www.dropbox.com/sh/ingo41xpnd6fuoi/5-8HaPoOhK/aizu_camp_2013
#include <iostream>
#include <cmath>
using namespace std;

int main(){
    long long m, rd, rr, cd, cr; cin >> m >> rd >> rr >> cd >> cr;
    cout << max(-1ll,
                m - (100*cd +rd-1)/rd - (100*cr + rr-1)/rr);
    cout << endl;
}

Measured memory_bytes: 1156
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
  ans += min(a[i],b[i])
  ans += min(a[i + 1],b[i] - min(a[i],b[i]))
  a[i + 1] -= min(a[i + 1],b[i] - min(a[i],b[i]))
print(ans)

Measured memory_bytes: 18476
from collections import deque
n,k = map(int,input().split())
p = list(map(int,input().split()))
s = deque()
s.append(0)
tot = 0
for i in p:
    tot += i
    s.append(tot)

top = 0
for i in range(n-k+1):
    top = max(top, s[i+k]-s[i])

print((top+k)/2)


Measured memory_bytes: 25700
#include <algorithm>
#include <iostream>
#include <stack>
#include <stdint.h>
#include <vector>
using namespace std;

typedef pair<int, int> pt;

inline int dir(pt a, pt b, pt c)
{
    b.first -= a.first;
    b.second -= a.second;

    c.first -= a.first;
    c.second -= a.second;

    int64_t v = (int64_t)b.first * c.second - (int64_t)b.second * c.first;

    return v > 0 ? 1 : -1;
}

int main()
{
    cin.tie(0);

    int r, c;
    cin >> r >> c;

    int n;
    cin >> n;
    vector<pt> as(n);
    vector<pt> bs(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i].first >> as[i].second;
        cin >> bs[i].first >> bs[i].second;
    }

    auto f = [&](const pt& p) {
        if (p.first == 0)
            return p.second;
        if (p.second == c)
            return c + p.first;
        if (p.first == r)
            return c + r + (c - p.second);
        if (p.second == 0)
            return c + r + c + (r - p.first);
        abort();
    };

    vector<pair<int, int>> cs;
    for (int i = 0; i < n; i++) {
        if (!((as[i].first == 0 || as[i].first == r || as[i].second == 0 || as[i].second == c)
                && (bs[i].first == 0 || bs[i].first == r || bs[i].second == 0 || bs[i].second == c))) {
            continue;
        }

        int t = f(as[i]);
        int u = f(bs[i]);
        if (t > u)
            swap(t, u);
        cs.emplace_back(t, u);
    }
    sort(cs.begin(), cs.end());

    bool ok = true;
    stack<int> stk;
    for (int i = 0; i < cs.size(); i++) {
        int s = cs[i].first;
        int e = cs[i].second;
        while (stk.size() > 0 && stk.top() < s) {
            stk.pop();
        }

        if (stk.size() > 0 && stk.top() < e) {
            ok = false;
            break;
        }

        stk.push(e);
    }

    /*
    bool ok = true;
    for (int i = 0; i < n; i++) {
        if (!((as[i].first == 0 || as[i].first == r || as[i].second == 0 || as[i].second == c)
                && (bs[i].first == 0 || bs[i].first == r || bs[i].second == 0 || bs[i].second == c))) {
            continue;
        }

        for (int j = 0; j < n; j++) {
            if (i == j)
                continue;
            if (!((as[j].first == 0 || as[j].first == r || as[j].second == 0 || as[j].second == c)
                    && (bs[j].first == 0 || bs[j].first == r || bs[j].second == 0 || bs[j].second == c))) {
                continue;
            }

            if (dir(as[i], bs[i], as[j]) != dir(as[i], bs[i], bs[j])
                && dir(as[j], bs[j], as[i]) != dir(as[j], bs[j], bs[i])) {
                ok = false;
                break;
            }
        }
        if (!ok)
            break;
    }
*/

    cout << (ok ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 2936
#include <iostream>

int main (){
  char c[4];
  int ans = 0;
  for (int i = 0; i < 4;++i){
    std::cin >> c[i];
  }
  
  for(int i=0; i<4;++i){
  if (c[i]=='+'){
  ans++;
  }
    else {
    ans--;
    }
  }
  std::cout << ans << std::endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);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;}
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1);
ll high_order_bit(ll n){ll tmp=1,i=-1;while(tmp<=n){tmp*=2;i++;}if(n==0) return 0;else return i;}
vector<ll> binary_expansion(ll n){vector<ll> B(40,0);ll tmp=n;for(ll i=high_order_bit(n);i>=0;i--){B[i]=tmp/pw2[i];tmp%=pw2[i];}return B;}

vector<ll> bitN(41,0);
vector<ll> value(41,0);
ll N;
ll rec(bool ok,ll n,ll rem,ll point){
	if(rem>=pw2[n+1]-1){
		rrep(i,n+1) point+=value[i];
		return point;
	}
	
	if(n==0){
		if(N-bitN[0]*2>0){
			if(rem>=1) return point+value[0];
		}
		else return point;
	}

	if(N-bitN[n]*2>0){
		if(!ok){
			if(rem<pw2[n]) return rec(false,n-1,rem,point); //ムリ
			else{
				return max(rec(true,n-1,rem,point),rec(false,n-1,rem-pw2[n],point+value[n])); //我慢した場合(左)(以下の桁はすべてOK)
			}
		}
		else{//我慢済み
			return rec(true,n-1,rem-pw2[n],point+value[n]);
		}
	}
	else return rec(ok,n-1,rem,point);
}

int main(){
	rep1(i,50) pw2[i]=2*pw2[i-1];

	ll K; cin>>N>>K;
	ll sum=0;
	vector<ll> A(N);
	rep(i,N){
		cin>>A[i];
		sum+=A[i];
	}

	//バグ回避
	if(K==0){
		cout<<sum;
		return 0;
	}

	ll H=high_order_bit(K);
	vector<ll> bitN(H+1,0);
	
	rep(i,N){
		vector<ll> v=binary_expansion(A[i]);
		rep(j,H+1){
			if(v[j]==1) bitN[j]++;
		}
	}

	//valueの計算
	rep(i,H+1){
		if(N-bitN[i]*2>0) value[i]=(N-bitN[i]*2)*pw2[i];
	}

	cout<<sum+rec(false,H,K,0ll);
}


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

int main() {

	int n, *a;
	cin >> n;
	a = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = n - 1; i >= 0; i--) {
		if (i != 0) {
			cout << a[i] << " ";
		} else {
			cout << a[i] << endl;
		}
	}
	delete[] a;
	return 0;
}

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

//const int mxH = 10, mxW = 1e3;
//int h, w, k, ans = 1e9;
//string g[mxH];
//vector<int> v[mxW];

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

	char* S = new char[7];
	cin >> S;

	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}






Measured memory_bytes: 256
from collections import defaultdict
N,W=map(int, input().split())
Ws=[]
Vs=[]
for i in range(N):
    w,v=map(int, input().split())
    Ws.append(w)
    Vs.append(v)

D=defaultdict(int)
D[0]=0


for i in range(N):
    w=Ws[i]
    v=Vs[i]
    A=list( D.items())
    for dw,dv in A:
        #print(dw,dv)
        if dw+w<=W:
            D[dw+w]=max(D[dw+w], v+dv)
#print(Ws,Vs)
#print(D)
print(max(D.values()))

Measured memory_bytes: 74316
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())

    S = [['#' if i < 50 else '.' for j in range(100)] for i in range(100)]

    for n in range(A - 1):
        q, r = divmod(n, 50)
        S[2 * q + 1][2 * r] = '.'

    for n in range(B - 1):
        q, r = divmod(n, 50)
        S[2 * q + 51][2 * r] = '#'

    print(100, 100)
    for row in S:
        print(''.join(row))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9136
#include <iostream>
#include <string>
#include <vector>
typedef unsigned int UINT;
using namespace std;

bool issimilar(vector<string> &mas) {
    if (mas[0][0] != mas[1][2])
        return false;
    if (mas[0][1] != mas[1][1])
        return false;
    if (mas[0][2] != mas[1][0])
        return false;
    return true;
}


int main(void) {
    vector<string> mas(2);
    for (auto &s : mas) {
        cin >> s;
    }
    if (issimilar(mas))
        cout << "YES\n";
    else
        cout << "NO\n";
       
    return 0;
}

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

int main(){
	
long long N,A,B;
cin>>N>>A>>B;

if(B==0){cout<<N<<endl;}
else{
	long long x=N/(A+B);
	long long y=N%(A+B);
	long long z=min(A,y);
	cout<<x*A+z<<endl;}

}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
from collections import deque

n, k = map(int, input().split())
radius = k // 2
edge = [[] for _ in range(n)]
uv = []
for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    edge[a].append(b)
    edge[b].append(a)
    uv.append((a, b))

def dfs(p, v, d):
    ret = 0
    for nv in edge[v]:
        if nv == p:
            continue
        ret += dfs(v, nv, d+1)
    if d > radius:
        return ret + 1
    else:
        return ret

ans = n 
if k % 2 == 0:
    for i in range(n):
        ret = dfs(-1, i, 0)
        ans = min(ans, ret)
else:
    for u, v in uv:
        ret = dfs(u, v, 0) + dfs(v, u, 0)
        ans = min(ans, ret)

print(ans)

Measured memory_bytes: 129160
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

#if people_to_orz
	%%% lys orz;
	%%% lyj orz;
	%%% shy orz;
	%%% yy  orz;
	cai->tlx;
#endif 
#define read(x) scanf("%lld",&x)
#define MAXN 5005 
#define ll long long

int n;
struct node
{
	ll h,p;
}a[MAXN];
ll dp[MAXN];
int ans;

bool cmp(node x,node y){return x.h+x.p<y.h+y.p;} 

int main()
{
	read(n);
	for(int i=1;i<=n;i++) read(a[i].h),read(a[i].p);
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++) dp[i]=0x7fffffffffffffff; 
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i;j>=1;j--) if(dp[j-1]<=a[i].h) dp[j]=min(dp[j],dp[j-1]+a[i].p);
	}
	for(int i=0;i<=n;i++) if(dp[i]<0x7fffffffffffffff) ans=i;
	printf("%d\n",ans);
	return 0; 
}
/*
6
5 8     13
9 3     12
7 10    17
1 9     10
1 10    11
8 4     12

6
1 9
1 10
9 3
8 4
5 8
7 10

5
10 3
8 2
6 9
3 5
5 2

*/

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

int main() {
long long int a,b=0;
cin>>a;
vector<long long int> vec(a);
for(long long int i=0;i<a;i++){
cin>>vec.at(i);
}
for(long long int i=0;i<a-1;i++){
if(vec.at(i)>=vec.at(i+1)){
b++;
}
}
cout<<b+1<<endl;
cout<<a<<endl;
}


Measured memory_bytes: 3612
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 mut $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")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};
//#[proconio::fastout]
fn main() {
    input!{
        n: usize,
        _l: usize,
        s: [String; n],
    }
    s.sort();
    let mut ans = String::new();
    for s_ in &s {
        ans += s_;
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 120000;
constexpr LL mod = 1000000007;
char s[maxn];
int c[maxn];
int main(){
	int n;
	scanf("%d %s", &n, s);
	for(int i = 0; i < n; i += 1) c[s[i] - 'a'] += 1;
	LL ans = 1;
	for(int i = 0; i < 26; i += 1) ans = ans * (c[i] + 1) % mod;
	printf("%lld", ans - 1);
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

i64 gcd(i64 a, i64 b) {
    if (a < b) swap(a, b);

    i64 t;
    while(b > 0) {
        t = a % b;
        a = b;
        b = t;
    }

    return a;
}

int main() {
    i64 N; cin >> N;
    vector<i64> A(N);
    REP(i, N) cin >> A[i];

    vector<i64> L(N + 1, 0);
    vector<i64> R(N + 1, 0);

    REP(i, N) {
        L[i + 1] = gcd(A[i], L[i]);
        R[i + 1] = gcd(A[N - i - 1], R[i]);
    }

    i64 max_g = 0;
    REP(i, N) {
        chmax(max_g, gcd(L[i], R[N - i - 1]));
    }
    cout << max_g << endl;

    return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		System.out.println((a[n-1]) - a[0]);
	}
}

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

typedef long long ll;
using namespace std;

int c;
void chk(vector<int> a, int & n, int & m, int & k) {
    if ((int)a.size() == n) {
        int i = 0;
        int tot = 0;
        while (i < n) {
            int cnt = 1;
            int j = i + 1;
            while (j < n && a[j] == a[i]) {
                cnt++;
                j++;
            }
            tot += cnt - 1;
            i = j;
        }
        if (tot == k) {
            c++;
        }
        return;
    }

    for (int i = 0; i < m; i++) {
        a.push_back(i);
        chk(a, n, m, k);
        a.pop_back();
    }
}

long long binExp(long long a, long long n, long long m) {
    long long res = 1;
    while (n) {
        if (n & 1) {
            res *= a;
            res %= m;
        }
        a *= a;
        a %= m;
        n = n >> 1;
    }
    return res;
}

vector<ll> fact;
ll M = 998244353;

void setFact(int & n) {
    fact = vector<ll>(n + 1);
    fact[0] = 1;
    for (int i = 1; i <= n; i++) {
        fact[i] = i * fact[i - 1];
        fact[i] %= M;
    }
}

ll modInv(ll a) {
    return binExp(a, M - 2, M);
}

ll nCr(int n, int r) {
    return (fact[n] * modInv((fact[r] * fact[n - r]) % M)) % M;
}

void solve(){
    int n, m, K;
    cin >> n >> m >> K;

    setFact(n);

    ll ans = 0;
    for (int k = 0; k <= K; k++) {
        ans += ((m * nCr(n - 1, k) % M) * binExp(m - 1, n - 1 - k, M)) % M;
        ans %= M;
    }
    cout << ans << endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 4752
#include<bits/stdc++.h>
    using namespace std;
    int main(){
      int n;
      cin>>n;
      int arr[n];
      for(int i=0;i<n;i++){
        cin>>arr[i];
        //cout<<arr[i]<<" ";
      }

      int a = 0;
      int b = abs(arr[1]-arr[0]);
      int cost=b;
      
      for(int i=2;i<n;i++){
     	int c1 = a + abs(arr[i]-arr[i-2]);
        int c2 = b + abs(arr[i]-arr[i-1]);
        //cout<<a<<" "<<b<<" ";
        cost=min(c1,c2);
        a=b;
        b=cost;
        //cout<<a<<" "<<b<<" "<<dp[i]<<" ";
      }
      
    //   for(auto i:dp)
    //     cout<<i<<" ";

      cout<<cost;
      return 0;
    }

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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);

    int n;
    set<string> s;
    cin >> n;
    for(int i = 1; i <= n; i ++){
        string t;
        cin >> t;
        s.insert(t);
    }
    cout << (int)s.size() << "\n";
}



Measured memory_bytes: 19216
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){
    vector<string> v={"Sunny", "Cloudy", "Rainy"};
    string s;

    cin>>s;
    for(int i=0; i<3; i++){
        if(v[i]==s){
            cout<<v[(i+1)%3];
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
int z=0;
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(){
    int n,t;cin>>n>>t;
    int ans=inf;
    rep(i,0,n){
        int c,tt;cin>>c>>tt;
        if(tt<=t)ans=min(ans,c);
    }
    if(ans==inf)cout<<"TLE"<<endl;
    else cout<<ans<<endl;return 0;
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
xs = gets.split.map(&:to_i).sort
all = Array.new(M, 0)
pair = Array.new(M, 0)
while xs.length > 0
    num = xs.shift
    sum = 1
    while xs.length > 0 && xs[0] == num
        xs.shift
        sum += 1
    end
    all[num % M] += sum
    pair[num % M] += sum / 2 * 2
end

ans = 0
(M/2+1).times do |i|
    if i == 0 || i*2 == M
        ans += all[i] / 2
    else
        j = M - i
        result = [all[i], all[j]].min
        ans += result
        ans += [all[i] - result, pair[i]].min / 2
        ans += [all[j] - result, pair[j]].min / 2
    end
end
puts ans

Measured memory_bytes: 13056
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{int p,l,r;};

Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  cout << "node " << u<<": ";
  cout <<"parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] <<", ";
  
  if(T[u].p==NIL)cout<<"root, ";
  else if(T[u].l==NIL)cout<<"leaf, ";
  else cout <<"internal node, ";
  
  cout<<"[";
  
  for (i = 0,c=T[u].l;c!=NIL;i++,c=T[c].r) {
    if(i)cout <<", ";
    cout<<c;
  }
  cout <<"]"<<endl;
}

//再帰的に深さを求める
int rec(int u,int p){
  D[u] =p;
  if(T[u].r!=NIL)rec(T[u].r,p); //右の兄弟に同じ深さを設定
  if(T[u].l!=NIL)rec(T[u].l,p+1); //もっとも左の子に自分の深さ+1を設定
  return 0;
}

int main(){
  int i,j,d,v,c,l,r;
  cin >> n;
  for(i=0;i<n;i++)T[i].p=T[i].l=T[i].r=NIL;
  
  for(i=0;i<n;i++){
    cin>>v>>d;
    for(j=0;j<d;j++){
      cin>>c;
      if(j==0)T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  } 
  for (i = 0; i < n; i++) {
    if(T[i].p==NIL)r=i;
  }
  
  rec(r,0);
  
  for (i = 0; i < n; i++) {
    print(i);
  }
  
  return 0;
}



Measured memory_bytes: 7696
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int M = sc.nextInt();
    int total = 0;
    int count = 0;

    int[] S = new int[N];
    
    for(int i = 0; i < N; i++) {
        int token = sc.nextInt();
        S[i] = token;
        total += token;
    }
    
    for(int i = 0; i < N; i++) {
        if( S[i] * 4 * M >= total) count++;
    }
    
    
    if(count >= M) {
        System.out.println("Yes");
    }else {
        System.out.println("No");
    }
  }
}


Measured memory_bytes: 21844
import itertools
import math
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
A= (sorted(P))
P1 = ''.join(map(str,P))
Q1 = ''.join(map(str,Q))
B = ''.join(map(str,A))
anagram_list = [''.join(v) for v in itertools.permutations(B)]

print(abs(anagram_list.index(P1)-anagram_list.index(Q1)))



Measured memory_bytes: 6064
from math import floor
n,l,t = map(int,input().split())
ants = []
touch = 0

for i in range(n):
    x, w = map(int,input().split())
    if w == 1:
        touch += (x + t) // l
        x1 = (x + t) % l
    else:
        touch += (x - t) // l
        x1 = (x - t) % l
    ants.append(x1)
touch = touch % n
ants.sort()
ants = ants[touch:]+ants[:touch]

for i in range(n):
    print(ants[i])


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

using namespace std;
#define int long long
int mod = 1000000007;
const int K = 100001;
int dp[K], dp2[K];
main(){
    int n;
    int x;
    cin >> n>>x;
    vector<int> v(n);
    for (int i=0; i < n; i++) cin >> v[i];
    dp[x] = 1;
    sort(v.begin(), v.end(), greater<int>());
    for (int i=0; i < n; i++){
        for (int j=0; j < K; j++) dp2[j]=0;
        for (int j=0; j < K; j++){
            dp2[j] += (dp[j]*(n-i-1));
            dp2[j] %= mod;
            dp2[j%v[i]] += dp[j];
            dp2[j%v[i]] %= mod;
        }
        //cout << dp2[19] << " " << dp2[5] << endl;
        for (int j=0;j<K;j++) dp[j] = dp2[j];
    }
    int ans=0;
    for (int i=0;i<K;i++) ans = (ans+dp[i]*i)%mod;
    cout << ans;
}


Measured memory_bytes: 1792
package main

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

func main() {
	var N int
	fmt.Scanln(&N)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	a := make([]int, N)
	b := make([]int, N)
	c := make([]int, N-1)

	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}

	for i := range b {
		sc.Scan()
		b[i], _ = strconv.Atoi(sc.Text())
	}

	for i := range c {
		sc.Scan()
		c[i], _ = strconv.Atoi(sc.Text())
	}

	ans := b[0]
	pre := a[0]

	for i := 1; i < N; i++ {
		ans += b[i]
		if pre+1 == a[i] {
			ans += c[pre-1]
		}
		pre = a[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
n = int(input())
ans_list = []
for i in range(n):
    s = input()
    if s[0] == "~" and s[-1] == ">":
        s = s[::-1]
    if s[0] == ">" and s[1] == "'" and s[-2] == "=" and s[-1] == "~":
        check_s = s[2:-1].split("#")
        if len(check_s) == 2:
            front = check_s[0]
            back = check_s[1]
            if front == back and set(front) == {"="}:
                ans = "A"
            else:
                ans = "NA"
        else:
            ans = "NA"
    elif s[0] == ">" and s[1] == "^" and s[-2] == "~" and s[-1] == "~":
        check_s = s[2:-2]
        check_list = set(check_s.split("Q="))
        if check_list == {""} and "Q=" in check_s:
            ans = "B"
        else:
            ans = "NA"
    else:
        ans = "NA"
    ans_list.append(ans)
for a in ans_list:
    print(a)



Measured memory_bytes: 5716
r, g, b = gets.split.map(&:to_i)
k = gets.to_i

def f(r, g, b)
  return [r, 2 * g, b] unless r < g
  return [r, g, 2 * b] unless g < b
  return [r, g, b]
end

k.times do
  r, g, b = f(r, g, b)
end

if r < g && g < b
  puts 'Yes'
else
  puts 'No'
end


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

int main() {
    /*変数定義，入力*/
    ll N, K;
    cin >> N >> K;
    ll minN = N;

    if(N >= K){
        N = N % K;
        minN = N;
    }

    N = K - N;
    minN = min(minN, N);

    cout << minN << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
int main()
{
    int N,Q,M,i;
    while(scanf("%d%d",&N,&Q),N)
    {
        int*p,a[100]={};
        while(N--)for(scanf("%d",&M);M--;)scanf("%d",&i),++a[i];
        p=std::max_element(a,a+100);
        printf("%d\n",*p<Q?0:p-a);
    }
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
using namespace std;
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
// #define int long long

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

signed main(){
    int N,M;
    int p[TENFIVE];
    cin>>N>>M;
    rep(i,N)cin>>p[i];
    UnionFind tree(N);
    int x,y;
    rep(i,M){
        cin>>x>>y;
        tree.unite(x-1,y-1);

    }
    int ans =0;
    rep(i,N){
        if(tree.same(i,p[i]-1))ans++;
    }

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


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

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll A[300001];
int main()
{
    ll n,k;
    cin>>n>>k;

    for(int i=0; i<n; i++)
        cin>>A[i];
    sort(A,A+n);
    ll ans=1,sign=1;
    int l=0,r=n-1;
    if(k%2)
    {
        ans=A[r--];
        --k;
        if(ans<0)
            sign=0;
    }
    while(k)
    {
        ll x=A[l]*A[l+1],y=A[r]*A[r-1];
        if(sign==1)
        {
            if(x>y)
            {
                ans=x%mod*ans%mod;
                l+=2;
            }
            else
            {
                ans=y%mod*ans%mod;
                r-=2;
            }
        }
        else
        {
            if(x<y)
            {
                ans=x%mod*ans%mod;
                l+=2;
            }
            else
            {
                ans=y%mod*ans%mod;
                r-=2;
            }
        }
        k-=2;
    }
    cout<<(ans+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 5188
process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.on('SIGINT', function(){
    input_stdin_array = input_stdin.split("\n");
    main();
    process.exit();
});

process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");
    main();    
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

/////////////// ignore above this line ////////////////////

function main() {
	var INF = 1000000000;
	/*solution: backpack 2D*/
	var s = readLine().split(" ");
	var N=parseInt(s[0]), Ma=parseInt(s[1]), Mb=parseInt(s[2]);
	var a = [0], b = [0], c = [0]; /*Array of objects*/
	for (var i=1; i <= N; i++){
		s = readLine().split(" ");
		a.push(parseInt(s[0]));
		b.push(parseInt(s[1]));
		c.push(parseInt(s[2]));
	}
	
	/*Creating DP*/
	var dp=[];
	for (var i=0; i <= 11*N; i++) 
		for (var j=0; j <= 11*N; j++) 
			dp.push(INF);
	dp[0] = 0;
	function getPos(i,j){
		return i*11*N+j;
	}
	for (var i=1; i <= N; i++){
		for (var j=10*N; j >= 0; j--){
			for (var k=10*N; k >= 0; k--){
				if (j - a[i] >= 0 || k - b[i] >= 0){
					var posActual = getPos(j,k);
					var posAnter = getPos(j-a[i],k-b[i]);
					if (dp[posActual] > dp[posAnter] + c[i])
						dp[posActual] = dp[posAnter] + c[i];
				}
			}
		}
	}
	
	var ans = INF;
	for (var i=1; i <= 10; i++){
		var pos = getPos(Ma * i, Mb * i);
		if(ans > dp[pos])
			ans = dp[pos];
	}
	
	if (ans == INF){
		console.log("-1\n");
	} else {
		console.log(ans.toString());
	}
}


Measured memory_bytes: 13772
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int in[100050];
int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &in[i]);

	sort(in + 1, in + N + 1);

	int mx = in[1];
	for (i = 2; i < N; i++) {
		int t = in[i];
		if (min(t, in[N] - t) > min(mx, in[N] - mx)) mx = t;
	}
	return !printf("%d %d\n", in[N], mx);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli mod=1000000007;

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    string s;
    cin>>s;
    lli sum=0;
    for(lli i=0;i<s.length();++i){
        sum=(sum+s[i]-'0')%9;
    }
    if(sum)
        cout<<"No"<<endl;
    else
        cout<<"Yes" <<endl;
}

Measured memory_bytes: 3736
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

a, b, c, d = MAP()

turn = 0
while a > 0 and c > 0:
    if turn % 2 == 0:
        c -= b
    else:
        a -= d
    turn = 1 - turn
if a > 0:
    Yes()
else:
    No()


Measured memory_bytes: 9264
import heapq
from collections import defaultdict

n = int(input())
graph = defaultdict(list)
for _ in range(n):
    u, k, *edges = map(int, input().split())
    for i in range(0, len(edges), 2):
        graph[u].append((edges[i], edges[i+1]))

q = [(0, 0)]
d = {}

# O(V^2)
while q:
    d_min, u = heapq.heappop(q)
    if u in d:
        continue
    d[u] = d_min
    for v, w in graph[u]:
        if v not in d:
            heapq.heappush(q, (d_min+w, v))

for i in range(len(d)):
    print(i, d[i])



Measured memory_bytes: 93184
#include <stdio.h>
#include <vector>

using namespace std;

#define MAXN 5005

typedef long long lint;

const lint MOD = 1e9 + 7;
vector<int> ed[MAXN];
int sz[MAXN], par[MAXN];
vector<int> s;
lint fac[MAXN], facinv[MAXN], dp[MAXN][MAXN];

void dfs(int x) {
	sz[x] = 1;
	for(auto a : ed[x]) if(a != par[x]) {
		par[a] = x;
		dfs(a);
		sz[x] += sz[a];
	}
}

lint pow(lint a, int b) {
	lint ans = 1;
	for(int i = 0; (1 << i) <= b; i++, a = a * a % MOD) if(b & (1 << i)) ans = ans * a % MOD;
	return ans;
}

int main() {
	int N;
	int u, v;

	scanf("%d", &N);
	for(int i = 0; i < N - 1; i++) {
		scanf("%d%d", &u, &v);
		ed[u].push_back(v);
		ed[v].push_back(u);
	}

	dfs(1);
	int ct = 1;
	while(true) {
		if(sz[ct] * 2 < N) ct = par[ct];
		else {
			bool b = false;
			for(auto a : ed[ct]) if(a != par[ct] && sz[a] * 2 > N) {
				ct = a;
				b = true;
				break;
			}
			if(!b) break;
		}
	}
	s.push_back(1);
	if(ct != 1) s.push_back(N - sz[ct]);
	for(auto a : ed[ct]) if(a != par[ct]) s.push_back(sz[a]);

	//for(auto a : s) printf("%d ", a);
	//printf("\n");

	fac[0] = 1ll;
	for(int i = 1; i <= N; i++) fac[i] = fac[i - 1] * i % MOD;
	for(int i = 0; i <= N; i++) facinv[i] = pow(fac[i], MOD - 2);

	dp[0][0] = 1ll;
	for(int i = 1; i < s.size(); i++) for(int j = 0; j < N; j++) {
		for(int k = 0; k <= j && k <= s[i]; k++)
			dp[i][j] = (dp[i][j] + dp[i - 1][j - k] * facinv[k] % MOD * pow(facinv[s[i] - k], 2) % MOD) % MOD;
	}

	lint ans = 0ll;
	for(int i = 0; i < N; i++) ans = (ans + pow(-1ll, i) * fac[N - i] * dp[s.size() - 1][i] % MOD + MOD) % MOD;
	for(auto a : s) ans = ans * pow(fac[a], 2) % MOD;
	
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 196224
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<functional>
#include<cstring>
#define N (1<<17)

using namespace std;
typedef long long ll;
ll dat[1<<18];
int id[1<<18];
int n,r,l;
int d[1000001],t[1000001],x[1000001];
int timel[100001];

void init(){
	memset(dat,0,sizeof(dat));
	for(int i=N;i<N*2;i++)id[i]=i-N;
}

void update(int k,ll a){
	k+=N-1;
	dat[k]+=a;
	while(k>0){
		k=(k-1)/2;
		if(dat[k*2+1]>=dat[k*2+2]){
			dat[k]=dat[k*2+1];
			id[k]=id[k*2+1];
		}else{
			dat[k]=dat[k*2+2];
			id[k]=id[k*2+2];
		}
	}
}

int main(void){
	scanf("%d%d%d",&n,&r,&l);
	for(int i=0;i<r;i++)scanf("%d%d%d",&d[i],&t[i],&x[i]);
	int nt=0;
	init();
	for(int i=0;i<r;i++){
		timel[id[0]]+=t[i]-nt;
		nt=t[i];
		update(d[i],x[i]);
	}
	timel[id[0]]+=l-nt;
	int sum=0,rid=0;
	for(int i=0;i<n;i++){
		if(sum<timel[i])sum=timel[i],rid=i;
	}
	printf("%d\n",rid+1);
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long long unsigned int llu;
#define tc long long int t; cin>>t; while(t--)
#define  sync ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define mpi unordered_map<ll, ll>
#define mpc unordered_map<char, ll>
#define map_loop(it,m) for(auto it = m.begin(); it!=m.end(); it++)
#define rep(i,n) for(ll i=0;i<n;i++)




int main(){
  
  sync;
  llu n,k;
  cin>>n>>k;
  
  llu r = n%k;
  cout<<min(r,k-r)<<endl;
  
}






















Measured memory_bytes: 256
// https://atcoder.jp/contests/abc056/tasks/abc056_c
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
const int INF = 1e9;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    int t = sqrt(2 * x);
    while (t * (t + 1) < 2 * x) {
        t++;
    }
    cout << t << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
d = []
for i in range(N):
    d.append(input())

d.sort(reverse=True)
cnt = 0
for i in range(N):
    if i==0:
        cnt += 1
        continue
    elif d[i]==d[i-1]:
        continue
    else:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int X, Y;
    cin >> X >> Y;
    if (Y % 2 != 0) {
        cout << "No" << endl;
    } else {
        if ((X * 4) >= Y && Y >= (X * 2)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> > 
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
  int n; cin >> n;
  n ^= 1;
  cout << n << '\n';
}

/*
  * overflow, array bounds
  * do smth instead of nothing and stay organized
*/
signed main() {   
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1; // cin >> t;
   for(int i = 1; i <= t; i++) {
   //  cout << "Case #" << i << ": ";
     solve();
  }
}    

/*

*/

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    char c;
    cin >> c;
    if (isupper(c)) {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
}


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



int main(){
  int N;
  cin>>N;
  int kiss=0;
  int ni=0;
  int yon=0;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(a%4==0) yon++;
    else if(a%2==0) ni++;
    else kiss++;
  }
  if(ni>=1){
    if(yon>=kiss) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  else{
    if(yon>=kiss-1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3636
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int A, B;

int main()
{
  scanf( "%d%d", &A, &B );

  printf( "%d\n", B % A == 0 ? A+B : B-A );

  return 0;
}

Measured memory_bytes: 128
use proconio::input;

fn main() {
	input!(n: i64);

	let mut n:i64 = n;
	let mut ans: String = String::new();

	for i in 1..99 {
		if n <= 26i64.pow(i) {
			n -= 1;
			for _j in 0..i {
				ans.push((('a' as i64 + (n % 26)) as u8) as char);
//				println!("debug:{}", n);
//				ans.push(std::char::from_digit('a' as u32 + (n % 26) as u32, 10).unwrap());
				n = n / 26;
//				println!("debug:{}", n);
			}
			break;
		}
		else {
			n -= 26i64.pow(i);
		}
	}

	println!("{}", ans.chars().rev().collect::<String>());
}


Measured memory_bytes: 2168