akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int color[100000];
vector<int> e[100000];
int t[100000];


void paint(int v,int d,int c){
    if(!color[v]) color[v]=c;
    if(d<=t[v]||d==0) return;
    t[v]=d;
    for(int i=0;i<e[v].size();i++){
        paint(e[v][i],d-1,c);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        a--,b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    int Q;
    cin >> Q;
    int v[Q],d[Q],c[Q];
    for(int i=0;i<Q;i++){
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }
    memset(t,-1,sizeof(t));
    for(int i=Q-1;i>=0;i--){
        if(t[v[i]]>=d[i]) continue;
        paint(v[i],d[i],c[i]);
    }
    for(int i=0;i<N;i++){
        cout << color[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 8440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    string S;
    cin >> S;
    bool ret = true;
    int itr = 0;
    reverse(S.begin(),S.end());
    while(itr < S.size()) {
        string str = S.substr(itr,5);
        if(str == "maerd" || str == "esare") {
            itr += 5;
            continue;
        }
        else {
            str = S.substr(itr,6);
            if(str == "resare") {
                itr += 6;
                continue;
            }
            else {
                str = S.substr(itr,7);
                if(str == "remaerd") {
                    itr += 7;
                    continue;
                }
            }
        }
        ret = false;
        break;
    }
    if(ret == true) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

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

vector<vector<int> > S;
vector<int> A;

int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];
    vector<int> A(N);
    rep(i, N) A[i] = i+1;

    map<vector<int>, int> mp;
    do {
        mp[A] = mp.size();
    } while (next_permutation(A.begin(), A.end()));

    int ans = abs(mp[P]-mp[Q]);
    cout << ans << endl;
    return 0;
}

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

int main()
{
	long long int a,b,c,d;
	cin>>a>>b>>c>>d;
	long long int p,q,r;
	if(a%c!=0)
	{
		p=-a/c+b/c;
	}
	else if(a%c==0)
	{
		p=-a/c+b/c+1;
	}
	if(a%d!=0)
	{
		q=-a/d+b/d;
	}
	else if(a%d==0)
	{
		q=-a/d+b/d+1;
	}
	long long int y=(c*d)/(__gcd(c,d));
	//cout<<y<<endl;
	if(a%y!=0)
	{
		r=-a/y+b/y;
	}
	else if(a%y==0)
	{
		r=-a/y+b/y+1;
	}
	//cout<<p<<" "<<q<<" "<<r<<endl;
	cout<<(b-a+1)-p-q+r;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int a, b; cin >> a >> b;
  if((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
  else cout << "IMPOSSIBLE\n";
  return;
}

int main(){
  solve();
  return 0;
}


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

int main()
{
    int n, m;
    bool t = true;
    cin >> n;
    m = n;
    while(cin >> n){
        if(m >= n){ t = false; break; }else{ m = n; }
    };
    if(t){ cout << "Yes"; }else{ cout << "No"; }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1156
N,K = map(int,input().split())
H = list(map(int,input().split()))

#print(N)
#print(K)
#print(H)

# Hをソートする
H_SORT = sorted(H, reverse=True)

#print(H_SORT)
#del H_SORT[0:K]
#print(H_SORT)
if K >=N:
    print(0)
else:
    del H_SORT[0:K]
    SUM = 0
    for j in range(len(H_SORT)):
        SUM += H_SORT[j]

    print(SUM)

Measured memory_bytes: 26024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL A[3][3],a[3][3],N,i,j,k,ans=0;
  FOR(i,0,3){
    scanf("%lld%lld%lld",&A[i][0],&A[i][1],&A[i][2]);
    a[i][0]=0,a[i][1]=0,a[i][2]=0;
  }
  scanf("%lld",&N);
  LL b[N];
  FOR(i,0,N)scanf("%lld",&b[i]);
  FOR(i,0,N)FOR(j,0,3)FOR(k,0,3){
    if(A[j][k]==b[i])a[j][k]=1;
  }
  FOR(i,0,3){
    if(a[i][0]==1&&a[i][1]==1&&a[i][2]==1)ans=1;
    if(a[0][i]==1&&a[1][i]==1&&a[2][i]==1)ans=1;
  }
  if(a[0][0]==1&&a[1][1]==1&&a[2][2]==1)ans=1;
  if(a[2][0]==1&&a[1][1]==1&&a[0][2]==1)ans=1;
  YN(ans);

  //printf("%lld\n",dup(N,2));
	return 0;
}


Measured memory_bytes: 128
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
S = list(input())

goal = sorted(S)

ans = 0
for i in range(N):
    if S[i] != goal[i]:
        ans += 1
print(ans // 2)

Measured memory_bytes: 13188
#include<bits/stdc++.h>
#define LL long long
#define RG register
#define R RG int
#define G if(++ip==ie)fread(ip=buf,1,SZ,stdin)
using namespace std;
const LL SZ=1<<19,N=1e5+9,M=1e10,S=2155;
char buf[SZ],*ie=buf+SZ,*ip=ie-1;
bool f[S];LL pr[S];
struct Data{LL ant;int cnt;};
map<LL,Data>mp;
inline LL in(){
	G;while(*ip<'-')G;
	RG LL x=*ip&15;G;
	while(*ip>'-'){x*=10;x+=*ip&15;G;}
	return x;
}
int main(){
	R n=in(),p=0,cnt,ans=0;
	RG LL a,b,c,l;
	for(R i=2;i<S;++i){
		if(f[i])continue;
		pr[++p]=i;
		for(R j=i*i;j<S;j+=i)f[j]=1;
	}
	for(R i=1;i<=n;++i){
		a=in();b=c=1;l=sqrt(a);
		for(R j=1;j<=p&&pr[j]<=l;++j){
			if(a%pr[j])continue;
			for(cnt=0;!(a%pr[j]);a/=pr[j],++cnt);
			if((cnt%=3)&1)b*=pr[j],c*=pr[j]*pr[j];
			else if(cnt&2)c*=pr[j],b*=pr[j]*pr[j];
			l=sqrt(a);
		}
		if(a!=1){
			if(l*l==a)b*=a,c*=l;
			else b*=a,c*=a*a;
		}
		if(c<=M)++mp.insert(make_pair(b,(Data){c,0})).first->second.cnt;
		else ++ans;
	}
	if(mp[1].cnt)++ans;mp.erase(1);
	for(map<LL,Data>::iterator it=mp.begin();it!=mp.end();it=mp.begin()){
		ans+=max(it->second.cnt,mp[c=it->second.ant].cnt);
		mp.erase(it);mp.erase(c);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6016
#include <iostream>
int h,n;
using namespace std;
int main(){
  cin>>h>>n;
  if(h>=n){
    for(int i=0;i<h;++i){
      cout<<n;
    }
  }
  else{
    for(int i=0;i<n;++i){
      cout<<h;
    }
  }
  
 
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int V = sc.nextInt();
		long[] x = new long[N];
		for (int i = 0; i < N; ++i) {
			x[i] = sc.nextLong();
		}

		int cnt = 0;
		int tmp = V;
		while (tmp > 0) {
			++cnt;
			tmp /= 2;
		}
		++cnt;
		int[] Vs = new int[cnt];
		Vs[0] = V;
		for (int i = 1; i < cnt; ++i) {
			Vs[i] = Vs[i - 1] / 2;
		}
		int[][] toRight = new int[cnt][N];
		int[][] toLeft = new int[cnt][N];
		for (int i = 0; i < cnt; ++i) {
			for (int j = 0; j < N; ++j) {
				toRight[i][j] = j;
				toLeft[i][j] = j;
			}
		}
		for (int i = 0; i < cnt; ++i) {
			for (int j = N - 2; j >= 0; --j) {
				if (x[j + 1] - x[j] <= Vs[i]) {
					toRight[i][j] = toRight[i][j + 1];
				}
			}
		}

		for (int i = 0; i < cnt; ++i) {
			for (int j = 1; j < N; ++j) {
				if (x[j] - x[j - 1] <= Vs[i]) {
					toLeft[i][j] = toLeft[i][j - 1];
				}
			}
		}
		int[] dpRight = new int[1 << cnt];
		int[] dpLeft = new int[1 << cnt];

		Arrays.fill(dpLeft, N);
		Arrays.fill(dpRight, -1);

		for (int i = 0; i < (1 << cnt); ++i) {
			for (int nxt = 0; nxt < cnt; ++nxt) {
				if ((i & (1 << nxt)) > 0) {
					continue;
				}
				int ni = i | (1 << nxt);
				dpRight[ni] = Math.max(dpRight[ni], dpRight[i]);
				if (dpRight[i] + 1 < N)
					dpRight[ni] = Math.max(dpRight[ni], toRight[nxt][dpRight[i] + 1]);
			}
		}
		for (int i = 0; i < (1 << cnt); ++i) {
			for (int nxt = 0; nxt < cnt; ++nxt) {
				if ((i & (1 << nxt)) > 0) {
					continue;
				}
				int ni = i | (1 << nxt);
				dpLeft[ni] = Math.min(dpLeft[ni], dpLeft[i]);
				if (dpLeft[i] - 1 >= 0)
					dpLeft[ni] = Math.min(dpLeft[ni], toLeft[nxt][dpLeft[i] - 1]);
			}
		}
		int[] ans = new int[N];
		for (int i = 0; i < (1 << cnt); i += 2) {
			int co = ((1 << cnt) - 1) ^ i;
			co -= 1;
			if (dpLeft[co] - dpRight[i] <= 1) {
				Arrays.fill(ans, 1);
				break;
			}
			if (dpLeft[co] - toRight[0][dpRight[i] + 1] <= 1) {
				++ans[toLeft[0][dpLeft[co] - 1]];
				if (toRight[0][dpRight[i] + 1] + 1 < N) {
					--ans[toRight[0][dpRight[i] + 1] + 1];
				}
			}
		}

		for (int i = 1; i < N; ++i) {
			ans[i] += ans[i - 1];
		}

		for (int i = 0; i < N; ++i) {
			if (ans[i] > 0) {
				System.out.println("Possible");
			} else {
				System.out.println("Impossible");
			}
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 133488
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
// #define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
// const int INF = 1e12;

int n, z, w;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> z >> w;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    cout << max(abs(w-a[n-1]),(n != 1 ? abs(a[n-1]-a[n-2]) : 0)) << endl;
}

Measured memory_bytes: 256
constexpr bool isDebugMode = false;
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
    #include <atcoder/all>
    using namespace atcoder;
#endif
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

ll gv;
ll op(ll u, ll v) { return max(u, v); };
ll e() { return -INF; }
bool f(ll x) { return x < gv; }

int main(){
    ll N, Q; cin >> N >> Q;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    vector<ll> ans;
    segtree<ll ,op, e> seg(a);
    rep(i, Q){
        ll q; cin >> q;
        if(q == 1){
            ll x, v; cin >> x >> v;
            seg.set(--x, v);
        }else if(q == 2){
            ll x, v; cin >> x >> v;
            ans.push_back(seg.prod(--x, v));
        }else{
            ll x, v; cin >> x >> v;
            gv = v;
            ans.push_back(seg.max_right<f>(--x) + 1);
        }
    }
    for(auto e : ans) pt(e);
    return 0;
}

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

int main() {
    int X, N;
    cin >> X >> N;
    int p[N];
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    int j = 0;
    while (true) {
        bool found_plus = false;
        bool found_minus = false;
        for (int i = 0; i < N; i++) {
            if (X + j == p[i]) {
                found_plus = true;
                break;
            }
        }
        for (int i = 0; i < N; i++) {
            if (X - j == p[i]) {
                found_minus = true;
                break;
            }
        }
        if (!found_minus) {
            cout << X - j << endl;
            break;
        }
        if (!found_plus) {
            cout << X + j << endl;
            break;
        }
        j++;
    }

}

Measured memory_bytes: 3616
# 解説

def main():
    N = int(input())

    ans = 0
    for div in range(1, N + 1):
        m = N // div  # div, div*2, ..., div*m
        ans += (m * (m + 1) // 2) * div
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9148
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
ll power(ll a,ll n){
  ll res = 1,r = a;
  for (; n > 0;n>>=1,r*=r) res *= (n & 1? r:1);
  return res;
}
int main(){
  ll n,p;
  cin >> n >> p;
  ll ans = 1;
  if(n==1) {
    cout << p << endl;
  }else if(n>=40){
    cout << 1 << endl;
  } else{
    ll i = 1;
    for(;power(i,n)<=p;++i){
      ll tmp = power(i,n);
      if(p%tmp==0) ans = i;
    }
    cout << ans << endl;
  }
  
}


Measured memory_bytes: 256
n = gets.chomp.to_i
answer = 0
(1..n).each do |num|
  if num.even?
    next
  end
  dividor = 0
  (1..num).each do |num2|
    dividor += 1 if num % num2 == 0
  end
  answer += 1 if dividor == 8
end
puts answer

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

using namespace std;

int main() {
  int H, W;
  scanf("%d %d", &H, &W);
  while (H || W) {
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d %d", &H, &W);
  }
  return 0;
}



Measured memory_bytes: 3148
N=input().split()
LIST=input().split()
FLUG=0

for num in LIST:
  if int(num)%2==0 and int(num)%3!=0 and int(num)%5!=0 :
    FLUG=1

if FLUG==0 :
  print("APPROVED")
else :
  print("DENIED")

Measured memory_bytes: 2940
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		StringBuilder A = new StringBuilder();
		StringBuilder B = new StringBuilder();
		for (int i = 0; i < b; i++) A.append(a);
		for (int i = 0; i < a; i++) B.append(b);
		System.out.println(a < b ? A : B);
	}
}

Measured memory_bytes: 23764
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
 
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <time.h>
#include <stack>
#include <bitset>

#define prev asasddlsa
#define rank aljds

#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i++)
 
using namespace std;
 
typedef long long ll;
typedef long double dbl;
 
template<typename T>
void print(const vector<T>& s){
    for (auto x : s)
        cout << x << ' ';
    cout << endl;
}
 
template<class T>   
void print(const T* s, int n){
    for (int i = 0; i < n; i++)
        cout << s[i] << ' ';
    cout << endl;
}
 
template<class T>
void print(vector<vector<T>> s){
    for (int i = 0; i < s.size(); i++)
        print(s[i]);
}

void solve(){
    int n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<int> s(n);
    for (int i = 0; i < n; i++)
        cin >> s[i];
    sort(s.begin(), s.end());
    int l = -1, r = n - 1;
    while (l + 1 < r){
        int med = (l + r) / 2;
        ll summa = 0, cnt = 0;
        bool ok = true;
        for (int i = med + 1; i < n - p + 1; i++){
            if (s[i] > s[med] + m){
                ok = false;
                break;
            }
            summa += s[med] + m - s[i];
            cnt++;
        }
        if (ok && summa >= (ll)m * max(0, v - med - 1 - p + 1))
            r = med;
        else
            l = med;
    }
    cout << n - r << '\n';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int ct[3]={};
	int n, a, b; cin>>n>>a>>b;
	for(int i=0; i<n; i++){
		int p; cin>>p;
		if(p<=a) ct[0]++;
		else if(p<=b) ct[1]++;
		else ct[2]++;
	}
	sort(ct, ct+3);
	cout<<ct[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <random>
#include <chrono>
// }}}

// debug(...) {{{
#ifdef LOCAL_DEBUG
#include "./debug.h"
#else
bool debug_enabled = false;
#define debug(...)
#define debugn(...)
#define debug_reset()
#endif

#include <cstdio>

template<class T>
std::string bin(int bits, const T& x) {
  char buf[bits + 1];
  buf[bits] = '\0';
  for(int i = 0; i < bits; i++) {
    if((x >> i) & 1) {
      buf[bits - i - 1] = '1';
    } else {
      buf[bits - i - 1] = '0';
    }
  }
  return std::string(buf);
}
std::string bin(int x) {
  if(x < 0) return bin(32, x);
  for(int i = 4; i < 31; i++) {
    int y = 1 << i;
    if(x < y) return bin(i, x);
  }
  return bin(32, x);
}
// }}}

// misc {{{
using namespace std;
template<class T, class U>

using umap = unordered_map<T, U>;
template<class T>
using uset = unordered_set<T>;

typedef long long ll;

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

template<class T>
void sort(T& arr) {
  std::sort(arr.begin(), arr.end());
}
template<class T, class By>
void sort_by(T& arr, By by) {
  std::sort(arr.begin(), arr.end(), [by](auto l, auto r){return  by(l) < by(r); });
}

template<class T>
void reverse(T& arr) {
  std::reverse(arr.begin(), arr.end());
}

class Random {
  public:
  std::uniform_int_distribution<> uniform_int;
  std::mt19937 rnd;
  std::bernoulli_distribution bern_dist;
  int uniform(int l, int r) {
    return uniform_int(rnd, std::uniform_int_distribution<>::param_type(l, r));
  }
  int next(int N) {
    return uniform(0, N - 1);
  }
  int bern(double p) {
    return bern_dist(rnd, std::bernoulli_distribution::param_type(p));
  }
};

template <class A>
ostream& out_vec(const vector<A>& x, const string& sep) {
  rep(i, x.size()) {
    cout << x[i];
    if(i < x.size() - 1)
      cout << sep;
  }
  return cout;
}
// }}}

// main {{{
void solve();
int main() {
  cout << setprecision(20);
  solve();
}
// }}}

void solve() {
  ll A, B;
  cin >> A >> B;
  if(A < B) swap(A, B);

  function<ll(ll, ll)> gcd = [&](ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a % b);
  };

  ll x = gcd(A, B);

  int sum = 1;
  for(ll i = 2; i * i <= x; i++) {
    if(x % i != 0) continue;
    sum++;
    while(x % i == 0) {
      x /= i;
    }
  }
  if(x != 1) sum++;

  cout << sum << endl;
}


Measured memory_bytes: 888
//TO CHANGE THE WORLD
#include <bits/stdc++.h>

using namespace std;

#define L first
#define R second
//#define int ll
typedef long long ll;

const int maxn=2e5+10, maxx=2000+10, mod=1e9+7, inv2=(mod+1)/2;
int dp[2*maxx][2*maxx], a[maxn], b[maxn], c[4*maxx][2*maxx], n;
int calcc(int n, int m)
{
    if(c[n][m]!=-1) return c[n][m];
    if(n==m) return c[n][m]=1;
    if(m==0) return c[n][m]=1;
    return c[n][m]=(1LL*calcc(n-1,m)+calcc(n-1,m-1))%mod;
}
main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    memset(c,-1,sizeof c);
    cin>>n;
    for(int i=0; i<n; i++) cin>>a[i]>>b[i], dp[maxx-a[i]][maxx-b[i]]++;
    for(int x=2; x<2*maxx; x++)
	for(int y=2;y<2*maxx;y++)
	    dp[x][y]=(1LL*dp[x][y]+dp[x-1][y]+dp[x][y-1])%mod;
    int sum=0, mi=0;
    for(int i=0; i<n; i++) sum=(1LL*sum+dp[maxx+a[i]][maxx+b[i]])%mod, mi=(1LL*mi+calcc(2*a[i]+2*b[i],2*min(a[i],b[i])))%mod;
    cout<<((1LL*sum-mi+mod)%mod*inv2*1LL)%mod<<endl;
}

Measured memory_bytes: 191616
//
// author  : Abhishek
//
#include <bits/stdc++.h>
#include<chrono>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;
using namespace chrono;

const ll MOD = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

void print(vector<pair<ll, ll> > v) {
    ll i;
    fo(i, v.size()) {
        cout << v[i].first << " " << v[i].second << "\n";
    }
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t = 1;
//    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;

        cin >> n >> m;

        vector<bool> done(n + 1, 0);
        vector<bool> ac(n + 1, 0);
        vector<ll> pen(n + 1, 0);

        fo(i, m) {
            string str;
            cin >> p >> str;

            done[p] = 1;
            if (!ac[p]) {
                if (str == "AC") {
                    ac[p] = 1;
                } else {
                    pen[p]++;
                }
            }

        }

        ll ansCt = 0, penCt = 0;
        Fo(i, 1, n + 1) {
            if (ac[i]) {
                ansCt++;
                penCt += pen[i];
            }

        }
        cout << ansCt << " " << penCt;
    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif

    auto start = high_resolution_clock::now();

    solve();

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() / 1000.0 << endl;
#endif


    return 0;
}




Measured memory_bytes: 4040
import math
jishin, hunshin, hour, minute = map(float, input().split())

x_ji = jishin * math.cos(math.radians((hour + minute / 60) * 360 / 12))
y_ji = jishin * math.sin(math.radians((hour + minute / 60) * 360 / 12))
x_hun = hunshin  * math.cos(math.radians(minute * 360 / 60))
y_hun = hunshin  * math.sin(math.radians(minute * 360 / 60))

kyori = math.sqrt((x_ji - x_hun) ** 2 + (y_ji - y_hun) ** 2)
print(kyori)


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

int main() {
    string S; cin >> S;
    if(S == "Sunny") cout << "Cloudy" << endl;
    else if(S == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e4;
const long inf=1e9;
int main(){
	int N,M;cin>>N>>M;
    int A[M];char B[M];
    rep(i,0,M){ cin>>A[i]>>B[i]; A[i]--; }
    int a,b;
    if(N==1){ a=0;b=10;}
    else if(N==2){ a=10;b=100; }
    else{ a=100;b=1000; }
    rep(i,a,b){
        string s=to_string(i);
        bool flag=true;
        rep(j,0,M){
            if(s[A[j]]!=B[j]) flag=false;
        }if(flag){
            cout<<i<<endl;
            return 0;
        }
    }cout<<-1<<endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
ad = 0
mod = 10 **9 + 7
for k in range(K,N+2):
  ma = (N*(N+1) - (N-k)*(N-k+1))//2
  mi = (k-1)*k//2
  ad += (ma - mi+1)
print(ad%mod)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    LL(n,a,b);
    vector<ll> vec(n),dp(n,0);
    in(vec);
    dp[0]=0;
    for(int i=1;i<n;i++){
        dp[i]=dp[i-1]+min((vec[i]-vec[i-1])*a,b);
    }
    out(dp[n-1]);
}

Measured memory_bytes: 4820
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int ans = 0;
	string S;
	cin >> S;
	for (int n = 0; n < 3; n++) {
		if (S[n] == '1')ans++;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3116
/*
tarun360
IIT Indore
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define forn_s(i,start,lim) for(ll_s i=start;i<lim;i++)
#define forn_d_s(i,start,lim) for(ll_s i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define debug1(a) cout<<a<<endl
#define debug2(a,b) cout<<a<<" "<<b<<endl
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define debug4(a) cout<<"chu "<<a<<endl

ll a[305];
double dp[305][305][305];

double fn(ll c1,ll c2,ll c3,ll n){
  if(c1<0 || c2<0 || c3<0) return 0.0;
  else if(c1==0 && c2==0 && c3==1) return (double)3*n;
  else if(c1==0 && c2==1 && c3==0) return (double)2*n;
  else if(c1==1 && c2==0 && c3==0) return (double)n;
  else if(dp[c1][c2][c3]!=-1) return dp[c1][c2][c3];
  double ans;
  ans=(double)(n + fn(c1-1,c2,c3,n)*c1 + fn(c1+1,c2-1,c3,n)*c2 + fn(c1,c2+1,c3-1,n)*c3)/(c1+c2+c3);
  return dp[c1][c2][c3]=ans;
}

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n,c1=0,c2=0,c3=0;
  cin>>n;
  forn(i,0,n+2){
    forn(j,0,n+2){
      forn(k,0,n+2)
        dp[i][j][k]=-1;
    }
  }
  forn(i,1,n+1) {
    cin>>a[i];
    if(a[i]==1) c1++;
    else if(a[i]==2) c2++;
    else c3++;
  }
  double ans=fn(c1,c2,c3,n);
  cout<<fixed<<setprecision(10)<<ans<<endl;
  return 0;
}


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

void dump(vector<int> d)
{
  rep(i, d.size())
  {
    printf("%d ", d[i]);
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i, N)
  {
    cin >> d[i];
  }

  // cout << N
  //      << endl;
  // dump(d);

  int total = 0;
  rep(i, N)
  {
    rep(j, N)
    {
      if (j == i)
        continue;
      total += d[i] * d[j];
    }
  }
  cout << total / 2 << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a[1000],i,cnt=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n,greater<int>());
	for(i=0;i<n;i++){
		if(a[i]!=a[i+1]){
			cnt++;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std::chrono;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
#define pb push_back
#define int long long
#define ios std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define fill(x, v) memset(x, v, sizeof(x))
const ll mod = 1000000007;
const double pi = 3.14159265359; // PI
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
/*
std::cout << std::setprecision(9) << f << '\n';//3.141590000;
map<char,int>::reverse_iterator rit;
for(rit = mp.rbegin(); rit!=mp.rend(); rit++)
    auto start = high_resolution_clock::now();
    // Call the function, here
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<milliseconds>(stop - start);
    cout << "Time taken by function: "<< duration.count() << " milliseconds" << endl;
*/

int32_t main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}


Measured memory_bytes: 3592
import itertools
import math
n,a,b = map(int,input().split())

mod = 10**9+7

def comb(n, r):
    ans = 1
    for i in range(r):
        ans = ans * (n-i) * pow(i+1, mod-2, mod) % mod
    return ans

print((pow(2, n, mod)-1-comb(n,a)-comb(n,b)) % mod)



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

#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)

#define ii pair<int, int>
#define mp make_pair
#define FF first
#define SS second

#define vi vector<int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>

#define eb emplace_back
#define ef emplace_front
#define lb lower_bound
#define sz(a) (int)a.size()

#define oo 1000000007LL
#define OO 1000000000000000007LL

using namespace std;

#define Pro "tmp"
#define maxN 200007

bool visited[maxN];
int step[maxN];

vii adj[maxN];

void DFS(int u) {
    visited[u] = 1;
    fto (i, 0, (int)adj[u].size()-1) {
        int v = adj[u][i].FF;
        int w = adj[u][i].SS;

        if (!visited[v]) {
            step[v] = step[u]+w;
            DFS(v);
        }
        else if (step[v] != step[u]+w) {
            puts("No");
            exit(0);
        }
    }
    return;
}

int main() {
    int n, m;
    scanf("%d%d", &n, &m);

    fto (i, 1, m) {
        int l, r, d;
        scanf("%d%d%d", &l, &r, &d);
        adj[l].eb(r, d);
        adj[r].eb(l, -d);
    }

    fto (i, 1, n) {
        if (visited[i]) continue;
        DFS(i);
    }

    puts("Yes");
    return 0;
}


Measured memory_bytes: 14464
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  int n;
  cin >> n;
  vector<int> x,y;
  double ansx2,ansy2;
  REP(i,n){
    int tmp;
    cin >> tmp;
    x.push_back(tmp);
    cin >> tmp;
    y.push_back(tmp);
  }
  REP(i,n){
    bool flag=true;
    ansx2=x[0]+x[i];
    ansy2=y[0]+y[i];
    REP(j,n){
      bool tmpflag=false;
      REP(k,n){
	if(x[j]+x[k]==ansx2 && y[j]+y[k]==ansy2){
	  tmpflag=true;
	  break;
	}
      }
      if(!tmpflag){
	flag=false;
	break;
      }
    }	
    if(flag){
      ansx2/=2.0;
      ansy2/=2.0;
      cout << fixed << setprecision(1) << ansx2 << ' ' << ansy2 << endl;
      return 0;
    }
  }
  cout << "NA" << endl;
  return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);


    int n, m;
    cin >> n >> m;

    ll sum = 0;

    for(int i = 0; i < m; i++) {
        ll a;
        cin >> a;
        sum += a;
    }

    cout << max(-1LL, n - sum);
}









Measured memory_bytes: 3660
fun solve(H:Int, A:Int) {
    var ans = H / A
    if (H % A > 0) {
        ans += 1
    }
    println(ans)
}

fun main() {
//    val S = readLine()!!
//    val N = readLine()!!.toInt()
    val (H, A) = readLine()!!.split(" ").map { it.toInt() }
//    val A = readLine()!!.split(" ").map { it.toInt() }
    solve(H, A)
}

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

int main()
{
    string s;
    cin >> s;
    for(int i= 0; i< s.length();i++)
    {
        if(s[i] == 'A' && s[i+1] == 'C') 
         {
            cout << "Yes" << endl;
            break;
         }
        else if (i==s.length()-1) cout << "No" << endl;
    }

    
    return 0;
}

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

int main() {
    long n, ac = 0, wa = 0, tle = 0, re = 0;
    string s;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s;
        if(s == "AC"){
            ac++;
        }else if(s == "WA"){
            wa++;
        }else if (s == "TLE"){
            tle++;
        }else{
            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: 3628
//package Atcoder;

import java.util.*;
import java.io.*;
public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		char arr[]=fs.next().toCharArray();
		char second[]=fs.next().toCharArray();
		int min=inf;
		for(int i=0;i<=arr.length-second.length;i++)
		{
			int cnt=0,index=0;
			for(int j=i;j<=i+second.length-1;j++)
			{
				if(arr[j]!=second[index])
				{
					cnt++;
				}
				index++;
			}
			min=Math.min(min,cnt);
		}
		System.out.println(min);
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

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

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

void dfs(int x, int y, vector<vector<bool> >& map){
    map[y][x] = false;
    for(int i=0; i<8; i++){
        if(map[y+dy[i]][x+dx[i]]){
            dfs(x+dx[i], y+dy[i], map);
        }
    }
}

int main(){
    while(1){
        int W,H;
        cin >> W >> H;
        if(W==0) break;

        vector<vector<bool> > map(H+2, vector<bool>(W+2,false));
        for(int y=1; y<=H; y++){
            for(int x=1; x<=W; x++){
                char tmp;
                cin >> tmp;
                if(tmp == '0'){
                    map[y][x]=false;
                }else{
                    map[y][x]=true;
                }
            }
        }

        int num=0;
        for(int y=1; y<=H; y++){
            for(int x=1; x<=W; x++){
                if(map[y][x]){
                    num++;
                    dfs(x,y,map);
                }
            }
        }
        cout << num << endl;
    }
    return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <climits>
#define MAX_N 400000
using namespace std;
int min(int a, int b){
  return a < b ? a : b;
}
int main(void){
  int n, T;
  int t[MAX_N];
  long long int ans = 0;
  cin >> n >> T;
  for(int i = 0; i < n; i++) cin >> t[i];
  t[n] = INT_MAX;
  for(int i = 0; i < n; i++) ans += min(T, t[i+1]-t[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
A_sorted = sorted(A)


class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)

    def reset(self):
        self.bit = [0] * (self.size + 1)


BIT = BinaryIndexedTree(2 * N + 1)  # N+1番目が真ん中
target = (N * (N+1)) // 4

# にぶたん
l, r = -1, 10**9+1
if N == 1:
    print(A[0])
    exit()
while r - l > 1:
    X = (r + l) // 2
    Binary = [(1 if a > X else -1) for a in A]
    Binary = list(accumulate(Binary))

    BIT.reset()

    inversion = 0

    for j in range(N):
        inversion += BIT.sum(Binary[j] + N + 1) + (Binary[j] >= 0)
        BIT.add(Binary[j] + N + 1, 1)

    #print(X, inversion, Binary)
    if inversion >= target:
        l = X
    else:
        r = X

#print(X, inversion)
print(r)


Measured memory_bytes: 121196
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {

	int x;
	cin >> x;
	int y=x;
	
	while(1) {
		if (x == 2) {
			cout << 2 << endl;
			return 0;
		}
		for (int i=2; i<x; i++) {
			if (y % i == 0) {
				break;
			}
			if (i == x-1) {
				cout << y << endl;
				return 0;
			}
		}
		y += 1;
	}

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,ss;
  while(cin >>s){
    ss = s;
    bool f = true;
    for(int i=0; i<10; i++){
      for(int j=0; j<s.size(); j++){
    if(s[j] == 'X'){ss[j] = i+'0';}
    else{ss[j] = s[j];}
      }
      string a,b,c,d;
      int pos_add = ss.find('+');
      int pos_equ = ss.find('=');
      a = ss.substr(0,pos_add);
      b = ss.substr(pos_add+1,pos_equ-pos_add-1);
      c = ss.substr(pos_equ+1,ss.size());
      int as = a.size(), bs = b.size();
      int alls = max(as,bs);
      int x = 0;
      for(int j=0; j<alls; j++){
    if(j<as && j<bs){x+=a[as-j-1]+b[bs-j-1]-'0'*2;}
    else if(j<as){x+=a[as-j-1]-'0';}
    else if(j<bs){x+=b[bs-j-1]-'0';}
    d = (char)(x%10+'0')+d;
    x/=10;
      }
      if(x){d = (char)(x%10+'0')+d;}
      if(d == c){cout <<i<<endl;f = false;break;}
    }
    if(f){cout <<"NA"<<endl;}
  }
  return 0;
}

Measured memory_bytes: 3080
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct edge{
	int t,next;
}g[10001];
int a[5001],h[5001],tot,f[5001],i,j,k,n,m;
void addedge(int x,int y){
	g[++tot].t=y;g[tot].next=h[x];h[x]=tot;
	g[++tot].t=x;g[tot].next=h[y];h[y]=tot;
}
void work(int x,int fa){
	int i;
	f[x]=0;
	for (i=h[x];i;i=g[i].next)
	 if (g[i].t!=fa){
	 	work(g[i].t,x);
	 	if (a[x]>a[g[i].t]&&!f[g[i].t]) f[x]=1;
	 }
}
int main(){
	scanf("%d",&n);tot=0;memset(h,0,sizeof(h));
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=1;i<n;i++) scanf("%d%d",&j,&k),addedge(j,k);
	for (i=1;i<=n;i++){
		work(i,0);
		if (f[i]) printf("%d ",i);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int m,f,b;
	scanf("%d %d %d",&m,&f,&b);
	if(m>=b){
		printf("0\n");
	}
	else if(m+f<b){
		printf("NA\n");
	}
	else{
		printf("%d\n",b-m);
	}
	return 0;
}


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

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int INF = 1e8;

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

	int N;
	cin >> N;

	int s[N];
	rep(i,N) cin >> s[i];

	int dp[10001];
	rep(j,10001) dp[j] = INF;

	dp[0] = 0;

	rep(i,N){
		rrep(j,10001){
			if(j - s[i] >= 0 && dp[j-s[i]] != INF){
				dp[j] = 0;
			} 
		}
	}
	
	rrep(i,10001) {
		if(i % 10 != 0 && dp[i] != INF) {
				cout << i << endl;
				return 0;
		}
	}
	cout << 0 << endl;	
}

Measured memory_bytes: 256