akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
map<ll, int> cnt;
set<int> g[100005];
vector<int> v1, v2;
int main() {
	scanf("%d", &n);
	for(int i=0; i<2*n-2; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		cnt[(ll)u*n+v]++;
		cnt[(ll)v*n+u]++;
		g[u].insert(v);
		g[v].insert(u);
		if(cnt[(ll)u*n+v]==2) {
			v1.push_back(u);
			v2.push_back(v);
		}
	}
	int ans=0;
	for(int i=0; i<v1.size(); i++) {
		if(cnt[(ll)v1[i]*n+v2[i]]==2) {
			ans++;
			if(g[v1[i]].size()<g[v2[i]].size())
				swap(v1[i], v2[i]);
			while(g[v2[i]].size()) {
				int w=*g[v2[i]].begin();
				cnt[(ll)v1[i]*n+w]+=cnt[(ll)v2[i]*n+w];
				cnt[(ll)w*n+v1[i]]+=cnt[(ll)w*n+v2[i]];
				cnt[(ll)v2[i]*n+w]=cnt[(ll)w*n+v2[i]]=0;
				g[v1[i]].insert(w);
				g[w].erase(v2[i]);
				g[w].insert(v1[i]);
				if(cnt[(ll)v1[i]*n+w]==2) {
					v1.push_back(v1[i]);
					v2.push_back(w);
				}
				g[v2[i]].erase(w);
			}
		}
	}
	if(ans==n-1)
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 55800
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 998244353;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}


signed main() {

    ll n, k;

    cin >> n >> k;

    vector<int> a(n);

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

    int logK = 1;

    while((1LL << logK) < k) logK++;
    // doubling[i][j] := j番目から2^i 進んだ町
    vector<vector<int>> doubling(logK, vector<int>(n));

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

    for(int i = 0; i < logK - 1; i++) {
        for(int j = 0; j < n; j++) {
            doubling[i + 1][j] = doubling[i][doubling[i][j]];
        }
    }

    int now = 0;

    for(int i = 0; k > 0; i++) {
        if(k & 1) now = doubling[i][now];
        k >>= 1;
    }

    cout << now + 1 << endl;

    return 0;
}


Measured memory_bytes: 51676
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    string s; cin >> s;
    int g = 0, p = 0, ans = 0;
    rep(i,0,s.length()) {
        if(s[i] == 'g') {
            if(g > p) {
                p++;
                ans++;
            }
            else g++;
        }
        else {
            if(g > p) p++;
            else {
                g++;
                ans--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <climits>

using namespace std;

const int BASE_NUMBER = 753;

int main() {
  string str;
  cin >> str;

  int diffMin = INT_MAX;
  for (int i = 0; i < (str.length() - 2); i++) {
    int num = stoi(str.substr(i,3));

    int diff = abs(num - BASE_NUMBER);

    if (diff < diffMin) {
      diffMin = diff;
    }
  }

  cout << diffMin << endl;
}

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

using ll=long long;



void solve(){
    char a,b;
    cin>>a>>b;
    if(a>b){
        cout<<">"<<endl;
    } 
    else if(a<b){
        cout<<"<"<<endl;
    }else{
        cout<<"="<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

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

// # DEFINES # //
#define ll long long
#define M (ll)(1e9+7)
#define EPS 1e-9

using namespace std;

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


    ll n, t;

    cin >> n >> t;

    int smallest = 10000;
    int c, ti;
    for(int i = 0; i < n; i++) {
        cin >> c >> ti;
        if(ti <= t && c < smallest) {
            smallest = c;
        }
    }
    if(smallest == 10000)
        cout << "TLE" << endl;
    else 
        cout << smallest << endl;

    return 0;
}

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

int main(){
    int m,f,r,s;
    char G;
    while(1){
        cin>>m>>f>>r;
        if(m==-1&&f==-1&&r==-1)break;
        s=m+f;
        if((m==-1)||(f==-1)){
            G='F';
        }else if(s>=80){
            G='A';
        }else if((s>=65)&&(s<80)){
            G='B';
        }else if((s>=50)&&(s<65)){
            G='C';
        }else if((s>=30)&&(s<50)){
            if(r>=50){
                G='C';
            }else{
                G='D';
            }
        }else if(s<30){
            G='F';
        }
        cout<<G<<endl;
    }
    return(0);
}

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

int main(){
  int n;
  cin >> n;
  std::vector<pair<pair<std::string, int>, int>> data(n); 
  for(int i = 1; i <= n; i++){
    string r;
    int x;
    cin >> r >> x;
    data.at(i - 1) = make_pair(make_pair(r, -x), i);
  }
  sort(begin(data), end(data));
  for(pair<pair<std::string, int>, int> p : data){
    pair<std::string, int> a;
    int y;
    tie(a, y) = p;
    cout << y << endl;
  }
}


Measured memory_bytes: 256
/**
 *   Author   :  Nguyen Canh Toan
 *   Created  :  19.05.2020 21:33:21
**/
#include <bits/stdc++.h>

using namespace std;

const long long INF = 1e9 + 5;

int main() { 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<int> dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j : {i + 1, i + 2}) {
		  if (j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	cout << dp[n - 1] << endl;
  return 0;
}


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

int main()
{
    int N;
    cin>>N;
    vector<long long> A(N);
    for (long long &a: A)
        cin>>a;

    vector<pair<long long, int>> V(N);
    for (int i=0; i<N; i++)
        V[i] = make_pair(A[i], i);
    sort(V.begin(), V.end());
    reverse(V.begin(), V.end());

    vector<long long> T(N+1, -1);
    T[0] = 0;
    for (int i=0; i<N; i++)
    {
        vector<long long> P(N+1, -1);
        P.swap(T);
        int x = V[i].second;
        for (int j=0; j<=i; j++)
        {
            T[j+1] = max(T[j+1], P[j]+abs(x-j)*A[x]);
            T[j] = max(T[j], P[j]+abs(x-(N-i+j-1))*A[x]);
        }
    }
    cout<<*max_element(T.begin(), T.end())<<endl;
}


Measured memory_bytes: 3272
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] map = new int[N];
        for (int i = 0; i < N; i++) {
        	map[i] = sc.nextInt();
        }
        
        Arrays.sort(map);
        int ans = 0;
        for (int i = N-1; N-K <= i; i--) {
        	ans += map[i];
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

// template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "vowel"; }
  string_type do_falsename() const { return "consonant"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

void solve() {
  string s;
  cin >> s;
  cout << (string("aiueo").find(s) != string::npos) << endl;
  return;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

tmp_S = {}
for s in S:
  if(s in tmp_S):
    tmp_S[s] += 1
  else:
    tmp_S[s] = 1
for t in T:
  if(t in tmp_S):
    tmp_S[t] -= 1
print(max(0, max(tmp_S.values())))

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

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n;
    bool ok = true;
    cin >> n;
    vll a(n);
    rep(i,n)cin >> a[i];
    sort(all(a));
    rep(i,n-1)if(a[i] == a[i+1]){
        ok = false;
        break;
    }

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100000];
vector<int> block[100000];
vector<int> label(100000);
void dfs(int node, int la) {
	if (label[node] != 0)
		return;
	label[node] = la;
	for (auto v : graph[node]) {
		dfs(v, la);
	}
	return;
}
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		x--;
		y--;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	for (int i = 0; i < n; i++) {
		dfs(i, i + 1);
	}
	map<int, int> cnt;
	for (int i = 0; i < n; i++) {
		cnt[label[i]]++;
	}
	cout << cnt.size() << endl;
	return 0;
}


Measured memory_bytes: 14556
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    return ret


MOD = 10**9 + 7
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

N, X, Y = read_ints()
X -= 1
Y -= 1

# 一箇所だけ短絡している
# もし短絡していなかったら簡単
# O(NN)でも間に合いそう

# 愚直にダイクストラしてもええか？
from scipy.sparse import csr_matrix  # 自分で配列を作ってからcsrに入れよう(lilに打ち込んでいくのは非常に遅い)

# ダイクストラ法 (正の単一始点最短経路) (全点間最短経路)
from scipy.sparse.csgraph import dijkstra
graph = [[0] * N for _ in range(N)]
for i in range(N - 1):
    graph[i][i + 1] = 1
    graph[i + 1][i] = 1
graph[X][Y] = 1
graph[Y][X] = 1
adj_mat = csr_matrix(graph)
D = dijkstra(adj_mat, directed=False)
cnt = Counter(D.reshape(-1))
for i in range(1, N):
    print(int(cnt[i]) // 2)


# D[i,j]でi→jに向かう最短経路
# indicesで始点を指定している場合は、D[j]でok


Measured memory_bytes: 78844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N; string S;
  cin >> N >> S;
  
  int ct = 0;
  rep(i, N-2) {
    if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') {
      ct++;
    }
  }
  
  fin(ct);
}

Measured memory_bytes: 384
void main() {
    int n = readln.chomp.to!int;
    int[] tmp = readln.split.to!(int[]);
    int t = tmp[0], a = tmp[1];
    double[] h = readln.split.to!(double[]);
    h[] *= -0.006;
    h[] += t - a;
    int[] ind = iota(1, n+1).array;
    zip(h, ind).sort!((t1, t2) => t1[0] * t1[0] < t2[0] * t2[0]);
    ind[0].writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 380
#!/usr/bin/env python3
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    c = list(input())
    left = 0
    right = n - 1
    ans = 0
    while True:
        if c[left] == "R" and left < n - 1:
            left += 1
        if c[right] == "W" and right > 0:
            right -= 1
        if right <= left:
            print(ans)
            break
        if c[left] == "W" and c[right] == "R":
            c[left] = "R"
            c[right] = "W"
            ans += 1
        """
        if c[left] == "W":
            c[left] = "R"
            ans += 1
        if c[right] == "R":
            c[right] = "W"
            ans += 1
        """



if __name__ == '__main__':
    main()


Measured memory_bytes: 73536
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long int 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define from(i,n)       for(int i=0;i<(int)n;i++)
#define from_j(i,j,n)   for(int i=j;i<(int)n;i++)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
int activity[100000][3]={0};
int a[100000][3];

int ans(int n,int temp){
    if(n==0){
        activity[n][temp]=a[n][temp];
        return activity[n][temp];
    }
    if(activity[n][temp])return activity[n][temp];
    int ac = inf;
    if(temp==0)ac = max(ans(n-1,2),ans(n-1,1));
    else if(temp==1)ac = max(ans(n-1,0),ans(n-1,2));
    else if(temp==2)ac = max(ans(n-1,0),ans(n-1,1));
    ac+=a[n][temp];
    activity[n][temp]=ac;
    return ac;
}
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
 
int32_t main()
{
    c_p_c();
    int n; cin>>n;
    from(i,n)cin>>a[i][0]>>a[i][1]>>a[i][2];
    cout<<max(ans(n-1,0),max(ans(n-1,1),ans(n-1,2)));
    
    return 0;
}

Measured memory_bytes: 9728
#include <iostream>
#include <string>

using namespace std;
int N;
string W[105];
int main(void) {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> W[i];
	}

	bool ans = true;
	for (int i = 1; i <= N - 1; i++) {
		for (int j = i + 1; j <= N; j++) {
			if (W[i] == W[j]) { ans = false; }
		}
	}

	for (int i = 1; i <= N - 1; i++) {
		int M = W[i].size();
		if (W[i][M - 1] != W[i + 1][0]) { ans = false; }
	}

	if (ans) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	//system("pause");
	return 0;
}

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

int main()
{
    ll n,t,a,b,c,d,e,p,q,cnt=0;
    map<ll,ll>mp;
    vector<ll>vec;
    string s,s1,s2;

    cin>>t;
    ll ans=t/1000;
    ll vag=t%1000;
    if(t%1000==0){
        cout<<0<<endl;
    }
    else
      cout<<1000-(t%1000)<<endl;


}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 111111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int b[MAXN] ;

int main() {
    int n , h  ,a, count = 0  , mx = 0;
    scanf("%d %d" ,&n ,&h) ;

    for(int i = 0 ;i<n ;i++){
        scanf("%d %d" ,&a ,&b[i]) ;
        mx = max(mx , a) ;
    }

    sort(b , b+n , greater<int>()) ;

    for(int i =0 ;i<n && b[i] > mx && h >0 ; i++)
        h-=b[i]  , count++ ;

    printf("%d\n" ,count+ (h>0?(h+mx-1)/mx:0)) ;

    return 0 ;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main()
{
	char o[55], e[55];
	scanf("%s%s", o, e);
	int n = strlen(o), m = strlen(e);
	int i;
	for (i = 0; i < n - 1; i++)
		printf("%c%c", o[i], e[i]);
	if (n == m)
		printf("%c%c\n", o[n - 1], e[m - 1]);
	else
		printf("%c\n", o[n - 1]);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
map<int,int> mmp;
priority_queue<int,vector<int>,greater<int> > Q;
int main()
{
	LL ans=0;
	int N,M;scanf("%d%d",&N,&M);
	for(int i=1;i<=N;++i)
	{
		int a;scanf("%d",&a);
		Q.push(a);ans+=a;
	}
	for(int i=1;i<=M;++i)
	{
		int a,b;scanf("%d%d",&a,&b);
		mmp[b]+=a;
	}
	map<int,int> ::reverse_iterator j=mmp.rbegin();
	for(int i=1;i<=N;++i)
	{
		if(!(j->second)) ++j;
		if(j==mmp.rend()||(j->first)<=Q.top()) break;
		ans+=(j->first),ans-=Q.top();
		Q.pop(),--(j->second);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 5368
s = input()
t = input()
lens, lent = len(s), len(t)
n = lens - lent + 1
mi = lent
for i in range(n):
    temp = 0
    for j in range(lent):
        if s[i + j] != t[j]:
            temp += 1
    if temp <= mi:
        mi = temp
print(mi)


Measured memory_bytes: 9108
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#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()

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

using ll = long long;

ll X, Y, A, B, C;
ll p[100010], q[100010], r[100010];
std::priority_queue<ll, std::vector<ll>, std::greater<ll>> pque, qque;

int main()
{
  std::cin >> X >> Y >> A >> B >> C;

  rep( i, A )
    std::cin >> p[i];
  rep( i, B )
    std::cin >> q[i];
  rep( i, C )
    std::cin >> r[i];

  std::sort( p, p+A );
  std::sort( q, q+B );
  std::sort( r, r+C );

  std::reverse( p, p+A );
  std::reverse( q, q+B );
  std::reverse( r, r+C );

  rep( i, X )
    pque.push( p[i] );

  rep( i, Y )
    qque.push( q[i] );

  rep( i, C )
  {
    ll ptop = pque.top();
    ll qtop = qque.top();

    if( r[i] > ptop || r[i] > qtop )
    {
      if( r[i]-ptop > r[i]-qtop )
      {
        pque.pop();
        pque.push( r[i] );
      }
      else
      {
        qque.pop();
        qque.push( r[i] );
      }
    }
  }

  ll ans = 0;

  while( !pque.empty() )
    ans += pque.top(), pque.pop();
  while( !qque.empty() )
    ans += qque.top(), qque.pop();

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 4852
// ※※※ 解答不能 ※※※
// 以下の回答を参照.
// https://atcoder.jp/contests/abc179/submissions/16845772
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){
    
    // 1. 入力情報.
    int N, Q;
    scanf("%d %d", &N, &Q);
    vector<int> a(N + 1), b(N + 1);
    repx(i, 1, N + 1) a[i] = b[i] = N;
    
    LL black = LL(N - 2) * (N - 2);
    
    // 2. クエリを処理.
    int H = N, W = N;
    while(Q--){
        int t, x;
        scanf("%d %d", &t, &x);
        
        // (1, x) に 白い石を置く.
        if(t == 1){
            if(x < W){
                repx(i, x, W) b[i] = H;
                W = x;
            }
            black -= b[x] - 2;
        }
        
        // (x, 1) に 白い石を置く.
        if(t == 2){
            if(x < H){
                repx(i, x, H) a[i] = W;
                H = x;
            }
            black -= a[x] - 2;
        }
    }
    
    // 3. 出力.
    printf("%lld\n", black);
    return 0;
    
}

Measured memory_bytes: 4820
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;

double L1 = 0, L2 = 0, L3 = 0, Li = 0;
double a[111], b[111];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    for (int i = 0; i < n; i++)
        L1 += abs(a[i] - b[i]);
    for (int i = 0; i < n; i++)
        L2 += (a[i] - b[i]) * (a[i] - b[i]);
    for (int i = 0; i < n; i++)
        L3 += abs(a[i] - b[i]) * abs(a[i] - b[i]) * abs(a[i] - b[i]);
    for (int i = 0; i < n; i++)
        Li = max(abs(a[i] - b[i]), Li);
    printf("%lf\n%lf\n%lf\n%lf\n", L1, sqrt(L2), pow(L3, 0.33333333333), Li);
}



Measured memory_bytes: 3408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B0Or1Swap solver = new B0Or1Swap();
        solver.solve(1, in, out);
        out.close();
    }

    static class B0Or1Swap {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), re = 0;
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                if (i != s.nextInt() - 1) {
                    re++;
                }
            }
            if (re == 2 || re == 0) w.println("YES");
            else w.println("NO");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
import math

r = 999999
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        for j in range(2*i+1,r,i+1):
            p[j] = 0

while True:
    try:
        n = int(raw_input())
        print p[:n].count(1)
    except:
        break

Measured memory_bytes: 35248
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CIN(int, M);

    ll ans, MOD = 1e9+7;

    if ( N == M ) {
        ans = 2;
    } else if ( fabs(N - M) == 1 ) {
        ans = max(N, M);
        N = min(N, M);
    } else {
        cout << 0 << "\n";
        return 0;
    }

    for (int i = 2; i <= N; i++) {
        ans = (ans * i) % MOD;
        ans = (ans * i) % MOD;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#input
N, M = [int(i) for i in input().split(" ")]
AB = []
money = 0
for i in range(N):
  AB.append([int(i) for i in input().split(" ")])
BA = sorted(AB)

for i in BA:

  if i[1] < M:
    M = M - i[1]
    money += i[0] * i[1]
  else :
    money += i[0] * M
    break
  

print(money)

Measured memory_bytes: 22384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,a) REP(i,0,a)
#define rev(s) reverse(s.begin(),s.end())
#define pb push_back
#define MAX 1000005
 
int main() 
{   
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	ll i;
	string s;
	cin>>s;
	rep(i,s.size())
	s[i]='x';
	cout<<s<<endl;
	return 0;
	}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define loop(n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int n;cin>>n;
    char a[n],b[n];
    cin>>a;
    cin>>b;
    for(int i=0;i<n;i++){
        cout<<a[i]<<b[i];
    }
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
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();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#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(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


void solve(long long N, std::vector<long long> A){
    LL sum =0;
    int ans=N;
    bool flag = false;
    SORT(A);
    REP(i, N-1){
        sum+=A[i];
        if((LL)2*sum<A[i+1]){
            ans = N-(i+1);
            flag = true;
        }
    }
    if(!flag)cout<<N<<endl;
    else cout<<ans<<endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

int main() {
    string S;
    cin >> S;
    string revS = S;
    reverse(revS.begin(), revS.end());
    ll count = 0;
    for (int i = 0; i < S.size() / 2; ++i){
        if (S[i] != revS[i]) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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


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

int main() {
    double A, B;
    cin >> A >> B;
    for(int p = 0; p < 100000; p++) {
        if((int) (p * 0.08) == (int) A && (int) (p * 0.1) == (int) B) {
            cout << p << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    n, a, b = LI()
    cnt = 0
    for i in range(1, n + 1):
        tmp = i
        i = list(str(i))
        if a <= sum(StoI(i)) <= b:
            cnt += tmp

    print(cnt)


solve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
bool vd[10];
int main() {
	for (ll i=0;i<10;i++) vd[i]=false;
	ll n,k; scanf("%lld %lld",&n,&k);
	for (ll i=0;i<k;i++) {
		ll d; scanf("%lld",&d); vd[d]=true;
	}
	for (ll x=n;;x++) {
		string s=to_string(x);
		bool ok=true;
		for (auto &c:s) {
			if (vd[c-'0']) {ok=false; break;}
		}
		if (ok) {
			printf("%lld\n",x);
			return 0;
		}
	}
}

Measured memory_bytes: 256
// Created by Davidia on 2018-12-17.
//

// copyright@ Dr. Davidia


#include <bits/stdc++.h>

using namespace std;
int cost(int a, int b, vector<int> &costs){
    return abs(costs.at(a) - costs.at(b));
}

int main(){
    int n; cin >> n;
    vector<int> costs(n);
    for (int i = 0; i < n; i++)
        cin >> costs.at(i);
    vector<int> dp(n,0);
    dp.at(1) = cost(0,1,costs);

    for (int i = 2; i < n; i++){
        dp.at(i) = dp.at(i-1) + cost(i,i-1,costs);
        dp.at(i) = min(dp.at(i-2) + cost(i,i-2,costs), dp.at(i));
    }
    cout << dp.at(n-1) << '\n';

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<int> a(n);
        for (int i = 0; i < n; i ++) {
                scanf("%d", &a[i]);
        }
        sort(a.rbegin(), a.rend());
        int ans = 0;
        for (int i = 0; i < n; i ++) {
                ans += (i & 1 ? -1 : 1) * a[i];
        }
        printf("%d\n", ans);
        return 0;
}



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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout<< #i<< "= "<< i << endl
using namespace std;

int main(){
    int n, ans=0;
    string s;
    cin >> n >> s;

    int k = s.size() - 2;
    REP(i, k){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int 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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    int n, p; cin >> n >> p;
    string s; cin >> s;
    ll res = 0;
    if (p==2 || p==5) {
        rep(i, n) {
            if ((s[i] - '0') % p == 0) res += i+1;
        }
    } else {
        int m = 1;
        vector<int> mods(n);
        vector<ll> cnt(p, 0);
        cnt[0] = 1ll;
        ll val = 0;
        for (int i=n-1; i>=0; --i) {
            val += m * (s[i]-'0');
            val %= p;
            cnt[val]++;
            m = 10 * m % p;
        }
        rep(i, p) res += cnt[i] * (cnt[i]-1) / 2;
    }
    cout << res << endl;
}


Measured memory_bytes: 1284
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;


public class Main {

	public static String decode(String s, int r) {
		String alph = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
		StringBuilder sb = new StringBuilder();
		for (int i = 0 ; i < s.length() ; i++) {
			char c = s.charAt(i);
			if (c < 'a' || c > 'z') {
				sb.append(c);
			} else {
				sb.append(alph.charAt(alph.indexOf(c)+r));
			}
		}
		return sb.toString();
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line;
		while ((line = br.readLine()) != null) {
			for (int r = 0 ; r < 27 ; r++) {
				String decoded = decode(line, r);
				if (decoded.indexOf("the") > -1 || decoded.indexOf("this") > -1 || decoded.indexOf("that") > -1) {
					System.out.println(decoded); break;
				}
			}

		}

	}
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1000000000 + 7;
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, x;
    cin >> n >> x;
    vector<int> s(n);
    for(int i = 0; i < n; ++i){
        cin >> s[i];
    }
    sort(begin(s), end(s), greater<int>());

    vector<vector<ll>> dp(n + 1, vector<ll>(x + 1));
    dp[0][x] = 1;

    for(int i = 0; i < n; ++i){
        for(int j = 0; j <= x; ++j){
            dp[i + 1][j % s[i]] += dp[i][j];
            if(i + 1 != n)dp[i + 1][j] += dp[i][j] *(n - i - 1);
            dp[i + 1][j] %= MOD;
        }
    }

    // for(int i = x; i >= 0; --i){
    //     for(int j = 0; j <= n; ++j){
    //         cout << dp[j][i] << " ";
    //     }
    //     cout << "\n";
    // }
    
    ll ans = 0;
    for(int i = 0; i < x + 1; ++i){
        ans += dp[n][i] * i;
        ans %= MOD;
    }
    
    cout << ans << "\n";

    
    return 0;
}


Measured memory_bytes: 158592
// author -> LetsGoAc
#include "bits/stdc++.h"
using    namespace std;
typedef  long double ld;
#define  int long long
typedef  pair<int,int> pii;
#define  RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  rep(i,n) for(i=0; i <n; i++)
#define  repv(i,k,n) for(int i=k; i<=n; i++)
#define  pb push_back
#define  mp make_pair
#define  F  first
#define  S  second
#define  sz(x)  (int)x.size()
#define  all(v) v.begin(),v.end()
#define  endl '\n'
#define  deb(x) c out<<#x<<" = "<<x<<endl
#define  gcd   __gcd
#define  inf   LLONG_MAX
#define  minf  LLONG_MIN 
#define  gi  greater<int> 
#define  gpi greater<pii>  
#define  sp(n) fixed<<setprecision(n)
const int mod = (int)(1e9+7);
int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
int pct(int x)
{   return __builtin_popcountll(x);}
int  lcm(int a,int b){return a*b/gcd(a,b);}
bool is_power_2(int n){ return log2(n)==floor(log2(n));}
bool is_prime(int n){for(int i=2; i*i<=n; i++)if(n%i==0)return 0; return 1;}
void db()
{   
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
void timeit()
{  
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " <<sp(5)<< 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}
int     dx []    =  {-1 , 0 , 1 , 0 ,-1,-1, 1,  1};
int     dy []    =  { 0 , 1 , 0 ,-1 ,-1, 1, 1, -1};
char    dir[]    =  {'U','R','D','L'};
/* ---------------------- 1.cpp --------------------------------- */
const int maxn = 1e6+5;
void solve(int tc)
{
    // cout<<"Case #"<<tc<<": ";
    int n,i,j,k,m,q,l,r;
    cin>>n>>k;
    int ar[n];
    rep(i,n)
        cin>>ar[i];
    l = 1 , r = mod;
    while(l<r)
    {
        int cnt = 0;
        int mid = l+r>>1;
        for(i=0; i<n; i++)
            cnt += (ar[i]-1)/mid;
        if(cnt<=k)
            r = mid;
        else
            l = mid+1;
    }
    cout<<l;
}   
signed main()
{
    // 1.cpp
    RAGE;
 //   db();    
    int t=1;
    //cin>>t;
    for(int i=1; i<=t; i++)
    {
        solve(i);
    }
  //  timeit();
    return 0;
}
/*
    1. To find 2's complement , reverse all the bits after 1st set bit. (right - >left.)

*/

Measured memory_bytes: 5128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
  int K;
  string S;
  cin >> K >> S;
  if(K >= S.size()){
    cout << S << endl;
  }else{
    REP(i,K){
      cout << S[i];
    }
    cout << "..." << endl;
  }
}

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

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2  

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;



int main(){
    bool flag=true;
    ll ans=0,sum=0;

    int n,m;
    cin >>n>>m;
    map<int,vector<int>> job;
    priority_queue<int> q;

    for (int i = 0; i < n; i++){
        int a,b;
        cin >>a>>b;

        if(a <= m)job[a].push_back(b);
    }
    
    for (int i = 1; i <= m; i++){
        
        if(job[i].size() > 0){
            for (int j = 0; j < job[i].size(); ++j){
                q.push(job[i][j]);
            }
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
int main()
{
	int l,r,d;cin>>l>>r>>d;
	int ll=l/d;
	if(l%d==0)
	ll--;
	cout<<r/d-ll<<endl; 
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define PR pair<int, int>
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
//constexpr int MOD = 10e9+7;
constexpr int INF = 1LL << 60;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int N;
  cin >> N;
  
  if(N == 0) 
    {cout << 0 <<endl; return 0;}
  string ans = "";
  int p= 1;
  while(N != 0)
  {
    int b = N%(p*(-2)) != 0;
    ans.push_back('0' + b);
    N -= b * p;
    p *= -2;
  }

  for(int i = ans.length() -1;i>=0;i--)
  {
    cout << ans[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
// 2017-01-21
#include <iostream>
#include <cmath>
using namespace std;

int main() {
	int n, c;
	cin >> n;
	for (c = 0; n > 1; c++) {
		int a = (n - 1) / 3 + 1;
		n = max(a, n - 2 * a);
	}
	cout << c << endl;
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    if(S == "SUN") cout << 7 << endl;
    if(S == "MON") cout << 6 << endl;
    if(S == "TUE") cout << 5 << endl;
    if(S == "WED") cout << 4 << endl;
    if(S == "THU") cout << 3 << endl;
    if(S == "FRI") cout << 2 << endl;
    if(S == "SAT") cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256