akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

int h,n,w;

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

    cout << (n-h+1)*(n-w+1) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>	
int main(void) {
	int min, x, y;

	while (1) {
		scanf("%d %d", &x, &y);

		if (x == 0 && y == 0)
			break;
		if (x > y) {
			printf("%d %d\n", y, x);
		}
		else {
			printf("%d %d\n", x, y);
		}
	}

	return 0;
}

Measured memory_bytes: 600
n,k = list(map(int,input().split()))
a =[]
for i in range(n):
    a.append(list(map(int,input().split())))
a.sort()
b =[]
c =[]
for i in range(n):
    b.append(a[i][0])
    c.append(a[i][1])
for i in range(n-1):
    c[i+1] = c[i]+c[i+1]
ans = c[-1]
for i in range(1,n):
    if c[i] >= k:
        ans = b[i]
        break

print(ans)

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

typedef pair<int, int> Pair;

vector<Pair> rects;

bool Compare(const Pair &a, const Pair &b) {
  int h1 = a.first;
  int h2 = b.first;
  int w1 = a.second;
  int w2 = b.second;
  int t1 = h1*h1+w1*w1;
  int t2 = h2*h2+w2*w2;
  if (t1 != t2) return t1 < t2;
  return h1 < h2;
}

int main() {
  for (int i=1; i<200; i++) {
    for (int j=i+1; j<200; j++) {
      rects.push_back(Pair(i, j));
    }
  }
  sort(rects.begin(), rects.end(), Compare);

  while (1) {
    int h, w;
    scanf("%d%d", &h, &w);
    if (h == 0 && w == 0) return 0;

    Pair ans = *upper_bound(rects.begin(), rects.end(), Pair(h, w), Compare);
    printf("%d %d\n", ans.first, ans.second);
  }
}

Measured memory_bytes: 3336
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;++i)
using namespace std;

const int mn=2006;
int a[mn],id[mn];
long long f[mn][mn],ans;

bool cmp(int x,int y)
{
	return a[x]>a[y];
}

int main()
{
	int n;
	scanf("%d",&n);
	FOR(i,0,n-1) {scanf("%d",a+i);id[i]=i;}
	sort(id,id+n,cmp);
	FOR(i,0,n-1) FOR(j,0,n-i-1) {
		int k=i+j;
		f[i+1][j]=max(f[i+1][j],f[i][j]+1ll*a[id[k]]*abs(id[k]-i));
		f[i][j+1]=max(f[i][j+1],f[i][j]+1ll*a[id[k]]*abs(id[k]-(n-j-1)));
	}
	FOR(i,0,n) ans=max(ans,f[i][n-i]);
	cout<<ans;
}

Measured memory_bytes: 26340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cntr=0;
	for(int i=0; i<n; i++){
		if(s[i]=='R')
		 cntr++;
	}
	int cnt=0;
	for(int i=0; i<cntr; i++){
		if(s[i]=='R')
		 cnt++;
	}
	int ans=cntr-cnt;
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 3720
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, sum, cnt int

func main() {
	reader.Split(bufio.ScanWords)
	a, _ := strconv.Atoi(read())
	s := read()

	if 3200 <= a {
		fmt.Println(s)
	} else {
		fmt.Println("red")
	}
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cmath>
#include<array>
#include<algorithm>
#include<queue>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n,int r) {
//	n = n + r - 1;
//	return nCr(n,r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	int X, A;
	cin >> X >> A;
	if (X<A) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>     
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)1e3 + 10;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

int n;
pair<pii, int> a[maxn];                  
bool cmp(pair<pii, int> a, pair<pii, int> b){
	return (a.f.f + a.f.s) < (b.f.f + b.f.s);
}              
int dp[maxn][maxn * 10];
int calc(int pos, int s){
	if(s > 10000) return 0;
	if(pos == n + 1)
		return 0;
	int &res = dp[pos][s];
	if(res != -1)
		return res;
	res = calc(pos + 1, s);
	if(s <= a[pos].f.s)
		res = max(res, calc(pos + 1, s + a[pos].f.f) + a[pos].s);
	return res;	
}
main () {
	cin >> n;
	forn(i, 1, n)
		cin >> a[i].f.f >> a[i].f.s >> a[i].s;
	sort(a + 1, a + n + 1, cmp);
	memset(dp, -1, sizeof(dp));
	cout << calc(1, 0);	
}


Measured memory_bytes: 80000
N = int(input())
A_list = map(int, input().split())
 
# [活発度, もとの番号] のリストを降順に並べる
A_list = [[A, index] for index, A in enumerate(A_list)]
A_list.sort(reverse=True)
 
# print(A_list)
 
dp = [[0 for i in range(N+1)] for j in range(N+1)]
# print(dp)
for left in range(0, N):
    for right in range(0, N - left):
        # print(f'left, righte: { left, right }')
        # print(A_list[left + right - 1][0])
        activity = A_list[left + right][0]
        distance_from_left = A_list[left + right][1] - left
        # print(f'distance_from_left: { distance_from_left }')
        distance_from_right = (N - 1 - right) - A_list[left + right][1]
        # print(f'distance_from_right: { distance_from_right }')
        dp[left + 1][right]\
            = max(dp[left + 1][right],
                  dp[left][right] + activity * distance_from_left)
        dp[left][right + 1]\
            = max(dp[left][right + 1],
                  dp[left][right] + activity * distance_from_right)
        # print('dp---')
        # print(dp)
        # print('---dp')
# print(dp)
dp_list = [flatten for inner in dp for flatten in inner]
print(max(dp_list))

Measured memory_bytes: 194140
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_3_A&lang=jp
# Min-Max

from functools import reduce
from collections import deque
import sys
input = sys.stdin.readline


def main():
    l  = list ( map(int,input().split()))
    max = reduce(lambda a,b : a if a > b else b,l)
    min = reduce(lambda a,b : a if a < b else b,l)
    print (min,max)

if __name__ == '__main__':
    main()

    


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int res = 0;
  int t = min(a, k);
  res += t;
  k -= t;
  t = min(b, k);
  k -= t;
  t = min(c, k);
  res -= t;
  k -= t;
  cout << res << '\n';
}


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

#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int N = 2e5+10;
int a[N];
vi g[N];

int n;

void compress()
{
    int b[n];
    f(i,n) b[i] = a[i];
    sort(b,b+n);
    unique(b,b+n);
    f(i,n) a[i] = upper_bound(b,b+n,a[i]) - b;
}

int res[N];
int seg[2*N + 1999];

void upd(int id,int val)
{
    for(seg[id+=N] = val;id > 1;id>>=1)
        seg[id>>1] = max(seg[id],seg[id^1]);
}

int qq(int l,int r)
{
    int res = 0;
    
    for(l+=N,r+=N+1;l<r;l>>=1,r>>=1)
    {
        if(l&1) res = max(res,seg[l++]);
        if(r&1) res = max(res,seg[--r]);             
    }
    
    return res;
}

void dfs(int node,int par = -1)
{
     int v = qq(1,a[node]-1);
    
    int old = qq(a[node],a[node]);
        
     upd(a[node],max(v + 1,old));
    
    res[node] = qq(1,N-1);
      
     for(auto x : g[node])
         if(x != par) dfs(x,node);
    
     upd(a[node],old);
}

void solve()
{
   cin >> n;
   f(i,n) cin >> a[i];
    
   compress(); 
    
   int u,v;
   
   f(i,n-1)
   {
      cin >> u >> v;
      u--; v--;
      g[u].pb(v);
      g[v].pb(u);
   }
    
   dfs(0);
    
   f(i,n) cout << res[i] << '\n';
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 32272
#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;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
void radd(int &a, int b)
{
	a=add(a,b); 
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
void rmult(int &a, int b)
{
	a=mult(a,b);
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}
	
ll median(vector<ll> &v)
{
	sort(v.begin(),v.end());
	int n=v.size();
	if(n%2==1)
	{
		return v[n/2];
	}
	else
	{
		return v[n/2-1]+v[n/2];
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	vector<ii> vec;
	for(int i=0;i<n;i++)
	{
		ll l,r; cin>>l>>r; 
		vec.pb({l,r});
	}
	vector<ll> L,R;
	for(int i=0;i<n;i++)
	{
		L.pb(vec[i].fi); R.pb(vec[i].se);
	}
	ll lef = median(L); ll ri = median(R);
	if(n%2==0)
	{
		cout<< ri-lef+1<<'\n';
	}
	else
	{
		cout<< ri-lef+1<<'\n';
	}
}


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

int main(){
  int N,K,S;
  cin >>N>>K>>S;
  if(N==K){
      for(int i=0;i<K-1;i++){
        cout<<S<<" ";
      }
      cout<<S<<endl;
      return 0;
    }
  if(S==1000000000){
    for (int i=0;i<K;i++){
      cout<<S<<" ";
    }
    for(int i=K;i<N-1;i++){
      cout<<1<<" ";
    }
    cout<<1<<endl;
    return 0;
  } 
  for(int i=0;i<K;i++){
    cout<<S<<" ";
  }
  for(int i=K;i<N-1;i++){
    cout<<S+1<<" ";
  }
  cout<<S+1<<endl;
  return 0;
}

   
    
  
 

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

int main(){
  const int64_t mod=998244353;
  int N,K;
  cin >> N >> K;
  vector<pair<int,int> > vp(K);
  for(int i=0;i<K;i++){
    cin >> vp.at(i).first >> vp.at(i).second;
  }
  vector<int64_t> dp(N+1,0),sum(N+1,0);
  dp.at(1)=1;
  sum.at(1)=sum.at(0)+dp.at(1);
  for(int i=2;i<=N;i++){
    for(int j=0;j<K;j++){
      if(i>vp.at(j).first){
        dp.at(i)+=(sum.at(i-vp.at(j).first)-sum.at(max(0,i-vp.at(j).second-1)))%mod;
        dp.at(i)%=mod;
      }
    }
    sum.at(i)+=(sum.at(i-1)+dp.at(i))%mod;
    sum.at(i)%=mod;
  }
  if(dp.at(N)<0){
    dp.at(N)+=mod;
  }
  cout << dp.at(N) << endl;
  return 0;
}


Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

ll solve(ll h){
    if(h==1)return 1;
    return 1+2*solve(h/2);
}

int main(){
    ll h;
    cin>>h;
    cout<<solve(h)<<endl;
}

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

int pos, var;
string s;
int formula() {
  pos++;
  if(s[pos]=='T') return 1;
  if(s[pos]=='F') return 0;
  if(isalpha(s[pos])) return var>>(s[pos]-'a')&1;
  if(s[pos]=='-') return !formula();
  int f1=formula();
  pos++; char op=s[pos]; if(op=='-') pos++;
  int f2=formula(); pos++;
  if(op=='*') return f1&f2;
  if(op=='+') return f1|f2;
  if(op=='-') return f1<=f2;
}

int main() {
  while(cin >> s) {
    if(s=="#") break;
    bool ok=true;
    for(var=0;var<(1<<11);var++) {
      pos=-1; int lhs=formula();
      pos++;
      if(lhs!=formula()) { ok=false; break; }
    }
    cout << (ok ? "YES":"NO") << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	n %= 10
	if n == 3 {
		fmt.Println("bon")
	} else if n == 0 || n == 1 || n == 6 || n == 8 {
		fmt.Println("pon")
	} else {
		fmt.Println("hon")
	}
}

Measured memory_bytes: 1752
const main = input => {
  const [a, b, c] = input.trim().split(' ').map(x => parseInt(x))
  const set = new Set()
  set.add(a)
  set.add(b)
  set.add(c)

  console.log(set.size)
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29560
/*************************************************************************
	> File Name: B.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Created Time: 2020/4/19 20:25:59
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	int n,m,a;
	n=read(); m=read();
	For(i,1,m){
		a=read();
		n-=a;
	}
	if(n<0) n=-1;
	printf("%d\n",n);
	return 0;
}


Measured memory_bytes: 3752
s = int(input())

def calc(n):
    if n%2 == 0:
        return int(n/2)
    else:
        return 3 * n + 1

done = [s]
for i in range(10000000):
    tmp = calc(done[i])
    if tmp in done:
        print(i + 2)
        exit()
    else:
        done.append(tmp)


Measured memory_bytes: 2940
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID

#include <bits/stdc++.h>

// #pragma GCC optimize("O3")
// #pragma GCC target("avx")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ll long long
#define MP make_pair
#define ERR cout << "================================================\n"
#define fi first
#define se second
#define PB push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define print(v)          \
	for (auto x : v)      \
	{                     \
		cout << x << " "; \
	}
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define SP << " " <<
#define W(t)  \
	ll t;     \
	cin >> t; \
	while (t--)
#define FIO                           \
	freopen("input.txt", "r", stdin); \
	freopen("output.txt", "w", stdout);
#define FAST                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll INF = 1e18;
const ll NEG_INF = -1 * (1e18);
using namespace std;

void usaco(string prob)
{
	freopen((prob + ".in").c_str(), "r", stdin);
	freopen((prob + ".out").c_str(), "w", stdout);
}

/* Function to check primality in O(sqrt(n)) */
bool prime(int n)
{
	if (n < 2)
		return false;
	for (int x = 2; x * x <= n; x++)
	{
		if (n % x == 0)
			return false;
	}
	return true;
}

/* Function to get prime factorization of n */
vector<int> getFactors(int n)
{
	vector<int> f;
	for (int x = 2; x * x <= n; x++)
	{
		while (n % x == 0)
		{
			f.push_back(x);
			n /= x;
		}
	}
	if (n > 1)
		f.push_back(n);
	return f;
}

void solve()
{
	/* Write Solution Here */
	ll d, t, s;
	cin >> d >> t >> s;
	if (d <= t * s)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}
}

int main()
{
	//FIO
	//FAST

	//usaco("cowlands");

	ll TC = 1;
	/*
	Uncomment when multiple test cases
	*/

	// cin>>TC;
	for1(tt, TC)
	{
		solve();
	}
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 3640
using System;
using System.Collections;
class Program
{
	static void Main(string[] args)
	{
            var line = Console.ReadLine().Split(' ');
            int a = int.Parse(line[0]);
            int b = int.Parse(line[1]);
            int cnt = 0;

            Hashtable ht = new Hashtable();

            for (int i = 1; i < 1000; i++)
            {
                cnt = cnt + i;
                ht.Add(i, cnt);
            }

            int value = (int)ht[(b - a)];
            Console.WriteLine(value - b);
        }
}

Measured memory_bytes: 13176
#include <iostream>
#include <vector>
#include <set>

using namespace std;

long long calc(const string& s, const set<int>& ops)
{
	int sum = 0;
	string buf;
	for (auto i = 0; i < (int)s.size(); i++) {
		buf.push_back(s[i]);
		if (ops.find(i) != ops.end()) {
			sum += strtoll(&buf[0], nullptr, 10);
			buf.clear();
		}
	}

	if (!buf.empty()) {
		sum += strtoll(&buf[0], nullptr, 10);
	}
	return sum;
}

vector<set<int>> combinations(int lv, int mv, int s)
{
	if (s == 0) return vector<set<int>>();

	std::vector<set<int>> result;
	for (auto i = lv; i <= mv; i++) {
		if (s == 1) {
			set<int> w;
			w.insert(i);
			result.push_back(w);
			continue;
		}
		auto nexts = combinations(i + 1, mv, s - 1);
		for (auto& v : nexts) {
			v.insert(i);
			result.push_back(std::move(v));
		}
	}

	return result;
}

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

	long long sum = 0;

	int max = s.size() - 1;
	for (auto i = 0; i <= max; i++) {
		if (i == 0) {
			sum += strtol(&s[0], nullptr, 10);
		} else {
			for (auto ops : combinations(0, max - 1, i)) {
				sum += calc(s, ops);
			}
		}
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Comparator;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int ans1 = a + b;
		int ans2 = a - b;
		int ans3 = a * b;
		System.out.println(Stream.of(ans1, ans2, ans3).max(Comparator.naturalOrder()).get());

	}

}


Measured memory_bytes: 28748
(X, Y, Z, K), As, Bs, Cs = readlines.map{|l| l.split.map(&:to_i)}

class Array
  def srt
    self.sort.reverse.take(K)
  end
end

def go(xs, ys)
  xs.srt.product(ys.srt).map{|x, y| x + y}.srt
end

puts go(go(As, Bs), Cs)

Measured memory_bytes: 289616
def agc034_b():
    s = str(input())
    n = len(s)
    if n < 3: return print(0)

    r = s[::-1]
    cb = 0
    ans = 0
    for i in range(1, n):
        if r[i] == 'A':
            if r[i-1] == 'C': cb = 0
            else: ans += cb
        elif r[i] == 'B':
            if r[i-1] == 'C': cb += 1
            else: cb = 0
        else:
            if r[i-1] == 'C': cb = 0
            else: continue
    print(ans)

if __name__ == '__main__':
    agc034_b()

Measured memory_bytes: 9284
#include <cstdio>
#include <cmath>
#include <algorithm>

#define pii pair <int, int>
#define f first
#define s second
#define pi 3.14159265358979

using namespace std;

pii v[128];
double a[128];

int main ()
{
   // freopen ("file.in", "r", stdin);

    int n;
    scanf ("%d", &n);

    for (int i = 1; i <= n; ++i)
        scanf ("%d %d", &v[i].f, &v[i].s);

    for (int i = 1; i <= n; ++i)
    {
        int k = 0;
        for (int j = 1; j <= n; ++j)
            if (i != j)
                a[++k] = atan2 (v[j].s - v[i].s, v[j].f - v[i].f);

        sort (a + 1, a + k + 1);

        double prop = 0.0;
        for (int i = 1; i < k; ++i)
            prop = max (prop, a[i + 1] - a[i] - pi);

        double fi = 2.0 * pi + a[1];

        prop = max (prop, fi - a[k] - pi);
        prop /= 2.0 * pi;

        printf ("%.8f\n", prop);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

    bool found = false;
    while(n > 0) {
        if(n % 10 == 7) found = true;
        n /= 10;
    }

    Yn(found);
    
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>

int solve(int *A, int n, int i, int m){
    if(m == 0){
        return 1;
    }
    if(i >= n){
        return 0;
    }
    return solve(A, n, i + 1, m) || solve(A, n, i + 1, m - A[i]);
}

int main(){
    int n, q, m, i;
    int *A;
    scanf("%d", &n);
    A = (int *)malloc(n * sizeof(int));
    for(i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d", &m);
        if (solve(A, n, 0, m)){
            printf("yes\n");
        }
        else{
            printf("no\n");
        }
    }
    free(A);
    return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100000+10;
int n,m,a[maxn],ans[maxn],res[maxn],tmp[maxn];
long long k;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    for(int i=1;i<n;++i)ans[i]=i;
    scanf("%d%lld",&m,&k);
    for(int i=1;i<=m;++i){
        int x;
        scanf("%d",&x);
        swap(ans[x],ans[x-1]);
    }
    for(int i=1;i<n;++i)res[i]=i;
    while(k){
        if(k&1)
            for(int i=1;i<n;++i)res[i]=ans[res[i]];
        for(int i=1;i<n;++i)tmp[i]=ans[ans[i]];
        for(int i=1;i<n;++i)ans[i]=tmp[i];
        k>>=1;
    }
    long long sum=a[1];
    for(int i=1;i<=n;++i){
        printf("%lld.0\n",sum);
        sum+=a[res[i]+1]-a[res[i]];
    }
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#define INF 10000000000
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
    ll a,b;
    cin >> a >> b;
    if(b%a==0){
        cout << a+b << endl;
    }else{
        cout << b-a << endl;
    }
} 

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

int main()
{
  int n,a[1000],b[1000],c[1000],m;
  string ans[1000];

  cin>>n;
  for(int i=0; i<n; i++)
    cin>>a[i]>>b[i]>>c[i];
    
  for(int i=0; i<n; i++){
    m = max(a[i],b[i]);
    m = max(m,c[i]);
    if(m == a[i]){
      if(a[i] * a[i] == b[i] * b[i] + c[i] * c[i])
	ans[i] = "YES";
      else
	ans[i] = "NO";
      continue;
    }
    if(m == b[i]){
      if(b[i] * b[i] == a[i] * a[i] + c[i] * c[i])
	ans[i] = "YES";
      else
	ans[i] = "NO";
      continue;
    }
    if(m == c[i]){
      if(c[i] * c[i] == a[i] * a[i] + b[i] * b[i])
	ans[i] = "YES";
      else
	ans[i] = "NO";
    }
  }

  for(int i=0; i<n; i++)
    cout<<ans[i]<<endl;

  return 0;
}

Measured memory_bytes: 1256
#include <stdio.h>

int main() {
    int x, y;
    
    while(1) {
        scanf("%d%d", &x, &y);
        if (x == 0 && y == 0) {
            break;
        } else if(x > y) {
            printf("%d %d\n", y, x);
        } else {
            printf("%d %d\n", x, y);
        }
    }
    
    return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
	int a, b;
	string s;

	cin >> a >> b >> s;

	for(int i = 0; i < a; i++){
		if(s[i] < '0' || s[i]  > '9'){
			cout << "No";
			return 0;
		}
	}

	if(s[a] != '-'){
		cout <<  "No";
		return 0;
	}

		for(int i = 0; i < b; i++){
		if(s[i+a+1] < '0' || s[i+a+1]  > '9'){
			cout << "No";
			return 0;
		}
		}

		cout << "Yes";
		return 0;
	
}



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

// Rytter
long long count_inversions(vector<int> seq) {
    long long result = 0;
    const size_t n = seq.size();
    for (size_t i = 0; i < __lg(n) + 2; i++) {
        auto cnt = vector<int>(n * 2 + 1, 0);
        for (auto &x : seq) {
            if (x % 2 == 1) {
                cnt[x] += 1;
            } else {
                result += cnt[x + 1];
            }
            x >>= 1; 
        }
    }

    return result;
}

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

    int n; cin >> n;
    vector<int> numbers(n);
    for (auto &x : numbers) {
        cin >> x;
    }

    // Is the median equal at least x?
    auto check = [&](int x) {
        auto sums = numbers;
        for (auto &value : sums) {
            value = (value < x ? -1 : 1);
        }
        sums.insert(begin(sums), 0);
        partial_sum(begin(sums), end(sums), begin(sums));

        // Shift value range to [0, 2n]
        for (auto &value : sums) {
            value += n;
        }

        auto positive_segments = (long long) n * (n + 1) / 2 - count_inversions(sums);

        return positive_segments >= ((long long) n * (n + 1) / 2 + 1) / 2;
    };

    int lo = *min_element(begin(numbers), end(numbers));
    int hi = *max_element(begin(numbers), end(numbers));
    while (lo < hi) {
        auto mid = (lo + hi) / 2 + 1;
        if (check(mid)) { // sprawdz warunki
            lo = mid;
        } else {
            hi = mid - 1;
        }
    }

    cout << lo << endl;
}

Measured memory_bytes: 5896
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    d = defaultdict(int)
    for i in range(M):
        B, C = map(int, input().split())
        d[C] += B
    
    for a in A:
        d[a] += 1

    ans = 0
    cnt = 0
    for i in sorted(d.keys(),reverse=True):
        if cnt + d[i] < N:
            ans += d[i] * i
            cnt += d[i]
        else:
            ans += i * (N - cnt)
            cnt = N
            break

    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 92568
#include <stdio.h>
int main(void){
    int A,B,K;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&K);
    
    int Max = A,counter = 0;
    if(A>B) Max = B;
    
    for(int i = Max;i > 0;i--){
        if(A%i == 0 && B%i == 0) counter++;
        if(counter == K){
            printf("%d",i);
            return 0;
        }
    }
    
    return 0;
    
}


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

using namespace std;
typedef long long ll;




int main()
{
    int H,W,A,B;
    cin >> H >> W >> A >> B;
    for (int j = 1; j <= B; j++) {
        for (int i = 1; i <= A; i++) {
            cout << 1;
        }
        for (int i = A+1; i <= W; i++) {
            cout << 0;
        }
        cout << endl;
    }
    for (int j = B+1; j <= H; j++) {
        for (int i = 1; i <= A; i++) {
            cout << 0;
        }
        for (int i = A+1; i <= W; i++) {
            cout << 1;
        }
        cout << endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define endl '\n'
#define mo 998244353
 
using namespace std ;

const lli MAXN = 100005 ;

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main()
{  
 
//////////////////////////////////////////////
    fastio;

    lli a,p;
    cin>>a>>p;

    lli k = 3*a + p;

    lli oo = k/2;
    cout<<oo<<endl;

}

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

#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif

int calc_gcd(int n, int m){
	if(n == m){ return n; }
	if(n > m){
		std::swap(n, m);
	}
	return calc_gcd(n, m - n);
}

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	int n = 0;
	std::vector<int> vec;
	int gcd = 1;

#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif
	vec.resize(n);
	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> vec[i];
#else
		std::cin >> vec[i];
#endif
	}
	std::sort(vec.begin(), vec.end());

	gcd = calc_gcd(vec[0], vec[1]);

	std::cout << "1" << std::endl;
	for(int i = 2; i <= gcd; i++){
		if(gcd % i == 0){
			if(n == 3){
				if(vec[2] % i == 0){
					std::cout << i << std::endl;
				}
			}
			else{
				std::cout << i << std::endl;
			}
		}
	}
	return 0;
}


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

const ll oo = 1e18;
 
ll DP[110][maxn];
int N,W;
ll w[110], v[110];
 
ll min(ll a, ll b) {
	if (a <= b) return a;
	return b;
}
 
ll cal(int pos, int val) {
 
	if (val == 0) return 0LL;
 
	if (pos == N || val < 0) return oo;
 
 
	ll &res = DP[pos][val];
 
	if (res != -1) {
		return res;
	}
 
	res = cal(pos+1, val);
	res = min(res, cal(pos+1, val -  v[pos])+w[pos]);
 
	return res;
}
 
int main() {
 
	cin >> N >> W;
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}
 
 
	memset(DP, -1, sizeof(DP));
 
 
 
	for (int i = N * 1000; i >= 0; i--) {
 
		if (cal(0, i) <= W) {
			cout << i << endl;
			return 0;
		}
	}
 
 
	return 0;
}

Measured memory_bytes: 86144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string S;
  cin >> S;
  long long ans = 0;
  vector<int> adding_sum(2019, 0);
  int current_num = 0; 
  int pow10 = 1;
  for(int i = S.size() - 1; i >= 0; i--)
  {
    int n = S[i] - '0';
    current_num = (current_num + pow10 * n) % 2019;
    pow10 = (pow10 * 10) % 2019;
    ans += adding_sum.at(current_num);
    if (current_num == 0) 
      ans++;
    
    adding_sum[current_num]++;
  }
  cout << ans << endl;
 return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


double w,h;
double x,y;

int main(){
	cin>>w>>h>>x>>y;
	double ans=(double)w*h/2;
	cout<<ans<<" ";
	if(w/2==x&&h/2==y){
		cout<<1<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
N,M=map(int,sys.stdin.readline().split())
L=sorted(list(map(lambda x: (1,int(x)), sys.stdin.readline().split()))
         +[tuple(map(int, sys.stdin.readline().split())) for _ in range(M)]
         ,key=lambda x: x[1],reverse=True)
ans,k=0,0
for n,a in L:
  if n+k>=N:
    ans+=a*(N-k)
    break
  else:
    ans+=a*n
    k+=n
print(ans)

Measured memory_bytes: 38968
using System;

class Program
{
	static void Main()
	{
		// input
		var input = Console.ReadLine().Split();
		var a = int.Parse(input[0]);
		var b = int.Parse(input[1]);

		// calc
		var l = (a + b) * 2;
		var s = a * b;

		Console.WriteLine(string.Format("{0} {1}", s, l));
	}
}

Measured memory_bytes: 9092
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)



void solve(void){

  int N;
  
  int T=0;
  
  cin >> N;
  
  vector<int> A(N,0);
//  int MN[N];
  int M = 1000000;
  REP(i,N){
    cin >> A.at(i);
    if(A[i]<M){
//      MN[i] = A[i];
      M = A[i];
      T++;
    }
    else{
//      MN[i] = M;
    }
  }
  
  cout << T << endl;

  return;
}

int main(int argc, const char * argv[]) {



    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = (int)1e6 + 1;
	void doIt() {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int a[] = new int[N];

		for(int i = 0; i < N; i++)
			a[i] = sc.nextInt();
		int count = numTwo(a[0]);
		for(int i = 1; i < N; i++) {
			if(count != numTwo(a[i])) {
				System.out.println(0);
				return;
			}
		}

		long lcm = a[0];
		for(int i = 1; i < N; i++) {
			long g = gcd(lcm, a[i]);
			lcm = lcm * a[i] / g;
			if(lcm / 2 > M) {
				System.out.println(0);
				return;
			}
		}
		long ans = M / (lcm / 2) - M / lcm;
		System.out.println(ans);

	}


	int numTwo(int n) {
		int cnt = 0;
		while(n % 2 == 0) {
			cnt++;
			n /= 2;
		}
		return cnt;
	}
	
	long gcd(long a, long b) {
		return (b == 0)?a:gcd(b, a % b);
	}

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

}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll a, b;
    cin >> a >> b;

    cout << ((a * b) % 2 == 0 ? "Even" : "Odd") << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int a=0,b=0,c=0,i;
	cin>>s;
	for(i=0;i<3;i++){
		if(s[i]=='a'){
			a++;
		}else if(s[i]=='b'){
			b++;
		}else{
			c++;
		}
	}
	if(a==1&&b==1&&c==1){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}

Measured memory_bytes: 256
N = int(input())
A, B = [int(a) for a in input().split()]
p_list = [int(a) for a in input().split()]

p_list1 = [a for a in p_list if a <= A]
p_list2 = [a for a in p_list if A < a <= B]
print(str(min([len(p_list1), len(p_list2),N - len(p_list1) - len(p_list2)])))


Measured memory_bytes: 3316
using System;
namespace AtCoder
{
    static class Solver
    {
        static IO io = new IO();
 
        public static void Solve()
        {
 
            io.ReadSplit();
            int A = io.Int();
            int B = io.Int();
            int C = io.Int();
 
            string str;
 
            if ((A <= C) && (C <= B))
            {
                str = "Yes";
            }
            else
            {
                str = "No";
            }
 
            io.WriteLine(str);
        }
    }
}
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Solver.Solve();
        }
    }
    class IO
    {
        private string[] _Inputs;
        private int _Index;
        public void Read()
        {
            _Inputs = new string[1];
            _Inputs[0] = Console.ReadLine();
            _Index = 0;
        }
        public void ReadSplit()
        {
            _Inputs = Console.ReadLine().Split(' ');
            _Index = 0;
        }
        public string String()
        {
            return _Inputs[_Index++];
        }
        public string[] String(int xCount)
        {
            string[] rv = new string[xCount];
            Array.Copy(_Inputs, _Index, rv, 0, xCount);
            _Index += xCount;
            return rv;
        }
        public int Int()
        {
            return int.Parse(_Inputs[_Index++]);
        }
        public int[] Int(int xCount)
        {
            int[] rv = new int[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = int.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public long Long()
        {
            return long.Parse(_Inputs[_Index++]);
        }
        public long[] Long(int xCount)
        {
            long[] rv = new long[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = long.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public void Write(string xStr)
        {
            Console.Write(xStr);
        }
        public void WriteLine(string xStr)
        {
            Console.WriteLine(xStr);
        }
    }
}

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

using namespace std;

int main(void){
  int x;
  int fx = 0;
  cin >> x;
  
  int temp = x;
  while(temp > 0){
    fx += temp % 10;
    temp /= 10;
  }
  
  cout << (x % fx == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;  

int main() {
  int n,t[109];
  long sum=0;
  cin>>n;
  rep(i,n){
    cin>>t[i];
    sum+=t[i];
  }
  int m;
  cin>>m;
  rep(i,m){
    int p,x;
    cin>>p>>x;
    cout<<sum-t[p-1]+x<<endl;
  }
}

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



int main(){
	
	string S;
	cin>>S;
	
	int a=0,b=0;
	for(int i=0;i<S.size();i++){
		if(S[i]=='0')a++;
		else b++;
	}
	
	cout<<min(a,b)*2<<endl;
	
	
	return 0;
}

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

ll f(ll n) {
  if(n % 2)
    return (n + 1) / 2 % 2;
  else
    return n / 2 % 2 ^ n;
}

int main() {
  ll a, b;
  cin >> a >> b;
  a--;
  cout << (f(a) ^ f(b)) << endl;
}


Measured memory_bytes: 256
class UnionFind():
  #負の値はルートで集合の個数
  #正の値は次の要素を返す
  def __init__(self,size):
    self.table = [-1 for _  in range(size)]
    self.num = [1 for _ in range(size)]

    #集合の代表を求める
  def find(self,x):
    while self.table[x] >= 0:
    #根に来た時,self.table[根のindex]は負の値なのでx = 根のindexで値が返される。
      x = self.table[x]
    return x

    #併合
  def union(self,x,y):
    s1 = self.find(x)#根のindex,table[s1]がグラフの高さ
    n1 = self.num[s1]        
    s2 = self.find(y)
    n2 = self.num[s2]
    if s1 != s2:#根が異なる場合
      if self.table[s1] != self.table[s2]:#グラフの高さが異なる場合
        if self.table[s1] < self.table[s2]:
          self.table[s2] = s1
        else:
          self.table[s1] = s2
      else:
                #グラフの長さが同じ場合,どちらを根にしても変わらない
                #その際,グラフが1長くなることを考慮する
        self.table[s1] += -1
        self.table[s2] = s1
      self.num[self.find(s1)]=n1+n2
      return n1*n2
    return 0
      
  def get_num(self, x):
    return self.num[x]

n, m = map(int, input().split())
h=[]
for _ in range(m):
  h.append(list(map(int, input().split())))
h.reverse()

u=UnionFind(n)
s=n*(n-1)//2
ans=[s]
for hi in h:
  s-=u.union(hi[0]-1, hi[1]-1)
  ans.append(s)
ans=ans[:len(ans)-1]
for ai in ans[::-1]:
  print(ai)


Measured memory_bytes: 36584