akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int n;
    double ans = 0;
    cin >> n;
    vector<int> t(n + 1), v(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> t[i];
        t[i] += t[i - 1];
    }
    for(int i = 1; i <= n; i++){
        cin >> v[i];
    }
    v.push_back(0);
    vector<double> v2(2 * t[n] + 1);
    int ti = 1;
    for(int i = 1; i <= n; i++){
        while(ti < 2 * t[i]){
            v2[ti] = v[i];
            ti++;
        }
        v2[ti] = min(v[i], v[i + 1]);
        ti++;
    }
    for(int i = 1; i <= 2 * t[n]; i++){
        v2[i] = min(v2[i], v2[i - 1] + 0.5);
    }
    for(int i = 2 * t[n] - 1; i >= 1; i--){
        v2[i] = min(v2[i], v2[i + 1] + 0.5);
    }
    for(int i = 0; i < 2 * t[n]; i++){
        ans += 0.25 * (v2[i] + v2[i + 1]);
    }
    cout << fixed << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;

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

    int ans=1;
    for(int i=1;i<=X;i++){
        for(int j=2;j<=X;j++){
            if(X>=pow(i,j)) ans=max(ans,(int)pow(i,j));
            else break;
        }
    }
    cout<<ans<<endl;
}

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

const int MOD = 1000000000 + 7;

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

    vector<int> a(M);
    for(int i=0; i<M; i++) {
        cin>>a[i];
    }
    for(int i=1; i<M; i++) {
        if(a[i]-a[i-1] == 1) {
            cout << 0 << endl;
            return 0;
        }
    }

    vector<int> s(N+1, 1);
    for(auto i : a) s[i] = -1;

    for (int i=2; i<=N; i++) {
        // for(auto x:s)
        //     cout << " " << x;
        //     cout<<endl;

        if(s[i]==-1) continue;

        s[i] = 0;
        if(s[i-1] != -1) {
            s[i] += s[i-1];
            s[i] %= MOD;
        }
        if(s[i-2] != -1) {
            s[i] += s[i-2];
            s[i] %= MOD;
        }

        // cout << s[i] << endl;
    }

    cout << (s[N]%MOD) << endl;   

    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int n,q,t;

    string name;
    queue<pair<string,int> > Q;  // Open between > and >

    cin >> n >> q;

    for(int i = 0;i<n;i++)
    {
        cin >> name >> t;
        Q.push(make_pair(name,t));
    }

    pair<string,int> u;
    int elaps = 0,a;

    while(!Q.empty())
    {
        u = Q.front();
        a = min(u.second,q);
        Q.pop();
        u.second -= a;
        elaps += a;
        if(u.second > 0)
        {
            Q.push(u);
        }else{
            cout << u.first << " " << elaps << endl;  //Don't forget to begin on a new line
        }
    }

    return 0;
}


Measured memory_bytes: 6300
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;

int main(){
	while(1){
		long d, n, m;
		long a[100000], b[10000];
		
		scanf(" %ld", &d);
		if(d==0) break;
		
		scanf(" %ld %ld", &n, &m);
		a[0]=0;
		for(long i=1; i<n; ++i) scanf(" %ld", &a[i]);
		for(long i=0; i<m; ++i) scanf(" %ld", &b[i]);
		
		sort(a, a+n);
		sort(b, b+m);
		
		//for(long i=0; i<n; ++i) printf(" a[%ld]=%ld\n", i,a[i]);
		
		long ans=0;
		long r=0;
		
		for(long i=0; i<m; ++i){
			if(b[i]==0) continue;
			while(r<n && b[i]>a[r]) r++;	
			
			//printf("b[%ld]=%ld :: r=%ld\n",i,b[i], r);
			
			long tt;
			if(r==n) tt=d;
			else tt=a[r];
			
			long p=b[i]-a[r-1];
			long q=tt-b[i];
			
			//printf("p::%ld, q::%ld\n", p, q);
			
			if(p<q) ans+=p;
			else ans+=q;
			
			//printf("%ld\n", ans);
		}
		
	printf("%ld\n", ans);
	}
}

Measured memory_bytes: 2060
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int a, b;
	cin >> a >> b;
	int co[100000];
	co[0] = 1;
	REP1(i, 99999){
		string s = to_string(i);
		//cout << s << endl;
		bool pa = true;
		REP(j, s.size()) if(s[j] != s[s.size()-1-j]) pa = false;
		if(pa) co[i] = co[i-1] +1;
		else co[i] = co[i-1];
	}
	cout << co[b] - co[a-1] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ




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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m ;
  cin >> n >> m ;
  if(n==m){
    yes() ;
  }
  else{
    no() ;
  }
  
  
  
  return 0 ;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF=20000000000000000;
 
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;  vector<vector<edge>> G;  vector<ll> d;

  graph(ll n){init(n);}

  void init(ll n){
    V = n;  G.resize(V);  d.resize(V);
    for(int i=0;i<V;i++){d[i] = INF;}
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;  e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    for(int i=0;i<V;i++){d[i] = INF;}
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top();  que.pop();  ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        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(){
  ll money=1000000000000000;
  ll n,m,s,t;
  cin >> n >> m >> s >> t;
  vector<ll> u(m+10),v(m+10),a(m+10),b(m+10);
  for(int i=0;i<m;i++)cin >> u[i] >> v[i] >> a[i] >> b[i];
  
  graph g1(n+10); graph g2(n+10); 
  for(int i=0;i<m;i++){g1.add_edge(u[i]-1,v[i]-1,a[i]); g1.add_edge(v[i]-1,u[i]-1,a[i]);}
  for(int i=0;i<m;i++){g2.add_edge(u[i]-1,v[i]-1,b[i]); g2.add_edge(v[i]-1,u[i]-1,b[i]);}
  g1.dijkstra(s-1); g2.dijkstra(t-1);
  ll x=-1;
  vector<pair<ll,ll>> w(n);
  for(int i=0;i<n;i++){w[i]=make_pair(money-g1.d[i]-g2.d[i],i);}
  sort(w.begin(),w.end());
  reverse(w.begin(),w.end());
  ll y=0;
  for(int i=0;i<n;i++){
    for(int j=y;j<n;j++){
      if(i<=w[j].second){y=j; cout << w[j].first << endl; break;}
    }
  }
}  

Measured memory_bytes: 23040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, m, a[112345];
    P b[112345];

    cin >> n >> m;
    REP(i, n)
    cin >> a[i];

    REP(i, m)
    cin >> b[i].second >> b[i].first;

    sort(b, b + m);
    sort(a, a + n);

    int i = 0;
    for (int j = m - 1; j >= 0; j--)
    {
        bool c = false;
        while (i < n && b[j].second)
        {
            if (b[j].first < a[i])
            {
                c = true;
                break;
            }
            a[i] = b[j].first;
            b[j].second--;
            i++;
        }

        if (c)
            break;
    }

    ll res = 0;
    REP(i, n)
    {
        res += a[i];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

int main() {
#ifdef kvutxdy
    freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/test/input.in", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll H;
    cin >> H;
    ll numMons = 1, ans = 0LL;
    while (H) {
        ans += numMons;
        numMons <<= 1LL;
        H >>= 1LL;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n, x, y=0;
    cin >> n >> x;
    int i = 0;
    for(; i < n; i++){
        int L; cin >> L;
        y += L;
        if(y > x) break;
    }
    cout << i+1 << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

S = input()
S = S[::-1]
U = [0] * len(S)

a = 1
for k,v in enumerate(S):
    U[k] = U[k-1] + a * int(v)
    U[k] %= 2019
    a *= 10
    a %= 2019

U.append(0)

ans = 0
for k,v in Counter(U).items():
    ans += v * (v-1) // 2

print(ans)

Measured memory_bytes: 72504
s = input()[::-1]

counts = [0]*2019 # 剰余の余りの回数を保存
counts[0] = 1 # 0%2019を累積和として含めることを想定

num, d = 0,1 # numは余りの累積和、dはcharの桁数
'''
charに一桁ずつ取り出す。そのmod2019を考え、累積和をとる。
しかし、それぞれの数字には10の累乗がかかっているので、それについては別途dを用意してmod2019をとる
つまり、numは1桁目のmod2019、2桁目のmod2019に1桁目のmod2019を加える
'''
for char in s:
  num += int(char) * d
  num %= 2019
  d *= 10
  d %= 2019
  counts[num] += 1

ans = 0
for c in counts:
  ans += c*(c-1)//2
  
print(ans)

Measured memory_bytes: 9368
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 2;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int main(){
    int N;
    cin >> N;
    int array[110];
    for(int i = 0; i < N; i++) cin >> array[i];
    set<int> st;

    for(int i = 0; i < N; i++) st.insert(array[i]);
    cout << st.size() << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define NMAX 40
struct node {
  long int value, weight;
};

int compare(const void *a, const void *b);

int main(void)
{
  int i, j, n, n2, c1 = 0, c2 = 1;
  long int w, res = 0;
  static struct node vw[NMAX], ps[1<<(NMAX/2)];
  scanf("%d%ld", &n, &w);
  for (i = 0; i < n; i++) scanf("%ld%ld", &vw[i].value, &vw[i].weight);
  n2 = n / 2;
  for (i = 0; i < 1 << n2; i++) {
    long int sv = 0, sw = 0;
    for (j = 0; j < n2; j++) {
      if (i >> j & 1) {
        sv += vw[j].value;
        sw += vw[j].weight;
      }
    }
    ps[c1].value = sv;
    ps[c1++].weight = sw;
  }
  qsort(ps, c1, sizeof(struct node), compare);
  for (i = 1; i < c1; i++) {
    if (ps[c2-1].value < ps[i].value) ps[c2++] = ps[i];
  }
  for (i = 0; i < 1 << (n - n2); i++) {
    long int sv = 0, sw = 0;
    for (j = 0; j < n - n2; j++) {
      if (i >> j & 1) {
        sv += vw[n2+j].value;
        sw += vw[n2+j].weight;
      }
    }
    if (sw <= w) {
      int m, l = 0, r = c2;
      long int x = w - sw;
      while (l < r) {
        m = (l + r) / 2;
        if (ps[m].weight <= x) l = m + 1;
        else r = m;
      }
      if (sv + ps[l-1].value > res) res = sv + ps[l-1].value;
    }
  }
  printf("%ld\n", res);
}

int compare(const void *a, const void *b)
{
  struct node ta = *(struct node*)a, tb = *(struct node*)b;
  if (ta.weight > tb.weight) return 1;
  else if (ta.weight < tb.weight) return -1;
  else if (ta.value > tb.value) return -1;
  else if (ta.value < tb.value) return 1;
  return 0;
}


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


int main(){
    int x=0,N,max=0,k=0;
    string s;
    cin >> N >> s;
    vector<int> od(N);
    rep(i,N){
        if(s[i]=='I'){
            od[k]=++max;
            k++;
        }
        if(s[i]=='D'){
            max--;
        }
    }
    sort(od.begin(),od.end());
    cout << od[od.size()-1] << endl;
    return 0;
}

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

int main() {
  
  string S, T;
  
  cin >> S;
  cin >> T;
  
  if(S.at(0) == T.at(0) && S.at(1) == T.at(1) && S.at(2) == T.at(2)){
    
    cout << "3";
    
  } else if(S.at(0) == T.at(0) && S.at(1) == T.at(1)){
    
    cout << "2";
    
  } else if(S.at(0) == T.at(0) && S.at(2) == T.at(2)){
    
    cout << "2";
    
  } else if(S.at(1) == T.at(1) && S.at(2) == T.at(2)){
    
    cout << "2";
    
  } else if(S.at(0) != T.at(0) && S.at(1) != T.at(1) && S.at(2) != T.at(2)){
    
    cout << "0";
    
  } else {
    
    cout << "1";
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
import java.util.*

fun main() {
    var (H, W) = readLine()!!.split(" ").map(String::toInt)
    var (CH, CW) = readLine()!!.split(" ").map{it.toInt()-1}
    var (DH, DW) = readLine()!!.split(" ").map{it.toInt()-1}
    var S = Array<String>(H){""}
    (0 .. H-1).forEach{ i ->
        S[i] = readLine()!!
    }

    // スタートノードから各ノードへの距離。ただし未訪問(初期状態)なら-1
    var dist = Array(H) {Array(W) {-1}}
    dist[CH][CW] = 0
    
    // スタートノードをキューに入れる
    var q = LinkedList<Pair<Int, Int>>()
    q.offer(Pair(CH, CW))
    // 幅優先探索で、未訪問のマスをスタートマスから近い順に巡る
    var DIR1 = arrayOf(Pair(0, 1), Pair(1, 0), Pair(0, -1), Pair(-1, 0))
    var DIR2 = arrayOf(
        Pair(-2, -2), Pair(-2, -1), Pair(-2, 0), Pair(-2, 1), Pair(-2, 2),
        Pair(-1, -2), Pair(-1, -1), Pair(-1, 1), Pair(-1, 2),
        Pair(0, -2), Pair(0, 2),
        Pair(1, -2), Pair(1, -1), Pair(1, 1), Pair(1, 2),
        Pair(2, -2), Pair(2, -1), Pair(2, 0), Pair(2, 1), Pair(2, 2)
        )
    while (!q.isEmpty()) {
        var (y, x) = q.poll()
        var d = dist[y][x]
        DIR1.forEach { (dy, dx) -> 
            var ny = y + dy
            var nx = x + dx
            if (0 <= ny && ny < H && 0 <= nx && nx < W && S[ny][nx] == '.' && (dist[ny][nx] == -1 || dist[ny][nx] > d)) {
                dist[ny][nx] = d
                q.offerFirst(Pair(ny, nx))
            }
        }
        DIR2.forEach { (dy, dx) -> 
            var ny = y + dy
            var nx = x + dx
            if (0 <= ny && ny < H && 0 <= nx && nx < W && S[ny][nx] == '.' && (dist[ny][nx] == -1 || dist[ny][nx] > d+1)) {
                dist[ny][nx] = d + 1
                q.offerLast(Pair(ny, nx))
            }
        }
    }
    println(dist[DH][DW])
}


Measured memory_bytes: 70760
//Copyright(c)2017 Mstdream
#include<bits/stdc++.h>
using namespace std;

inline void splay(int &v){
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
const int mod=1000000007;
void upd(int&v){if(v>=mod)v-=mod;}
int dp[100][4][4],n;
char s[100],t[100];
int main(){
	cin>>n;
	scanf("%s%s",s+1,t+1);
	if(s[1]==t[1])dp[1][1][1]=dp[1][2][2]=dp[1][3][3]=1;
	else dp[1][1][2]=dp[1][1][3]=dp[1][2][1]=dp[1][2][3]=dp[1][3][1]=dp[1][3][2]=1;
	for(int i=2;i<=n;i++){
		if(s[i]==t[i]){
			for(int p=1;p<=3;p++){
				for(int q=1;q<=3;q++){
					for(int l=1;l<=3;l++){
						if(l==p||l==q)continue;
						dp[i][l][l]+=dp[i-1][p][q];
						upd(dp[i][l][l]);
					}
				}
			}
		}
		else{
			for(int p=1;p<=3;p++){
				for(int q=1;q<=3;q++){
					for(int l=1;l<=3;l++){
						for(int r=1;r<=3;r++){
							if(l==r)continue;
							if(l!=p&&s[i]==s[i-1])continue;
							if(r!=q&&t[i]==t[i-1])continue;
							if(l==p&&s[i]!=s[i-1])continue;
							if(r==q&&t[i]!=t[i-1])continue;
							dp[i][l][r]+=dp[i-1][p][q];
							upd(dp[i][l][r]);
						}
					}
				}
			}
		}
	}
	int ans=0;
	for(int p=1;p<=3;p++){
		for(int q=1;q<=3;q++){
			ans+=dp[n][p][q];
			upd(ans);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	N := nextInt()
	K := nextInt()
	ans := 0
	for i := 0; i < N; i++ {
		hi := nextInt()
		if hi >= K {
			ans++
		}
	}
	fmt.Fprintln(out, ans)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// Genericsがないので筋肉で...
// interfaceでの取扱がようわからんし
func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// mapからkeysとvaluesを返す感じのやつ
// なんかしらんけどmap[interface{}]interface{}しか受け付けない。なんのためのinterface{}やねん
// なので呼ぶときのmapはmap[int]stringとかじゃダメ
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
	return
}


Measured memory_bytes: 896
#include<stdio.h>
//小さい順にソート
int c[100002];
void merge(int i,int j,long long *s){
  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]=s[b];
        b++;
      }
      else if(j<b){
        c[d]=s[a];
        a++;
      }
      else if(s[a]<s[b]){
        c[d]=s[a];
        a++;
      }
      else{
        c[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=c[d];
  }
}

int main(){
  int n,i,count=0;
  scanf("%d",&n);
  long long a[n+1],sum=0;
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
    if(a[i]<0){
      a[i]=-a[i];
      count++;
    }
  }
  merge(0,n-1,a);
  if(count%2==0)
    sum+=a[0];
  else
    sum-=a[0];
  for(i=1;i<n;i++)
    sum+=a[i];
  printf("%lld\n",sum);
  return 0;
}


Measured memory_bytes: 1280
/**
 * Walk on Multiplication Table
 * https://atcoder.jp/contests/abc144/tasks/abc144_c
 **/
#include<iostream>
#include<math.h>
using namespace std;

long f(long x, long y) {
    return x + y - 2;
}

int main() {
    long N;
    cin >> N;
    long sqrt_N = ceil(sqrt(N));
    long ans = N-1;
    for(long i=1; i<sqrt_N+1; i++) {
        if(N%i==0) {
            long tmp_ans = f(i, N/i);
            if(tmp_ans < ans) {
                ans = tmp_ans;
            }
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    int k;
    cin >> k;
    queue<ll> q;
    vector<ll> v;
    for(int i = 1; i <= 9; i++){
        q.push(i);
        v.push_back(i);
    }
    while(true){
        if(k < v.size())
            return cout << v[--k], 0;
        ll x = q.front();
        q.pop();
        if(x % 10 == 0){
            q.push(x * 10);
            q.push(x * 10 + 1);

            v.push_back(x * 10);
            v.push_back(x * 10 + 1);
        }
        else if(x % 10 == 9){
            q.push(x * 10 + 8);
            q.push(x * 10 + 9);

            v.push_back(x * 10 + 8);
            v.push_back(x * 10 + 9);
        }
        else{
            q.push(x * 10 + ((x % 10) - 1));
            q.push(x * 10 + ((x % 10)));
            q.push(x * 10 + ((x % 10) + 1));

            v.push_back(x * 10 + ((x % 10) - 1));
            v.push_back(x * 10 + ((x % 10)));
            v.push_back(x * 10 + ((x % 10) + 1));
        }
    }
    return 0;
}

Measured memory_bytes: 1656
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=5e5+5,inf=0x3f3f3f3f;
ll res;int a[N],n,mn;
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&a[i]);
	res=a[1]-1,mn=1;
	fp(i,2,n){
		if(a[i]==mn+1)++mn;
		else res+=(a[i]-1)/(mn+1);
//		printf("%d %d %d\n",i,mn,res,(a[i]-1)/(mn+1)*(mn+1));
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 640
//phoenix




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


#define spdio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pp pop_back
#define mp make_pair
#define fr(i,j,n) for(ll i=j; i<n; i++)
#define rfr(i,j,n) for(ll i=n-1; i>=0; i--)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a) sort(a,a+n);


typedef long double ld;
typedef long long int ll;


//getline(cin,string);
const ll inf = (ll) 1e18 + 19;



/*
ll solveDp(ll i,ll w[],ll v[],ll n,ll wt,map <ll,map <ll,ll> > &dp) {
    if(i>=n || wt<0)
        return 0;
    if(dp[wt][i])
        return dp[wt][i];
    else if(wt<w[i])
        return dp.insert(mp([wt][i]=solveDp(i+1,w,v,n,wt,dp);
    else
        return dp[wt][i]=max(solveDp(i+1,w,v,n,wt,dp),v[i]+solveDp(i+1,w,v,n,wt-w[i],dp));
}
*/


/*
void bfs(ll k,bool vis[],ll n,vector <ll> v[]) {
    queue <ll> q;
    q.push(k);
    while(!q.empty()) {
        ll node=q.front();
        q.pop();
        cout<<node<<" ";
        vis[node-1]=true;
        fr(j,0,v[node-1].size()) {
            if(vis[v[node-1][j]-1]!=true)
                q.push(v[node-1][j]),vis[v[node-1][j]-1]=true;
        }
    }
}




void dfs(ll k,bool vis[],ll n,vector <ll> v[]) {
    cout<<k<<" ";
    vis[k-1]=true;
    fr(i,0,v[k-1].size()) {
        if(!vis[v[k-1][i]-1])
            dfs(v[k-1][i],vis,n,v);
    }
}




ll solveDp(ll i,ll a[],ll n,vector <ll> &dp) {
    if(i>=n)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    else {
        ll mx=-inf;
        fr(j,0,n) {
            mx=max(mx,a[i]+solveDp(i+j+2,a,n,dp));
        }
        return dp[i]=mx;
    }
}
*/



void cazz() {
    ll n,i,j,k,ans=0,f=0,b=0,wt,m=0;
    cin>>n>>m;
    ll a[m];
    fr(i,0,m) cin>>a[i];
    fr(i,0,m) {
        b+=a[i];
        if(b>n)
            f=1;
    }
    if(f)
        cout<<-1<<"\n";
    else
        cout<<n-b<<"\n";
    /*cin>>n>>m;
    vector <ll> v[n];
    fr(i,0,m) {
        cin>>j>>k;
        v[j-1].pb(k);
        v[k-1].pb(j);
    }
    cout<<"\n";
    fr(i,0,n) {
        cout<<i+1<<"\t";
        fr(j,0,v[i].size()) {
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
    cout<<"\n";
    cin>>k;
    bool vis[n]={};
    bfs(k,vis,n,v);
    cout<<"\n";
    bool vi[n]={};
    dfs(k,vi,n,v);*/
}




int main() {
    spdio;
	cazz();
	return 0;
}




Measured memory_bytes: 3720
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main()
{
  ll n;
  cin >> n;
  ll ans = n * (n - 1) / 2;
  cout << ans << "\n";
  return 0;
}

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

using namespace std;

int main (void){
  int x, y;
  cin >> x >> y;

  int a[7] = {1, 3, 5, 7, 8, 10, 12};
  int b[4] = {4, 6, 9, 11};
  int c = 2;

  int xg = 0, yg = 0;
  for (int i = 0; i< 7; i++){
    if(a[i] == x) xg = 0;
    if(a[i] == y) yg = 0;
  }
  for (int i = 0; i< 4; i++){
    if(b[i] == x) xg = 1;
    if(b[i] == y) yg = 1;
  }
  if(x == c) xg = 2;
  if(y == c) yg = 2;

  if(xg == yg) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
/*
 * Author:  heyuhhh
 * Created Time:  2019/11/18 18:16:10
 */
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << '\n'; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
#else
  #define dbg(...)
#endif
void pt() {std::cout << '\n'; }
template<typename T, typename...Args>
void pt(T a, Args...args) {std::cout << a << ' '; pt(args...); }
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 300 + 5;

int n, K;

int h[N];
ll dp[N][N];

void run(){
    for(int i = 1; i <= n; i++) cin >> h[i];
    memset(dp, INF, sizeof(dp));
    dp[0][0] = 0;
    for(int i = 1; i <= n - K; i++) {
        for(int j = i; j <= n; j++) {
            for(int k = 0; k < j; k++) {
                dp[j][i] = min(dp[j][i], dp[k][i - 1] + max(0, h[j] - h[k]));   
            }
        }   
    }
    ll ans = INF;
    for(int i = 1; i <= n; i++) ans = min(ans, dp[i][n - K]);
    if(ans == INF) ans = 0;
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    while(cin >> n >> K) run();
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        // get a integer
        String s = sc.next();
        int res = 700;
        for (int i = 0; i < 3; ++i) {
            char a = s.charAt(i);
            if (a == 'o') {
                res += 100;
            }
        }

        System.out.println(res);
    }

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<string>
#include<map>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vii         vector<pair<ll,ll> >
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         100000001
#define fast_io      ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
#define scan(var)    scanf("%lld",&var)
#define print(var)   printf("%lld\n", var);
#define BLOCK 317
#define double       long double
#define mod          998244353
using namespace std;
double dp[3001][3001];
double arr[3001];
double solvedp(ll index,ll heads,ll n)
{
  if(index == n)
  {
    if(heads > (index - heads))
    {
      return 1;
    }
    else
    {
      return 0;
    }
  }
  if(dp[index][heads] != -1.0)
  {
    return dp[index][heads];
  }
  double ans = 1;
  ans = arr[index]*solvedp(index + 1,heads + 1,n) + (1 - arr[index])*solvedp(index + 1,heads,n);
  dp[index][heads] = ans;
  return ans;
}
int main()
{
  fast_io
  ll n;
  cin >> n;
  rep(i,0,n)
  {
    cin >> arr[i];
  }
  for(ll i = 0; i <= 3000; i++)
  {
    for(ll j = 0; j <= 3000; j++)
    {
      dp[i][j] = -1;
    }
  }
  cout << fixed << setprecision(20) << solvedp(0,0,n);
  return 0;
}



Measured memory_bytes: 141312
let input f = stdin.ReadLine() |> f
let inputs f = stdin.ReadLine().Split() |> Array.map f

let N = input int
let C = inputs int |> Array.map (fun x -> x - 1)
let G = [|for i in 1..N -> [] |]

for _ in 1..N-1 do
    let [|u; v|] = inputs int |> Array.map (fun x -> x - 1)
    G.[u] <- v :: G.[u]
    G.[v] <- u :: G.[v]

let C2 (n : int64) = n * (n + 1L) / 2L

let cnt = Array.create N 0L
let del = Array.create N 0L
let mutable all = 0L
let ans = Array.create N (C2 (int64 N))

let rec dfs u p =
    let L = if p <> -1 then all - del.[C.[p]] else 0L
    for v in G.[u] do
        if v <> p then
            let l = all - del.[C.[u]]
            dfs v u
            let r = all - del.[C.[u]]
            del.[C.[u]] <- del.[C.[u]] + (r - l)
    del.[C.[u]] <- del.[C.[u]] + 1L
    all <- all + 1L
    let R = if p <> -1 then all - del.[C.[p]] else 0L
    if p <> -1 then
        ans.[C.[p]] <- ans.[C.[p]] - C2 (R - L)

dfs 0 (-1)
for i in 0..N-1 do
    ans.[i] <- ans.[i] - C2 (all - del.[i])
    printfn "%d" ans.[i]

Measured memory_bytes: 94296
#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl "\n";
#define pb push_back
#define md 1000000007
#define ll long long int
#define all(v) v.begin(),v.end()
ll power(ll a,ll b){ll z=1;while(b){if(b&1){z*=a;z%=md;}a*=a;a%=md;b/=2;}return z%md;}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N=3001;
ll n,sum=0;
ll dp[N][N];
vector<ll> val;

ll solve(ll i,ll j,ll t){
	if(i>j)
		return 0;
	ll &ans=dp[i][j];
	if(ans!=-1)
		return ans;
	ans=0;
	if(t==0){
		ans = max(val[i] +solve(i+1,j,!t),val[j]+solve(i,j-1,!t));
	}
	else{
		ans = min(solve(i+1,j,!t),solve(i,j-1,!t));		
	}
	return ans;
}

int main(){
	//You need to change array size!
	#ifndef LOCAL
	ios_base::sync_with_stdio(false);	cin.tie(NULL);
	#endif 
	memset(dp,-1,sizeof dp);
	cin>>n;
	val.resize(n+1);
	for(int i=1;i<=n;++i){
		cin>>val[i];	
		sum+=val[i];
	}
	
	ll x=solve(1,n,0);
	
	cout<<2*x - sum<<endl;	


	return 0;	
}

Measured memory_bytes: 74236
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  V a(n);
  REP(i, n) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int i = 0, sum = 0;
  while (i < n) {
    int cnt = 1;
    while (i < n-1 && a[i] == a[i+1]) {
      i++;
      cnt++;
    }
    if (a[i] > cnt) {
      sum += cnt;
    }
    else {
      sum += cnt-a[i];
    }
    i++;
  }
  dump(sum);
  return 0;
}


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

void fnInput(vector<int>& rvnBinHeap)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvnBinHeap.resize(nMaxSiz + 1);

  for (int i = 1; i < nMaxSiz + 1; ++i)
    cin >> rvnBinHeap[i];
}

void fnBinaryHeap(const vector<int>& cnrvnBinHeap)
{
  for (int i = 1; i < cnrvnBinHeap.size(); ++i)
  {
    cout << "node " << i << ": key = " << cnrvnBinHeap[i] << ", ";
    int nParnt = i / 2;
    int nLeft = i * 2;
    int nRigt = nLeft + 1;
    if (nParnt >= 1)
      cout << "parent key = " << cnrvnBinHeap[nParnt] << ", ";
    if (nLeft < cnrvnBinHeap.size())
      cout << "left key = " << cnrvnBinHeap[nLeft] << ", ";
    if (nRigt < cnrvnBinHeap.size())
      cout << "right key = " << cnrvnBinHeap[nRigt] << ", ";
    cout << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnBinHeap; 

  fnInput(vnBinHeap);
  fnBinaryHeap(vnBinHeap);
  return 0;
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

int main(){
    string s;cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 1, 0, -1, -1}, dy1[] = {1, 0, -1, -1, -1, 0}, dy2[] = {1, 1, 0, -1, 0, 1};

// d[y][x][t%6] = (ここにたどり着く最小の無視した回数)
int d[250][250][6];
int board[250][250];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;
  int n;
  cin >> n;
  REP(i, n) {
    int x, y;
    cin >> x >> y;
    board[y+100][x+100] = 1;
  }
  int lx, ly;
  cin >> lx >> ly;

  REP(i, 250) REP(j, 250) REP(k, 6) d[i][j][k] = LLINF;
  d[100+sy][100+sx][0] = 0;
  priority_queue<VI, VVI, greater<VI>> que;
  que.push({d[100+sy][100+sx][0], 100+sy, 100+sx, 0});

  while(que.size()) {
    VI v = que.top(); que.pop();
    // cout << v << endl;
    int x = v[2], y = v[1], t = v[3];
    REP(i, 6) {
      int nx = x + dx[i], ny = y + (x%2==0?dy1:dy2)[i];
      if(100-lx <= nx && nx <= 100+lx && 100-ly <= ny && ny <= 100+ly && board[ny][nx]==0) {
        int tmp = abs((x-100)*(y-100)*t)%6 != i;
        // cout << i << " " << nx << " " << ny << " " << tmp << endl;
        if(d[ny][nx][(t+1)%6] > d[y][x][t] + tmp) {
          d[ny][nx][(t+1)%6] = d[y][x][t] + tmp;
          que.push({d[ny][nx][(t+1)%6], ny, nx, (t+1)%6});
        }
      }
    }
    if(d[y][x][(t+1)%6] > d[y][x][t] + 1) {
      d[y][x][(t+1)%6] = d[y][x][t] + 1;
      que.push({d[y][x][(t+1)%6], y, x, (t+1)%6});
    }
  }

  int ans = LLINF;
  REP(i, 6) {
    chmin(ans, d[100+gy][100+gx][i]);
    // cout << d[100+gy][100+gx][i] << endl;
  }
  if(ans==LLINF) cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}



Measured memory_bytes: 6848
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

lst = []

for a in A:
	for b in B:
		lst.append(a + b)
		
lst.sort(reverse = True)

lst = lst[0 : K] 
# もしCのc番目の値しか使わないケースを考えたとき、大小関係は保たれるから、
# K番目以降の値は使うことがない

ans = []

for c in C:
	for i in lst:
		ans.append(c + i)
		
ans.sort(reverse = True)

for i in range(K):
	print(ans[i])

Measured memory_bytes: 160872
from functools import reduce
N = int(input())
a = list(map(int, input().split()))

def gcd_impl(n,m):
    K = 5
    for _ in range(80):
        t = n - m
        s = n - m*K
        q = t < m
        p = t < m*K
        if q:
            n = m
        else:
            n = t
        if q:
            m = t
        else:
            m = m
        if m == 0:
            return n
        if p:
            n = n
        else:
            n = s
    return gcd_impl(m, n%m)

def gcd_pre(n,m):
    for _ in range(4):
        t = n - m
        q = t < m
        if q:
            n = m
        else:
            n = t
        if q:
            m = t
        else:
            m = m
        if m == 0:
            return n
    return gcd_impl(n,m)

def gcd(n,m):
    if n > m:
        return gcd_pre(n,m)
    else:
        return gcd_pre(m,n)

def lcm(a,b):
    return (a*b)//gcd(a,b)

def lcm_list(lst):
    return reduce(lcm, lst)

M = lcm_list(a) - 1

res = 0
for i in a:
    res += M%i
print(res)

Measured memory_bytes: 3936
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int v[] = new int[n];
        int c[] = new int[n];
        int ans=0;
        for(int i=0;i<n;i++) v[i] = in.nextInt();
        for(int i=0;i<n;i++) c[i] = in.nextInt();
        for(int i=0;i<n;i++) if(v[i]>c[i]) ans+=v[i]-c[i];
        out.println(ans);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

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

int main()
{
	int n;
	while(cin>>n){
		if(n==0) break;
		int mx=0,mi=500;
		for(int i=0;i<n;i++){
			int temp=0;
			for(int j=0;j<5;j++){
				int t;
				cin>>t;
				temp+=t;
			}
			mx=max(mx,temp);
			mi=min(mi,temp);
		}
		cout<<mx<<" "<<mi<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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();}

int main(){
    std::ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;

    ll div = n / k;
    n -= div * k;
    cout << min(n, k-n) << endl;    
}

Measured memory_bytes: 256
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let env = Env {
        a: read::<i64>(),
        b: read::<i64>(),
        c: read::<i64>(),
        ll: (0..n).map(|_| read::<i64>()).collect::<Vec<_>>(),
    };

    println!("{}", dfs(&env, 0, 0, 0, 0, 0));

    struct Env {
        ll: Vec<i64>,
        a: i64,
        b: i64,
        c: i64,
    };

    fn dfs(env: &Env, i: usize, a: i64, b: i64, c: i64, total: i64) -> i64 {
        if i < env.ll.len() {
            let s = env.ll[i];
            let &small = vec![
                dfs(env, i + 1, a + s, b, c, total + if a > 0 { 10 } else { 0 }),
                dfs(env, i + 1, a, b + s, c, total + if b > 0 { 10 } else { 0 }),
                dfs(env, i + 1, a, b, c + s, total + if c > 0 { 10 } else { 0 }),
                dfs(env, i + 1, a, b, c, total),
            ]
            .iter()
            .min()
            .unwrap();
            small
        } else {
            if a > 0 && b > 0 && c > 0 {
                (env.a - a).abs() + (env.b - b).abs() + (env.c - c).abs() + total
            } else {
                let inf = i64::max_value();
                inf
            }
        }
    };
}


Measured memory_bytes: 4352
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
# from collections import defaultdict,deque,Counter
# from heapq import heappush,heappop
# import numpy as np
# n=int(input())

h1,m1,h2,m2,k=LI()
t1=60*h1+m1
t2=60*h2+m2
print(max(0,-t1+t2-k))

Measured memory_bytes: 9176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 100005

int main() {

	int n;
	cin>>n;
	int ac = 0, wa = 0, tle = 0, re = 0;
	while(n--) {

		char s[100];
	
		scanf("%s", s);

		if(s[0] == 'A') ac++;
		else if (s[0] == 'T') tle++;
		else if(s[0] == 'W') wa++;
		else if (s[0] == 'R') re++;

	}

	cout<<"AC x "<<ac<<endl;

	cout<<"WA x "<<wa<<endl;

	cout<<"TLE x "<<tle<<endl;

	cout<<"RE x "<<re<<endl;


	return 0;
}

Measured memory_bytes: 3684
#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;
 
struct Ses{
    int st, en, si;
};
 
int main(){
    string str;
    cin >> str;
    int n = str.size();
    int Am = 0;
    stack<Ses> Em;
    stack<int> F;
    Ses Km; 

    for(int i = 0; i < n; i++){
        if(str[i] == '\\'){
            F.push(i);
        } else if(str[i] == '/'){
            if(!F.empty()){
                int b = F.top();
                F.pop();
                Km.st = b;
                Km.en = i;
                Km.si = i-b;
                Am += Km.si;
                while( !Em.empty() ){
                    if(Km.st < Em.top().st){
                        Km.si += Em.top().si;
                        Em.pop();
                    } else {
                        break;
                    }
                }
                Em.push(Km);
            }
        }
    }
    cout << Am << endl;
    int m = Em.size(), T[m];
    cout << m;
    for(int i = 0; i < m; i++){
        T[m - i - 1] = Em.top().si;
        Em.pop();
    }
    for(int i = 0; i < m; i++)
        cout << " " << T[i];
    cout << endl;
}

Measured memory_bytes: 1312
a,b,c = map(int,input().split())
k = int(input())
for i in range(k):
    if a < b:
        if b < c:
            break
        else:
            c *= 2
            if b < c:
                break
    else:
        b *= 2
else:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 9172
#include <stdio.h>
int main(void){
  int h;
  int h1=0,h2=0,h3=0;
  while(scanf("%d\n",&h)!=EOF) {
    if (h>h3) h3=h;
    if(h3>h2){int s=h2;h2=h3;h3=s;}
    if(h2>h1){int s=h1;h1=h2;h2=s;}
  }
  printf("%d\n%d\n%d\n",h1,h2,h3);
  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	int a[15],b=0;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='0')a[b]=0,b++;
		if(s[i]=='1')a[b]=1,b++;
		if(s[i]=='B')b--;
		if(b<0)b=0;
	}
	for(int i=0;i<b;i++)cout<<a[i];cout<<endl;
	return 0;
}


Measured memory_bytes: 256