akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n,k; cin >> n >> k;
  if(k==1){
    cout << 0 << endl;
  }else{
    cout << n-k << endl;
  }
  return 0;
}


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

int main(){
  int h, w, n;
  cin >> h >> w >> n;
  int lim = h < w ? h : w;
  int max = h < w ? w : h;
  
  for(int i = 1; i <= lim; i++) {
    if(max * i >= n) {
      cout << i << endl;
      break;
    }
  }
}

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

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

int main() {
    long long int n, k;
    cin >> n >> k;

    long long int cnt = 0;

    for (long long int a = 1; a <= n; a++){
        long long int t = a % k;
        
        if(2*(k-t)%k==0){
            long long int m = (n - k + t) / k + 1;
            cnt += m * m;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
# ITP1_2_C: Sorting Three Numbers

def sort_three_num(a, b, c)
  if a < b
    b < c ? [a, b, c] : a < c ? [a, c, b] : [c, a, b]
  else
    c < b ? [c, b, a] : a < c ? [b, a, c] : [b, c, a]
  end
end

a, b, c = gets.split.map &:to_i
puts sort_three_num(a, b, c).join(' ')

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):

    if (S[2] == S[3]) & (S[4] == S[5]):
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

int main(){
    long int N;
    cin >> N;

    if(N>=65 && N<=90){
        cout << "1" << '\n';
    }else if(N>=97 && N<=122){
        cout << "2" << '\n';
    }else{
        cout << "0" << '\n';
    }
    return 0;

}


Measured memory_bytes: 3056
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    n, m, k = map(int, input().split())

    for i in range(n + 1):
        for j in range(m + 1):
            if j*n+i*m-i*j-j*i == k == k:
                #print(i, j)
                print('Yes')
                exit(0)
    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int H[200010];
int main()
{
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	sort(H, H + N,greater<int>());
	ll ans = 0;
	for (int i = K; i < N; i++) {
		ans += H[i];
	}
	cout << ans << endl;
}

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

int main() {
 	int n,k;
	int h;
	int ans = 0;
	cin >> n >> k;
	for(int i=0; i!=n; i++){
		cin >> h;
		if(h >= k){
			ans += 1;
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string S;
    cin >> S;
    int N = S.size(), cnt[26] = {};
    REP(i, N) {
        cnt[S[i] - 'a']++;
    }
    REP(i, 26) {
        if (cnt[i] == 0) {
            cout << char(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 29 14:54:30 2020

@author: liang
"""

n = int(input())
S = [input() for _ in range(n)]

ans = [100]*26

for i in range(n):
    tmp = [0]*26
    for s in S[i]:
        key = ord(s)-ord('a')
        if tmp[key] < ans[key]:
            tmp[key] += 1
    ans = tmp.copy()

res = ""
for i in range(26):
    res += chr(ord('a') + i)*tmp[i]
print(res)

Measured memory_bytes: 9044
#include"bits/stdc++.h"
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define MAXN 100005
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vll a(n);
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    ll start=1,end=1000000000,mid,res=1000000000;
    while(start<=end){
        mid=(start+end)/2;
        ll cnt=0;
        for (int i = 0; i < n; ++i)
        {
            cnt+=(a[i]-1)/mid;
        }
        if(cnt<=k){
            res=min(res,mid);
            end=mid-1;
        }else{
            start=mid+1;
        }
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
	return a*a + b*b;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &x[i], &y[i]);
		X += x[i]; Y += y[i];
	}
	X /= n; Y /= n;
	double P = 0.1;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}
	cout << fixed << setprecision(10) << sqrt(d) << endl;
}

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

int main() {
    string s;
    cin >> s;
    int q;
    cin >> q;
    string t;
    rep(qi,q){
        int ty;
        cin >> ty;
        if(ty == 1){
            swap(s,t);
        }else{
            int f;char c;
            cin >> f >> c;
            if(f == 1){
                t += c; //先頭に追加
            }else{
                s += c; //末尾に追加
            }
        }
    }
    reverse(t.begin(), t.end());
    t += s;
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ar array
#define db double
const db pi = acos(-1);
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for (int i=0;i<n;i++) cout<<"ACL";
    return 0;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back
using namespace std;
typedef long long int ll;
#define MOD 1000000007
int  main(){
	ll n;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	ll mi=INT_MAX;
	for(int i=v[0];i<=v[n-1];i++){
		ll sum=0;
		for(int j=0;j<n;j++){
			sum+=(i-v[j])*(i-v[j]);
		}
		mi=min(mi,sum);
	}
	cout<<mi<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(u == s) a--;
    else b--;
    cout << a << ' ' <<  b << endl;
}

Measured memory_bytes: 256
#include<cstdio>
const int N=2e5+5;
struct edge{
	int to,nxt;
}e[N<<1];
int head[N],n,cnt;
int g(int u,int p){
	int r=0;
	for(int i=head[u];i;i=e[i].nxt)
	if(e[i].to!=p)r^=g(e[i].to,u)+1;
	return r;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;++i){
		int u,v;
		scanf("%d%d",&u,&v);
		e[++cnt]=(edge){v,head[u]},head[u]=cnt;
		e[++cnt]=(edge){u,head[v]},head[v]=cnt;
	}
	puts(g(1,0)?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 6784
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    d = I()
    ans = [" Eve"]*(25-d)
    print("Christmas",end = "")
    for i in ans:
        print(i,end = "")
    print()
    return

#B
def B():
    n = I()
    p = IR(n)
    s = sum(p)
    print(s-max(p)//2)
    return

#C
def C():
    n,k = LI()
    h = IR(n)
    h.sort()
    ans = float("inf")
    for i in range(n-k+1):
        ans = min(ans,h[i+k-1]-h[i])
    print(ans)

#D
def D():
    n,x = LI()
    l = [1 for i in range(n+1)]
    for i in range(n):
        l[i+1] = 2*l[i]+3
    p = [1 for i in range(n+1)]
    for i in range(n):
        p[i+1] = 2*p[i]+1
    ans = 0
    for i in range(1,n+1)[::-1]:
        if i == 1:
            if x == 5:ans += 3
            else:ans += max(0,x-1)
        else:
            if x == 0:continue
            if x == l[i]:
                ans += p[i]
                x = 0
            if x > l[i-1]+1:
                ans += p[i-1]+1
                x -= l[i-1]+2
            else:
                x -= 1
    print(ans)
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 38768
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
const double PI = 3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = 1LL << 50;
typedef pair<int, int> P;
const int mod = 1e9 + 7;

struct mint
{
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint &operator+=(const mint a)
    {
        (x += a.x) %= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        (x -= mod - a.x) %= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t % 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        fact[0] = 1;
        for (int i = 1; i < n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] + ifact[n - k];
    }
};

ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

ll gcd(vector<ll> a)
{
    ll ans = 0;
    for (ll i = 0; i < a.size(); ++i)
    {
        ans = gcd(ans, a[i]);
    }
    return ans;
}
int main(){
    ll a,b,c,d;
    cin >> a >> b >> c  >> d;
    ll maxi = a*c;
    if(maxi<a*c)maxi=a*c;
    if(maxi<a*d)maxi=a*d;
    if(maxi<b*c)maxi=b*c;
    if(maxi<b*d)maxi=b*d;
    // printf("%18\n",maxi);
    cout << maxi << endl;
    return 0;
}

Measured memory_bytes: 3628
/*
ACplease
　　 ●
　　/⌒ヽ
　 ｜ 　|/⌒ヽ(ヽ
　 (｀　∥ー⌒) |
　|￣||￣￣￣￣￣|
　|―||―――――|
　|　Ｕ　　　　　|
　|￣￣￣￣￣￣￣|
　|＿＿＿＿＿＿＿|
　　|―――――|
　　|―――――|
ｗｗＷｗｗＷｗＷＷｗ
*/
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#include <cassert>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}

//----------------------------------------------
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);
    srand((unsigned)time(NULL));
    
    double l; cin >> l;
    cout << pow(l/3,3);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,d;
    cin >> n>>d;
    int count=0;
    for(int i=0; i<n; i++){
        int a,b;
        cin >> a >>b;
        if(sqrt(pow(a,2)+pow(b,2))<=d){
            count++;
        }
    }
    cout << count <<endl;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second 

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

// End of template code!
int main() 
{
    buff();
    ll n, m;
    cin >> n >> m;
    vector<ll> v(m); for(auto& x : v) cin >> x;
    ll sum = accumulate(all(v), 0ll, [&] (ll a, ll b) { return a + b; } );
    ll res = max(-1ll , n - sum );
    cout << res << '\n';
    return 0;
}



Measured memory_bytes: 3676
#include<stdio.h>
//チャンネル順、小さい順にソート
int c[100002][4];
void merge(int i,int j,int s[][4]){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d][0]=s[b][0];
        c[d][1]=s[b][1];
        c[d][2]=s[b][2];
        b++;
      }
      else if(j<b){
        c[d][0]=s[a][0];
        c[d][1]=s[a][1];
        c[d][2]=s[a][2];
        a++;
      }
      else if(s[a][2]<s[b][2] || (s[a][2]==s[b][2] && s[a][0]<s[b][0])){
        c[d][0]=s[a][0];
        c[d][1]=s[a][1];
        c[d][2]=s[a][2];
        a++;
      }
      else{
        c[d][0]=s[b][0];
        c[d][1]=s[b][1];
        c[d][2]=s[b][2];
        b++;
      }
    }
    for(d=i;d<=j;d++){
      s[d][0]=c[d][0];
      s[d][1]=c[d][1];
      s[d][2]=c[d][2];
    }
  }
}

int main(){
  int n,c,i,j;
  scanf("%d%d",&n,&c);
  int s[n+1][4];
  for(i=0;i<n;i++)
    for(j=0;j<3;j++)
      scanf("%d",&s[i][j]);
  merge(0,n-1,s);
  int time[100002];
  for(i=0;i<100002;i++)
    time[i]=0;
  for(i=0;i<n;i++){
    if(s[i][2]==s[i-1][2] || i==0){
      for(j=s[i][0];j<s[i][1];j++)
        time[j]++;
      if(s[i][0]!=s[i-1][1] || i==0)
        time[s[i][0]-1]++;
    }
    else
      for(j=s[i][0]-1;j<s[i][1];j++)
        time[j]++;
  }
  int max=0;
  for(i=0;i<100002;i++)
    if(max<time[i])
      max=time[i];
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 3712
const lines=readlines()
const N=parse(Int,shift!(lines))
const G=[Int[] for _=1:N]
const mod=10^9+7
S=0
function dfs(u,p)
	ret=0
	for v=G[u]
		if v!=p
			now=dfs(v,u)
			ret+=now
			global S+=(1-invmod(powermod(2,now,mod),mod))*(1-invmod(powermod(2,N-now,mod),mod))%mod
		end
	end
	ret+1
end
function main()
	for s=lines
		u,v=map(x->parse(Int,x),split(s))
		push!(G[u],v)
		push!(G[v],u)
	end
	dfs(1,0)
	println(((S-N*invmod(2,mod)+1-invmod(powermod(2,N,mod),mod))%mod+mod)%mod)
end
main()

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

using namespace std;

typedef long long ll;

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

int main() {
    int N, K; cin >> N >> K;
    int MAX = 200010;

    int bucket[MAX]; for (int i = 0; i < MAX; ++i) bucket[i] = 0;
    int pt = 0;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (bucket[a] == 0) ++pt;
        ++bucket[a];
    }
    sort(bucket, bucket + MAX);

    int res = 0;
    for (int i = 0; i < pt - K; ++i)  res += bucket[i+MAX-pt];

    cout << res << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
    ll n; cin >> n;
    vector <vector <pair <ll, ll>>> v(n, vector <pair <ll, ll>> ());
    rep(i, n-1) {
        ll a, b, c; cin >> a >> b >> c;
        a--; b--;
        v.at(a).push_back(make_pair(b, c));
        v.at(b).push_back(make_pair(a, c));
    }
    ll q, k; cin >> q >> k;
    k--;
    vector <ll> d(n, INF);
    stack <ll> s;
    d.at(k) = 0;
    s.push(k);
    while (s.size()) {
        ll p = s.top(); s.pop();
        rep(i, v.at(p).size()) {
            ll next = v.at(p).at(i).first, dis = v.at(p).at(i).second;
            if (d.at(next) > d.at(p)+dis) {
                d.at(next) = d.at(p)+dis;
                s.push(next);
            }
        }
    }
    rep(i, q) {
        ll x, y; cin >> x >> y;
        x--; y--;
        cout << d.at(x) + d.at(y) << endl;
    }
}

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

int main() {
  int h, n;
  cin >> h >> n;
  int sum = 0;
  int a;
  rep(i,n) {
    cin >> a;
    sum += a;
  }
  if (sum >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

typedef long long ll;

typedef pair<ll, ll> P;
struct edge { ll to, cost; };

const int MAX_V =1000000;
const ll INF = 1LL<<60;

int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        rep(i,G[v].size()) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int T;
    cin >> T;
    vector<ll> N(T), A(T), B(T), C(T), D(T);
    queue<ll> q;
    rep(i, T) {
        cin >> N[i] >> A[i] >> B[i] >> C[i] >> D[i];
        q.push(N[i]);
    }
    set<ll> done;
    while (!q.empty()) {
        ll p = q.front();
        q.pop();
        if (done.find(p) != done.end()) continue;
        if (p % 2 == 0) {
            q.push(p / 2);
        }
        if (p % 3 == 0) {
            q.push(p / 3);
        }
        if (p % 5 == 0) {
            q.push(p / 5);
        }
        ll s1 = p / 2 * 2, s2 = p / 3 * 3, s3 = p / 5 * 5;
        ll s = s1;
        if (s2 < s) s = s2;
        if (s3 < s) s = s3;
        ll g1 = (p + 1) / 2 * 2, g2 = (p + 2) / 3 * 3, g3 = (p + 4) / 5 * 5;
        ll g = g1;
        if (g2 > g) g = g2;
        if (g3 > g) g = g3;
        //cout << "s=" << s << " g=" << g << "\n";
        for (ll j = s; j <= g; j++) {
            if (done.find(j) == done.end()) q.push(j);
        }
        done.insert(p);
    }
    int n = done.size();
    map<ll, int> m;
    vector<ll> v(n);
    int c = 0;
    for (auto i : done) {
        m[i] = c;
        v[c] = i;
        c++;
        //cout << i << "\n";
    }
    //cout << "n=" << n << "\n";
    /*
    rep(i, 10) {
        cout << v[i] << "\n";
    }
    */
    V = n;
    rep(i, T) {
        rep(j, n) {
            G[j] = {};
            if (done.find(v[j] * 2) != done.end()) G[j].push_back({m[v[j] * 2], A[i]});
            if (done.find(v[j] * 3) != done.end()) G[j].push_back({m[v[j] * 3], B[i]});
            if (done.find(v[j] * 5) != done.end()) G[j].push_back({m[v[j] * 5], C[i]});
            if (done.find(v[j] + 1) != done.end()) G[j].push_back({m[v[j] + 1], D[i]});
            if (done.find(v[j] - 1) != done.end()) G[j].push_back({m[v[j] - 1], D[i]});
        }
        int l1 = log2(D[i]);
        rep(j, n) {
            int l2 = log2(v[j]);
            if (l1 + l2 <= 60) G[0].push_back({j, D[i] * v[j]});
        }
        /*
        rep(j, n) {
            cout << "j=" << j << "\n";
            rep(k, G[j].size()) {
                cout << G[j][k].to << " " << G[j][k].cost << "\n";
            }
        }
        */
        dijkstra(m[0]);
        //cout << "m[0]=" << m[0] << " m[N[i]]=" << m[N[i]] << "\n";
        cout << d[m[N[i]]] << "\n";
        //rep(j, n) cout << "d[" << j << "]=" << d[j] << "\n";
    }
}

Measured memory_bytes: 77888
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	ans := 0
	for _, v := range iSScan(n) {
		for v%2 != 1 {
			v /= 2
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2016
import bisect

def ctoi(char):
  return ord(char)-97

s=input()
ls=len(s)
t=input()
lt=len(t)
pos=[[] for _ in range(26)]
for i in range(ls):
  val=ctoi(s[i])
  pos[val].append(i)
larr=[0]*26
for i in range(26):
  larr[i]=len(pos[i])
pos2=[]
cnt=[0]*26
flag=True
num=-1
for i in range(lt):
  val=ctoi(t[i])
  if larr[val]==0:
    flag=False
    break
  tmp=bisect.bisect_right(pos[val],num)
  if tmp==larr[val]:
    num=pos[val][0]
  else:
    num=pos[val][tmp]
  pos2.append(num)
if flag==False:
  print(-1)
else:
  loop=0
  tmp=pos2[0]
  for i in range(1,lt):
    if pos2[i]<=tmp:
      loop+=1
    tmp=pos2[i]
  ans=loop*ls+(pos2[-1]+1)
  print(ans)

Measured memory_bytes: 49756
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string A;
  cin >> A;
  ll n = A.size();
  ll ans = 1;
  map<char, ll> mp;
  for (int i = 0; i < n; i++)
    mp[A[i]]++;

  ll plus = n * (n - 1) / 2;
  for (auto itr = mp.begin(); itr != mp.end(); itr++)
    plus -= itr->second * (itr->second - 1) / 2; // (同じ文字の数)C2
  ans += plus;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3712
def deencrypt(str, key):
    plaintext = ""

    for ch in list(str):
        if 'A' <= ch <= 'Z':
            plaintext += chr((ord(ch) - ord('A') + key) % 26 + ord('A'))
        elif 'a' <= ch <= 'z':
            plaintext += chr((ord(ch) - ord('a') + key) % 26 + ord('a'))
        else:
            plaintext += ch

    return plaintext


N = int(input())
ciphertext = input()

print(deencrypt(ciphertext, N))

Measured memory_bytes: 3064
s = int(input())

mod = 10 ** 9 + 7


def inv(x):
    return pow(x, mod - 2, mod)


fac = [1] * 3000
for i in range(2, 2500):
    fac[i] = fac[i - 1] * i % mod


def c(n, k):
    if n < k or n < 0 or k < 0:
        return 0
    return fac[n] * inv(fac[n - k] * fac[k] % mod) % mod


# n項を決め打ち、するとs - n * 3をn個の区別する箱に分ける問題になる。
ans = 0
for n in range(1, 690):
    rem = s - n * 3
    if rem < 0:
        break
    ans += c(n + rem - 1, rem)
    ans %= mod
print(ans)


Measured memory_bytes: 9232
n, m = map(int, input().split())
ab, c, d = [], set(), set()
for i in range(m):
    ab.append(list(map(int, input().split())))
for i in range(m):
    if(ab[i][0] == n):
        c.add(ab[i][1])
    elif(ab[i][1] == n):
        c.add(ab[i][0])
    elif(ab[i][0] == 1):
        d.add(ab[i][1])
    elif(ab[i][1] == 1):
        d.add(ab[i][0])
if(c & d):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 58892
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a, b, c;
    
    a = scan.nextInt();
    b = scan.nextInt();
    c = scan.nextInt();
    
    int ans = (a + b) * c / 2;
    System.out.println(ans);
  }

}

Measured memory_bytes: 20948
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int diff[] = new int[N + 1];
		int sum = 0;
		int ans = 0;
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N + 1; i++) {
			if (i == 0) {
				diff[i] = A[i] - 0;
			} else if (i == N) {
				diff[i] = 0 - A[i - 1];
			} else {
				diff[i] = A[i] - A[i - 1];
			}
			sum += Math.abs(diff[i]);
		}

		for (int i = 0; i < N; i++) {
			ans = sum - Math.abs(diff[i]) - Math.abs(diff[i + 1]);
			ans += Math.abs(diff[i] + diff[i + 1]);
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 64028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  double X[N];
  string U[N];
  for(int i = 0; i < N; i++){
  	cin >> X[i] >> U[i];
    if(U[i] == "BTC"){
    	X[i] *= 380000.0;
    }
  }
  double ans = 0.0;
  for(int i = 0; i < N; i++){
  	ans += X[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
r1,c1,r2,c2=map(int,input().split())
mod=10**9+7
n_max=2*(10**6+1)
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
  FI[i+1]=pow(F[i+1],mod-2,mod)
def comb(x,y):
  return (F[x]*FI[x-y]*FI[y])%mod

def f(x,y):
  return comb(x+y+2,y+1)-1

print((f(r2,c2)-f(r2,c1-1)-f(r1-1,c2)+f(r1-1,c1-1))%mod)

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

using namespace std;

#define DEBUG

#ifdef DEBUG
#define dump(i) cout << "[*] " #i " : " << i << endl;
#define debug(i) i
#else
#define dump(i)
#define debug(i)
#endif

int main() {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << min(a, b) + min(c, d) << endl;
        return 0;
}

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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0; // to be set

    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) {
        for(int iter = 0; iter < 2; ++iter)
            dat[iter].assign(n + 1, UNITY_SUM);
    }

    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for(int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1));
        sub_add(1, a, x);
        sub_add(0, b, x * (b - 1));
        sub_add(1, b, x * (-1));
    }

    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for(int i = a; i > 0; i -= i & -i)
            res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) -
               sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }

    /* debug */
    void print() {
        for(int i = 1; i < (int)dat[0].size(); ++i)
            cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

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

    vector<int> lefts(Q), rights(Q), ids(Q);
    for(int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(),
         [&](int i, int j) { return rights[i] < rights[j]; });

    BIT<int> bit(N + 5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for(auto i : ids) {
        for(; r < rights[i]; ++r) {
            bit.add(prev[a[r]] + 2, r + 2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i] + 1, lefts[i] + 2);
        res[i] = max(res[i], tmp);
    }
    for(int i = 0; i < Q; ++i)
        cout << res[i] << endl;
}

Measured memory_bytes: 21724
N = int(input())
A = list(map(int, input().split()))

sum = 0 # 踏み台合計値
for i in range(N-1):
  if A[i] > A[i+1]:
    diff = A[i] - A[i+1]
    sum += diff
    A[i+1] = A[i]

print(str(sum))

Measured memory_bytes: 32376
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<climits>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

int main(void) {
	int N,K;
	cin >> N >> K;

	vector<long long> h(N+K);
	rep(i, N) cin >> h[i];

	vector<long long> dp(N+K, LLONG_MAX);
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 1; j <= K; j++) {
			chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007;
#define MOD2 998244353;
#define INF ((1<<30)-1);
#define LINF (1LL<<60);
#define EPS (1e-10);
typedef long long Int;
typedef pair<Int, Int> P;

int n, h, w;

int main() {
    cin >> n >> h >> w;
    int ans = (n - h + 1) * (n - w + 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int kazu;
    while (cin>>kazu) {
        int count=0;
        for (int a=0; a<10; a++) {
            for (int b=0; b<10; b++) {
                for (int c=0; c<10; c++) {
                    for (int d=0; d<10; d++) {
                        if (a+b+c+d==kazu) {
                            count++;
                        }
                    }
                }
            }
        }
        cout<<count<<endl;
    }
}

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

int main(){
  	int a,b,c;
	cin >> a >> b >> c;
  	if(a+b+c<=21){
   		cout << "win" << endl;
    }
	else{
    	cout << "bust" << endl;
  	}
  	return 0;
}
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int main(){
    ll n, i, j, tem, res = 0;
    ll c[10][10] = {};
    cin >> n;
    for(i=1; i<=n; i++){
        tem = i;
        while(tem > 9){
            tem /= 10;
        }
        c[i%10][tem]++;
    }
    for(i=0; i<10; i++){
        for(j=0; j<10; j++){
            res += c[i][j] * c[j][i];
        }
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int dpx[8]={1,1,1,-1,-1,-1,0,0};
int dpy[8]={-1,1,0,1,-1,0,-1,1};

int32_t main()
{
	fastIO
	inp_out();
	int n; 
	cin >> n; 
	int ans = n + n * n + n * n * n; 
	cout << ans; 
	return 0;
}

Measured memory_bytes: 3648
from collections import Counter

N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
gain = 0

s_count = Counter(s)
t_count = Counter(t)
for s_str, s_num in s_count.items():
    if s_str not in t_count:
        gain = max(s_num, gain)
    elif s_num > t_count[s_str]:
        gain = max(s_num - t_count[s_str], gain)

print(gain)

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

int main(){
  int N;
  cin >> N;
  vector<string> W(N);
  for(int i=0;i<N;i++){
    cin >> W.at(i);
  }
  for(int i=1;i<N;i++){
    for(int j=0;j<i;j++){
      if(W.at(i) == W.at(j)){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  for(int i=0;i<N-1;i++){
    string w = W.at(i);
    int k = w.size();
    string s = W.at(i+1);
    if(w.at(k-1)!=s.at(0)){
      cout << "No" <<  endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

int GCD(int a, int b) {
   if (b == 0) return a;
   return GCD(b, a%b);
}

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
        a[i+1]=GCD(a[i],a[i+1]);
    }
    cout<<a[n-1]<<endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int a, b;
    cin >> a >> b;
    if(a > b){
        a--;
    }
    cout << a << endl;

        return 0;
}

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

int main()
{
	int a, b, c, len, ans=0;
	char s[100000];

	a = b = c = 0;
	cin >> s;
	len = strlen(s);

	for (int i = 0; i < len; i++){
		if (s[i] == 'a')
			a++;
		else if (s[i] == 'b')
			b++;
		else if (s[i] == 'c')
			c++;
	}

	if (a == b){
		if (a == c || a == c - 1 || a == c + 1)
			ans = 1;
	}
	else if (b == c){
		if (a == b - 1 || a == b + 1)
			ans = 1;
	}
	else if (a == c){
		if (a == b - 1 || a == b + 1)
			ans = 1;
	}

	if (ans == 1)
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}

Measured memory_bytes: 384
n, k = map(int, input().split())
a = list(map(int, input().split()))

ap, am, a0 = [], [], []
for i in a:
    if i > 0:
        ap.append(i)
    elif i < 0:
        am.append(i)
    else:
        a0.append(i)
lp, lm, l0 = len(ap), len(am), len(a0)
ap.sort()
am.sort(reverse=True)

# binary search
if k <= lp * lm:
    start = max(ap) * min(am)
    stop = -1
    while start < stop:
        # i以下になるペアがnum個ある
        # 尺取法
        num = 0
        i = (start + stop) // 2
        j = 0
        flag = True
        for l in range(lm-1, -1, -1):
            while flag and am[l] * ap[j] > i:
                j += 1
                if j == lp:
                    flag = False
                    break
            num += lp - j
        if num < k:
            start = i + 1
        else:
            stop = i
    print(start)

elif k <= lp * lm + (lp + lm) * l0 + l0 * (l0 - 1) // 2:
    print(0)

else:
    k -= lp * lm + (lp + lm) * l0 + l0 * (l0 - 1) // 2
    start = 1
    if ap == []:
        stop = min(am) * min(am)
    elif am == []:
        stop = max(ap) * max(ap)
    else:
        stop = max([max(ap) * max(ap), min(am) * min(am)])
    while start < stop:
        # 1以上i以下になるペアがnum個ある
        # 尺取法
        num = 0
        i = (start + stop) // 2

        # 正の数
        j = 0
        flag = True
        flag2 = True
        for l in range(lp-1, -1, -1):
            while flag and ap[l] * ap[j] <= i:
                if flag2 and l <= j:
                    num -= l + 1
                    flag2 = False
                j += 1
                if j == lp:
                    flag = False
            num += j

        # 負の数
        j = 0
        flag = True
        flag2 = True
        for l in range(lm-1, -1, -1):
            while flag and am[l] * am[j] <= i:
                if flag2 and l <= j:
                    num -= l + 1
                    flag2 = False
                j += 1
                if j == lm:
                    flag = False
            num += j

        num //= 2
        if num < k:
            start = i + 1
        else:
            stop = i
    print(start)

Measured memory_bytes: 96980
A, B, C, D = tuple(map(int, input().split()))

while True:
    # 高橋くんの攻撃
    C = C - B
    if C <= 0:
        print('Yes')
        exit()

    # 青木くんの攻撃
    A = A - D
    if A <= 0:
        print('No')
        exit()


Measured memory_bytes: 61600
#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(void){
    
    long long h;
    cin>>h;
    
    long long ans=0;
    long long k=1;
    
    while(1){
        if(h==1){
            ans+=k;
            break;
        }
        ans+=k;
        h/=2;
        k*=2;
        
    }
    
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#define int long long
typedef long long ll;
using namespace std;

signed main(){
    ll a, b, n, flag=1;
    cin >> n;
    for(b=0;b<100000;b++){
        ll num = n + pow(b, 5);
        int d = pow(num, 0.2);
        if(num==pow(d, 5)){
            a = (pow(num, 0.2));
            break;
        }
        num = n - pow(b, 5);
        
        if(num>0){
            d = pow(num, 0.2);
            if(num==pow(d, 5)){
                a = (pow(num, 0.2));
                flag = -1;
                break;
            }
        }
    }
    cout << a << " " << b*flag << endl;
    return 0;
}

Measured memory_bytes: 4032
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    BigDecimal a = sc.nextBigDecimal();
    BigDecimal b = sc.nextBigDecimal();


    if (a.compareTo(b) > 0) {
      System.out.println("GREATER");
    } else if (a.compareTo(b) < 0) {
      System.out.println("LESS");
    } else {
      System.out.println("EQUAL");
    }
  }

}


Measured memory_bytes: 24148
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int X = s.nextInt();
		int Y = s.nextInt();
		
		if((Y - 2*X) >= 0 && (2*X - 0.5 * Y) >= 0 &&
				Y%2==0 && (Y-2*X)%2 == 0) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 35768
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll r,d,x;
    cin>>r>>d>>x;
    for (ll i =0; i < 10; i++){
        x = r*x-d;
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#ifdef ONLINE_JUDGE

#include "bits/stdc++.h"
using namespace std;

#define ui unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double

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

#define speed ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ld PI = 3.1415926535897932384626;
ll MOD = 1000000007;
const ld EPS = 1e-9;
const int N = 3e5 + 7;

inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ui setBits(ui v) { ui c; for(c = 0 ; v; ++c) v &= (v - 1); return c; }
inline bool isPowerOfTwo(ui v) { return (v && !(v & (v - 1))); }
ll power(ll base, ull exp, ll mod = MOD) { 
	ll res = 1; base %= mod; 
	while(exp) { 
		if(exp & 1) res = (res * base)%mod; 
		exp >>= 1; base = (base * base)%mod; 
	} 
	return res; 
}
ll modInv(ll a, ll mod = MOD) { 
	if(mod == 1) return 0; 
	ll x = 1, y = 0, m = mod; 
	while(a > 1) { 
		ll q = a/m, t = m; m = a%m; a = t; t = y; y = x - q * y; x = t; 
	} 
	if(x < 0) x += mod; 
	return x; 
}
inline ui iabs(int x) { ui y = x; return (y > 0) ? y : -y; }
inline ll add(ll a, ll b, ll mod = MOD) { ll res = (a%mod + b%mod)%mod; return res; }
inline ll sub(ll a, ll b, ll mod = MOD) { ll res = (a%mod - b%mod + mod)%mod; return res; }
inline ll mult(ll a, ll b, ll mod = MOD) { ll res = (a%mod * b%mod)%mod; return res; }
inline ll div(ll a, ll b, ll mod = MOD) { ll res = (a%mod * modInv(b, mod))%mod; return res; }

#else

#include "custom.h"
using namespace std;

#endif

void openf() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
}

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

Measured memory_bytes: 3756
#include <iostream>

using namespace std;

int main() {
    double a;
    cout.precision(10);
    cout.setf(ios::fixed, ios::floatfield);
    while(cin >> a) {
        double sum = 0;
        for(int i = 1; i <= 10; ++i) {
            sum += a;
            if(i % 2 == 0) a /= 3;
            else a *= 2;
        }
        cout << sum << endl;
    }
    return 0;
}

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

int main() {
  ll n,i=2,j; cin>>n;
  ll m=n-1;
  while(n>=i*i){
    if(n%i==0){
      j=n/i;
      
      m=min(m,i+j-2);
      if(i>j)break;
    }
    i++;
  }
  cout<<m;
}
      



Measured memory_bytes: 256
n,m = map(int,input().split())
a=[]
b=[]
for i in range(n):
    a1 = input()
    a.append(a1)
for i in range(m):
    b1 = input()
    b.append(b1)
for i in range(n-m+1):
    for j in range(n-m+1):
        flag = True
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] != b[k][l]:
                    flag = False
                    break
        if flag:
            print("Yes")
            exit()
print("No")


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



int main() {
    int n;
    cin >> n;
    
    vector<int> d(n);
    rep(i,n) {
        cin >> d[i];
    }
    
    int sum = 0;
    for(int i = 0; i < n-1; i++) {
        for(int j = i+1; j < n; j++) {
            sum += d[i] * d[j];
        }
    }
    
    cout << sum << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 3576