akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

using namespace std;
static int imin = std::numeric_limits<int>::min();
static int imax = std::numeric_limits<int>::max();
#define ll long long
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define debug(x) cout << #x << ":" << x << "\n";
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T>
std::istream& operator >> (std::istream& is, std::vector<T>& vec){
  T tmp;
  is >> tmp;
  vec.push_back(tmp);
  return is;
}
template <class T>
auto mkVec(unsigned int x){
  return std::vector<int>(x);
}

template <class T>
auto mkVec2(unsigned int x, unsigned int y){
  return std::vector<std::vector<T>>(x, std::vector<T>(y));
}

template <class T>
auto mkVec3(unsigned int x, unsigned int y, unsigned int z){
  return std::vector<std::vector<std::vector<T>>>(x, std::vector<std::vector<T>>(y, std::vector<T>(z)));
}

// 113C
// #ifndef BOOST_TEST_MAIN
// int main(int const argc, char const** argv){
//   int N, M;
//   cin >> N >> M;
//   vector<ll> P;
//   vector<ll> Y;
//   auto X = mkVec2<ll>(N + 1, 0);
//   rep(i, M){
//     ll p, y;
//     cin >> p >> y;
//     P.push_back(p);
//     Y.push_back(y);
//     X[p].push_back(y);
//   }
//   rep(i, N + 1){
//     sort(X[i].begin(), X[i].end());
//   }
//   rep(i, M) {
//     ll y;
//     rep(j, N + 1){
//       auto x = find(X[j].begin(), X[j].end(), Y[i]);
//       if(x != X[j].end()){
//         y = x - X[j].begin();
//         break;
//       }
//     }
//     printf("%06lld%06lld\n", P[i], y + 1);
//   }
// }
// #endif

ll gcd(ll l, ll r){
  if(r == 0) return l;
  if(l<r) return gcd(r, l);
  return gcd(l % r, r);
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  unsigned int N, X;
  cin >> N >> X;

  auto x = mkVec<ll>(N);
  rep(i, N){
    int n;
    cin >> x[i];
  }
  x.push_back(X);
  sort(x.begin(), x.end());
  int y = x[0];
  rep(i, N + 1){
    x[i] -= y;
  }
  int res = x[0];
  rep1(i, N + 1){
    res = gcd(res, x[i]);
  }
  cout << res;
}
#endif


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;


int main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }

    double sum=0;
    int cnt=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum += sqrt( (double)((x[i]-x[j] ) * (x[i]-x[j] ) + (y[i]-y[j]) * (y[i]-y[j])));
            cnt ++;
        }
    }
    sum /= (double)cnt;
    sum *= (double)(n-1);
    printf("%.10lf", sum);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <bitset>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define x  first
#define y  second
#define mp make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#ifndef ONLINE_JUDGE
	// #include "debug.h"
#else
// #define debug(...) 42
#endif

const int mxN=5e5+5;
const ld PI=acos(-1);
const int MD=1e9+9;


int main() {
	fast_cin();
	int t=1;
	// cin>>t;
	while(t--)
	{
		int n,k,a[mxN];
		cin>>n>>k;
		for(int i=0;i<n;i++) cin>>a[i];
		for(int i=k;i<n;i++){
			if(a[i]<=a[i-k]){
				cout<<"No"<<"\n";
			}
			else cout<<"Yes"<<"\n";
		}
	}
	return 0;	
}

Measured memory_bytes: 4404
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;

int n, m, a, b, vt[1005];
vector<int> gr[1005], tmp, ans;

void dfs(int p) {
	tmp.push_back(p);
	vt[p] = 1;
	for(int x:gr[p]) {
		if(x == tmp[0]) {
			if(ans.empty() || tmp.size() < ans.size()) ans = tmp;
		} else if (!vt[x]) {
			dfs(x);
		}
	}
	tmp.pop_back();
}

int main() {
	cin >> n >> m;
	while(m--) {
		cin >> a >> b;
		gr[a].push_back(b);
	}
	for(int i=1; i<=n; i++) {
		memset(vt, 0, sizeof(vt));
		tmp.clear();
		dfs(i);
	}
	if(ans.empty()) {puts("-1"); return 0;}
	cout << ans.size() << endl;
	for(auto x:ans) cout << x << endl;
	return 0;
}


Measured memory_bytes: 384
w = input()
d = {}
for i in range(len(w)):
    if w[i] in d:
        d[w[i]] += 1
    else:
        d[w[i]] = 1
        
res = 'Yes'
for key in d:
    if d[key]%2 != 0:
        res ='No'
print(res)

Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
public class Main {
    public static void main(String[] args) {
       FS fs = new FS();
        int n = fs.nextInt();
        int a[] = new int[n];
        int max= Integer.MIN_VALUE;
        int min =Integer.MAX_VALUE;
        for(int i =0;i<n;i++){
            a[i]=fs.nextInt();
            if (a[i]>max)max=a[i];
            if (a[i]<min)min=a[i];
        }
        int mm = max - min + 1;
        int[] b = new int[mm];
        for(int i=0;i<n;i++){
            b[a[i]-min]++;
        }
        for (int i=1;i<mm;i++){
            b[i]+=b[i-1];
        }
        int[] c = new int[n];
        for (int i=n-1;i>=0;i--){
             c[b[a[i]-min]-1]=a[i];
             b[a[i]-min]--;
        }
        StringBuilder sb= new StringBuilder();
        for(int i=0;i<n;i++){
            sb.append(c[i]+" ");
        }
        sb.deleteCharAt(sb.length()-1);
        System.out.println(sb.toString());
    }
   static class FS {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        return hasNextByte() ? buffer[ptr++] : -1;
    }

    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
        return (int) nextLong();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}
}


Measured memory_bytes: 189252
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll D, T, S;
  cin >> D >> T >> S;
  if (T * S >= D)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3564
#include <stdio.h>

int main(void)
{
	int bn, an;
	int maxi;
	char maxi_c;
	int i;
	
	while (scanf("%d %d", &bn, &an) * bn != 0){
		maxi = bn + an;
		maxi_c = 'A';
		for (i = 0; i < 4; i++){
			scanf("%d %d", &bn, &an);
			if (maxi < bn + an){
				maxi = bn + an;
				maxi_c = 'A' + i + 1;
			}
		}
		printf("%c %d\n", maxi_c, maxi);
	}
	
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int min = 1000;
        for (int i = 0; i < S.length() - 2; i++) {
            int X = Integer.parseInt(S.substring(i, i + 3));
            min = Math.min(min, Math.abs(X - 753));
        }
        System.out.println(min);
        sc.close();
    }
}

Measured memory_bytes: 23764
n, m = map(int, input().split())
a = []
for _ in range(n):
    a.append(list(input()))
b = []
for _ in range(m):
    b.append(list(input()))
ans = "No"
for i in range(n-m+1):
    for j in range(n-m+1):
        aaa = 0
        for k in range(m):
            if b[k] == a[i+k][j:j+m]:
                aaa += 1
            else:
                break
        if aaa == m:
            ans = "Yes"
            break
print(ans)

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

int main(){
    int n;
    cin >> n;
    int min=1000000;
    int max=-1000000;
    long sum=0;
    for (int i=0; i<n; i++){
        int a;
        cin >> a;
        if (a<min) {min=a;}
        if (max<a) {max=a;}
        sum+=a;
    }
    cout << min << " " << max << " " << sum << endl;
}


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

max_dist = 0
for i in range(n):
    next = (i+1) % n
    dist = a[next] - a[i]
    if dist < 0: dist+= k
    max_dist = max(max_dist, dist)
print(k - max_dist)

Measured memory_bytes: 25452
from collections import defaultdict
vertice, edge = (int(n) for n in input().split(" "))
connect = defaultdict(list)
indegree = [0 for n in range(vertice)]
for _ in range(edge):
    s, t = (int(n) for n in input().split(" "))
    connect[s].append(t)
    indegree[t] += 1
answer = []
zeroin = []
for i, n in enumerate(indegree):
    if n == 0:
        zeroin.append(i)
while len(zeroin) > 0:
    next_v = zeroin.pop()
    indegree[next_v] -= 1
    answer.append(next_v)
    for c in connect[next_v]:
        indegree[c] -= 1
        if indegree[c] == 0:
            zeroin.append(c)
for a in answer:
    print(a)

Measured memory_bytes: 11892
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}


int main() {
    string s;
    cin >> s;
    string t = s;
    reverse(s.begin(),s.end());
    if(s==t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define maxn 200010

int n,a[maxn],b[maxn],st[maxn],top;

int main() {
	int i,j,s;
	scanf("%d",&n);
	for (i=1;i<=n;i++) 
		scanf("%d",&a[i]);
	for (i=n;i>=1;i--) {
		s=0;
		for (j=1;j*i<=n;j++) s^=b[j*i];
		if (s^a[i]) b[i]=1;
	}
	for (i=1;i<=n;i++) if (b[i]) st[++top]=i;
	printf("%d\n",top);
	for (i=1;i<=top;i++) printf("%d ",st[i]);
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, a, b;
  cin >> n >> a >> b;
  if (b <= a + 2) {
    cout << n + 1 << '\n';
  } else {
    long long ans = 1;
    long long first = min(n, a - 1);
    ans += first;
    n -= first;
    ans += (n / 2) * (b - a);
    if (n % 2 == 1) {
      ans++;
    }
    cout << ans << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int dp[101][10001];

int main(){
  int N, W;
  int val[100], wei[100];
  cin >> N >> W;
  for(int i = 0; i < N; i++)
    cin >> val[i] >> wei[i];
  for(int i = 1; i <= N; i++){
    for(int j = 1; j <= W; j++){
	dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      if(j >= wei[i - 1])
	dp[i][j] = max(dp[i][j], dp[i - 1][j - wei[i - 1]] + val[i - 1]);
    }
  }
  cout << dp[N][W] <<endl;
  return 0;
}

Measured memory_bytes: 5068
#define _USE_MATH_DEFINES
#include <iostream>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fore(i,a,b) for(int i = (int)a; i < (int)b; i++)
#define fr(i,a,b) for(int i = (int)a - 1; i >= (int)b; i--)
#define inf INT32_MAX
#define N 200005
#define mod 1000000000 + 7

using namespace std;

typedef long long ll;
typedef pair<int,int> pr;

inline void solve()
{
    int a,b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b));
}


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

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

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

  bool c = false;
  bool f = false;

  for(int i=0;i<s.size();i++) {
    if(s[i] == 'C') c = true;
    if(c && s[i] == 'F') f = true;
  }

  if(c&&f) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var Nums = InputNumList();
            var As = InputNumList();
            var H = Nums[0];
            var N = Nums[1];

            var Sum = As.Sum();

            WriteLine(Sum < H ? "No" : "Yes");
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 17632
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define endl '\n'
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main(void){
    ioboost;
    double n,m,d;
    cin >> n >> m >> d;
    if(d == 0){
        cout << (m - 1.00) / n << endl;
        return 0;
    }
    cout << double(2)*(n-d)*(m-1)/(n*n) << endl;
}


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

# dp[i][j]
# 上からi桁目まで見たとき、
# j=0:XがK未満であることが未確定である場合の、f(X)の最大値
# j=1:XがK未満であることが確定である場合の、f(X)の最大値
#
# XがK未満であることが確定->確定の遷移
#  Xiは0でも1でも可なので、Aiの0と1の個数のうち多い方を足せばよい。
# XがK未満であることが未確定->確定の遷移
#  Kiが1でXiを0としたとき、未確定->確定となる。
#  Xiを0にするということは、Aiの1の個数を足すことになる。
# XがK未満であることが未確定->未確定の遷移
#  (1)Kiが1でXiを1としたとき(2)Kiが0でXiを0としたときの2パターンがある。
#  (1)の場合はAiの0の個数、(2)の場合はAiの1の個数を足すことになる。

MAX_DIGIT = 42
dp = [[-1 for _ in range(2)] for _ in range(MAX_DIGIT+1)]
dp[MAX_DIGIT][0] = 0
for i in range(MAX_DIGIT-1,-1,-1):
  c0 = c1 = 0
  for a in A:
    if (a>>i)&1 == 1:
      c1 += 1
    else:
      c0 += 1
  if dp[i+1][1] >= 0:
    # 確定->確定
    dp[i][1] = max(dp[i][1], dp[i+1][1] + max((c1<<i),(c0<<i)))
  if dp[i+1][0] >= 0:
    if (K>>i)&1 == 1:
      # 未確定->未確定でKi=1&Xi=1
      dp[i][0] = dp[i+1][0] + (c0<<i)
      # 未確定->確定(つまりKi=1&Xi=0) 
      dp[i][1] = max(dp[i][1], dp[i+1][0] + (c1<<i))
    else:
      # 未確定->未確定でKi=0&Xi=0
      dp[i][0] = dp[i+1][0] + (c1<<i)
# dp[0][0]:最後まで XがK未満であることが未確定、つまりK=Xの場合の最大値
# dp[0][1]:XがK未満である場合の最大値
print(max(dp[0][0],dp[0][1]))
#print(dp)

Measured memory_bytes: 69776
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int A = sc.nextInt();
            int B = sc.nextInt();

            int result = A >= 13 ? B : A >= 6 && A <= 12 ? B / 2 : 0;

            System.out.println(result);

        }
    }

}

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

#define pb push_back
#define mp make_pair


long long int res(long long int num) 
{ 
    long long int ans = 0; 
    for (long long int i = 1; i <= sqrt(num); i++) 
    { 
        if (num % i == 0)
        { 
             
            long long int target = num / i;
            target -= 1;

            if(target == 0) continue;

            if(num / target == num % target) {
                ans += target;
            }
            
            if (i != (num / i)) {
                target = i - 1;
                if(target == 0) continue;

                if(num / target == num % target) {
                    ans += target;
                }   
            }
        } 
    } 
  
    return ans; 
} 

int main() {
    ios_base::sync_with_stdio(false);

    long long int n;
    cin >> n;

    long long int ans;
    if(n == 1) {
        ans = 0;
    }  else {
        ans = res(n);
    }

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

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

const int MAX = 1000001;
int b[MAX]{};

int main() {
    int N;
    cin >> N;
    int A[N];
    set<int> s;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        b[A[i]]++;
        s.insert(A[i]);
    }
    if (A[0] == 1) {
        if (b[1] == 1) {
            cout << "1\n";
        } else {
            cout << "0\n";
        }
        return 0;
    }
    bool flag[MAX]{};
    for (int i : s) {
        for (int j = 2; j < MAX; j++) {
            if (i * j >= MAX) break;
            flag[i * j] = true;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (b[A[i]] == 1 && !flag[A[i]]) ans++; 
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 17752
#include <stdio.h>

int isprime(int n)
{
	int i;
	for (i = 2; i*i <= n; i++){
		if (n%i == 0)
			return 0;
	}
	return 1;
}

int main(){
	int p[10001];
	int i, n;
	for (i = 2; i<10001; i++)
		p[i] = isprime(i);
	while (scanf("%d", &n), n++){
		while (n--){
			if (p[n] * p[n - 2] == 1)break;
		}
		printf("%d %d\n", n - 2, n);
	}
	return 0;
}

Measured memory_bytes: 640
N = int(input())
D = {}
for i in range(N):
  a_i = input()
  if a_i in D.keys():
    D[a_i] += 1
  else:
    D[a_i] = 1
m = 0
for v in D.values():
	m = max(m, v)
ans = []
for k, v in D.items():
	if v == m:
		ans.append(k)
ans.sort()
print(*ans, sep="\n")

Measured memory_bytes: 34012
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
    ll X; cin >> X;
    vector<ll> fac(2001);
    for (ll i = 0; i <= 2000; i++) {
        ll temp = 1;
        for(ll j=0;j<5;j++)
            temp *= (i - 1000);
        fac[i] = temp;
       // cout << i << " " << fac[i] << endl;
    }

    ll A, B;
    int a, b;
    bool flag = false;
    for (int i = 0; i <= 2000 && !flag; i++) {
         B = fac[i];
         b = i;
        for (int j = 0; j <= 2000; j++) {
            A = fac[j];
            a = j;
            if (A - B == X) {
                //cout << a - 1000 << " " << b - 1000 << endl;
                flag = true;
                break;
            }
        }
    }
    cout << a-1000 << " " << b-1000 << endl;
}


Measured memory_bytes: 3636
local s = io.read()
local n = #s
local t = {}
for i = 1, n do
  local ss = s:sub(i, i)
  if ss == "B" then
    if 0 < #t then table.remove(t) end
  else
    table.insert(t, ss)
  end
end
print(table.concat(t))


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

int main() {
  int n,k,in;
  ll sum;

  priority_queue<int> h;

  cin >> n >> k;
  sum = 0;
  rep(i, n){
    cin >> in;
    sum += in;
    h.push(in);
  }
  rep(i, k) {
    in = h.top();
    sum -= in;
    h.pop();
  }
  ll ans = sum >= 0 ? sum : 0;
  cout << ans << endl;

  return 0;
}

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

int main(){
    int n, i, res = 1000000;
    string s;
    cin >> n >> s;
    int cb[n+1] = {}, cw[n+1] = {};
    cb[0] = 0;
    for(i=0; i<n; i++){
        cb[i+1] = cb[i] + (s[i] == '#');
    }
    cw[n] = 0;
    for(i=n; i>0; i--){
        cw[i-1] = cw[i] + (s[i] == '.');
    }
    for(i=0; i<=n; i++){
        res = min(res, cb[i]+cw[i]);
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 2180
let () =
  let n = read_int () in
  let rec read result =
    let op = read_line () and
        m = read_int in
    if op = "+" then
      read (result + (m ()))
    else if op = "-" then
      read (result - (m ()))
    else if op = "*" then
      read (result * (m ()))
    else if op = "/" then
      read (result / (m ()))
    else
      result
  in
  Printf.printf "%d\n" (read n)
;;

Measured memory_bytes: 2296
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int ans=0;
		while(true){
			int a=sc.nextInt();
			String op=sc.next();
			int b=sc.nextInt();
			
			if(op.equals("?"))break;
			
				switch(op){
					case"+":
						ans=a+b;
						break;
					case"-":
						ans=a-b;;
						break;
					case"*":
						ans=a*b;;
						break;
					case"/":
						ans=a/b;;
						break;
				}
				System.out.println(ans);
			}
		}
}





Measured memory_bytes: 26140
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	string t=s;
	int n=s.size();
	for(int i=n-1;i>=0;i--){
		if(s[i]<='4')continue;
		else{
			if(s[i]=='5'&&(i==0||s[i-1]<='4'))continue;
			while(i<n&&s[i]>='5'){
				s[i]=(char)(10-(s[i]-'0')+'0');
				if(s[i]=='5'&&(i==0||s[i-1]<='4'))break;
				if(i){
					bool end=0;
					while(i>=1&&s[i-1]=='9'){
						s[i-1]='0';
						if(s[0]=='0'){
							s='1'+s;
							end=1;
							break;
						}
						i--;
					}
					if(!end){
						s[i-1]++;
					}
				}
				else{
					s='1'+s;
					i=-1;
					break;
				}
				i--;
			}
			i++;
		}
	}
	ll ans=0;
	for(int i=0;i<s.size();i++){
		ans+=(s[i]-'0');
	}
	cout << ans << endl;
	// えー何が間違ってるのかわからん
	// sample3の答えが1ずれてる
}

/* メモ
3800
3755
45 20
4000
3755
 245
*/

Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long long a, long long b){
  if (a%b == 0){
    return(b);
  }else{
    return(gcd(b, a%b));
  }
}

long long lcm(long long a, long long b){
  return a * b / gcd(a, b);
}

int main(){
  long long a,b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int n, ans = 0;
	cin >> n;
	vector<int> a(n+1);
	for (int i = 1; i <= n; i++){
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++){
		if (i%2 && a[i]%2) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>

void merge(int[],int,int,int);
void mergesort(int[],int,int);

int count=0;

int main(void){
  int n,s[500000];
  int left = 0;
  int i;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&s[i]);
  }
 
  mergesort(s,left,n);
  
  for(i=0; i < n; i++){    
    printf("%d",s[i]);  
    if(i < n-1){
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n",count);
  
  return 0;
}

void merge(int a[],int left,int mid,int right){
  int n1,n2;
  int i,j,k;
  
  n1 = mid - left;
  n2 = right - mid;

  int l[n1+1],r[n2+1];
  
  for(i = 0; i < n1; i++){
    l[i] = a[left + i];
  }


  for(i = 0; i < n2; i++){
    r[i] = a[mid + i];
  }
  l[n1] = 1000000000;
  r[n2] = 1000000000;

  i = 0;
  j = 0;
  
  for(k = left; k < right; k++){
    if(l[i] <= r[j]){
      a[k] = l[i];
      i += 1;
      count++;
    }
    else{
      a[k] = r[j];
      j += 1;
      count++;
    }
  }
}

void mergesort(int a[],int left,int right){
  int mid,i;
  if(left + 1 < right){
    mid = (left + right)/2;
    mergesort(a,left,mid);
    mergesort(a,mid,right);
    merge(a,left,mid,right);
  }
}

Measured memory_bytes: 4508
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
string s, t;
deque<char> pphead;

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

	cin >> s >> t;
	for(int i = 0; i<t.size(); i++)
		pphead.pb(s[i]);

	int cur = t.size(), ans = INT_MAX;
	for(int i = 0; i<pphead.size(); i++)
		if(t[i] == pphead[i]) cur--;
	ans = min(ans, cur);


	for(int i = t.size(); i<s.size(); i++){
		pphead.pb(s[i]);
		pphead.pop_front();
		cur = t.size();
		for(int i = 0; i<pphead.size(); i++)
			if(t[i] == pphead[i]) cur--;
		ans = min(ans, cur);
	}

	cout << ans << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define rep(i,n) for (i = 0; i < n; ++i)
#define REP(i,k,n) for (i = k; i <= n; ++i)
#define REPR(i,k,n) for (i = k; i >= n; --i)

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)


void solve() {
    string s;
    cin >> s;
    int sum = 0;
    int i;
    rep(i, s.length()) {
        sum += s[i] - '0';
    }
    string ans = sum % 9 == 0 ? "Yes" : "No";
    cout << ans;
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();

    return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    long long int A, B, K; cin >> A >> B >> K;
    for (int i = 0; i < K; i++) {
        if (i % 2 == 0) {
            if (A % 2 != 0) A--;
            B += A / 2;
            A /= 2;
        }
        else {
            if (B % 2 != 0) B--;
            A += B / 2;
            B /= 2;
        }
    }
    printf("%lld %lld", A, B);
}


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

using namespace std;

vector<int> stovi(string s){
    vector<int> ret;
    int t=0;
    for (int i = 1; i < s.size(); ++i) {
        if(isdigit(s[i])){
            t=t*10;
            t+=s[i]-'0';
        }
        else {
            ret.emplace_back(t);
            t=0;
        }
    }
    ret.emplace_back(t);
    return ret;
}

int calscore(string s){
    vector<int> scores=stovi(s);
    int ret=0;
    int flame=1;
    bool first=true;
    bool spare=false;
    bool strike=false;
    bool strike2=false;
    for (int i = 0; i < scores.size(); ++i) {
        ret+=scores[i];
        if(spare)ret+=scores[i];
        if(strike)ret+=scores[i];
        if(strike2)ret+=scores[i];
        strike2=strike;
        strike=false;
        spare=false;
        if(first){
            if(flame!=10&&scores[i]==10){
                strike=true;
                ++flame;
            }
            else first=false;
        }
        else{
            if(flame!=10&&scores[i]+scores[i-1]==10)spare=true;
            first=true;
            ++flame;
        }
    }
    return ret;
}

int main(){
    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        vector<pair<int,int>> sc;
        for (int i = 0; i < n; ++i) {
            int id;
            string s;
            cin>>id;
            getline(cin,s);
            sc.emplace_back(calscore(s),-id);
        }
        sort(sc.rbegin(),sc.rend());
        for(auto i:sc)cout<<-i.second<<" "<<i.first<<endl;
    }
    return 0;
}


Measured memory_bytes: 3012
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <functional>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0スタート
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1スタート
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //aからb - 1まで
#define p(x) cout<<x<<endl  //xを改行付きで出力
const int INF = 1000000007;  //最大値兼MOD
//  cin.tie(0);
//  ios::sync_with_stdio(false);
typedef long long ll;
using namespace std;
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; }
int main(){
  string s;
  cin>>s;
  if(s == "Sunny")cout<<"Cloudy"<<endl;
  else if(s == "Rainy")cout<<"Sunny"<<endl;
  else cout<<"Rainy"<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		long n = scan.nextLong();
		long power = 1;

		for(int i = 1; i <= n; i++){
			power *= i;
			power %= 1000000007;
		}
		System.out.println(power);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int a[3];
int main() {
    for (int i = 0; i< 3; ++i) cin >> a[i];
    sort(a, a+3);
    if (a[0] == 5 && a[1] == 5 && a[2] == 7) puts("YES");
    else puts("NO");
}













Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
using namespace std;
const int INF = 1e9;
typedef long long ll;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}
 
int main() {
	string s; cin >> s;
	vector<char> a(s.size()), b(s.size());
	rep(i,s.size()){
		if (i%2){
			a[i] = '1';
			b[i] = '0';
		}else{
			a[i] = '0';
			b[i] = '1';
		}
	}

	int c=0,d=0;
	rep(i,s.size()){
		if (a[i] != s[i]) c++;
		if (b[i] != s[i]) d++;
	}

	cout << min(c,d) << endl;

}

Measured memory_bytes: 512
/******************************************
 	AUTHOR : PRATIK 
 INSTITUTION : BITS PILANI HYDERABAD CAMPUS 
******************************************/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef multiset<int> ms;
typedef set<int> s;
typedef vector<double> vid;
typedef multiset<double> msd;
typedef set<double> sd;
#define sp setprecision 
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

void fastscan(ll &number)
{
    //variable to indicate sign of input number
    bool negative = false;
    register int c;
 
    number = 0;
 
    // extract current character from buffer
    c = getchar();
    if (c=='-')
    {
        // number is negative
        negative = true;
 
        // extract the next character from the buffer
        c = getchar();
    }
 
    // Keep on extracting characters if they are integers
    // i.e ASCII Value lies from '0'(48) to '9' (57)
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
 
    // if scanned input has a negative sign, negate the
    // value of the input number
    if (negative)
        number *= -1;
}
 
// Function Call

int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ios_base& scientific (ios_base& str);
	
    ll t;
    cin>>t;

    if(t%2==0) cout<<t;
    else cout<<t*2;

	return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

ll rec(ll n) {
    if (n == 1) {
        return 1;
    } else {
        return 2*rec(n/2)+1;
    }
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll H;
    cin >> H;

    cout << rec(H) << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq, collections
X, Y, Z, K = [int(_) for _ in input().split()]
A, B, C = [
    sorted([int(_) for _ in input().split()], reverse=True) for _ in range(3)
]
H = [[-A[0] - B[0] - C[0], 0, 0, 0]]
heapq.heapify(H)
memo = collections.defaultdict(
    lambda: collections.defaultdict(lambda: collections.defaultdict(int)))
for _ in range(K):
    v, a, b, c = heapq.heappop(H)
    print(-v)
    for x, y, z in [[a + 1, b, c], [a, b + 1, c], [a, b, c + 1]]:
        if x < X and y < Y and z < Z and memo[x][y][z] == 0:
            heapq.heappush(H, [-A[x] - B[y] - C[z], x, y, z])
            memo[x][y][z] = 1


Measured memory_bytes: 5620
#include <iostream>
using namespace std;
int a[3][3],b[3][3];
bool judge(){
	for(int i=0;i<3;i++){
		if(b[i][0]&&b[i][1]&&b[i][2]) return true;
	}
	for(int j=0;j<3;j++){
		if(b[0][j]&&b[1][j]&&b[2][j]) return true;
	}
	if(b[0][0]&&b[1][1]&&b[2][2]) return true;
	if(b[0][2]&&b[1][1]&&b[2][0]) return true;
	return false;
}
int main(){
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			cin>>a[i][j];
	int n; cin>>n;
	while(n--){
		int temp; cin>>temp;
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++){
				if(a[i][j]==temp) b[i][j]=1;
			}
	}
	cout<<(judge()?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(string, s);

  bool ok = false;
  if (regex_match(s, regex(".*keyence"))) ok = true;
  if (regex_match(s, regex("k.*eyence"))) ok = true;
  if (regex_match(s, regex("ke.*yence"))) ok = true;
  if (regex_match(s, regex("key.*ence"))) ok = true;
  if (regex_match(s, regex("keye.*nce"))) ok = true;
  if (regex_match(s, regex("keyen.*ce"))) ok = true;
  if (regex_match(s, regex("keyenc.*e"))) ok = true;
  if (regex_match(s, regex("keyence.*"))) ok = true;

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

Measured memory_bytes: 256
import numpy as np
import bisect
 
(A,B,Q) = map(int,input().split())
inf = 10**12
s = np.empty(A+2,dtype=np.object)
t = np.empty(B+2,dtype=np.object)
s[0] = -inf
t[0] = -inf
s[A+1] = inf
t[B+1] = inf
 
for i in range(A):
    s[i+1] = int(input())
for i in range(B):
    t[i+1] = int(input())
 
for i in range(Q):
    x = int(input())
    p = bisect.bisect_left(s,x)
    q = bisect.bisect_left(t,x)
    ans = min(max(s[p]-x,t[q]-x),
              max(x-s[p-1],x-t[q-1]),
                  (s[p]-x)*2 + (x-t[q-1]),
                  (s[p]-x) + (x-t[q-1])*2,
                  (t[q]-x)*2 + (x-s[p-1]),
                  (t[q]-x) + (x-s[p-1])*2)
    print(ans)

Measured memory_bytes: 20976
#include<iostream>
using namespace std;
int main(){
	int a;
	int b;
	cin>>a;
	cin>>b;
	if(a == b){
		cout<<"a == b"<<endl;
	}
	else if(a > b){
		cout<<"a > b"<<endl;
	}
	else if(a < b){
		cout<<"a < b"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e18
#define mm 998244353

void solve(){
	int n; cin>>n;
	ll ans=0;
	ff(i,1,n){
		if(i%3==0 || i%5==0) continue;
		else ans += i;
	}
	cout<<ans<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 3620
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 10005
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
ll sum;

int main() {
	scanf("%lld %lld", &N, &M);
	fi(i, 0, M, 1) {
		scanf("%lld", &arr[i]);
		sum += arr[i];
	}
	ll vac = max(N - sum, -1ll);
	printf("%lld\n", vac);

	return 0; 
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3824
while 1:
    n,w = map(int,raw_input().split())
    if n == 0: break
    v = [0]*11
    m = 0
    for i in range(n):
        p = int(raw_input())/w
        v[p] += 1
        m = max(m,p)
    ans = 0.01
    for i in range(m):
        ans += (v[i]*1.0/max(v))*(1-i*1.0/m)
    print ans

Measured memory_bytes: 4248
import java.io.*;
import java.util.*;

public class Main {
  private static int solve(int n, int[] as) {
    int aMax = as[0];
    int aMin = as[0];
    for (int a : as) {
      aMax = Math.max(aMax, a);
      aMin = Math.min(aMin, a);
    }
    return aMax - aMin;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] as = reader.nextInt(n);
    out.println(solve(n, as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    lli N, K;
    cin >> N >> K;
    lli ans = 0;
    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }
    REP (b, K + 1, N + 1) {
        lli s = K, e = b - 1;
        while (s <= N) {
            ans += (min(e, N) - s + 1);
            s += b;
            e += b;
//            dump(s);
//            dump(e);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

# heap
class Heap
  def initialize(n)
    @heap = Array.new(n) { 0 }
    @sz = 0
  end

  def size
    @sz
  end

  def empty?
    @sz.zero?
  end

  def push(x)
    i = @sz
    @sz += 1
    while i > 0
      p = (i - 1) / 2
      break if @heap[p] >= x

      @heap[i] = @heap[p]
      i = p
    end
    @heap[i] = x
  end

  def pop
    ret = @heap[0]
    @sz -= 1
    x = @heap[@sz]
    i = 0
    while i * 2 + 1 < @sz
      a = i * 2 + 1
      b = i * 2 + 2
      a = b if b < @sz && @heap[b] > @heap[a]

      break if @heap[a] <= x

      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    ret
  end

  def top
    @heap[0]
  end
end

heap = Heap.new(n)

a.each do |e|
  heap.push e
end

m.times do
  heap.push(heap.pop / 2)
end
sum = 0
until heap.empty?
  sum += heap.pop
end
puts sum


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

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

int main() {
	size_t N;
	cin >> N;
	vector<int> A(N);
	for (int& i : A) cin >> i;
	for (size_t i = 1; i < N; ++i) A[i] = gcd(A[i - 1], A[i]);
	cout << A[N - 1];
}

Measured memory_bytes: 640
R,C,K=map(int,input().split())
value=[[0]*(C+1) for i in range(R+1)]
for i in range(K):
  r,c,v=map(int,input().split())
  value[r][c]=v
DP0=[[0]*(C+1) for i in range(R+1)]
DP1=[[0]*(C+1) for i in range(R+1)]
DP2=[[0]*(C+1) for i in range(R+1)]
DP3=[[0]*(C+1) for i in range(R+1)]
for i in range(1,R+1):
  for j in range(1,C+1):
    v=value[i][j]
    a=DP0[i][j-1]
    b=DP1[i][j-1]
    c=DP1[i-1][j]
    d=DP2[i-1][j]
    e=DP3[i-1][j]
    f=DP2[i][j-1]
    DP0[i][j]=max(a,c,d,e)
    DP1[i][j]=max(DP0[i-1][j]+v,c+v,d+v,e+v,b,a+v)
    DP2[i][j]=max(b+v,f)
    DP3[i][j]=max(f+v,DP3[i][j-1])

print(max(DP0[R][C],DP1[R][C],DP2[R][C],DP3[R][C]))

Measured memory_bytes: 433380