akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2 vector<vec>
#define vecll2 vector<vecll>
#define vec3 vector<vec2d>
#define vecll3 vector<vecll2d>
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(vector<T> v){for(T e:v)cout<<e<<" ";cout<<endl;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}

const int N=1e5+10;
const ll INF=1e9+7;
ll a[N<<4];
int sum[11];
main(){
    
    int h,w,n;scanf("%d%d%d",&h,&w,&n);
    int x,y;
    int cnt=0;
    ll m=(ll)(h-2)*(w-2);
    rep(iii,n){
        scanf("%d%d",&x,&y);
        rep(i,3)rep(j,3)if( x-i>=1 && x-i<=h-2 && y-j>=1 && y-j<=w-2){
            a[cnt++]=INF*(x-i)+(y-j);
        }
    }
    sort(a,a+cnt);
    ll t=1;
    rep(i,cnt){
        if(a[i]==a[i+1])t++;
        else sum[t]++,t=1,m--;
    }
    printf("%lld %d %d %d %d %d %d %d %d %d",m,sum[1],sum[2],sum[3],sum[4],sum[5],sum[6],sum[7],sum[8],sum[9]);
}



Measured memory_bytes: 8448
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

void solve(){
    int n;
    cin >> n;

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

    ll need_b = 0;

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

    ll can_a = 0;

    for(int i = 0; i < n; i++){
        can_a += (a[i] < b[i]? (b[i]-a[i])/2 : 0);
    }

    if(can_a >= need_b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

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

Measured memory_bytes: 384
#include <stdio.h>
int main(void)
{

        int a,b,d;

        scanf("%d%d",&a,&b);
        if(a<3||b<3||20<a||20<b)
                printf("正しい値を入力してください\n");
        if(a>b)
                d = a + (a - 1);
        else if(a==b)
                d = a + b;
        else
                d = b + (b - 1);

        printf("%d\n",d);
        return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  int a[n];
  REP(i, n){
    cin>>a[i];
  }
  REP(i, n){
    if(a[i] % 2 == 1)continue;
    if(a[i] % 3 == 0 || a[i] % 5 == 0)continue;
    cout<<"DENIED"<<endl;
    return 0;
  }
  cout<<"APPROVED"<<endl; 
  return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    n, m = map(int, input().split())
    a = [int(i) for i in input().split()]
    s = sum(a)
    a = sorted(a)[::-1]
    if a[m-1] >= (s / (4 * m)):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 9176
N = int(input())
X = map(int,input().split())
def check():
    for i in X:
        if(i%2 == 0):
            if(i%3 == 0 or i%5 == 0):
                continue
            else:
                print("DENIED")
                return 0

        else:
            continue
    print("APPROVED")
check()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    Int N, A, B; cin >> N >> A >> B;
    Int ans = 0;
    Int k = N / (A + B);
    ans += k * A;
    N -= (A + B) * k;
    ans += min(N, A);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long Total;
long long Ans;
inline double GetSum(long long X)
{
	register long long Return;
	Return=0;
	register long long Y;
	Y=X;
	while(X)
	{
		Return+=X%10;
		X/=10;
	}
	return 1.0*Y/Return;
}
int main(void)
{
	register long long i;
	cin>>Total;
	i=1;
	while(Total--)
	{
		while(true)
		{
			if(GetSum(i+Ans)>GetSum(i*10+Ans))
			{
				i*=10;
			}
			else
			{
				break;
			}
		}
		Ans+=i;
		cout<<Ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3432
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
//↓10進数でi桁目の数を取り出すセット
unsigned long long deci[20]={1};
//iは0-indexedなので注意！
int deciBit(long long N,int i){
	N/=deci[i];
	return (int)(N%10);
}
//N以上で最小のすぬけ数を求める
ll Snuke(ll N){
	stringstream SS;
	SS<<N;
	string S=SS.str();
	double mini=1.*INFLL*INFLL*INFLL;
	ll snuke=N;
	for(int i=0;i<S.length();i++){
		for(int j=S[i]-'0';j<=9;j++){
			string T=S;
			for(int k=0;k<S.length();k++)
				if(k==i)
					T[k]=j+'0';
				else if(k>i)
					T[k]='9';
			ll M=stoll(T);
			ll ds=0;
			for(int k=0;k<20;k++)
				ds+=deciBit(M,k);
			double temp=1.*M/ds;
			if(mini>temp){
				mini=temp;
				snuke=M;
			}
		}
	}
	return snuke;
}
int main(){
	for(int i=1;i<20;i++){
		deci[i]=deci[i-1]*10;
	}
	int K;
	cin>>K;
	ll N=1;
	for(int i=0;i<K;i++){
		cout<<N<<endl;
		N=Snuke(N+1);
	}
	return 0;
}

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

int main() {



//write code hare

	int n, k, x, y;
	cin >> n >> k >> x >> y;

	int fee ;
	if (n > k) {
		fee =  (k * x) + ((n - k) * y);
	}
	else {
		fee = (n * x);
	}
	cout << fee;



}

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

int main() {
    int H, W;
    for(int i=0; ; i++){
    cin >> H >> W;
    if(H==0 && W==0) break;
    for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
        if(i%2==0){
        if(j%2==0) cout << "#";
        if(j%2!=0) cout << ".";
        }
        if(i%2!=0){
        if(j%2==0) cout << ".";
        if(j%2!=0) cout << "#";
        }
    }
    cout << endl;
    }
    cout << endl;
    }
    return 0;
}




Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main(void)
{
	int i=0, n, a[10]={}, sum=0;

	char s[10];

	cin>>s;

	n=atoi(s);

	while(s[i]!='\0'){
		a[i]=(int)s[i]-'0';
		sum+=a[i++];
	}
	if(n%sum==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
K=int(input())
ans=0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans+=gcd(i,j,k)
print(ans)

Measured memory_bytes: 69836
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int h, a;
    cin >> h >> a;
    // cout << (h / a) + 1 << endl;
    rep(i, 10010) {
        if (a * i >= h) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if (a+b >= c){
        printf("No");
    }
    else if (4ll*(long long)a*b < (long long)(c-a-b)*(c-a-b)){
        printf("Yes");
    }
    else printf("No");
}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
//  freopen(Task".out", "w", stdout);
  int m, n; cin >> n >> m;
  vector<int> a(n);
  int s = 0;
  for (int i = 0; i < n; ++i) cin >> a[i], s += a[i];
  sort(All(a), greater<int>());
  int cnt = 0;
  for (int i = 0; i < n; ++i){
    if (a[i] * 4 * m >= s) ++cnt;
  }
  cout << (cnt >= m ? "Yes" : "No");
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int stage[20][20];
int dp[65536];
int stageid[17];
int bit[17];
int x,d,k,n,cost,mincost;
int main(){
	stageid[0]=1;
	for(int i=1;i<17;i++){
		stageid[i]=2*stageid[i-1];
	}
	while(1){
		cin >>n;
		if(n==0)break;
		dp[0]=0;
		for(int i=1;i<stageid[n];i++){
			dp[i]=2000000;
		}

		for(int i=0;i<n;i++){
			for(int j=0;j<=n;j++){
				cin >>stage[i][j];
			}
		}
		for(int i=1;i<stageid[n];i++){
			x=i;
			k=0;
			while(x>0){
				bit[k]=x%2;
				x/=2;
				k++;
			}

			for(int j=0;j<k;j++){
				if(bit[j]==0)continue;
				mincost=stage[j][0];
				for(int l=0;l<k;l++){
					if(bit[l]==0||j==l)continue;
					if(mincost>stage[j][l+1])mincost=stage[j][l+1];
				}
				cost=dp[i-stageid[j]]+mincost;
				if(cost<dp[i])dp[i]=cost;
			}
		}
		//for(int i=1;i<stageid[n];i++){
			cout <<dp[stageid[n]-1] <<endl;
		//}

	}
}

Measured memory_bytes: 3356
#include <stdio.h>
#include <map>

using namespace std;

int main() {
	int s, hitung = 1;
	map<int, int> id;
	scanf("%d", &s);
	while (id.count(s) < 1) {
		id[s] = hitung++;
		if (s & 1)
			s = (3 * s) + 1;
		else
			s /= 2;
	}
	printf("%d\n", hitung);
	return 0;
}

Measured memory_bytes: 256
using System;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            // 2 <= K <= 2500
            int K = int.Parse(strs[0]);
            // 0 <= S <= 3K
            int S = int.Parse(strs[1]);
            // 0 <= X,Y,Z <= K

            // X + Y + Z = S　は何通りか
            int result = 0;

            for (int X = 0; X <= K; ++X)
            {
                for (int Y = 0; Y <= K; ++Y)
                {
                    if (S - X - Y >= 0 &&
                        S - X - Y <= K)
                    {
                        ++result;
                    }
                }
            }

            Console.WriteLine(result);
        }
    }
}

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

using namespace std;
using ll = long long;

#define int ll
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#define pb push_back
#define sz(x) int(x.size())

signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);

	int a;
	int b;
	int k;
	cin >> a >> b >> k;
	
	int x = min(a, k);
	a -= x;
	k -= x;
	x = min(b, k);
	b -= x;
	k -= x;
	cout << a << " " << b << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

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

    cout << max(A-K, (long long)0) << ' ' << max(B-max(K-A,(long long)0),(long long)0) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;

class DisjointSet{
public:
    vector <int> rank,p;

    DisjointSet() {}
    DisjointSet(int size){
        rank.resize(size,0);
        p.resize(size,0);
        for (int i=0;i< size; i++){
            makeSet (i);
        }
    }

    void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
    }

    bool same(int x, int y){
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y){
        link(findSet(x), findSet(y));
    }

    void link(int x, int y){
        if(rank[x] > rank[y]){
            p[y] = x;
        }else{
            p[x] = y;
            if(rank[x] == rank[y]){
                rank[y]++;
            }
        }
    }

    int findSet(int x){
        if(x != p[x]){
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};
int main() {
    

    int n,a,b,q;
    int t;

    cin >> n >> q;
    DisjointSet ds = DisjointSet(n);
    for (int i=0;i<q;i++){
        cin >> t >> a >> b;
        if (t == 0){
            ds.unite(a,b);
        }else if(t == 1){
            if(ds.same(a,b)){
                cout << 1 << endl;
            }else{
                cout << 0 << endl;
            }
        }
    }


}


Measured memory_bytes: 3188
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

public class Main {
	public static void main (String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int arr[] = new int[n];
	    for(int i=0;i<n;i++){
	        arr[i] = sc.nextInt();
	    }
	    if(arr[0]!=0){
	        System.out.println(-1);return;
	    }
	    for(int i=1;i<n;i++){
	        int dif = arr[i] - arr[i-1];
	        if(dif>1){
	            System.out.println(-1);return;
	        }
	    }
	    long ans = 0;
	    for(int i=n-1;i>=0;i--){
	        ans+=arr[i];
	        if(arr[i]>0){
	            while(i>0 && arr[i] - arr[i-1] == 1){
	                i--;
	            }
	        }
	    }
	    System.out.println(ans);return;
	}
}

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

int n, ret=0;

void dfs(long a){
  if(a>n)return;
  long a0=a;
  map<int, int>m;
  while(a0>0){
    m[a0%10]++;
    a0/=10;
  }
  if(m.size()==3)ret++;
  dfs(a*10+3);
  dfs(a*10+5);
  dfs(a*10+7);
  return;
}

int main(){
  cin >> n;
  dfs(3);
  dfs(5);
  dfs(7);
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
n,x = map(int,input().split())
x = min(x,n-x)
n = n - x
ans = 0
while True:
  new_x = n%x 
  new_n = n//x
  if new_x ==0:
    print(ans+x*new_n*3)
    exit()
  else:
    ans = ans + x*new_n*3
    n = x
    x = new_x 

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

struct td{
  ll t,d;
  bool operator<(const td& right ) const {
    return d==right.d?t<right.t:d>right.d;
  }
};

int main(){
  ll k,n,t,d,tm=0,ans=0,v=0;
  bool c[100010]={};
  td p[100010];
  cin>>n>>k;
  fr(i,n){
    cin>>t>>d;
    t--;
    p[i]=(td){t,d};
  }
  sort(p,p+n);
  stack<ll> q;
  fr(i,n){
    if(i<k){
      tm+=p[i].d;
      if(c[p[i].t]){
        q.push(p[i].d);
      }
      else{
        c[p[i].t]=1;
        v++;
      }
      ans=tm+v*v;
    }
    else{
      if(q.empty()) break;
      if(!c[p[i].t]){
        c[p[i].t]=1;
        tm-=q.top();
        q.pop();
        tm+=p[i].d;
        v++;
        ans=max(ans,tm+v*v);
      }
    }
  }
  cout<<ans<<endl;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll t=1;
ll n,x,m;
string s;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n>>m;
	vll a(m);
	for(ll i=0;i<m;i++) cin>>a[i];

	cout<<max((ll)-1,n - accumulate(all(a),0)) ;
}

int main() {
	fastio;randomINT;
	//cin>>t;
	while(t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 238116
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main() {
  uint64_t A = 0;
  std::cin >> A;
  std::string B_temp;
  std::cin >> B_temp;
  uint64_t B = std::stoul(B_temp.erase(1, 1));
  std::cout << A * B / 100 << std::endl;

  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	string s = s1 + s2;

	//int len = (int)s.size();

	double num = stod(s);

/*	REP(i, len){
		num *= 10;
		num += s[i] - '0';
	}	*/

	REP(i, 317){
		if (i == sqrt(num)){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

}


Measured memory_bytes: 384
def main():
    N = int(input())
    T, A = map(int, input().split())
    H = [int(x) for x in input().split()]
    rec = 100000000
    ans = 0
    
    for i in range(N):
        C = T - (H[i] * 0.006)
        if C < A:
            C = A - C
        else:
            C = C - A
        if C < 0:
            C = C * (-1)
        if rec > C:
            rec = C
            ans = i + 1
    print(ans)
main()  

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    int N, M;
    cin >> N >> M;
    atcoder::dsu d(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        d.merge(a, b);
    }

    // すでにつながっているので
    if (d.size(0) == N) {
        cout << 0 << endl;
        return 0;
    }

    set<int> st;
    rep(i, N) {
        st.insert(d.leader(i));
    }

    cout << st.size()-1 << endl;


}


Measured memory_bytes: 7468
import Control.Monad
import Control.Applicative
import Data.List
  
main :: IO ()
main = do
  n <- readLn :: IO Int
  if n == 0
    then return ()
    else do
    ns <- getData n
    let ans = solve ns
    if null ans then putStrLn "NA"
                else mapM_ print ans
    main
  
getData :: Int -> IO [((Int, Int), Int)]
getData n = go 0
  where
    go :: Int -> IO [((Int, Int), Int)]
    go m
      | m == n = return []
      | otherwise = do
          [i, x, y] <- map read . words <$> getLine :: IO [Int]
          (:) ((m, i), x * y) <$> go (m+1)

solve :: [((Int, Int), Int)] -> [Int]
solve ns = map (snd . fst)
           $ sortBy (\(x,_) (x2,_) -> compare x x2)
           $ filter ((>= 1000000) . snd)
           $ map (\ls -> (fst (head ls), sum (map snd ls)))
           $ groupBy (\((_, y1), _) ((_, y2), _) -> y1 == y2)
           $ sortBy (\((_, y1), _) ((_, y2), _) ->
                       compare y1 y2) ns

Measured memory_bytes: 5004
#include <iostream>
#include <cmath>
using namespace std;
int n,k,tmp,ans;
char s[100010];
int main()
{
	scanf("%d%d",&n,&k);
	getchar();
	for(int i = 1;i <= n;i ++)
	{
		s[i] = getchar();
		if(s[i] == s[i - 1])
			tmp ++;
	}
	ans = min(tmp + 2 * k,n - 1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3888
let () =
  let n = read_int () in
  for _ = 0 to n - 1 do
    let (xa, ya, ra, xb, yb, rb) =
      Scanf.scanf "%f %f %f %f %f %f " (fun xa ya ra xb yb rb ->
        xa, ya, ra, xb, yb, rb) in
    let d = (xa -. xb)**2. +. (ya -. yb)**2. |> sqrt in
    print_endline
      (if ra -. rb > d then "2"
       else if rb -. ra > d then "-2"
       else if ra +. rb < d then "0"
       else "1")
  done

Measured memory_bytes: 2280
N,M,C = (int(i) for i in input().split())
B = list(int(i) for i in input().split())
cnt = 0
# N個のソースコードを1個ずつ正しいかを確かめるfor文
for i in range(N):
    judge = 0
    A = list(int(i) for i in input().split())
    # Aの列を1個ずつ正しいかを確かめるfor文
    for j in range(M):
        judge += A[j] * B[j]
        # ここにif文を置かない(2回目のfor文でカウントされてしまうので)
    if judge + C > 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 3060
import numpy as np
n, m = list(map(int, input().split()))

price = np.zeros(n)
limit = np.zeros(n)

for i in range(n):
    a, b = list(map(int, input().split()))
    price[i] = a
    limit[i] = b

p = 0
for i in price.argsort():
    l = limit[i]
   # print(price[i], m, l, p)

    if l < m:
        #print("T")
        p += price[i] * l
        m-=l
    else:
        #print("F")
        p += price[i] * m
        break
print(int(p))



Measured memory_bytes: 16252
#include <iostream>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>
#include <type_traits>
#include <map>
#include <cstdio>
#include <string>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

int gcd_euclid(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

// 最大公約数算出
int calc_gcd(const vector<int> vec){
	int gcd = *min_element(vec.begin(), vec.end());
	for (const int ele: vec){
		gcd = gcd_euclid(gcd,ele);
	}
	return gcd;
}

// 最小公倍数
int calc_lcm(const vector<int> vec) {
	int tmp = 1;
	for (const int ele: vec){
		tmp *= ele;
	}
	int gcd = calc_gcd(vec);
	return tmp/gcd;
}

// nが奇数、偶数の場合の場合分け
// n & 1 ? odd : even

// distinctはsortしてunique + erase
// https://qiita.com/ysk24ok/items/30ae72f4f1060b088588
//sort(vec.begin(), vec.end());
//vec.erase(unique(vec.begin(), vec.end()), vec.end());


// 全パターン列挙
//vector<vector<int>> res;
//
//void exp(int range, int times, vector<int>& vec){
//	if (times == 0){
//		res.push_back(vec);
//		return;
//	}
//	rep(i,0,range){
//		if (find(vec.begin(),vec.end(),i) == vec.end()) {
//			vector<int> tmp{vec};
//			tmp.emplace_back(i);
//			exp(range, times - 1, tmp);
//		}
//	}
//}

void run() {

	int n;get n;
	vector<int> a(n);

	rep(i,0,n){
		get a[i];
	}

	int ave = round((double)accumulate(a.begin(), a.end(), 0) / n);

	int ans = 0;
	for(auto i : a){
		ans += pow(abs(i - ave), 2);
	}

	put ans;
}
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class abc167_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();

            if (S.regionMatches(true, 0, T, 0, S.length())) {
                out.println("Yes");

            } else {
                out.println("No");

            }
        }

    }
}



Measured memory_bytes: 35780
n, k = map(int, input().split())
#d = list(map(int, input().split()))
d = input().split()

while 1:
    temp = list(str(n))
    for c in d:
        #print(c, temp)
        if c in temp:
            #print('a')
            break
    else:
        print(n)
        exit()
    n += 1
    continue


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;
//for (int i = 0; i < N; i++){}

int main() {
    int K, S;
    cin >> K >> S;
    int res = 0;
    for(int i = 0;i <= K;i++){
        for(int j = 0;j<=K;j++){
            if(i + j <= S && (S-i-j) <= K){
                res++;
            }
        }   
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long int ll;

int main() {
	
	ll a, b, c;
	cin >> a >> b >> c;
	if (b + a < c) cout << 2 * b + a + 1;
	else cout << b + c;
}

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

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

  int prev_H = 0;
  bool ok = true;

  for(int i = 0; i < N; i++){
    int h;
    cin >> h;
    if(h > prev_H){
      h--;
    }else if(h < prev_H){
      ok = false;
    }
    prev_H = h;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;
int n,m;
int ans = 0;
int main(){
    cin >> n >> m;
    ans += n*(n-1)/2;
    ans += m*(m-1)/2;
    cout << ans << endl;
}

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

using namespace std;

int n,x,i,j,a[100005];

int main(){
	scanf("%d%d", &n, &x);
	
	for(i = 0; i < n; i++)
	scanf("%d", &a[i]);
	
	long long res = 0;
	
	for(i = 1; i < n; i++){
		if(a[i] + a[i - 1] > x){
			int val = (a[i] + a[i - 1]) - x;
			a[i] = max(0, a[i] - val);
			res += val;			
		}
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;
     
int main(void)
{
  int a,b,c,n;
  cin >> a >> b;
  c = b - a;
  n = c*(c+1)/2;
  cout << n - b;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 998244353
#define y1 dskgj
#define y2 dskfj
#define N 310
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,z,m,q,w,h;
ll a[100500], b[100500], pre[1005000], C[205][205];
map<pair<pii,pii>,ll> f;
ll gcd(ll a, ll b)
{
    return (b==0?a:gcd(b,a%b));
}
ll Abs(ll x)
{
    return (x>0?x:-x);
}
int main() {
    //freopen("input.txt","r",stdin);
    for (i = 0; i <= 1000; i++)
        pre[i*(i+1)/2] = i+1;
    for (i = 0; i <= 200; i++)
        C[i][0] = 1;
    for (i = 1; i <= 200; i++)
        for (j = i; j <= 200; j++)
            C[j][i] = (C[j-1][i-1] + C[j-1][i])%MOD;
    ll ans = 1;
    cin >> n;
    if (n < 3)
    {
        cout << 0 << endl;
        return 0;
    }
    for (i = 1; i <= n; i++)
        ans = (ans*2)%MOD;
    ans -= n+1;
    ans -= n*(n-1)/2;
    ans += MOD;
    ans %= MOD;
    for (i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    for (i = 0; i < n; i++)
        for (j = i+1; j < n; j++)
        {
            if (a[i] == a[j])
            {
                f[mp(mp(0,a[i]),mp(MOD,MOD))]++;
                continue;
            }
            int p = a[i]-a[j];
            int q = b[i]-b[j];
            int g = gcd(Abs(p), Abs(q));
            p /= g;
            q /= g;
            if ( p < 0)
                p = -p, q = -q;
            if (p == 0 && q < 0)
                q = -q;
            int x1 = a[i], y1 = b[i], x2 = a[j], y2 = b[j];
            int xx = y1*(x2-x1)-x1*(y2-y1);
            int yy = x2-x1;
            int gg = gcd(Abs(xx), Abs(yy));
            xx /= gg;
            yy /= gg;
            if ( xx < 0)
                xx = -xx, yy = -yy;
            if (xx == 0 && yy < 0)
                yy = -yy;
            f[mp(mp(p,q),mp(xx,yy))]++;
        }
    for (auto itr = f.begin(); itr != f.end(); itr++)
    {
        int val = (*itr).Y;
        val = pre[val];
        for (j = 3; j <= val; j++)
        {
            ans -= C[val][j];
            ans += MOD;
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int count = 0;
  for (int i = 0; i < (S.size())/2; i++) {
    if (S.at(i) != S.at(S.size() - i - 1))
      count++;
  }
  
  cout << count << endl;

}


Measured memory_bytes: 3624
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)
n,m=map(int,input().split())
uni = UnionFind(n-1)

for i in range(m):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    uni.union(a,b)
t = set([])
for i in range(n):
    p = uni.find(i)
    t.add(p)
print(len(t))

Measured memory_bytes: 16784
def provjera(listaznakova):
    x = 0
    for znak in listaznakova:
        if znak == ".":
            x = x+1
    if x == len(listaznakova):
        return False
    else:
        return True
            
    
h,w = map(int,input().split())
matrica = []
matrica_dva = []
matrica_tri = []
matrica_cet = []
matrica_rez = []
red_t = []



for x in range(h):
    red=input()
    matrica.append(red)
    
for c in matrica:
    if provjera(c):
        matrica_dva.append(c)
    else:
        h-=1
    
for x in range(w):
    for y in range(h):
        red_t.append(matrica_dva[y][x])
    matrica_tri.append(red_t)
    red_t = []

for c in matrica_tri:
    if provjera(c):
        matrica_cet.append(c)
    else:
        w-=1
red_t = []

for x in range(h):
    for y in range(w):
        red_t.append(matrica_cet[y][x])
    matrica_rez.append(red_t)
    red_t = []

for x in range(h):
    print("".join(matrica_rez[x]))

Measured memory_bytes: 3188
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
using namespace std;
#define LL long long

int main() {
    int a, b;
    cin >> a >> b;
    int e = 1, cnt = 0;
    while (e < b) {
        cnt++;
        e = e + a - 1;
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
ll gcd(ll a, ll b)
{
	if (a < b) swap(a, b);
	return (a%b ? gcd(a%b, b) : b);
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b)*b;
}
ll p, q, a, n;

ll solve(ll x, ll y, ll i, ll m, ll t)
{
	if (i == n) return 0;
	int res = 0;
	FOR(j, t, 12000)
	{
		if (1.0 / j - double(x) / y>EPS) continue;
		double tmp = double(x) / y - (n - i)*(1.0) / j;
		if (j*m > a || tmp > 0) break;
		ll tq = lcm(y, j);
		ll tp = tq / y*x - tq / j;

		if (tp == 0)
		{
			res++;
		}
		else
		{
			int g = gcd(tq, tp);
			tq /= g;
			tp /= g;
			res += solve(tp, tq, i + 1, m*j, j);
		}
	}
	return res;
}

int main()
{
	while (cin >> p >> q >> a >> n, p)
	{
		cout << solve(p, q, 0, 1, 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int a, b ;
	cin >> a >> b;
	if(a>b){
		rep(i,0,a)cout << b ;
	}
	else{
		rep(i,0,b)cout << a;
	}
	
	
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,x;
  x = 0;
  cin >> N;
  for(int i = 0; i < N; i++)
  {
    int l,r;
    cin >> l >> r;
    x += r - l + 1;
  }

  cout << x << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

# level_count = dict()
# for a in A:
#     bin_a = bin(a)
#     for i in range(len(bin_a[2:])):
#         if int(bin_a[-i-1]) == 1:
#             try:
#                 level_count[i] += 1
#             except:
#                 level_count[i] = 1
# 
# sum_ = 0
# for level, count in level_count.items():
#     sum_ += 2**level * count * (N - count)
# print(sum_ % (10**9 + 7))

import numpy as np

A = np.array(A)
sum_ = 0
for i in range(len(bin(np.max(A))) - 2):
    count = np.count_nonzero(A & 1)
    sum_ += 2**i * count * (N - count)
    A >>= 1
print(sum_ % (10**9 + 7))


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

int main(){
  int n, k;
  cin >> n >> k;
  int ans = (n-k) + 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	long long a,b,c;
	scanf("%lld%lld%lld", &a,&b,&c);


	if(c-a-b <= 0)
		printf("No");
	else if(2 * a * b < c*c+a*a+b*b-2*b*c-2*a*c)
		printf("Yes");
	else
		printf("No");
	return 0;
}

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

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

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

	int64_t prod=1;
	for (int i=0;i<n;++i)
	{
		if ( 1e18L/prod < a[i] )
		{
			cout << -1 << endl;
			return 0;
		}
		prod*=a[i];
	}
	cout << prod << endl;
}







Measured memory_bytes: 3996
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

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

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

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

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    for (auto &i : a) cin >> i;
    ll ans = 0;
    sort(all(a));
    reverse(all(a));
    for (int i = k; i < n; i++) {
        ans += a[i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
void allcout(auto V) {
    for(auto x : V) cout << x << ' ';
    cout << endl;
}
int factorial[200010];
void init(int mm) {
    factorial[0] = 1;
    rep(i, 200010) factorial[i + 1] = factorial[i] * (i + 1) % mm;
}
int extgcd(int a, int b, int &x, int &y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}
int mod_inverse(int a, int mm) {
    int x, y;
    extgcd(a, mod, x, y);
    return (mod + x % mm) % mm;
}
int combination(int m, int n, int mm) {
    return factorial[m] * mod_inverse(factorial[n], mm) % mm * mod_inverse(factorial[m - n], mm) % mm;
}

map<int, int> factorization(int n) {
    map<int, int> res;
    for(int i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            int count = 0;
            while(n % i == 0) {
                n /= i;
                count++;
            }
            res[i] = count;
        }
    }
    if(n > 1) res[n] = 1;
    return res;
}
signed main() {
    int N, M;
    cin >> N >> M;
    init(mod);
    map<int, int> fac = factorization(M);
    int ans = 1;
    for(auto p : fac) {
        int c = p.S;
        ans = ans * combination(N + c - 1, c, mod) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

H,W,K=map(int,input().split())
MAP=[input().strip() for i in range(H)]

ANS=1<<30
for i in range(1<<(H-1)):
    A=[]
    for j in range(H):
        if i & (1<<j) !=0:
            A.append(j+1)
    #print(A)

    SCORE=len(A)
    B=[0]*(len(A)+1)

    for w in range(W):
        ind=0
        for i in range(H):           
            if ind<len(A) and i==A[ind]:
                ind+=1
            if MAP[i][w]=="1":
                B[ind]+=1

        #print(A,w,B,SCORE)
        if max(B)>K:
            SCORE+=1
            B=[0]*(len(A)+1)
            ind=0

            for i in range(H):           
                if ind<len(A) and i==A[ind]:
                    ind+=1
                if MAP[i][w]=="1":
                    B[ind]+=1

        #print(A,w,B,SCORE)
        if max(B)>K:
            break
    else:
        ANS=min(ANS,SCORE)

print(ANS)

Measured memory_bytes: 47580
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

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

    if(B > N) {
        cout << A * N / B << endl; 
    }  else {
        cout << A * (B - 1) / B;
    }

    return 0;
}

Measured memory_bytes: 3580
use proconio::input;
use std::collections::HashMap;
use MyEither::{IsPrime, NotPrime, Undecided};

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let limit = 1000000;
    let m = 1000000007;
    let mut map = HashMap::new();
    let sieve = make_sieve(limit);

    for &na in &a {
        let tmp = prime_factorize_fast(na, &sieve);
        for (&key, &value) in &tmp {
            let count = map.entry(key).or_insert(0);
            if *count < value {
                *count = value;
            }
        }
    }

    let mut lcm = 1usize;
    for (key, value) in &map {
        let mut tmp = 1;
        for _ in 0..*value {
            tmp = tmp * key % m;
        }
        lcm = lcm * tmp % m;
    }

    let mut ans = 0usize;
    for &na in &a {
        ans = ans + lcm * modinv(na as isize, m as isize) as usize % m;
        ans %= m;
    }

    println!("{}", ans);
}

#[derive(Clone, Copy, PartialEq)]
enum MyEither<T> {
    IsPrime,
    NotPrime(T),
    Undecided,
}

fn make_sieve(limit: usize) -> Vec<MyEither<usize>>{
    let mut sieve: Vec<MyEither<usize>> = vec![Undecided; limit + 1];
    let mut num = 2;

    while num <= limit {
        if sieve[num] == Undecided {
            sieve[num] = IsPrime;
            let mut tmp = num * num;
            while tmp <= limit {
                sieve[tmp] = match &sieve[tmp] {
                    Undecided => NotPrime(num),
                    n => *n,
                };
                tmp += num;
            }
        }
        num += 1;
    }
    sieve
}


fn prime_factorize_fast(mut n: usize, sieve: &Vec<MyEither<usize>>) -> HashMap<usize, usize> {
    let mut res = HashMap::new();

    while sieve[n] != IsPrime {
        match &sieve[n] {
            NotPrime(num) => {
                let entry = res.entry(*num).or_insert(0);
                *entry += 1;
                n = n / *num;
            }
            _ => break,
        }
    }
    if n != 1 {
        let entry = res.entry(n).or_insert(0);
        *entry += 1;
    }

    res
}

fn prime_factorize(mut n: usize) -> Vec<(usize, usize)> {
    let mut res = vec![];
    let mut a = 2;
    while a * a <= n {
        if n % a != 0 {
            a += 1;
            continue;
        }
        let mut ex = 0;

        while n % a == 0 {
            ex += 1;
            n /= a;
        }

        res.push((a, ex));
        a += 1;
    }
    if n != 1 {
        res.push((n, 1));
    }

    res
}

use std::mem;

fn modinv(mut a: isize, m: isize) -> isize {
    let mut b: isize = m;
    let mut u: isize = 1;
    let mut v = 0;

    while b != 0 {
        let t = a / b;
        a -= t * b;
        mem::swap(&mut a, &mut b);
        u -= t * v;
        mem::swap(&mut u, &mut v);
    }

    u %= m;

    if u < 0 {
        u += m;
    }
    u
}


Measured memory_bytes: 18460
function Main(input) {
    var NKA = input.split('\n')
    var NK = NKA[0].split(' ')
    var N = parseInt(NK[0], 10)
    var K = parseInt(NK[1], 10)
    var A = NKA[1].split(' ').map(v => parseInt(v, 10))

    console.log(Math.ceil((N - 1) / (K - 1)));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 16716
#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>;
const int MAX = 1000;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
//setprecision(15)

int main() {
	int H, A; cin >> H >> A;
	int ans = H / A;
	if (H % A != 0) ans++;
	cout << ans << endl;
}

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

int main() {
	string s="    ";
	for(int i = 0;i < 4;i++)
	{
		cin >> s.at(i);
	}
	sort(s.begin(),s.end());
	string k = "NO";
	if(s == "1479")
	{
		k = "YES";
	}
	cout << k <<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int n;
    cin >> n;
    if(n % 111 == 0) cout << n << endl;
    else{
        int tmp = n / 111 + 1;
        cout << tmp * 111 << endl;
    }
    return 0;
}


Measured memory_bytes: 256