akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int n; cin >> n;
  cout << (n <= 999 ? "ABC" : "ABD") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int N;
int ans=1e9,INF=1e9;
void calc(char L,char R,vector<pair<pair<int,int>,char> >&A)
{
	int ret=INF;
	map<int,vector<pair<int,int> > >mp;
	for(pair<pair<int,int>,char>p:A)
	{
		if(p.second==L||p.second==R)mp[p.first.first].push_back(make_pair(p.first.second,p.second==L?-1:1));
	}
	for(map<int,vector<pair<int,int> > >::iterator it=mp.begin();it!=mp.end();it++)
	{
		vector<pair<int,int> >now=it->second;
		sort(now.begin(),now.end());
		int X=-INF;
		for(pair<int,int>&p:now)
		{
			int b=p.first%2==0?0:1;
			if(p.second==-1)
			{
				X=p.first;
			}
			else if(X!=-INF)
			{
				ret=min(ret,p.first-X);
			}
		}
	}
	ans=min(ans,ret);
}
int X[2<<17],Y[2<<17];
char dir[2<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>X[i]>>Y[i]>>dir[i];
	}
	vector<pair<pair<int,int>,char> >A(N);
	for(int i=0;i<N;i++)
	{
		A[i]=make_pair(make_pair(X[i],Y[i]),dir[i]);
	}
	calc('U','D',A);
	for(int i=0;i<N;i++)
	{
		A[i]=make_pair(make_pair(Y[i],X[i]),dir[i]);
	}
	calc('R','L',A);
	for(int i=0;i<N;i++)
	{
		A[i]=make_pair(make_pair(X[i]+Y[i],X[i]-Y[i]),dir[i]);
	}
	calc('R','U',A);
	for(int i=0;i<N;i++)
	{
		A[i]=make_pair(make_pair(X[i]-Y[i],X[i]+Y[i]),dir[i]);
	}
	calc('U','L',A);
	for(int i=0;i<N;i++)
	{
		A[i]=make_pair(make_pair(X[i]+Y[i],Y[i]-X[i]),dir[i]);
	}
	calc('L','D',A);
	for(int i=0;i<N;i++)
	{
		A[i]=make_pair(make_pair(X[i]-Y[i],-X[i]-Y[i]),dir[i]);
	}
	calc('D','R',A);
	if(ans==INF)cout<<"SAFE"<<endl;
	else cout<<ans*5<<endl;
}


Measured memory_bytes: 28792
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N,Q = map(int,input().split())
V,W = np.array([input().split() for _ in range(Q)],dtype=np.int64).T

if N == 1:
    answer = np.minimum(V,W)
else:
    for _ in range(50):
        V[V>W] = (V[V>W]+N-2)//N
        W[W>V] = (W[W>V]+N-2)//N
    answer = V

print('\n'.join(answer.astype(str)))

Measured memory_bytes: 52984
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N, M;
  cin >> N >> M;
  if (N % 2) {
    rep(i, 0, M) { cout << M - i << " " << M + i + 1 << endl; }
  } else {
    if (4 * M > N) {
      rep(i, 0, M) {
        if ((i + 1) * 4 > N)
          cout << M - i << " " << M + i + 2 << endl;
        else
          cout << M - i << " " << M + i + 1 << endl;
      }
    } else {
      rep(i, 0, M) { cout << M - i << " " << M + i + 1 << endl; }
    }
  }
  return (0 ^ _ ^ 0);
}



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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void){
	int N,K;
	scanf("%d %d",&N,&K);
	int h[N];
	int i,j;
	for(i=0;i<N;i++){
		scanf("%d",&h[i]);
	}
	//h[i]をソートしてh[0]とh[K-1]の差と
	//h[1]とh[K-1+1]の差を出していって一番小さいやつを採用する
	qsort(h,N, sizeof(int), compare_int);
	int min = abs(h[0] - h[K-1]);
	for(i=0;i<=N-K;i++){
		j = abs(h[0+i] - h[K-1+i]);
		if( min > j){
			min =j;
		}
	}
	printf("%d",min);
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    int evenCnt = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0) {
            evenCnt++;
        }
    }

    cout << pow(3, N) - pow(2, evenCnt) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> vec(n);
    ll hoge = 1;
    rep(i,n){
        hoge *= 3;
        cin >> vec[i];
    }
    ll diff = 1;
    rep(i,n){
        if(vec[i] % 2 == 0){
            diff *= 2;
        }else{
            diff *= 1;
        }
    }
    cout << hoge - diff << "\n";
    return 0;
}


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

const ll mod = 1e9+7;



int main()
{
    ll n;
    cin>>n;
    vector<pair<ll,ll>> points(n);
    ll i,ans=-1;
    for(i=0;i<n;++i){
        cin>>points[i].first>>points[i].second;
    }
    sort(points.begin(),points.end());
    ll mxabove = -points[0].first+points[0].second,mnbelow = points[0].first+points[0].second;

    for(i=1;i<n;++i){
        ans = max({ans,points[i].first+points[i].second-mnbelow,points[i].first-points[i].second+mxabove});

        mxabove = max(mxabove,-points[i].first+points[i].second);

        mnbelow = min(mnbelow,points[i].first+points[i].second);
    }

    cout<<ans;
}

Measured memory_bytes: 6344
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (ll i = (ll)(a); i<(ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL <class T = int> inline T IN() { T x; cin >> x; return x; }
TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void bOUT(bool c, string s, string t) { OUT(c ? s : t); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }
TPL<TNM T> vector<T> make_v(size_t a) { return vector<T>(a); }
TPL<TNM T, TNM... Ts> auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }

TPL<TNM T> using vec2 = decltype(make_v<T>(0, 0));
TPL<TNM T> using vec3 = decltype(make_v<T>(0, 0, 0));
TPL<TNM T> using vec4 = decltype(make_v<T>(0, 0, 0, 0));
TPL<TNM T> using vec5 = decltype(make_v<T>(0, 0, 0, 0, 0));

int main(void) {
	ll N, X;
	cin >> N >> X;
	vll M(N);
	REP(i, N)M[i] = IN();
	sort(ALL(M));

	int ans = 0;
	REP(i, N) {
		ans++;
		X -= M[i];
	}

	ans += X / M[0];
	OUT(ans);
	return 0;
}

Measured memory_bytes: 256
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
int64 N, M;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> M;

    if (N > M)
        swap(N, M);

    if (N == 1 && M == 1) {
        cout << 1 << "\n";
    } else if (N <= 2 && M <= 2) {
        cout << 0 << "\n";
    } else if (N == 1) {
        cout << M - 2 << "\n";
    } else if (N >= 3) {
        cout << (N - 2) * (M - 2) << "\n";
    } else {
        cout << 0 << "\n";
    }

    return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int INF = 1000100100;

int main()
{
    int n; cin >> n;
    int m; cin >> m;
    int s[m], c[m];
    rep(i,m) cin >> s[i] >> c[i];

    int rn, sn;
    if(n == 1) rn = 10, sn = 0;
    else if(n == 2) rn = 100, sn=10;
    else rn = 1000,sn=100;

    int res = INF;
    for(int i=sn; i<rn; i++){
        int cnt = 0;
        rep(j,m){
            int sj = n-s[j]+1;
            int num;
            if(sj == 1){
                num = i%10;
                if(c[j] == num) cnt++;
            }else if(sj ==2){
                num = i / 10;
                num %= 10;
                if(c[j] == num) cnt++;
            }else{
                num = i/100;
                if(c[j] == num) cnt++;
            }
        }
        if(cnt == m) res = min(i, res);
    }

    if(res == INF) cout << -1 << endl;
    else cout << res << endl;
}

Measured memory_bytes: 3612
S  = input()
N = len(S)
n1,n2 = ((N-1)/2),(N+3)/2
n1,n2 = int(n1),int(n2)
sh,st = S[:n1],S[n2-1:N]

if sh == sh[::-1] and st == st[::-1] and S==S[::-1]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()){
			int[] a = new int[4];
			int[] b = new int[4];
			for(int i = 0; i < a.length; i++) a[i] = sc.nextInt();
			for(int i = 0; i < b.length; i++) b[i] = sc.nextInt();
			System.out.println(hit(a, b) + " " + blow(a, b));
		}
		sc.close();
	}
	
	static int blow(int[] q, int[] a) {
		int result = 0;
		for(int i: a) {
			if(contains(q, i)) result++;
		}
		result -= hit(q, a);
		return result;
	}
	
	static int hit(int[] q, int[] a) {
		int result = 0;
		for(int i = 0; i < q.length; i++) {
			if(q[i] == a[i]) result++;
		}
		return result;
	}
	
	static boolean contains(int[] q, int a) {
		for(int i: q) {
			if(i == a) return true;
		}
		return false;
	}
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int x;
	cin >> x;
	vi tbl;
	for(int i = 1; i < 1000; i++)
	{
		for(int j = 2; j < 1000; j++)
		{
			int beki = pow(i, j);
			tbl.push_back(beki);
		}
	}
	sort(all(tbl));
	auto i = upper_bound(all(tbl), x);
	cout << *(i - 1) << endl;
	return 0;
}

Measured memory_bytes: 6000
N,M = (int(X) for X in input().split())
if N==1 or M==1:
    if N==M:
        print(1)
    else:
        print(max(N,M)-2)
else:
    Four = 4
    Six  = 2*(N+M-4)
    Nine = N*M-(Four+Six)
    print(Nine)

Measured memory_bytes: 9008
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N, M = getNM()
query = [getList() for i in range(N)]

A_list = [[] for i in range(10 ** 5 + 1)]
for a, b in query:
    A_list[a].append(b)

job = []
heapq.heapify(job)

ans = 0
for i in range(1, M + 1):
    for j in A_list[i]:
        heapq.heappush(job, -j)
    if len(job) > 0:
        u = heapq.heappop(job)
        ans += -u
print(ans)

Measured memory_bytes: 110448
object Main extends App {
  import scala.io.StdIn._
  val Array(n, m, k) = readLine.trim.split(' ').map(_.toLong)
  val base = (n % 10).toInt
  val nm = power(n % 10, m)
  val first = Array.fill(10){-1}
  var whileFirst = -1
  var loopLen = -1
  first(base) = 0
  for (i ← 1 to 11 if whileFirst == -1) {
    if (first(base * power(nm, i) % 10) == -1) {
      first(base * power(nm, i) % 10) = i
    }else {
      whileFirst = first(base * power(nm, i) % 10)
      loopLen = i - whileFirst
    }
  }
  val f = (0 until whileFirst).map(i ⇒ base * power(nm, i) % 10)
  val l = (0 until loopLen).map(i ⇒ base * power(nm, whileFirst + i) % 10)
  val r = (0L until (k - whileFirst) % loopLen).map(i ⇒ base * power(nm, whileFirst + i) % 10)
  println(f.sum + l.sum * ((k - whileFirst) / loopLen) + r.sum)
  def power(base: Long, exp: Long): Int = {
    exp match {
      case 0 ⇒ 1
      case 1 ⇒ (base % 10).toInt
      case _ ⇒ power(base * base % 10, exp / 2) * power(base, exp % 2) % 10
    }
  }
}


Measured memory_bytes: 44924
#include <iostream>

#define MAXN 100

using namespace std;

int A[MAXN+1], B[MAXN+1];

int main()
{
  int N;
  int max = 0;

  cin >> N;
  for ( int i = 1; i <= N; ++i ) scanf("%d", &A[i]);
  for ( int j = 1; j <= N; ++j ) scanf("%d", &B[j]);

  for ( int i = 1; i <= N; ++i ) A[i] += A[i-1], B[i] += B[i-1];

  for ( int i = 1; i <= N; ++i ) {
    int tmp = A[i]+B[N]-B[i-1];
    if ( max < tmp ) max = tmp;
  }

  cout << max << "\n";

}


Measured memory_bytes: 888
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, T = MAP()
A = LIST()

buy = [0]*N
sell = [0]*N
buy_memo = [0]*N
sell_memo = [0]*N

tmp_buy = INF
tmp_buy_memo = -1
for i in range(N):
	if A[i] <= tmp_buy:
		tmp_buy = A[i]
		tmp_buy_memo = i
	buy[i] = tmp_buy
	buy_memo[i] = tmp_buy_memo

tmp_sell = 0
tmp_sell_memo = -1
for i in range(N-1, -1, -1):
	if tmp_sell <= A[i]:
		tmp_sell = A[i]
		tmp_sell_memo = i
	sell[i] = tmp_sell
	sell_memo[i] = tmp_sell_memo

diff = [sell[i]-buy[i] for i in range(N)]
max_diff = max(diff)

buy_possible = [0]*N
sell_possible = [0]*N

for i in range(N):
	if diff[i] == max_diff:
		buy_possible[buy_memo[i]] = 1
		sell_possible[sell_memo[i]] = 1

print(min(sum(buy_possible), sum(sell_possible)))
 

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

int main(){
    int N,M;
    cin >> N >> M;

    vector<int> X(M,0);
    for(int i=0; i < M; i++){
        cin >> X[i];
    }

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

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

    vector<int> diff(M-1,0);
    for(int i=0; i<(M-1); i++)
        diff[i] = X[i+1] - X[i];
    
    sort(diff.begin(),diff.end(),greater<int>());
    for(int i=0; i<(N-1); i++){
        diff[i] = 0;
    }
    
    int sum = accumulate(diff.begin(),diff.end(),0);
    cout << sum << endl;
    return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1000000007;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

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

int N, K;

int main() {
  cin >> N;

  int happiness[N][3];
  for(int i = 0; i < N; i++) {
    cin >> happiness[i][0] >> happiness[i][1] >> happiness[i][2];
  }

  int dp[N][3] = {0};
  dp[0][0] = happiness[0][0];
  dp[0][1] = happiness[0][1];
  dp[0][2] = happiness[0][2];

  for(int i = 1; i < N; i++) {
    for(int j = 0; j < 3; j++) {
      for(int k = 0; k < 3; k++) {
        if(j == k) continue;
        chmax(dp[i][k], dp[i-1][j] + happiness[i][k]);
      }
    }
  }

  int ans = max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2]));
  cout << ans << endl;
  return 0;
}



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

#define mp(x, y) make_pair(x, y)

const int maxn = 5e5 + 10;

int nex1[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}, nex2[20][2] = {{1, 1}, {1, -1}, {-1, 1}, {-1, -1}, {-2, -2}, {-2, -1}, {-2, 0}, {-2, 1}, {-2, 2}, {-1, 2}, {-1, -2}, {0, 2}, {0, -2}, {1, 2}, {1, -2}, {2, 2}, {2, 1}, {2, 0}, {2, -1}, {2, -2}};
int d[1005][1005];
char Map[10005][1005];
int n, m;
inline int check(int x, int y)
{
  if (x <= 0 || x > n || y <= 0 || y > m || Map[x][y] == '#')
    return 0;
  return 1;
}
void bfs(int a, int b)
{
  d[a][b] = 0;
  deque<pair<int, int> > que;
  que.push_back(mp(a, b));
  while (!que.empty())
  {
    int x, y;
    x = que.front().first, y = que.front().second;
    que.pop_front();
    for (int i = 0; i < 4; i++)
    {
      int _x = x + nex1[i][0], _y = y + nex1[i][1];
      if (check(_x, _y) && d[_x][_y]>d[x][y])
      {
        que.push_front(mp(_x, _y));
        d[_x][_y] = d[x][y];
      }
    }
    for (int i = 0; i < 20; i++)
    {
      int _x = x + nex2[i][0], _y = y + nex2[i][1];
      if (check(_x, _y) && d[_x][_y] > d[x][y]+1)
      {
        d[_x][_y] = d[x][y] + 1;
        que.push_back(mp(_x, _y));
      }
    }
  }
}
void init()
{
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      d[i][j] = 1e9;
}
void solve()
{
  cin>>n>>m;
  int x, y, tox, toy;
  cin>>x>>y>>tox>>toy;
  init();
  getchar();
  for (int i = 1; i <= n; i++)
    scanf("%s", Map[i] + 1);
  bfs(x, y);
  if (d[tox][toy] == 1e9)
    cout << -1 << endl;
  else
    cout << d[tox][toy] << endl;
}
signed main()
{
  solve();
  return 0;
}


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

using namespace std;

const int N = 1000000;

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

	int n;
	cin >> n;

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

	vector<int> cnt(N + 1);
	for(int i : a) {
		cnt[i] += 1;
	}

	bool ok = true;
	for(int i = 2; i <= N; ++i) {
		int tot = 0;
		for(int j = i; j <= N; j += i) {
			tot += cnt[j];
		}
		if(tot > 1) {
			ok = false;
		}
	}

	if(ok) {
		cout << "pairwise coprime" << '\n';
	} else {
		int g = 0;
		for(int i : a) {
			g = __gcd(i, g);
		}
		if(g == 1) {
			cout << "setwise coprime" << '\n';
		} else {
			cout << "not coprime" << '\n';
		}
	}

	return 0;
}


Measured memory_bytes: 11112
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    let mut ans = 0;
    for ki in k..=n + 1 {
        let min: usize = (ki - 1) * ki / 2;
        let max: usize = (n - (ki - 1) + n) * ki / 2;
        ans += max - min + 1;
        ans %= 1_000_000_007;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A, B, C, X;
  cin >> A >> B >> C >> X;
  int d =0;
  for(int i =0; i<= A;i++){
    for(int j =0;j <= B;j++){
      for(int k =0; k <= C;k++){
        if(500*i+100*j + 50*k == X){
          d++;}
      }
    }
  }
  cout << d << endl;
      
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int H,W;
char g[105][105];
bool c[105][2];
int main(){
	scanf("%d%d",&H,&W);
	for(int i=1;i<=H;i++)
		for(int j=1;j<=W;j++){
			scanf(" %c",&g[i][j]);	
			if(g[i][j]=='#')c[i][0]=true;
		}
	for(int j=1;j<=W;j++)
		for(int i=1;i<=H;i++)
			if(g[i][j]=='#'){
				c[j][1]=true;
				break;
			}
	for(int i=1,f;i<=H;i++){
		f=0;
		for(int j=1;j<=W;j++)
			if(c[i][0]&&c[j][1]){
				printf("%c",g[i][j]);	
				f=1;
			}
			if(f)putchar('\n');
		}
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll T;
    cin >> T;
    rep(time, T){
        ll a,b,c,d;
        cin >> a >> b >> c >> d;
        
        if(a < b) {cout << "No" << endl; continue;}
        if(d < b) {cout << "No" << endl; continue;}
        if(c >= b){cout << "Yes" << endl; continue;}

        ll g = gcd(b,d);
        ll ans = b - (g-(a % g));
        if(ans > c) cout << "No" << endl ;
        else cout << "Yes" << endl;
    }
    
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50*k == X:
                count += 1
            
print(count)
               

Measured memory_bytes: 3188
#include <cstring>
#include <bitset>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include<stdio.h>
#include<map>
#include<algorithm>
#include<cstdio>
#include <math.h>
#include<cmath>
#define inc(i,a,b) for(register int i=a;i<=b;i++)
#define dec(i,a,b) for(register int i=a;i>=b;i--)
using namespace std;
typedef long long LL;
inline void read(int &x)
{
	x=0;bool f=0;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=1;c=getchar();}
	while(c<='9'&&c>='0')x=(x<<3)+(x<<1)+c-'0',c=getchar();
	if(f)x=-x;return;
}
inline void read(LL &x)
{
	x=0;bool f=0;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=1;c=getchar();}
	while(c<='9'&&c>='0')x=(x<<3)+(x<<1)+c-'0',c=getchar();
	if(f)x=-x;return;	
}
const int mx=100007;
struct node
{
	int n,t,u;
}nx[mx];
int n,siz[mx],cnt,h[mx];
pair <LL,int> d[mx];
#define f first
#define s second
void add(int u,int v)
{
	nx[++cnt].n=h[u];
	nx[cnt].u=u;
	nx[cnt].t=v;
	h[u]=cnt;
}
int find(LL x)
{
	int l=1,r=n,mid=(l+r)>>1;
	while(l<=r)
	{
		if(d[mid].f==x)return mid;
		if(d[mid].f<x)l=mid+1;
		else r=mid-1;mid=(l+r)>>1;
	}
	return 0;
}
LL check;
#define link(i,x) for(register int i=h[x];i;i=nx[i].n)
LL dfs(int x,LL upp)
{
	LL res=upp;
	link(i,x)res+=dfs(nx[i].t,upp+1);
	return res;
}
int main()
{
	read(n);
	inc(i,1,n)
	{
		read(d[i].f);
		d[i].s=i;
		siz[i]=1;
	}
	sort(d+1,d+n+1);
	dec(i,n,2)
	{
		int fr=find(d[i].f+(siz[i]<<1)-n);
		if(fr)add(fr,i),siz[fr]+=siz[i];
		else {printf("-1\n");return 0;}
	}
	check=dfs(1,0);
	if(check!=d[1].f)
	{
		printf("-1\n");
		return 0;
	}
	inc(i,1,cnt)printf("%d %d\n",d[nx[i].u].s,d[nx[i].t].s);
}

Measured memory_bytes: 6528
def Lucas(n):
    a0, a1 = 2, 1
    if n == 0:
        return a0
    elif n == 1:
        return a1
    else:
        for _ in range(n - 1):
            a1, a0 = a0 + a1, a1
        return a1


print(Lucas(int(input())))


Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;

struct st_string{
	string str;
	st_string *next;
};

class array_class{
public:
	st_string *start;
	st_string *end,*buf;
	int n;
	array_class(){
		n=0;
		start=end=NULL;
	}
	void add(string str){
		if(start==NULL){
			start=new st_string;
			start->str=str;
			start->next=NULL;
			end=start;
			n++;
			return;
		}
		buf=start;
		while(buf!=NULL){
			if(str==buf->str) return;
			buf=buf->next;
		}
		buf=new st_string;
		buf->str=str;
		buf->next=NULL;
		end->next=buf;
		end=buf;
		n++;
		return;
	}
	int size(){
		return n;
	}
	void show(){
		buf=start;
		while(buf!=NULL){
			cout<<"  "<<buf->str<<endl;
			buf=buf->next;
		}
	}
	void clear(){
		while(start!=NULL){
			buf=start;
			start=start->next;
			delete buf;
		}
		n=0;
		start=NULL;
		return;
	}
};

array_class v;

void rev(char *start,char *end){
	char t;
	while(start<end){
		t=*start;
		*start=*end;
		*end=t;
		start++;
		end--;
	}
	return;
}

void add(char *s1,char *s2){
	string str;
	char *start,*end;
	char t;
	str=string(s1)+string(s2);
	v.add(str);
	str=string(s2)+string(s1);
	v.add(str);
	rev(s1,&s1[strlen(s1)-1]);
	str=string(s1)+string(s2);
	v.add(str);
	str=string(s2)+string(s1);
	v.add(str);
	rev(s2,&s2[strlen(s2)-1]);
	str=string(s1)+string(s2);
	v.add(str);
	str=string(s2)+string(s1);
	v.add(str);
	rev(s1,&s1[strlen(s1)-1]);
	str=string(s1)+string(s2);
	v.add(str);
	str=string(s2)+string(s1);
	v.add(str);
	return;
}

int main(){
	int n,count;
	char str[75],s1[75],s2[75];
	cin>>n;
	for(int p=0;p<n;p++){
		v.clear();
		cin>>str;
		int l=(strlen(str));
		for(int i=1;i<l;i++){
			strncpy(s1,str,i);
			s1[i]=0;
			strcpy(s2,&str[i]);
			add(s1,s2);
		}
		cout<<v.size()<<endl;;
	}
	return 0;
}

Measured memory_bytes: 996
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	string p;
	cin >> p;
	if (p[0] == p[2])cout << "Yes" << endl;
	else cout << "No" << endl;
		return 0;

}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int tmp;
		if(a>b) {
					tmp=a;
					a=b;
					b=tmp;
		}
		if(b>c) {
			tmp=b;
			b=c;
			c=tmp;
		}
		if(a>b) {
			tmp=a;
			a=b;
			b=tmp;
		}



			System.out.printf("%d %d %d\n",a,b,c);
	}
}




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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
  int N, x;
  cin >> N >> x;
  if (x == 1 || x == 2 * N - 1) {
    cout << "No" << endl;
    return;
  }
  cout << "Yes" << endl;
  if (N == 2) {
    cout << 1 << endl;
    cout << 2 << endl;
    cout << 3 << endl;
    return;
  }
  // N >= 3

  vector<int> ans(2 * N - 1, -1);
  ans[ans.size() / 2] = x;
  ans[ans.size() / 2 - 1] = x - 1;
  ans[ans.size() / 2 + 1] = x + 1;

  if (x - 2 != 0) {
    ans[ans.size() / 2 + 2] = x - 2;
  } else {
    ans[ans.size() / 2 - 2] = x + 2;
  }

  vector<int> flag(2 * N);
  for (int i = 0; i < 2 * N - 1; i++) {
    if (ans[i] == -1) continue;
    flag[ans[i]] = 1;
  }
  int now = 1;
  for (int i = 0; i < 2 * N - 1; i++) {
    if (ans[i] != -1) continue;
    while(flag[now]) now++;
    flag[now] = 1;
    ans[i] = now;
  }

  for (int i = 0; i < 2 * N - 1; i++) {
    cout << ans[i] << endl;
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

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

int main()
{
    int _1, _9, _7, _4;
    _1 = _9 = _7 = _4 = 0;
    int dat;

    for (int i = 0; i < 4; i++) {
        cin >> dat;

        if (dat == 1) {
            _1++;
        } else if (dat == 9) {
            _9++;
        } else if (dat == 7) {
            _7++;
        } else if (dat == 4) {
            _4++;
        }
    }

    if (_1 && _9 && _7 && _4) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
         
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        var vList = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var cList = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var vcList = vList.Zip(cList, (v, c) => new { v, c });
        Console.WriteLine(vcList.Where(itm => itm.v - itm.c >= 0).Sum(itm => itm.v - itm.c));
    }
    
}

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

using namespace std;

#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fastio { ios_base::sync_with_stdio(false), cin.tie(NULL); }
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define for1(i, n) for(int i = 1; i <= (int)(n); i++)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

#ifdef RICARDO
//Header here
	#include "E:\\Code\\dbg.h"
#else
	#define bug(...) "RICARDO MILOS"
#endif


template<class T> bool mini(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool maxi(T &a, T b) { return a < b ? (a = b, true) : false; }

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

//=================================================CODE=================================================//
const int N = 1000;
const i64 mod = 1e9 + 7;
vvi64 F(N + 1, vi64(N + 1, 0));
vi64 fac(N + 1);

i64 pw(i64 a, i64 b) {
	i64 RES = 1;
	for(; b; b >>= 1, a = a * a % mod) if(b & 1)
		RES = (RES * a) % mod;
	return RES;
}

map<i64, i64> dp;
i64 inv(i64 x) {
	if(x == 1) return 1;
	if(dp.count(x)) return dp[x];
	return dp[x] = (mod - mod / x * inv(mod % x) % mod ) % mod;
}

i64 C(i64 n, i64 k) {
	return fac[n] * inv(fac[n - k]) % mod * inv(fac[k]) % mod;
}

signed main()
{	
	fastio;
	cout.precision(10);
	cout << fixed;
#ifdef RICARDO		
	freopen("i", "r", stdin);
#endif
	fac[0] = 1;
	for1(i, N) fac[i] = (fac[i - 1] * i) % mod;

	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	int cnt = 0;
	F[a - 1][0] = 1;
	fore(i, a, b) forn(j, n + 1) {
		F[i][j] = F[i - 1][j];
		fore(k, c, d) {
			if(i * k > j) break;
			i64 temp = C(j, i * k) * fac[i * k] % mod * inv(pw(fac[i], k)) % mod * inv(fac[k]) % mod;
			F[i][j] = (F[i][j] + F[i - 1][j - i * k] * temp % mod) % mod;                  
		}
	}

	cout << F[b][n] << endl;
#ifdef RICARDO
	cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}

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

int main(){
   int n;
   cin >> n;
    vector<int> a(n+2);
    vector<int> b(n+2,0);
    for( int i = 0; i < n; i++){
        int ai;
        cin >> ai;
        a.at(i) = ai;
    }
    bool allfrag = false;
    int sum = 0;
    while( allfrag == false){
        bool frag = false;
        int i = 0;
        while(i < n){
            while(a.at(i) > b.at(i)){
                frag = true;
                sum += 1;
                while(a.at(i)> b.at(i)){
                    b.at(i) += 1;
                    i++; 
                }
            }
            i++;
        }
        if(frag == false){
            allfrag = true;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a, b, c;
    int count = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) count++;        
    }
    cout << count << endl;
    return 0;
}


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

namespace lineAralgebra
{
	class Program
	{
		public static void Main(String[] args)
		{
			var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
			var h = input[0];
			var a = input[1];

			int ans = 0;

			while (h > 0)
			{
				ans++;
				h -= a;
			}

			System.Console.WriteLine(ans);
		}
	}
}



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

#define N 100000

int aa[N], bb[N];

int compare(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return bb[j] - bb[i];
}

int main() {
	static int ii[N];
	int n, h, i, a, ans;

	scanf("%d%d", &n, &h);
	a = 0;
	for (i = 0; i < n; i++) {
		scanf("%d%d", &aa[i], &bb[i]);
		if (a < aa[i])
			a = aa[i];
		ii[i] = i;
	}
	qsort(ii, n, sizeof *ii, compare);
	ans = 0;
	for (i = 0; i < n; i++)
		if (bb[ii[i]] >= a && h > 0) {
			h -= bb[ii[i]];
			ans++;
		}
	if (h > 0)
		ans += (h + a - 1) / a;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1660
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(){
	long long int N, a, b, aB = 1;
	scanf("%lld", &N);
	a = 1;
	b = N;
	while(++a * a <= N)
	{
		if(N % a == 0 && N / a < b)
		{
			b = N / a;
			aB = a;
		}	
	}
	printf("%lld\n", aB + b - 2);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
/*Sawal nahi hone wala phir bhi kar lo ek try*/
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n;i>=0;i--)
#define rep_a(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define debug(x) do { std::cerr << #x << ": " << x << std::endl; } while (0);
#define debugg(x,y) do { std::cerr << #x << ": " << x << "  "<< #y << ": " << y << std::endl; } while (0);
const long long mod = 1000000007;
typedef vector<ll>              vll;
typedef vector<string>          vstr;
typedef vector<char>            vchar;
typedef vector<pair<ll,ll> >    vpll;
typedef set<ll>                 sll;
typedef set<string>             sstr;
typedef set<pair<ll,ll> >       spll;
typedef map<ll,ll>              mllll;
typedef map<string,ll>          mstrll;
typedef queue<ll>               qll;


ll powMod(ll x,ll y)            {ll p=1; while(y){if(y%2){p=(p*x)%mod;} y/=2; x=(x*x)%mod;} return p;}
ll invMod(ll x)                 {return powMod(x,mod-2);}
ll gcd(ll a, ll b)              {return b == 0 ? a : gcd(b, a % b);}
ll nCr(ll n, ll r)              { if(n<r)return 0;ll nfac = 1;ll dfac = 1;for(ll i=n-r+1;i<=n;i++){nfac = (nfac*i)%mod;}for(ll i=1;i<=r;i++){dfac = (dfac*invMod(i))%mod;}return (nfac*dfac)%mod;}

int solve()
{
    int a,b,c,d;cin>>a>>b>>c>>d;
    int i =1;
    while(a>0&&c>0)
    {
        if(i%2)c -=b;
        else
        {
            a-=d;
        }
        i++;
    }
    if(a<=0)cout<<"No";
    else
    {
        cout<<"Yes";
    }
    
    
   return 0;    
}

int main()
{
    //fast;
	/* #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#else
	#endif */
	solve();
	/* #ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC <<" Sec\n";
	#endif */
	return 0;
}

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

using namespace std;

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

    if(n>=400 && n<=599)cout<<8<<endl;

    else if(n>=600 && n<=799)cout<<7<<endl;

    else if(n>=800 && n<=999)cout<<6<<endl;

    else if(n>=1000 && n<=1199)cout<<5<<endl;

    else if(n>=1200 && n<=1399)cout<<4<<endl;

    else if(n>=1400 && n<=1599)cout<<3<<endl;

    else if(n>=1600 && n<=1799)cout<<2<<endl;

    else if(n>=1800 && n<=1999)cout<<1<<endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
bool is_integer( double x ){
  return std::floor(x)==x;
}
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    REP(i,50005){
        double dn = i*1.08;
        int in = dn;
        //cout << in <<endl;
        if(in==n){
            cout << i << endl;
            return 0;
        }
        if(in>n)break;
    }
cout << ":(" << endl;
    return 0;
}

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

int n;
int a[110],ma,mi,id1,id2;
int main()
{
	scanf("%d",&n);
	ma=-1; mi=1e7;
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		if (a[i]>ma) ma=a[i],id1=i;
		if (a[i]<mi) mi=a[i],id2=i;
	}
	
	printf("%d\n",2*n-1);
	if (abs(ma)>=abs(mi)) {
		for (int i=1;i<=n;i++) printf("%d %d\n",id1,i);
		for (int i=1;i<n;i++) printf("%d %d\n",i,i+1);
	} else {
		for (int i=1;i<=n;i++) printf("%d %d\n",id2,i);
		for (int i=n;i>1;i--) printf("%d %d\n",i,i-1);
	}
	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
x = len(s)-len(t)
ans = 10000000
y = 0
cnt = 0
for i in range(x+1):
    for j in range(i, i+len(t)):
        if s[j] != t[j-y]:
            cnt += 1
    ans = min(ans, cnt)
    y += 1
    cnt = 0
print(ans)

Measured memory_bytes: 73212
#include <stdio.h>

int main(void)
{
    char s[100000][11];
    int i, n;
    long long int x, h[5]={0};

    scanf("%d", &n);
    for (i=0; i<n; i++){
        scanf("%s", s[i]);

        switch(s[i][0]) {
            case 'M':   h[0]++; break;
            case 'A':   h[1]++; break;
            case 'R':   h[2]++; break;
            case 'C':   h[3]++; break;
            case 'H':   h[4]++; break;
        }
    }

    x = 0;
    x  = h[0]*h[1]*h[2];
    x += h[0]*h[1]*h[3];
    x += h[0]*h[1]*h[4];
    x += h[0]*h[2]*h[3];
    x += h[0]*h[2]*h[4];
    x += h[0]*h[3]*h[4];
    x += h[1]*h[2]*h[3];
    x += h[1]*h[2]*h[4];
    x += h[1]*h[3]*h[4];
    x += h[2]*h[3]*h[4];

    printf("%lld\n", x);

    return 0;
}

Measured memory_bytes: 1280
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    a_list = li()
    box_list = [0] * n
    div = 1
    while n // (div + 1) - 1 >= 0:
        for i in range(n // div - 1, n // (div + 1) - 1, -1):
            value = a_list[i]
            index = (i + 1) * 2 - 1
            while index < n:
                value = value ^ box_list[index]
                index = index + (i + 1)
            box_list[i] = value
            # print(value)
        div = div + 1
    box_sum = sum(box_list)
    box_list[0] = (box_sum % 2) ^ a_list[0]
    print(box_sum + box_list[0])
    for index, box in enumerate(box_list):
        if box == 1:
            print(index + 1, end=" ")

# n // 2 + 1 -- n まではaの通りにボールを入れる
# n // 3 + 1 -- n // 2 まではaと２倍した場所の箱を見てボールを入れる
#


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

int main() {
    int N;
    int i = 0;

    int sum = 0;

    cin >> N;

    for (i = 0; i < N; i++) {
        string x;
        cin >> x;

        if (x == "Y") {
            sum += 1;
        }
    }

    if (sum == 0) {
        cout << "Three" << endl;
    }
    else {
        cout << "Four" << endl;
    }

}

Measured memory_bytes: 3600
#include <stdio.h>
int main(){
    int a,b;
    scanf("%d%d", &a, &b);
    if (a<b){
        printf("a < b\n");
    }
    else if (a>b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 2580
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

a, b = map(int, raw_input().split())
print min(str(a) * b, str(b) * a)

Measured memory_bytes: 4268
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    string S, T, U;
    cin >> S >> T >> U;
    cout << S[0] << T[1] << U[2] << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<bool> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n ; cin >> n;
    ll ans = 0;
    for(int i=1;i<=n;i++){
        ans += i * (n/i) * (n/i + 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

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


int main()
{
    int h1 , h2 , m1 , m2 , k;cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = h1 * 60 + m1;
    int t2 = h2 * 60 + m2;

    int dist = t2 - t1 + 1;
    cout << max(dist - k - 1 , 0);
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <string.h>
#include <stdio.h>
using namespace std;
using std::cout;
#include <algorithm>
#include <map>
int main(){
long long n,m=0;
cin>>n;
map<string,long long>freq;
string x[n];
for(int i=0;i<n;i++)
                    {
cin>>x[i];
sort(x[i].begin(),x[i].end());
                    }
                    for(int i=0;i<n;i++){
                        freq[x[i]]++;
                    }
for(auto i=freq.begin();i!=freq.end();i++)
    m+=(((i->second))*(((i->second)-1)))/2;
                     cout<<m<<endl;
return 0;
            }

Measured memory_bytes: 14488