akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

const int MAX = 30000;//設定して

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit(ll p) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % p;
        inv[i] = p - inv[p%i] * (p / i) % p;//＊１
        finv[i] = finv[i - 1] * inv[i] % p;
    }
}

long long modpow(long long a, long long n, long long MOD) {//a^n(MOD)を求める
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;//次の準備
        n >>= 1;
    }
    return res;
}


ll powinv(ll x,ll p){
  return inv[modpow(10,x,p)];
}


signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,p;cin>>n>>p;
  string s;cin>>s;
  COMinit(p);

  map<ll,ll> ma;
  ll ans=0,tmp=0;

  if(p==2){
    rep(i,0,n){
      if((s[i]-'0')%2==0)ans+=i+1;
    }
  }else if(p==5){
    rep(i,0,n){
      if((s[i]-'0')%5==0)ans+=i+1;
    }
  }else{
    rep(i,0,n){
    tmp+=(ll)((s[i]-'0')%p);
    tmp%=p;


      ans+=ma[(tmp*powinv(i,p))%p];
      ma[(tmp*powinv(i,p))%p]++;
    

    if(tmp%p==0)ans++;

    tmp*=10;
    tmp%=p;
    }
  }

  
  cout<<ans<<ENDL;

}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 1812
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}

void solve()
{
 
int n,k;
cin >> n >> k;
int p[n+1];

for(int i=1;i<=n;i++) cin >> p[i];

int vl = -1,cur=0;

for(int i=1;i<=k;i++) cur+=p[i];
vl = cur;
for(int i=k+1;i<=n;i++)
{
    cur+=p[i];
    cur-=p[i-k];
    vl = max(vl,cur);
} 
//cout<<vl<<endl;
if((vl+k)%2==0)
{
    cout<<(vl+k)/2<<endl;
}
else 
{
    cout<<(vl+k)/2<<".500000000\n";
}

}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 5188
#include<stdio.h>

int main(void)
{
  //nを入力	
  int n;
  scanf("%d",&n);

  int h[n],i,j,ans=1,cnt;
  scanf("%d",&h[0]);
  for(i=1;i<n;i++){
    scanf("%d",&h[i]);
    cnt=0;
    for(j=0;j<i;j++){
      if(h[j]>h[i])
        break;
      cnt++;
      }
    if(cnt>=i)
      ans++;
  }

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

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        private static long mod = 1000000007;

        static void Main(string[] args)
        {
            var a = Read().ToCharArray();
            if (Char.IsUpper(a[0]))
            {
                WriteRead("A");
            }
            else
            {
                WriteRead("a");
            }
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 17484
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		string[] a=Console.ReadLine().Split();
		string[] s=new string[n];
		int b=n%2,c=n/2;
		s[c]=a[0];
		for(int i=1;i<n;i++){
			if(i%2==b){s[c+(i+1)/2]=a[i];}
			else {s[c-(i+1-b)/2]=a[i];}
		}
		Console.WriteLine("{0}",string.Join(" ",s));
	}
}

Measured memory_bytes: 45888
#include<iostream>
#include<cstring>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<utility>
#include<cstdio>
using namespace std;
typedef long long LL;
#define RI register int
const int MAX=10e3+10;
int a[MAX];
int main()
{

    int n;
    bool flag=1;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]%2==0){
            if(a[i]%3!=0&&a[i]%5!=0)
            flag=0;
        }
    }
    if(flag)printf("APPROVED");
    else printf("DENIED");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define ll long long

int main() {

    int i;

    cin >> i;


    switch(i % 10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
        default:
            break;
    }

    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()
const int INF = pow(2, 31) - 1;
int cnt;
void merge(int a[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int l[n1+1], r[n2+1];
    rep(i,n1)l[i] = a[left + i];
    rep(i,n2)r[i] = a[mid + i];
    l[n1] = INF;
    r[n2] = INF;
    int i = 0, j = 0;
    REP(k,left,right){
        cnt++;
        if(l[i] <= r[j]){
            a[k] = l[i];
            i++;
        }else {
            a[k] = r[j];
            j++;
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    merge_sort(a, 0, n);
    rep(i,n){
        cout << a[i];
        if(i < n-1)printf(" ");
        else printf("\n");
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6908
n = int(input())

div_cnt = [2] * n
div_cnt[0] = 1

for i in range(2, n + 1):
    j = 2 * i
    while j < n + 1:
        div_cnt[j - 1] += 1
        j += i


res = 0
for i in range(n):
    res += (i + 1) * div_cnt[i]

print(res)



Measured memory_bytes: 145660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
#define day 500000000000

int pow(ull a, ull n) {
  if (n == 0) return 1;
  if (n == 1) return a ;
  if (n % 2 == 1) return (a * pow(a, n - 1));
  ll t = pow(a, n / 2);
  return (t * t);
}

int main(){
    string S;
    cin >> S;
    ull K;
    cin >> K;

    int ans, i = 0;
    while (true) {
        if (S.at(i) != '1') {
            ans = S.at(i) - '0';
            break;
        } else {
            if (i >= K - 1) {
                ans = S.at(i) - '0';
                break;
            } else {
                i++;
                continue;
            }
        }
    }
    
    /*ull tmp = 0;
    int ans, i = 0;
    while (tmp < K || i < S.length()) {
        cout <<  tmp << endl;
        ans = S.at(i) - '0';
        tmp += pow(ans, day);
        i++;
    }*/

    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<ll,P>  PP;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;
typedef priority_queue<PP, vector<PP>, greater<PP>> PPQueue;

#define fi          first
#define se          second
#define sfi         se.fi
#define sse         se.se
#define pb          push_back
#define INF         INT_MAX
#define MOD         1000000007
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     (upper_bound(all(x),y)-x.begin())
#define lb(x,y)     (lower_bound(all(x),y)-x.begin())
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)

int main(){
  cin.sync_with_stdio(false);
  ll h,w,d,q,tmp;
  cin >> h >> w >> d;
  ll size = h*w;
  Vector costs(size+1);
  vector<P> mp(size+1);
  rep(i,h)rep(j,w)cin >> tmp,mp[tmp] = mkp(i,j);
  repl(i, d+1, size)costs[i] = costs[i-d] + abs(mp[i].fi-mp[i-d].fi)+abs(mp[i].se-mp[i-d].se);
  cin >> q;
  rep(i,q){
    ll ans = 0;
    ll L,R;
    cin >> L >> R;
    cout << costs[R] - costs[L] << endl;
  }
}


Measured memory_bytes: 3200
#include<stdio.h>
int main()
{
	int n,c=1,b=0;
	int a,i,r=1;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(b==0&&a==0){
			b=0;
		}else if(b==0&&a==1){
			b=1;
			c++;
		}else if(b==1&&a==0){
			if(r<c){
				r=c;
			}
			c=1;
			b=0;
		}else{
			b=1;
			c++;
		}
	}
	if(b==1){
		if(r<c){
			r=c;
		}
	}
	printf("%d\n",r);
	return 0;
}



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

int type(int x){
    if(x == 2){
        return 3;
    }else if( x == 11 || x == 9 || x == 6 || x == 4){
        return 2;
    }else{
        return 1;
    }
}

int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    if(type(a) == type(b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
L = [ int(input()) for _ in range(n) ]
print(lcm(L))

Measured memory_bytes: 5304
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<lint> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	A[0] %= M;
	for (int i = 0; i < N - 1; i++) {
		A[i + 1] += A[i];
		A[i + 1] %= M;
	}

	map<int, lint> mod;
	for (int i = 0; i < N; i++) mod[A[i] % M]++;

	lint ans = mod[0] * (mod[0] + 1) / 2 - mod[0] * (mod[0] - 1) / 2;
	for (const auto &elem : mod) ans += elem.second * (elem.second - 1) / 2;

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <set>
using namespace std;
#define ll long long 
#define vvll vector<vector<long long>>
#define vll vector<long long>
#define fri(i,n) for(int i=0;i<n;i++)
#define fri1(i,n) for(int i=n-1;i>=0;i--)
#define map map<ll,ll>
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ump unordered_map<long long ,long long>
#define ub upper_bound
#define bsearch binary_search

ll parent[100001]={0};

int find(int x)
{
    if(parent[x]!=x)
    {
        parent[x]=find(parent[x]);
    }
    return parent[x];
}

int main() 
{
    fast
    ll n,m,x,y;
    cin>>n>>m;
    fri(i,n+1)
    {
        parent[i]=i;
    }
    fri(i,m)
    {
        cin>>x>>y;
        if(find(y)!=find(x))
        {
        parent[find(y)]=find(x);
        }
    }
    set<int> st,st1;
    for(int i=1;i<=n;i++)
    {
        st.insert(parent[i]);
    }
    for(auto it: st)
    {
        st1.insert(find(it));
    }
    cout<<st1.size()-1<<"\n";
	return 0;
}


Measured memory_bytes: 11792
N, K = map(int, input().split())

num_list = []
d = []
for i in range(N):
  try:
      d.append(list(map(int,input().split())))
      num_list.append(list(map(int,input().split())))
  except EOFError:
    pass
  
#those who has snack
snack = set(sum(num_list, []))

ppl = []
for i in range(N):
    ppl.append(N)
    N -= 1
    
nsnack = set(ppl) - snack
nosnack = list(nsnack)

print(len(nosnack))

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmin(T &_a, T _b){
    if(_a > _b){
        _a = _b;
        return true;
    }else{
        return false;
    }
}

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

    int n, l;
    cin >> n >> l;

    int ans = 0, mini = IINF;
    int sum = 0;
    rep(i, n){
        sum += i + l;
    }
    for(int i = 0 ; i < n ; ++i){
        int cnt = 0;
        for(int j = 0 ; j < n ; ++j){
            if(i == j) continue;
            cnt += l + j;
        }
        if(chmin(mini, abs(sum - cnt))){
            ans = cnt;
        }
    }


    cout << ans << endl;

    return 0;
}

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

int A,B;

int main()
{
    cin>>A>>B;
    int ans=0;
    for (int a = 1; a <= 9; a++)
    {
        for (int b = 0; b <= 9; b++)
        {
            for (int c = 0; c <= 9; c++)
            {
                int x = a*10000 + b*1000 + c*100 + b*10 + a;
                if(x>=A && x<=B) ans++;
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int main(){
    int A,B;
    string S;
    cin >> A >> B >> S;
    for(int i=0; i<A+B+1; i++) {
        if(i != A) {
            if(S[i] != '-') {
                continue;
            }
            else {
                cout << "No" << endl;
                return 0;
            }
        } 
        else {
            if(S[i] != '-') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


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

using namespace std;

#define ll long long
#define all(x) (x).begin(),(x).end()
#define desc greater<int>()
#define pb(x) push_back(x)
ll gcd(ll a, ll b) { return (!a)?b:gcd(b%a,a);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
void pArr(int arr[], int s);
void pVec(vector<int> v);
bool isPrime(int x);
int binarySearch(int arr[], int l, int r, int x);
int vBinarySearch(vector<ll> v, int l, int r, ll x);
int nChoosek( int n, int k );
int mod=1e9+7;

void solve(){
    int a,b;
    cin >> a >> b;
    if (b==1){
        cout << 0 << endl;
    }
    else{
        if (b-a<=0){
            cout << 1 << endl;
        }
        else{
            b-=a;
            int r=(b%(a-1)==0)?0:1;
            cout << b/(a-1)+r+1 << endl;
        }
    }
}



int main(){
/*
    string temp;
    int t;
    cin >> t;
    getline(cin, temp);
    while (t--){
        solve();
    }
*/
    solve();
    return 0;
}


void pArr(int arr[], int s){
    for (int i=0;i<s;i++){
        cout << arr[i] << " ";
    }
    cout << endl;
}
void pVec(vector<int> v){
    for (int i=0;i<v.size();i++){
        cout << v.at(i) << " ";
    }
    cout << endl;
}
bool isPrime(int x){
    if (x==1){
        return false;
    }
    if(x==2){
        return true;
    }
    for (int i=2;i<=(int)(pow(x,0.5));i++){
        if (x%i==0){
            return false;
        }
    }
    return true;
}

int vBinarySearch(vector<ll> v, int l, int r, ll x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;
        if (v.at(m) == x)
            return m;
        if (v.at(m) < x)
            l = m + 1;
        else
            r = m - 1;
    }
    //bigger
    return r+1;
}

int binarySearch(int arr[], int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;
        if (arr[m] == x)
            return m;
        if (arr[m] < x)
            l = m + 1;
        else
            r = m - 1;
    }
    //smaller
    return r;
}

int nChoosek( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}


Measured memory_bytes: 3684
#include<stdio.h>
int main(void){
	int n, h[3]={-1,-1,-1};
	int i, j, k;
	for(i=0;i<10;i++){
		scanf("%d", &n);
		for(j=0;j<3;j++){
			if(h[j] < n){
				for(k=2;k>j;k--){
					h[k] = h[k-1];
				}
				h[j]=n;
				break;
			}
		}
	}
	for(i=0;i<3;i++){
		printf("%d\n", h[i]);
	}
	return 0;
}

Measured memory_bytes: 1028
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main (){
    int a,b,c,d;
    cin >> a >> b>> c >> d;
    while(1){
        a = a-d;
        c = c-b;
        
        if(c <= 0){
        cout << "Yes" << endl;
        return 0;
        }
        else if(a <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

int main(){
    int n;
    char s[10010];
    scanf("%d", &n);
    scanf("%s", s);
    int len = strlen(s);
    for(int i = 0; i < len;i++){
        int x = s[i] - 'A';
        x=(x+n)%26;
        putchar('A'+x);
    }
}

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> L(N);
    for (int i=0; i<N; i++) cin >> L.at(i);
    sort(L.begin(), L.end());
    reverse(L.begin(), L.end());

    int ans = 0;
    for(int i= 0; i<K; i++) ans += L.at(i);

    cout << ans << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    s.push_back('E');
    int ans = 0;
    int l = 0, g = 0;
    auto c = s[0];
    for (int i = 1; i < n + 1; i++) {
        if (s[i] == c) continue;
        ans += i - l - 1;
        g++, l = i, c = s[i];
    }

    if (g / 2 <= k) {
        ans += g / 2 * 2;
        if (g % 2 == 0) ans--;
    } else {
        ans += 2 * k;
    }

    cout << ans << endl;
}


Measured memory_bytes: 512
N = gets.to_i
Ans = []
n = 0
a = 0
i = 0
b = "true"

    loop{ i = i + 1
      #puts Ans.count
      if Ans.count >= N
        break
      end
      a = (i **(1/2.0)).to_i
      #puts a
      for j in 2..(a + 1)
        if i % j == 0
          b = "false"
        end
      end
        #puts b
        if (i % 5 == 1) && (b == "true") && (i != 1) 
          #puts i
          Ans.push(i)
        end
            b = "true"
    }
#puts Ans
for k in 0..(Ans.count - 1)
  print Ans[k]
  print " "
end
  print "\n"
  

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

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


Measured memory_bytes: 256
n=int(input())
ans=[]
def b(s):
  if len(s)==n:
    ans.append(s)
    return
  for i in "abcdefghijklmnopqrstuvwxyz":
    b(s+i)
    if max(list(s))==chr(ord(i)-1):return
b("a")
ans.sort()
for i in ans:print(i)

Measured memory_bytes: 12668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var < (end); var++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; var >= (end); var--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

const ll MOD = 1e9 + 7;

struct PCMod {
    vector<ll> fact, inv, finv;

    PCMod(int n) : fact(n + 1), inv(n + 1), finv(n + 1) {
      fact[0] = 1;
      fact[1] = 1;
      inv[0] = 1;
      inv[1] = 1;
      finv[0] = 1;
      finv[1] = 1;

      FOR(i, 2, n + 1) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
      }
    }

    ll P(int m, int n) {
      if (m < n) return 0;
      return fact[m] * finv[m - n] % MOD;
    }

    ll C(int m, int n) {
      if (m < n) return 0;
      return fact[m] * (finv[n] * finv[m - n] % MOD) % MOD;
    }

};

void solve(istream& cin, ostream& cout) {
  int n, m;
  cin >> n;
  map<int, int> pf;
  PCMod pc(n);

  FOR(i, 2, n + 1) {
    m = i;
    for (int j = 2; j * j <= m; j++) {
      while (m % j == 0) {
        pf[j]++;
        m /= j;
      }
    }
    if (m != 1) pf[m]++;
  }

  int n75 = 0;
  int n25 = 0;
  int n15 = 0;
  int n5 = 0;
  int n3 = 0;
  for (auto itr : pf) {
    if (itr.second >= 74) {
      n75++;
    }
    if (itr.second >= 24) {
      n25++;
    }
    if (itr.second >= 14) {
      n15++;
    }
    if (itr.second >= 4) {
      n5++;
    }
    if (itr.second >= 2) {
      n3++;
    }
  }

  int ans = 0;
  ans += n75;
  ans += n25 * (n3 - 1);
  ans += n15 * (n5 - 1);
  ans += pc.C(n5, 2) * (n3 - 2);
  cout << ans << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1,d2,d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    n = II()
    aa = MII()
    total = sum(aa)
    x1 = total - 2*sum(aa[1::2])
    ans = [x1]
    for i in range(0, n-1):
        ans.append(2*aa[i]-ans[-1])
    print(*ans)


if __name__ == '__main__':
    main()

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int main(){
	double a,b,x;cin>>a>>b>>x;
	double h=x/(a*a);
	if(h*2<=b){
		double A=h*a*2/b;
		printf("%.12lf\n",atan2(b,A)/M_PI*180);
	}
	else{
		double A=h*2-b;
		printf("%.12lf\n",atan2(b-A,a)/M_PI*180);
	}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const double PI = acos(-1);
#define MOD 1000000007

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (abs(a*b)/gcd(a,b))
#define sqr(a) (a*a)

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

main()
{
    ///optimize();


    ll n,m,i;
    while(cin>>n>>m){
        ll s=0;
        while(m--){
            cin>>i;
            s+=i;
        }
        if(s>n) cout<<"-1" el;
        else cout<<n-s el;
    }




}





///Brainless people are gonna understand this code.




///Brainless_Loco Terminates Here!


Measured memory_bytes: 3592
#include <iostream>
using namespace std;
using ll = long long;

int main()
{
  int a, b, c, d;

  cin >> a >> b >> c >> d;

  while(true){
    c=c-b;
    if(c<=0){
      cout << "Yes" << endl;
      break;
    }
    a=a-d;
    if(a<=0){
      cout << "No" << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int dp[3000][3000];
char ans[3000][3000];
pair<int, int> nxt[3000][3000];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  string a, b;
  cin >> a >> b;
  int na = a.size();
  int nb = b.size();
  if (a[0] == b[0]) {
    dp[0][0] = 1;
    ans[0][0] = a[0];
  }
  else {
    dp[0][0] = 0;
    ans[0][0] = 0;
  }
  nxt[0][0] = { -1, -1};
  for (int j = 1; j < nb; j++) {
    if (a[0] == b[j]) {
      dp[0][j] = 1;
      ans[0][j] = a[0];
      nxt[0][j] = { -1, -1};
    }
    else {
      dp[0][j] = dp[0][j - 1];
      nxt[0][j] = {0, j - 1};
    }
  }
  for (int i = 1; i < na; i++) {
    if (a[i] == b[0]) {
      dp[i][0] = 1;
      ans[i][0] = b[0];
      nxt[i][0] = { -1, -1};
    }
    else {
      dp[i][0] = dp[i - 1][0];
      nxt[i][0] = { i - 1, 0};
    }
  }
  for (int i = 1; i < na; i++) {
    for (int j = 1; j < nb; j++) {
      if (a[i] == b[j]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
        ans[i][j] = a[i];
        nxt[i][j] = {i - 1, j - 1};
      }
      else {
        if (dp[i - 1][j] > dp[i][j - 1]) {
          nxt[i][j] = {i - 1, j};
        }
        else {
          nxt[i][j] = {i, j - 1};
        }
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  int i = na - 1, j = nb - 1, ilast, jlast;
  string res = "";
  while (i != -1) {
    if (ans[i][j]) {
      res += ans[i][j];
    }
    ilast = i, jlast = j;
    i = nxt[ilast][jlast].first;
    j = nxt[ilast][jlast].second;
  }
  reverse(res.begin(), res.end());
  cout << res;
  return 0;
}

Measured memory_bytes: 117892
END { load __FILE__ unless $stdin.eof? }

a, b, c, d = gets.split.map!(&:to_i)
M = 998244353

$dp = Array.new(c + 1) { Array.new(d + 1) }
a.upto(c) do |x|
  $dp[x][b] = b.pow(x - a, M)
end
b.upto(d) do |y|
  $dp[a][y] = a.pow(y - b, M)
end

def f(x, y)
  $dp[x][y] ||= (
    f(x - 1, y) * y + f(x, y - 1) * x - f(x - 1, y - 1) * (x - 1) * (y - 1)
  ) % M
end

puts f(c, d)


Measured memory_bytes: 85192
N=int(input())
h=list(map(int,input().split()))
dp=[10**9]*N
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))
print(dp[N-1])


Measured memory_bytes: 13976
#include <stdio.h>
#include <string.h>
int main(void) {
    int sp=0,count[500]={0},i=0,maxlen[2]={0},max[2]={0};
    char word[500][32],temp[32];
    while (scanf(" %s",&temp)!=EOF) {
        if (sp==0) {
            strcpy(word[sp],temp);
            count[sp]++;
            maxlen[1]=strlen(word[sp]);
            maxlen[0]=sp;
            sp++;
        } else {
            for (i=0; i<sp; i++) if (strcmp(word[i],temp)==0) break;
            if (i==sp) {
                strcpy(word[sp],temp);
                count[sp]++;
                if (strlen(word[sp])>maxlen[1]) {
                    maxlen[0]=sp;
                    maxlen[1]=strlen(word[sp]);
                }
                sp++;
            } else {
                count[i]++;
            }
        }
    }
    for (i=0; i<sp; i++) {
        if (count[i]>max[1]) {
            max[1]=count[i];
            max[0]=i;
        }
    }
    printf("%s %s\n",word[max[0]],word[maxlen[0]]);
    return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#define NIL -1
#define MAX 25

typedef struct{
  int parent,left,right;
} Node;
Node Tree[MAX];
int n,Depth[MAX],Height[MAX];

int setHeight(int u){
  int h1,h2;
  h1=h2=0;
  if(Tree[u].right!=NIL) h1=setHeight(Tree[u].right)+1;
  if(Tree[u].left!=NIL) h2=setHeight(Tree[u].left)+1;
  if(h1>h2) return Height[u]=h1;
  else return Height[u]=h2;
}
void setDepth(int u,int depth){
  if(u==NIL) return;
  Depth[u]=depth;
  if(Tree[u].right!=NIL) setDepth(Tree[u].right,depth+1);
  if(Tree[u].left!=NIL) setDepth(Tree[u].left,depth+1);
}
int getSibling(int u){
  if(Tree[u].parent==NIL) return NIL;
  else if(Tree[Tree[u].parent].left==NIL || Tree[Tree[u].parent].right==NIL)
    return NIL;
  else if(Tree[Tree[u].parent].left==u) return Tree[Tree[u].parent].right;
  else return Tree[Tree[u].parent].left;
}


int main(){
  int root,id,i,r,l,degree[MAX];
  char typ[MAX][15];
  scanf("%d",&n);
  for(i=0;i<n;i++)Tree[i].parent=Tree[i].left=Tree[i].right=NIL;
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&r,&l);
    if(r==-1&&l==-1) degree[id]=0;
    else if(r==-1 || l==-1) degree[id]=1;
    else degree[id]=2;
    Tree[r].parent=id;
    Tree[l].parent=id;
    Tree[id].right=r;
    Tree[id].left=l;
  }
  for(i=0;i<n;i++) if(Tree[i].parent==NIL) root=i;
  setDepth(root,0);
  setHeight(root);
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,",i,Tree[i].parent,getSibling(i),degree[i],Depth[i],Height[i]);
    if (Depth[i]==0) printf(" root\n");
    else if(Height[i]==0) printf(" leaf\n");
    else printf(" internal node\n");
  }
  return 0;
}

    
  
  
  



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

int main()
{
    string s,c;
    cin>>s;
    char x=' ';
    for (int i=0; i<s.size(); i++){
        if(s[i]==','){
            c.push_back(x);
        }
        else{
            c.push_back(s[i]);
        }
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 384
class UnionFind:
    def __init__(self, N):
        self.N = N  # ノード数
        # 親ノードを示す。負は自身が親ということ。親だった場合は−(その集合のサイズ)
        self.parent = [-1] * N

    def root(self, A):
        # Aがどのグループに属しているか調べる
        # ノード番号を受けとって一番上の親ノードの番号を返す
        # print(A)
        if self.parent[A] < 0:
            return A
        self.parent[A] = self.root(self.parent[A])
        return self.parent[A]

    def size(self, A):
        # 自分のいるグループの頂点数を調べる
        return -self.parent[self.root(A)]

    def connect(self, A, B):
        # AとBをくっつける
        # AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = self.root(A)
        B = self.root(B)

        if A == B:
            return False  # すでにくっついてるからくっつけない

        if self.size(A) < self.size(B):
            # 大きい方(A)に小さいほう(B)をくっ付けたい
            # 大小が逆だったらひっくり返しちゃう。
            A, B = B, A

        # Aのサイズを更新する
        self.parent[A] += self.parent[B]
        # Bの親をAに変更する
        self.parent[B] = A

        return True


N, M = map(int, input().split())
is_A = []
is_B = []

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    is_A.append(a)
    is_B.append(b)

# print(is_A, is_B)

Uni = UnionFind(N)
ans = [0] * M
ans[M - 1] = N * (N - 1) // 2

for i in range(M - 1, 0, -1):
    if Uni.root(is_A[i]) != Uni.root(is_B[i]):
        ans[i - 1] = ans[i] - Uni.size(is_A[i]) * Uni.size(is_B[i])
        Uni.connect(is_A[i], is_B[i])
    else:
        ans[i - 1] = ans[i]

for i in range(M):
    print(ans[i])



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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A*C < B) cout << C;
  else cout << B/A;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main{

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

      while(true){
      int H=sc.nextInt();
      int W=sc.nextInt();
      
      if(H==0&&W==0) break;
    
      for(int i=0;i<H/2;i++){
          
       for(int j=0;j<W/2;j++){
        System.out.print("#");
        System.out.print(".");
       }
       if(W%2==1)
       System.out.print("#");
       System.out.print("\n");
       
       for(int j=0;j<W/2;j++){
        System.out.print(".");
        System.out.print("#");
       }
       if(W%2==1)
       System.out.print(".");
       System.out.print("\n");
      }
       
       if(H%2==1){
        for(int j=0;j<W/2;j++){
        System.out.print("#");
        System.out.print(".");
       }
       if(W%2==1)
       System.out.print("#");
       System.out.print("\n");
       }
      
      System.out.print("\n");
     
}
}

}


Measured memory_bytes: 37496
x = int(input())
#h, w = list(map(int, input().split()))
#((n+1)*n)//2 >= x
# (n+1)*n = 2*x
n = 1
a = ((n+1)*n)//2
while a < x:
    a = ((n+1)*n)//2
    n += 1

if (n-1)*n < 2*x:
    print(n)
else:
    print(n-1)


Measured memory_bytes: 38512
N = int(input())
x = N //1000
x1 = (N - x*1000)//100
x2 = (N - x*1000 - x1*100)//10
x3 = N - x*1000 - x1*100 - x2*10
sum = x+x1+x2+x3
if sum % 9 != 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    vector<pair<ll,ll> > ans;
    vector<ll> v;
    ll ma=a[n-1];
    ll mi=a[0];
    for(int i=1;i<n-1;i++){
        if(a[i]<0){
            ans.pb(make_pair(ma,a[i]));
            ma-=a[i];
        }
        else if(a[i]==0){
            ans.pb(make_pair(ma,0));
        }
        else{
            ans.pb(make_pair(mi,a[i]));
            mi-=a[i];
        }
    }
    ans.pb(make_pair(ma,mi));
    ma-=mi;
    cout << ma<<endl;
    for(int i=0;i<n-1;i++){
        cout <<ans[i].first<<" "<<ans[i].second<<endl;
    }
    return 0;

}



Measured memory_bytes: 4336
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int b,a;
    cin >> a >> b;
    
    if(a < b) cout << "a < b" <<endl;
    else if(a > b) cout << "a > b" << endl;
    else cout << "a == b" << endl;
}


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

using namespace std;

using ll = long long;

constexpr int INF = 1e9;

int dp[105][105];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;

    vector<string> s(H);
    for (int i = 0; i < H; ++i) {
        cin >> s[i];
        for (int j = 0; j < W; ++j) {
            dp[i][j] = INF;
            dp[i][j] = INF;
        }
    }

    dp[0][0] = (s[0][0] == '#');
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (i > 0) dp[i][j] = min(dp[i][j], dp[i - 1][j] + (s[i - 1][j] != s[i][j] && s[i][j] == '#'));
            if (j > 0) dp[i][j] = min(dp[i][j], dp[i][j - 1] + (s[i][j - 1] != s[i][j] && s[i][j] == '#'));
            //cerr << i << " " << j << " " << dp[i][j] << endl;
        }
    }

    cout << dp[H - 1][W - 1] << "\n";
    return 0;
}

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

int main(){

	int S , h , m , s;
	cin >> S;
	h = S / 3600;
	m =( S - h * 3600 ) / 60;
	s = S - h * 3600 - m * 60;

	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


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

int main() {
    int n;cin>>n;
    int digit=7;
    int cnt=0;
    while(n>0)
    {
       int rem=n%10;
        if(rem==digit)
            cnt++;
        n/=10;
    }
    if(cnt>0)  cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
	return 0;
}

Measured memory_bytes: 3644
s = input()

cnt = [1] if s[0] == "<" else [0, 1]

bc = s[0]

for i in range(1, len(s)):
    if s[i] == bc:
        cnt[-1] += 1
    else:
        cnt.append(1)
    bc = s[i]

if len(cnt) % 2 == 1:
    cnt.append(0)


ans = 0

for i in range(0, len(cnt), 2):
    ma = max(cnt[i], cnt[i + 1])
    mi = min(cnt[i], cnt[i + 1])
    ans += max(0, ma * (ma + 1) // 2)
    ans += max(0, (mi - 1) * mi // 2)

print(ans)


Measured memory_bytes: 12128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pl;
const ll N = 1e3 + 50;
const ll MOD = 1000000000;

int n, m, x;

int main() {
	cin>>n>>m;
  int cnt = 0;
  for(int i=0;i<m;i++) {
  	cin>>x;
    cnt += x;
  }
  n = n - cnt;
  if(n < 0)n = -1;
  cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 3624
from fractions import gcd


def resolve():
    n = int(input())
    aaa = [0] + list(map(int, input().split())) + [0]
    lll = [0 for i in range(n+2)]
    rrr = [0 for i in range(n+2)]
    for i in range(1, n+1):
        lll[i] = gcd(lll[i-1], aaa[i])
    for i in range(n,0,-1):
        rrr[i] = gcd(rrr[i+1], aaa[i])
    z = [gcd(lll[i-1],rrr[i+1]) for i in range(1,n+1)]
    print(max(z))
resolve()

Measured memory_bytes: 16180
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
const ll MAX_N = 3000;
/**/
int main() {
	// 入力
	ll A,B,N;cin>>A>>B>>N;
    
	// 解法
	ll ans = 0;
	if (N<B){
		ans = (A*N)/B;
	}
	else{
		ans = (A*(B-1))/B;
	}

	//出力
	printf("%lld\n", ans);
}


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

int main() {
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b (m);
    vector<vector<int>> a (n,vector<int>(m));
    for(int i=0; i<m; i++){
        cin >> b.at(i);
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a.at(i).at(j);
        }
    }
    int count = 0;
    int ans = 0;
    for(int i=0; i<n; i++){
        count = 0;
        for(int j=0; j<m; j++){
            count += a.at(i).at(j) * b.at(j);
        }
        if(count + c > 0){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int r,c,q;
    while(scanf(" %d %d %d", &r, &c, &q),r){
        vector<int> a(q),b(q),o(q);
        rep(i,q) scanf(" %d %d %d", &a[i], &b[i], &o[i]);

        ll ans = 0;
        int R = r, C = c;
        vector<int> y(r,-1), x(c,-1);
        for(int i=q-1; i>=0; --i){
            if(a[i]==0){
                if(y[b[i]] != -1) continue;
                if(o[i]==1) ans += C;
                --R;
                y[b[i]] = o[i];
            }
            else{
                if(x[b[i]] != -1) continue;
                if(o[i]==1) ans += R;
                --C;
                x[b[i]] = o[i];
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}



Measured memory_bytes: 3872
package main

import (
	"fmt"
)

func main() {
	var N, W int
	fmt.Scanf("%d%d", &N, &W)
	w, v := make([]int, N), make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d%d", &w[i], &v[i])
	}
	dp := make([][]int, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = make([]int, W+1)
	}
	for i := 1; i <= N; i++ {
		for j := 0; j <= W; j++ {
			dp[i][j] = dp[i-1][j]
			if j >= w[i-1] {
				dp2 := dp[i-1][j-w[i-1]] + v[i-1]
				if dp[i][j] < dp2 {
					dp[i][j] = dp2
				}
			}
		}
	}
	fmt.Printf("%d\n", dp[N][W])
}


Measured memory_bytes: 81792
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

const int INF = 10000000;

int main(int, const char**)
{
    int h, w;
    cin >> h >> w;
    
    int ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;

    vector<string> grid(h);
    vector<vector<int>> costs(h, vector<int>(w, INF));

    rep(i, h)
    {
        cin >> grid[i];
    }

    struct Data
    {
        int y;
        int x;
        int cost;
    };

    auto compare = [](const Data& a, const Data& b)
    {
        return b.cost < a.cost;
    };

    priority_queue<Data, vector<Data>, decltype(compare)> q{compare};
    q.push({ch, cw, 0});
    while(!q.empty())
    {
        auto d = q.top();
        q.pop();
        if(d.cost < costs[d.y][d.x])
        {
            costs[d.y][d.x] = d.cost;
            rep(j, 5)
            {
                auto dy = j - 2;
                auto ny = d.y + dy;
                if(ny < 0 || ny >= h)
                {
                    continue;
                }
                rep(k, 5)
                {
                    auto dx = k - 2;
                    auto nx = d.x + dx;

                    if(nx < 0 || nx >= w)
                    {
                        continue;
                    }

                    if(dy == 0 && dx == 0)
                    {
                        continue;
                    }

                    if(grid[ny][nx] == '.')
                    {
                        auto cost = ((dy == 0 && dx == 1) || (dy == 0 && dx == -1) || (dy == -1 && dx == 0) || (dy == 1 && dx == 0))
                            ? 0
                            : 1;
                        q.push({ny, nx, d.cost + cost});
                    }
                }
            }
        }
    }

    auto ans = costs[dh][dw];
    if(ans == INF)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 12120
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int m,n;
	cin>>m>>n;
	char a[m][n];
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=0;i<=n+1;i++)
	cout<<"#";
	cout<<endl;
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(j==0)
			cout<<"#";
			if(j==(n-1))
			cout<<a[i][j]<<"#";
			else cout<<a[i][j];
		}
		cout<<endl;
	}
	for(int i=0;i<=n+1;i++)
	cout<<"#";

}

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 m = sc.nextInt();
		int max = 1;
		int min = n + 1;
		int li;
		int ri;
		for (int i = 1; i <= m; i++) {
			li = sc.nextInt();
			ri = sc.nextInt();

			if (li > max) {
				max = li;
			}
			if (ri < min) {
				min = ri;
			}
		}

		int ans = min - max + 1;
		if (ans >= 0) {
			System.out.println(ans);
		} else {

			System.out.println(0);
		}
	}
}


Measured memory_bytes: 64760
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

template<typename T>
class Bit {
  public:
    Bit(int size, T z): N(size), zero(z), bit(size+1, z) {
    }

    // [1,k]
    T sum(int k) const {
      T s = zero;
      for (int i = k; i > 0; i -= i&(-i)) {
        s += bit[i];
      }
      return s;
    }

    // [l,r)
    T sum(int l, int r) const {
      return sum(r-1) - sum(l-1);
    }

    void add(int k, T x) {
      for (int i = k; i <= N; i += i&(-i)) {
        bit[i] += x;
      }
    }

  private:
    int const N;
    T const zero;
    std::vector<T> bit;
};

int main() {
  int N, Q;
  cin >> N >> Q;
  Bit<int> bit(N, 0);
  REP(i, Q) {
    int COM, X, Y;
    cin >> COM >> X >> Y;
    if (COM) {
      cout << bit.sum(X, Y+1) << endl;
    } else {
      bit.add(X, Y);
    }
  }
  return 0;
}



Measured memory_bytes: 3140