akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int N,X;

int main()
{
    scanf("%d%d",&N,&X);
    int MIN = 1001001001;
    for(int i = 0; i < N; i++)
    {
        int a;
        scanf("%d",&a);
        MIN = min(MIN,a);
        X -= a;
    }

    printf("%d\n",N + X / MIN);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int res;
if(K==1){
    res = 0;
}else{
    res = N-K;
}
        
        System.out.println(res);
        }
    }

Measured memory_bytes: 35860
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int n;
	cin >> n;
	cout << (1000 - n % 1000) % 1000 << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main(){
	int i,j,k,l;
	int n;
	int f[105][15];
	int p[105][15];
	int t[15];
	int s[105];
	int point;
	for(i=0;i<100;i++)
	{
		s[i]=0;
	}
	int max;
	for(i=0;i<10;i++)
	{
		t[i]=0;
	}
	t[0]=1;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		for(j=0;j<10;j++)
		{
			scanf("%d",&f[i][j]);
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<11;j++)
		{
			scanf("%d",&p[i][j]);
		}
	}
	
	for(i=0;i<1023;i++)//店の開業パターン
	{
		for(k=0;k<10;k++)
		{
			if(t[k]>=2)
			{
				t[k]=0;
				t[k+1]++;
			}
		}
		
		
		for(j=0;j<n;j++)
		{
			for(l=0;l<10;l++)
			{
				if(t[l]==1&&f[j][l]==1)
					s[j]++;//j番目の店と被る回数
			}
		}
		
		for(j=0;j<n;j++)
		{

				point=point+p[j][s[j]];
			
		}
		
		if(i==0)
		{
			max=point;
			
		}else if(max<point)
		 {
		 	max=point;
		 	
		 }
		
		 
		for(j=0;j<n;j++)
		{
			
			s[j]=0;//j番目の店と被る回数を0に
				
		}
		t[0]++;
		
		point=0;
	}
	
	printf("%d",max);
	
	return 0;
	}


Measured memory_bytes: 128
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt
from fractions import gcd

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

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



A, B = mulinputs()

# 出力
n = min(A, B)
m = max(A, B)

print(str(n)*m)




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

int main() {
  int n;cin>>n;
  int ans=0;
  for(int i=1;i<=n;i+=2){
    int cnt=0;
    for(int j=1;j<=i;j++){
      if(i%j==0)cnt++;
    }
    if(cnt==8)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3532
#include<iostream>
#include<string>
#include<algorithm> 
using namespace std;
int main(){
  int a,b,sum=0;
  cin>>a>>b;
  for(int i=a;i<=b;i++){
    int sw1=i/10000;
    int sw2=i%10000/1000;
    int sw4=i%100/10;
    int sw5=i%10;
    if(sw1==sw5 && sw2==sw4){
      sum++;
    }
  }
  cout<<sum<<endl;  
  return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
  uint32_t N, M, k[10], s[10][10], p[10];
  cin >> N >> M;
  for (uint32_t i = 0; i < M; ++i) {
    cin >> k[i];
    for (uint32_t j = 0; j < k[i]; ++j) {
      cin >> s[i][j];
    }
  }
  for (uint32_t i = 0; i < M; ++i) cin >> p[i];
  uint32_t Pattern = 1;
  for (uint32_t i = 0; i < N; ++i) Pattern *= 2;

  uint32_t Res = 0;

  for (uint32_t index = 0; index < Pattern; ++index) {
    uint32_t light_num = 0;
    for (uint32_t light = 0; light < M; ++light) {
      uint32_t sum = 0;
      for (uint32_t sw = 0; sw < k[light]; ++sw) {
        sum += (index >> (s[light][sw] - 1)) & 0x01;
      }
      if ((sum & 0x01) == p[light]) {
        ++light_num;
      }
    }
    if (light_num == M) ++Res;
  }

  cout << Res << endl;

  return 0;
}


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

int main() {
  int a, b, c, d, e ,k;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cin >> e;
  cin >> k;
  
  if(e-a>k){
    cout << ":(" << endl;
  }
  
  else{
    cout << "Yay!" << endl;
  }
    
}


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

int main() {
 int n;
  string s;
  cin>>n>>s;
  int ans=300000;
  vector<int> sE(n+1),sW(n+1);
  sE[0]=0;
  sW[0]=0;
  for(int i=1;i<=n;i++){
    sE[i]=sE[i-1];
    sW[i]=sW[i-1];
    if(s[i-1]=='E') sE[i]++;
    else sW[i]++;
  }
  for(int i=1;i<=n;i++){
  ans=min(ans,sW[i-1]+(sE[n]-sE[i]));
  }
  cout<<ans<<endl;
}
    
  

Measured memory_bytes: 3076
N,A,B = map(int,input().split())
S = input()
cnta = 0
cntb = 0
for i in S:
    if i == 'a':
        if cnta + cntb < A + B:
            cnta += 1
            print('Yes')
        else:
            print('No')
    elif i == 'b':
        if cnta + cntb < A+B and cntb < B:
            cntb+=1
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 4016
/**
*   @Author : MeGA
*   @InitTime :01/25/20 11:26:24
*   @Idea : 
*
*
*
*
*
*
*
**/
#include <bits/stdc++.h>
using namespace std;

int main(){
#ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
#endif
     long long a,b;
     scanf("%lld %lld",&a,&b);

     set<int>divisors;
     divisors.insert(1);
     while(a!=1){
       if(a%2==0)divisors.insert(2);
       while (a % 2 == 0){  
          a/=2;  
       }  

       for (int i = 3; i <= sqrt(a); i = i + 2){
         bool first=1; 
         while (a % i == 0){  
           if(first==1)divisors.insert(i);
           first=0;
            a/=i;  
         }  
       }
       if(a>2){
         divisors.insert(a);
         break;
       }
     }

     set<int>divisors1;
     divisors1.insert(1);
     while(b!=1){
       if(b%2==0)divisors1.insert(2);
       while (b % 2 == 0){  
          b = b/2;  
       }  

       for (int i = 3; i <= sqrt(b); i = i + 2){
         bool first=1; 
         while (b % i == 0){  
           if(first==1)divisors1.insert(i);
           first=0;
           b/=i;  
        }  
      }

      if(b>2){
         divisors1.insert(b);
         break;
       }

     }
     int ans=0;
     for(auto &c: divisors){
     	
        if(divisors1.count(c))ans++;
     }

     printf("%d",ans);



}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        int[] sum = new int[10000];
        int[] n = new int[1000];
        int i, j;
        String s;

        Scanner sc = new Scanner(System.in);

        for (i = 0; true; i++) {
            sum[i] = 0;
            s = sc.nextLine();
            if (s.equals("0")) break;

            for (j = 0; j < s.length(); j++) {
                n[j] = Character.getNumericValue(s.charAt(j));
                sum[i] += n[j];
            }
        }
        sc.close();

        int I = i;

        for (i = 0; i < I; i++) {
            System.out.println(sum[i]);
        }
    }
}


Measured memory_bytes: 26576
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int x; cin >> x;
    int num1=x/100,num2=x%100;
    if(1<=num1 && num1<=12){
        if(1<=num2 && num2<=12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(1<=num2 && num2<=12){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
N,D = map(int,(input().split()))
X = [list(map(int, input().split())) for _ in range(N)]
Sum = 0
d = [0]*(N*(N-1)//2)
t = 0
for i in range(N-1):
    for j in range(i+1,N):
        for s in range(D):
            d[t] += abs(X[i][s]-X[j][s])**2
        d[t] = pow(d[t],0.5)
        if d[t].is_integer():
            Sum += 1
        t += 1
print(Sum)

Measured memory_bytes: 3188
from itertools import accumulate
n = int(input())
a = [0]+list(map(int,input().split()))+[0]
b = []
for i in range(n+1):
    b.append(abs(a[i]-a[i+1]))
c = sum(b)
for j in range(0,n):
    print(c - b[j] - b[j+1] + abs(a[j]-a[j+2]))

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) cout << "No" << endl;
    else if (a != b && b != c && a != c) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3576
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	long long int a[100005], b[100005];
	int i;
	for (i = 0; i <= n; i++)
		scanf("%lld", &a[i]);
	for (i = 0; i < n; i++)
		scanf("%lld", &b[i]);
	long long int ans = 0;
	for (i = 0; i < n; i++)
	{
		if (a[i] <= b[i])
		{
			ans += a[i];
			b[i] -= a[i];
			if (a[i + 1] <= b[i])
			{
				ans += a[i + 1];
				a[i + 1] = 0;
			}
			else
			{
				ans += b[i];
				a[i + 1] -= b[i];
			}
		}
		else
			ans += b[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1664
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {
	int N;
	cin >> N;
	for (int i = N;i > 0;i--) {
		if (i==1 || i == 2 || i==4 || i==8 || i==16 || i==32 || i==64) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
//__builtin_popcount(n)
using pi = pair<int,int>;
signed main(){
	string t; cin>>t;
	int m=t.size();
	bool n=0,s=0,e=0,w=0;
	rep(i,0,m){
		if(t[i]=='N')n=1;
		else if(t[i]=='S')s=1;
		else if(t[i]=='E')e=1;
		else w=1;
	}
	bool ok=true;
	if(s!=n)ok=false;
	if(w!=e)ok=false;
	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

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

int main() {
    int n,x,y;cin>>n>>x>>y;
    int d[n]{};
    for (int i=1;i<=n;i++)
        for (int j=i+1;j<=n;j++)
            d[min(j-i,abs(i-x)+1+abs(j-y))]++;
    for (int i=1;i<n;i++)
        cout<<d[i]<<endl;
    return 0;
}

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

int main()
{
    int a,b;
    vector<int>v,v1;
    cin>>a;
    for(int i=0; i<a; i++)
    {
        cin>>b;
        v.push_back(b);
    }
    sort(v.begin(),v.end());
    if(v[0]==v[v.size()-1])
    {
        v1.push_back(0);
    }
    for(int i=v[0]; i<v[v.size()-1]; i++)
    {
        int sum=0;
        for(int j=0; j<v.size(); j++)
        {
            sum=sum+(abs(i-v[j])*abs(i-v[j]));
        }
        v1.push_back(sum);
        sum=0;
    }
    sort(v1.begin(),v1.end());
    cout<<v1[0]<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int a,b;
    string s;
    scanf("%d%d",&a,&b);
    cin >> s;
    bool rullonz = true;
    REP(i,a){
        if(!isdigit(s[i])) rullonz = false;
    }
    if(s[a]!='-') rullonz = false;
    FOR(i,a+1,a+b+1) if(!isdigit(s[i])) rullonz = false;

    puts(rullonz?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

ll gcd(ll a, ll b){
    if(a < b){
        ll t = a;
        a = b;
        b = t;
    }
    if(a % b == 0)return b;
    else return gcd(b, a%b);
}
ll lcm(ll a, ll b){
    ll l = gcd(a, b);
    return a/l*b;
}
int main(void){
    int  n;
    scanf("%d", &n);
    ll ans = 1;
    for(int i = 0;i < n;i++){
        ll t;
        scanf("%lld", &t);
        ans = lcm(ans, t);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int a, b, c;
    vector<int> data;

    cin >> a >> b >> c;
    data.push_back(a);
    data.push_back(b);
    data.push_back(c);

    int count = 0;
    while (data[0] != data[1] || data[1] != data[2]) {
        sort(data.begin(), data.end());
        if (data[1] != data[2]) {
            data[0] += 1;
            data[1] += 1;
            count++;
        } else if (data[1] == data[2]){
            data[0] += 2;
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal[] input = Console.ReadLine().Split(" ").Select(x => decimal.Parse(x)).ToArray();
            decimal cnt = input[0];
            decimal legs = input[1];
            decimal a = (legs - 2 * cnt) / 2;
            decimal b = (4 * cnt - legs) / 2;
            if (a >= 0 && b >= 0 && (int)a==a && (int)b == b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 28252
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 3e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

#define int ll

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, a[N], b[N],sum,sum2,ans;
main() {
    file("dishes");
    ios;
    cin>>n;
    fo(i,1,n+1,1) cin>>a[i],sum+=a[i];
    fo(i,1,n,1) cin>>b[i], sum2+=b[i];
    fo(i,1,n,1) {
        if (a[i]<=b[i]) {
            ans+=a[i];
            b[i]-=a[i];
            a[i]=0;
            if (a[i+1]<=b[i]) {
                ans+=a[i+1];
                b[i]-=a[i+1];
                a[i+1]=0;
            } else {
                ans+=b[i];
                a[i+1]-=b[i];
                b[i]=0;
            }
        } else {
            ans+=b[i];
            a[i]-=b[i];
            b[i]=0;
        }
    }
    cout<<ans;
    return 0;
}
/**

*/


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define pq priority_queue

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> nos(n);
    for (int i = 0; i < n; i++) {
        cin >> nos[i];
    }
    vector<int> sorted_v = nos;
    sort(sorted_v.begin(), sorted_v.end());
    int low_med = sorted_v[n / 2 - 1];
    int high_med = sorted_v[n / 2];
    for (int i = 0; i < n; i++) {
        if (nos[i] <= low_med) {
            cout << high_med << '\n';
        } else {
            cout << low_med << '\n';
        }
    }
}

Measured memory_bytes: 6304
#include<bits/stdc++.h>
using namespace std;
int ar[100000];
int main()
{
 
   long long n,k,i,j,m,c=0;
   cin>>n>>m;
    long long h[n+3],v[n+2];
    
    for(i=1;i<=n;i++)
    {
        cin>>h[i];
        v[i]=h[i];    
    }

    while(m--)
    {
        long long a,b;
        cin>>a>>b;
         if(v[a]>v[b])
         {
            h[b]=0;
         }
         if(v[a]<v[b])
         {
            h[a]=0;
         }
         if(v[a]==v[b])
         {
            h[a]=0;
            h[b]=0;
         }
    }
   for(i=1;i<=n;i++)
   {
    if(h[i]!=0)
    {
        c++;
    }
   }
   cout<<c<<endl;
    return 0;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int q[200005];

map<int, int> pt;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
  int n;cin>>n;
  for(int i=0;i<n;i++){
    int t;
    cin>>t;
    t--;
    q[t]=i;
  }
  ll mx=1;
  ll ans=1;
  for(int i=1;i<n;i++){
    if(q[i]>q[i-1]){
      mx++;
      ans=max(mx,ans);
    }else{
      mx=1;
    }
  }
  cout<<n-ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    ans = [0]*n
    for i in range(n):
        ans[a[i]-1] = i+1
    ans_list = map(str, ans)  # mapで要素すべてを文字列に
    ans_str =' '.join(ans_list)
    print(ans_str)

Measured memory_bytes: 18372
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    string K;
    //if(S.length() < T.length()) {cout << "UNRESTORABLE" << endl; return 0;}
    rep(i, S.length()) {
        bool ok = true;
        string U;
        rep(j, i) {
            if(S[j] == '?') U += 'a'; 
            else U += S[j];
        }
        rep(j, T.length()) {
            if(i + j >= S.length()) {ok = false; break;}
            if(S[i + j] != T[j] && S[i + j] != '?') ok = false;
            U += T[j];
        }
        REP(j, i + T.length(), S.length() - 1) {
            if(S[j] == '?') U += 'a'; 
            else U += S[j];
        }
        if(ok) {
            if(K == "") K = U;
            else if(K > U) K = U;
        } 
    }
    if(K == "") {
        cout << "UNRESTORABLE" << endl;
    } else {
        cout << K << endl;
    }

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int a[N];

    for(int i=0; i<N;i++) {
        cin >> a[i];
        if (a[i] % 2 == 0) {
            if (a[i] % 3 != 0 && a[i] % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        } 
    }
    cout << "APPROVED" << endl;
    return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long K, std::string S){
    if(S.size() <= K) {
        cout << S << endl;
        return;
    }

    REP(i, K) {
        cout << S[i];
    }

    cout << "..." << endl;
}

int main(){
    long long K;
    scanf("%lld",&K);
    std::string S;
    std::cin >> S;
    solve(K, S);
    return 0;
}


Measured memory_bytes: 3696
# Acceptance of input
import sys

file_input = sys.stdin

V, E = map(int, file_input.readline().split())

adj = [[] for i in range(V)]

for i in range(E):
    s, t = map(int, file_input.readline().split())
    adj[s].append(t)

# Tarjan's strongly connected components algorithm(repetition)
import collections

S = collections.deque()
path = collections.deque()
index = 0
indices = [None] * V
lowlink = [None] * V
onStack = [False] * V
scc_id = [None] * V
parent = [0] * V

for v in range(V):
    if not indices[v]:
        index += 1
        indices[v] = index
        lowlink[v] = index
        S.append(v)
        path.append(v)
        onStack[v] = True

        while path:
            s = path[-1]
            adj_v = adj[s]
            for t in adj_v:
                if not indices[t]:
                    parent[t] = s
                    path.append(t)
                    S.append(t)
                    index += 1
                    indices[t] = index
                    lowlink[t] = index
                    onStack[t] = True
                    break
            if s == path[-1]:
                for t in adj_v:
                    if onStack[t]:
                        lowlink[s] = min(lowlink[s], lowlink[t])
                p = parent[s]
                lowlink[p] = min(lowlink[p], lowlink[s])
                if indices[s] == lowlink[s]:
                    while S:
                        w = S.pop()
                        onStack[w] =False
                        scc_id[w] = s
                        if w == s:
                            break
                path.pop()


# Output
Q = file_input.readline()

for line in file_input:
    u, v = map(int, line.split())
    if scc_id[u] == scc_id[v]:
        print(1)
    else:
        print(0)

Measured memory_bytes: 11152
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;


void swap(int* a, int* b){
    int temp = *a;
    *a = *b;
    *b = temp;
}


int main(){
    char s[11], t[12];
    cin >> s >> t;
    for (int i = 0; i <= 10; ++i){
        if (s[i] == '\0'){
            cout << "Yes";
            break;
        }
        else if (s[i] != t[i]){
            cout << "No";
            break;
        }
    }
}



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

long long int a[100010];
int main(){
	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	sort(a, a + n);
	long long int x1 = -1, x2 = -1, i;
	for(i = n - 1; i >= 1; i--){
		if(a[i] == a[i - 1]){
			x1 = a[i];
			i = i - 2;
			break;
		}
	}
	for(; i >= 1; i--){
		if(a[i] == a[i-1]){
			x2 = a[i];
			break;
		}
	}
	if(x1 == -1 || x2 == -1)cout<<0;
	else cout<<x1 * x2;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll n;
cin>>n;
cout<<n/3<<endl;
}









Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int[] a) {
    int n = cast(int)a.length;

    auto b = new int[n + 1];
    for (int i = n; i >= 1; i--) {
        // i の倍数の箱に入っているボールをカウントする
        int s = 0;
        for (int j = i + i; j <= n; j += i) {
            s += b[j];
        }

        // 偶奇が一致するように i 番目の箱にボールを入れるか判定
        b[i] = a[i-1] ^ (s % 2);
    }

    int t = b.sum;
    writeln(t);
    if (t > 0) {
        foreach (i, e; b) {
            if (e == 1) writeln(i, " ");
        }
        writeln();
    }
}

void main() {
    readint;
    auto a = readints;
    calc(a);
}


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

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int m = in.nextInt();
        int[] a = in.nextIntArray(n);

        int total = Arrays.stream(a).sum();

        int count = 0;
        for (int i : a) {
            if ((i * 4 * m) >= total) {
                count++;
            }
        }

        out.println(count >= m ? "Yes" : "No");
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 28372
#include<stdio.h>
#define MAX 21
#define XMAX 50010


int min(int a,int b){
 if(a<b)return a;

return b;
}



void func(int A[],int n,int m){
int X[XMAX];
int Y[XMAX];
int i,j;

for(i=1;i<=n;i++)X[i]=i;

for(i=1;i<m;i++){/*たて*/

 if(i%2==1){

    for(j=1;j<=n;j++){/*よこ*/
       if(A[i]>j)Y[j]=X[j];
       else if(j%A[i]==0)Y[j]=min(X[j],j/A[i]);
       else if(A[i]<j)Y[j]=Y[j-A[i]]+1;

       Y[j]=min(Y[j],X[j]);
    }

 }


 else if(i%2==0){

    for(j=1;j<=n;j++){/*よこ*/
       if(A[i]>j)X[j]=Y[j];
       else if(j%A[i]==0)X[j]=min(Y[j],j/A[i]);
       else if(A[i]<j)X[j]=X[j-A[i]]+1;

       X[j]=min(Y[j],X[j]);
    }

 }



}


if(m%2==1)printf("%d\n",X[n]);
else if(m%2==0)printf("%d\n",Y[n]);

return;
}

void swap(int A[],int a,int b){
int temp;
temp=A[a];
A[a]=A[b];
A[b]=temp;

return;
}


void bubblesort(int A[],int m){
int i,j;

for(i=1;i<m;i++){
 for(j=0;j<m-i;j++){
   if(A[j]>A[j+1])swap(A,j,j+1);
 }
}


return;
}







int main(){
int n,m,i;
int A[MAX];

scanf("%d %d",&n,&m);
for(i=0;i<m;i++)scanf("%d",&A[i]);


bubblesort(A,m);


func(A,n,m);

return 0;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll inf=1e18;
ll p= 998244353;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
   while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i,j,y,k,z,w,g,m,t,n,a,b;
	ll t2,t3,t4,t1;
	    string s;
	    cin>>n;
	    do
	    {
	        n--;
	        ll temp=n%26;
	        
	        s.pb(char(temp+'a'));
	        n/=26;
	        
	    }while(n>0);
	    for(i=s.length()-1;i>=0;i--)
	    cout<<s[i];
	     
	 return 0;
	 
           
}

Measured memory_bytes: 3652
n = int(input())
A = sorted(tuple(map(int, input().split())))
B = tuple(map(int, input().split()))
C = sorted(tuple(map(int, input().split())))

import bisect

count = 0
for b in B:
    # Aの候補
    la = bisect.bisect_left(A, b)
    # Cの候補
    rc = bisect.bisect_right(C, b)
    
    count += la*(n-rc)

print(count)

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

		else
			 if ( b < c)
				cout << b << " " << c << " " << a << endl;
				
		
			else
				cout << c << " " << b << " " << a << endl;
	return 0;
}


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

int main() {
	int N,l,ba=0,b=0,a=0,r=0;
	string S;
	cin >> N;

	rep(i,N) {
		cin >> S;
		l = S.size();

		rep(j,l-1)
			if(S.substr(j,2) == "AB")
				++r;

		if(S.at(0)=='B' && S.at(l-1)=='A')
			++ba;
		else if(S.at(0) == 'B')
			++b;
		else if(S.at(l-1) == 'A')
			++a;
	}

	cout << r+min(b,a)+ba+(-1)*(ba>0&&b+a==0) << endl;
}

Measured memory_bytes: 256
// lannisters don't act like fools
#include <bits/stdc++.h>
using namespace std;
#define yah_faster_baby ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


void solve() {

    int n;
    cin >> n;
    string s;
    map<string, int>mp;
    mp["A"] = 0;
    mp["WA"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;
    for (int i = 0; i < n; i++) {
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}



int main() {
    yah_faster_baby
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif // ONLINE_JUDGE
    solve();
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define OO 1e9
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))

const double eps=1e-9;
const  int MOD=1e10;
const int N=1e5+9;
const int inf = 1LL<<32;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <typename T> T exp(T b, T p){T x = 1;while(p){if(p&1)x=(x*b);b=(b*b);p=p>>1;}return x;}
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
int sum[N];
int32_t main() {
    IOS;
int n,m;
cin>>n>>m;
vector<pair<int,int> > arr(n);
    for (int i = 0; i < n; ++i) {
        cin>>arr[i].first>>arr[i].second;
    }
    sort(all(arr));
    int sum=0;
    for (int i = 0; i < n; ++i) {
        if(m!=0){
            int mi=min(m,arr[i].second);
            sum+=mi*arr[i].first;
            m-=mi;
        }else break;
    }
    cout<<sum;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
    using namespace std;
    
    bool isPrime(int x) {
      for (int d = 2; d * d <= x; d++) {
        if (x % d == 0)
          return false;
      }
      return true;
    }

    int main(){
      int n;
      cin >> n;
      vector<int> v;
      for(int i = 2 ; i  <= 55555 ; i++){
          if(isPrime(i) && (i % 5 == 1)) v.push_back(i);
      } 
      
      cout << v[0];
      for ( int i = 1; i < n ; i++){
          cout << " " << v[i] ;
      }
      cout << endl;
      
      return 0;
    }

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

#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;

const int N = 3123;
const int T = 3123;

int dp[T][2];

void solve(void) {

	int n, t;
	cin >> n >> t;
	
	vector<pair<int, int>> dishes;
	for(int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		dishes.emplace_back(a, b);
	}
	
	// dp[T][2], 
	// dp[i][0] = best so far ending at time i, 
	// dp[i][1] = best so far with last item possibly starting at time i
	for(int i = 0; i < n; i++) {
		int a = dishes[i].first, b = dishes[i].second;
		for(int j = t - 1; j >= 0; j--) {
			if(j + a < t) {
				dp[j+a][0] = max(dp[j+a][0], dp[j][0] + b);
				dp[j+a][1] = max(dp[j+a][1], dp[j][1] + b);
			}
			// order at time j 
			dp[j][1] = max(dp[j][1], dp[j][0] + b);
		}
		
	}
	
	cout << dp[t-1][1] << '\n';

}

int main(void) {

	solve();

	return 0;
}


Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let l = i.read::<usize>();

    let (nodes, g) = solve(l);
    writeln!(o, "{} {}", nodes, g.len()).unwrap();
    for (u, v, w) in g {
        writeln!(o, "{} {} {}", u, v, w).unwrap();
    }
}
pub fn solve(mut l: usize) -> (usize, Vec<(usize, usize, usize)>) {
    let mut g = Vec::new();
    let mut nodes = 1;
    let mut b = 1;
    while b * 2 <= l {
        g.push((nodes, nodes + 1, 0));
        g.push((nodes, nodes + 1, b));
        nodes += 1;
        b *= 2;
    }
    if l != b {
        let mut bn = nodes;
        let mut w = b;
        l -= b;
        loop {
            if l >= b {
                g.push((bn, nodes, w));
                l -= b;
                if l == 0 {
                    break;
                }
                w += b;
            }
            b /= 2;
            bn -= 1;
        }
    }
    (nodes, g)
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin>>N>>M;
  va.resize(M);
  rep(i,0,M-1){
    cin>>va[i];
  }
  ;
}
void solve() {
  int a = 0;
  for(auto x : va){
    a += x;
  }
  cout<<max(-1LL,N-a)<<endl;
  ;

  ;
}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    int N;
    scan(N);
    vector<int> c(N - 1), s(N - 1), f(N - 1);
    REP(i, N - 1) scan(c[i], s[i], f[i]);

    vector<ll> ans(N);
    REP(i, N - 1) {
        ll sum = s[i];
        FOR(j, i + 1, N - 1) {
            sum += c[j - 1];
            chmax(sum, (ll)s[j]);
            if (s[j] < sum && sum % f[j] != 0) {
                sum += f[j] - sum % f[j];
            }
        }
        sum += c[N - 2];
        ans[i] = sum;
    }
    vprint(ans);

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int K = int.Parse(Console.ReadLine());
		string str = Console.ReadLine();
		if(str.Length <= K){
			Console.WriteLine(str);
		} else {
			Console.WriteLine(str.Substring(0,K)+"...");
		}
	}
}

Measured memory_bytes: 17620
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		ScannerModule sm = new ScannerModule();
		int input_a = sm.scanInt();
		int input_b = sm.scanInt();
		int seki = input_a * input_b;
		if(seki % 2 == 0) {
			System.out.println("Even");
		}
		else {
			System.out.println("Odd");
		}
	}
}
class ScannerModule {
	Scanner scanner = new Scanner(System.in);
	int scanInt() {
		return Integer.parseInt(scanner.next());
	}
	String scanString() {
		return scanner.next();
	}
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n,k;cin >>n>>k;
    ll g=0;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        g=__gcd(g,a[i]);
    }
    bool flg=false;
    for (int i = 0; i < n; ++i) {
        ll d=a[i]-k;
        if(d<0)continue;
        if(d%g==0)flg=true;
    }
    if(flg)puts("POSSIBLE");
    else puts("IMPOSSIBLE");
    return 0;
}


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

int main(){
    int N, X, T;
    cin >> N >> X >> T;
    if(N%X==0){
        cout << N*T/X << endl;
    }else{
        cout << (N/X+1)*T << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int64_t A,B;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> A>>B;

	if (abs(A - B) <= 1) {
		out << "Brown" << endl;
	}
	else {
		out << "Alice" << endl;
	}

	return 0;
}
#endif


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		int[] p = new int[n];
		for(int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		int min=0;
		for(int i = 0; i < n; i++) {
			if(i == 0) {
				min = p[i];
				count++;
			}
			else if(p[i] < min) {
				count++;
				min = p[i];
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 64964