akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        if (h == 1 || w == 1) {
            System.out.println(1);
            return;
        }
        long evCount;
        long odCount;
        if (w % 2 == 0) {
            odCount = w / 2;
            evCount = w / 2;
        } else {
            odCount = w / 2 + 1;
            evCount = w / 2;
        }
        long ans = 0;
        if (h % 2 == 0) {
            ans = (odCount + evCount) * (h / 2);
        } else {
            ans += odCount * (h / 2 + 1);
            ans += evCount * (h / 2);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(xx) (xx).begin(),(xx).end()
#define print(a); for(auto xx:a)cout<<xx<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    ll a=n%1000;
    if(a!=0)a=1000-a;
    cout<<a<<"\n";
}


Measured memory_bytes: 3576
///******* In the name of Allah *******///

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

//long int ar[10013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//long int sieve(long long int a)
//{
//    long long int i,j,k = 0;
//    memset(ar,0,sizeof(ar));
//    ar[1] = 1;
//    for(i=2; i<=713; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=713; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//    return ar[a];
//}

void Ok()
{
    long int a,b,c,d,e,f,g,h,t,i,j,k,l,m,n;
    long int ans_1,ans_2,ans_3,cnt_1,cnt_2,cnt_3,flag_1,flag_2,flag_3,temp,sum;
    double aa,bb,cc,dd,ee,ff,gg;
    char aaa,bbb,ccc,ddd;
    string spc,in,store;

    cin>>n;
    for(i=1;i<=13;i++)
    {
        ans_1 = (i * 1000);
        if(ans_1>=n)
            break;
    }
    ans_2 = ans_1 - n;
    cout<<ans_2<<endl;


    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 3612
#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 push_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 all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 1000004

void solve()
{
	lli n,k;
	cin>>n>>k;

	lli a[n+1];
	loopl(i,1,n+1) cin>>a[i];

	
	loopl(i,k+1,n+1)
	{
		if(a[i] > a[i-k]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;

	}

}

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

    lli t;
    t=1;
    
    loopl(i,1,t+1)
    {
    	//cout<<"Case #"<<i<<": ";
    	solve();
    }  
}	
   


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

#define pb push_back
#define mp make_pair
#define size(n) ( int( n.size() ) )
#define sqr(n) ( (n) * (n) )

using namespace std;

typedef long long ll;
typedef long double ld;

int n, a, b, c, d;


int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n >> a >> b >> c >> d;
    for ( int i = 0; i <= ( n - 1 ); i++ ){
        int j = n - 1 - i;
        ll li = i * 1ll * c;
        ll ri = i * 1ll * d;
        ll lj = j * 1ll * c;
        ll rj = j * 1ll * d;
        ll l = li - rj + a;
        ll r = ri - lj + a;
        if ( ( l <= b ) && ( r >= b ) ){
            puts("YES");
            return 0;
        }
    }
    puts("NO");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
#define SIZE(v) int(v.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class Tree {
	int n;
	vector<vector<pair<int, ll>>> edge;
	vector<ll> dis;
public:
	Tree(int N) :n(N), edge(N), dis(N) { ; }
	void unite(int i, int j, ll w) {
		edge[i].emplace_back(j, w);
		edge[j].emplace_back(i, w);
	}
	void dijkstra() {
		fill(dis.begin(), dis.end(), INT64_MAX);
		priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
		pq.emplace(0, 0);
		while (!pq.empty()) {
			ll d;
			int i;
			tie(d, i) = pq.top();
			pq.pop();
			if (d >= dis[i]) continue;
			dis[i] = d;
			ITER(itr, edge[i]) {
				ll w;
				int j;
				tie(j, w) = *itr;
				if (d + w < dis[j]) pq.emplace(d + w, j);
			}
		}
	}
	ll distance(int i) {
		return dis[i];
	}
};

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

	int N;
	cin >> N;
	Tree tree(N);
	REP(i, N - 1) {
		int u, v;
		ll w;
		cin >> u >> v >> w;
		--u;
		--v;
		tree.unite(u, v, w);
	}
	tree.dijkstra();
	REP(i, N) cout << tree.distance(i) % 2 << endl;
	
	return 0;
}


Measured memory_bytes: 8704
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<stack>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;

bool ansflag;

int Calc(int p,int num[4],int op[3],int pr[3]){
	int np,npr;

	int b = num[p+1];
	npr = 3;
	for(int i=p+1;i<3 && pr[i]>pr[p];i++){
		if(npr>pr[i] && pr[i]>pr[p]){
			np = i; npr = pr[i];
		}
	}
	if(npr!=3){
		b = Calc(np,num,op,pr);
	}

	int a = num[p];
	npr = 3;
	for(int i=p-1;i>=0 && pr[i]>pr[p];i--){
		if(npr>pr[i] && pr[i]>pr[p]){
			np = i; npr = pr[i];
		}
	}
	if(npr!=3){
		a = Calc(np,num,op,pr);
	}

	//printf("%d: %d|%d|%d\n",p,a,op[p],b);

	if(op[p]==0) return a+b;
	else if(op[p]==1) return a-b;
	else return a*b;
}

void OpEnum(int num[4],int op[3],int pr[3],int dep){
	if(ansflag) return;
	if(dep<3){
		for(int i=0;i<3;i++){
			op[dep] = i;
			OpEnum(num,op,pr,dep+1);
			if(ansflag) return;
		}
	}
	int sp,npr=3;
	for(int i=2;i>=0;i--){
		if(npr>pr[i]){
			sp = i; npr = pr[i];
		}
	}
	if(Calc(sp,num,op,pr)==10){
		ansflag = true;
		return;
	}
}

int main(){
	int num[4],op[4],pr[4];
	while(true){
		op[3] = -1; pr[3] = 0; ansflag = false;
		bool endflag = true;
		for(int i=0;i<4;i++){
			cin>>num[i];
			if(num[i]!=0) endflag = false;
		}
		if(endflag) return 0;
		/*for(int i=0;i<3;i++) cin>>op[i];
		for(int i=0;i<3;i++) cin>>pr[i];
		int sp,npr=3;
		for(int i=2;i>=0;i--){
			if(npr>pr[i]){
				sp = i; npr = pr[i];
			}
		}
		bool used[3]={};
		printf("%d\n",Calc(sp,num,op,pr,used));*/
		sort(num,num+4);
		do{
			for(int i=0;i<3;i++) pr[i]=i;
			do{
				OpEnum(num,op,pr,0);
				if(ansflag) goto OUT;
			}while(next_permutation(pr,pr+3));
		}while(next_permutation(num,num+4));
	
		OUT:
		if(ansflag==false) puts("0");
		else{
			int np = 0;
			for(int i=0;i<4;i++){
				for(;np<pr[i];np++) printf("(");
				printf("%d",num[i]);
				for(;np>pr[i];np--) printf(")");
				if(op[i]==0) printf(" + ");
				else if(op[i]==1) printf(" - ");
				else if(op[i]==2) printf(" * ");
			}puts("");
		}
	}
}

Measured memory_bytes: 1172
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    
    int n,m;
    cin>>n>>m;
    vi v(n);
    rep(i,n){
        cin>>v[i];
    }
    int ans=0;
    n-=m;
    ans++;
    ans+=ceil(n/(double)(m-1));
    fin(ans);
}




Measured memory_bytes: 640
import bisect


def main():
    H, W, K = map(int, input().split())
    S = [input() for _ in range(H)]

    C = [[0] for _ in range(W)]
    for i in range(W):
        for j in range(H):
            if S[j][i] == "1":
                C[i].append(C[i][-1] + 1)
            else:
                C[i].append(C[i][-1])

    if W == 1:
        c = C[0]
        res = 0
        cut = 0
        for i in range(H):
            if c[i + 1] - c[cut] > K:
                res += 1
                cut = i
        return res

    res = 20000
    for i in range(2 ** (H - 1)):
        f = 0
        cut = [[0]]
        for j in range(H - 1):
            if (2 ** j) & i != 0:
                cut[-1].append(j + 1)
                cut.append([j + 1])
        cut[-1].append(H)
        lc = len(cut)
        tres = lc - 1
        w = [0 for _ in range(lc)]
        for k in range(W):
            if f == 1:
                break
            for j in range(lc):
                t = C[k][cut[j][1]] - C[k][cut[j][0]]
                if t > K:
                    f = 1
                    break
                w[j] += t
            if max(w) > K:
                tres += 1
                w = [C[k][cut[p][1]] - C[k][cut[p][0]] for p in range(lc)]
        if f == 0:
            res = min(res, tres)

    return res


print(main())


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


int main(){

  int count[5][4][11] , n = 0 , b = 0 , f = 0 , r = 0 , v = 0;
   
  
 
 for( int i = 0 ; i < 4 ; i++ ){
   for( int j = 0 ; j < 3 ; j++ ){
     for( int p = 0 ; p < 10 ; p++ ){
       count[i][j][p] = 0;
     }
   }
 }
 
 cin >> n;

 for( int i = 0 ; i < n ; i++ ){
 
   cin >> b >> f >> r >> v;
 
   count[b-1][f-1][r-1] += v;

  
 }

 for(int l = 0; l < 4; l++){
     if( l != 0){

cout << "####################" << "\n";
     }
   for(int i = 0; i < 3; i++){
     for(int j = 0; j < 10; j++){

       cout << " " << count[l][i][j];

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

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> s(N);
    REP(i, N) cin >> s[i];

    ll res = 0;
    REP(C, N+1){
    	ll k = 0;
    	ll tmp = 0;
    	set<ll> st;
    	while(1){
    		ll A = N-1-k*C;
    		ll B = A-C;
    		if(A<0||B<0) break;
    		if(k*C>N-1) break;
    		if(st.find(A) != st.end()) break;
    		st.insert(A);
    		tmp += s[A];
    		if(st.find(k*C) != st.end()) break;
    		st.insert(k*C);
    		tmp += s[k*C];
    		res = max(res, tmp);
    		k++;
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 7424
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    string s;
    string result ("Good");
    cin >> s;

    for (ll i=1; i<s.size(); ++i)
    {
            if (s[i-1] == s[i])
            {
                    result = "Bad";
                    cout << result << endl;
                    return 0;
            }
    }
    cout << result << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	int n;
	string s;
	std::cin >> n;
	std::cin >> s;
	int le=s.size();
	string a,b;
	int counter=0,mcou=0;
	rep(i,le){
		if(s[i]==')')counter++;
		else counter--;
		if(counter>0){
			a.push_back('(');
			counter--;
		}
		
	}
	if(counter<0){
		counter=-counter;
		rep(i,counter)b.push_back(')');
	}
	std::cout << a+s+b << std::endl;
}

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

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

		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);

		if (a[0] == a[1] && a[0] == 5 && a[2] == 7)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}

Measured memory_bytes: 20820
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sun Mar 25 19:37:08 2018
//
package main

import (
	"fmt"
)

var a, b int

func main() {
	fmt.Scan(&a, &b)
	if 0 < a {
		fmt.Println("Positive")
	} else if b < 0 {
		if (-a+b+1)%2 == 0 {
			fmt.Println("Positive")
		} else {
			fmt.Println("Negative")
		}
	} else {
		fmt.Println("Zero")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,b,k,i;
	cin>>k>>a>>b;
	for(i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			printf("OK");
			return 0;
		}
	}
	printf("NG");
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Kattio in = new Kattio(System.in);
        int n = in.nextInt();
        
        double sum = 0;
        for (int i = 0; i < n; ++i) {
            double x = in.nextInt() * 1.0;
            sum += 1/x;
        }

        in.println(1 / sum);

        in.close();
        in.flush();
    }


}


class Kattio extends PrintWriter {
    public Kattio(InputStream i) {
	super(new BufferedOutputStream(System.out));
	r = new BufferedReader(new InputStreamReader(i));
    }
    public Kattio(InputStream i, OutputStream o) {
	super(new BufferedOutputStream(o));
	r = new BufferedReader(new InputStreamReader(i));
    }

    public boolean hasMoreTokens() {
	return peekToken() != null;
    }

    public int getInt() {
	return Integer.parseInt(nextToken());
    }

    public double getDouble() { 
	return Double.parseDouble(nextToken());
    }

    public long getLong() {
	return Long.parseLong(nextToken());
    }

    public String getWord() {
	return nextToken();
    }



    private BufferedReader r;
    private String line;
    private StringTokenizer st;
    private String token;

    private String peekToken() {
	if (token == null) 
	    try {
		while (st == null || !st.hasMoreTokens()) {
		    line = r.readLine();
		    if (line == null) return null;
		    st = new StringTokenizer(line);
		}
		token = st.nextToken();
	    } catch (IOException e) { }
	return token;
    }

    private String nextToken() {
        String ans = peekToken();
        token = null;
        return ans;
    }

    public int nextInt() {
        return Integer.parseInt(getWord());
    }

}

Measured memory_bytes: 21204
#include "bits/stdc++.h"
using namespace std;
const int maxN = 1e5 + 10;
int n, m, x, y, deg[maxN], dp[maxN];
vector<int> edge[maxN];
queue<int> Q;
int main()
{
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		cin >> x >> y;
		x--, y--;
		edge[x].push_back(y);
		deg[y]++;
	}
	for(int i = 0; i < n; i++) if(deg[i] == 0) Q.push(i);
	while(!Q.empty())
	{
		int now = Q.front();
		Q.pop();
		for(auto to : edge[now])
		{
			deg[to]--;
			dp[to] = max(dp[to], dp[now] + 1);
			if(deg[to] == 0) Q.push(to);
		}
	}
	cout << *max_element(dp, dp + n) << endl;
	return 0;
}

Measured memory_bytes: 6528
N = int(input())
S =[input() for i in range(N)]
#print(S)

cnt = 0
BA = 0 # 'B~A'
lA = 0 # last 'A'
fB = 0 # first 'B'

for i in S:
  c = i.count('AB')
  # count 'B~*', 'B~A' '*~A'
  if i.find('B') == 0 and i.rfind('A') == len(i)-1:
    BA += 1
  elif i.find('B') == 0:
    fB += 1
  elif i.rfind('A') == len(i)-1:
    lA += 1
  cnt += c

# lA_fB = min(lA, fB)  
# r = min(abs(lA - fB), BA)
# n = max(0, (BA -r) // 2)

if BA > 0:
  cnt += BA -1
  if lA > 0:
    cnt += 1
    lA -= 1
  if fB > 0:
    cnt += 1
    fB -= 1

cnt += min(fB, lA)
print(cnt)


Measured memory_bytes: 3700
while n = gets.to_i
  break if n.zero?
  teams = {}
  n.times do
    id, m1, s1, m2, s2, m3, s3, m4, s4 = gets.split.map(&:to_i)
    teams[id] = 60*(m1+m2+m3+m4) + (s1+s2+s3+s4)
  end
  result = teams.sort_by{|k,v| v}
  puts result[0].first
  puts result[1].first
  puts result[-2].first
end

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

int main(void){
  int i,j,k; 
  int n;
  string s1;
  cin>>s1;
  sort(s1.begin(), s1.end());
  s1.erase(unique(s1.begin(), s1.end()), s1.end());
  if(s1.size()==2)cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,max_sum=0;;
  cin>>N;
  vector<int> as(pow(10,5));
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    as.at(a)++;
  }
  for(int i=1;i<as.size()-1;i++){
    int sum=as.at(i-1)+as.at(i)+as.at(i+1);
    max_sum=max(max_sum,sum);
  }
  cout<<max_sum<<endl;
}

Measured memory_bytes: 640
# Your code here!

s=gets.chomp

n=s.length
flag=true

for c in 'a'..'z' do
    cnt=0
    for i in 0..n-1 do
        if(s[i]==c)
            cnt+=1
        end
    end
    if(cnt%2==1)
        flag=false
        break
    end
end

puts (flag ? "Yes":"No")

Measured memory_bytes: 1788
#include <string>

#include <iostream>
using namespace std;

int main(){
    string S;
    int num=700;
    cin>>S;
    for (int i=0; i<3; i++) {
        if (S[i]=='o') {
            num=num+100;
        }
    }
    cout<<num;

    return 0;
}


Measured memory_bytes: 256
while True:
    try:
        n,r=map(int,raw_input().split())
    except EOFError:
        break
    cset=map(int,raw_input().split())
    I=range(n)
    for c in cset:
        A,B,C=I[n/2:],I[:n/2],[]
        while A<>[] or B<>[]:
            if c<=len(A):
                C+=A[:c]
                A=A[c:]
            else:
                C+=A[:]
                A=[]
            if c<=len(B):
                C+=B[:c]
                B=B[c:]
            else:
                C+=B[:]
                B=[]
        I=C[:]
    print C[-1]

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

pos=0
sum=0

for i in range(1,N+1):
    pos=1/N
    count=0
    while i<K:
        i*=2
        count+=1
    #print(count)
    pos*=pow(1/2,count)
    sum+=pos



print(sum)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
 
int main(){
	fast;
	lli n;
	cin>>n;
	lli sum=0, ans=0;
	while(n>0){
	    lli temp = (int)log2(n);
	    n/= ((int)pow(2,temp));
	    n-=1;
	    sum+=temp;
	}
	//cout<<sum<<"\n";
	for(int i=0; i<=sum; i++){
	    ans+=((long long int)pow(2,i));
	}
	cout<<ans<<"\n";
  	return 0;
}


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

const int dx[2] = {0, 1};
const int dy[2] = {1, 0};
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (auto i = 0; i < h; i++) cin >> s[i];
    vector<vector<int>> dp(h, vector<int>(w, 1 << 20));
    dp[0][0] = (s[0][0] == '#');
    for (auto i = 0; i < h; i++) {
        for (auto j = 0; j < w; j++) {
            for (auto k = 0; k < 2; k++) {
                int nx = i + dx[k], ny = j + dy[k];
                int cost = dp[i][j];
                if (nx >= h or ny >= w) continue;
                if (s[i][j] == '.' and s[nx][ny] == '#')
                    cost++;
                dp[nx][ny] = min(dp[nx][ny], cost);
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    string S, T;
    int N;
    cin >> N >> S >> T;
    string result = "";
    int i = 0;
    int j = 0;
    while (i < S.length() && j < T.length()) {
        result = result + S[i] + T[j];
        i++;
        j++;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 384
h, n = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.reverse()
ans = False
dmg = 0
for i in a:
    dmg += i
    if dmg >= h:
        ans = True
        break
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 13964
N,K = map(int, input().split())
ary1 = sorted([int(input()) for x in range(N)])
min1 = 10**9+1
for i in range(K-1,N):
  dist1 = ary1[i]-ary1[i-K+1]
  if dist1 < min1:
    min1 = dist1
    
print(min1)

Measured memory_bytes: 51648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(long long N, long long A, long long B){
	cout << min(A*N, B) << endl;
}

int main(){	
	long long B;
	long long N;
	long long A;
	scanf("%lld",&N);
	scanf("%lld",&A);
	scanf("%lld",&B);
	solve(N, A, B);
	return 0;
}



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

using namespace std;
typedef long long ll;

constexpr ll MOD = 998244353;

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

    vector<vector<ll>> dp(c + 1, vector<ll>(d + 1));
    dp[a][b] = 1;
    for (int i = a; i <= c; i++) {
        for (int j = b; j <= d; j++) {
            if (i > a)dp[i][j] += dp[i - 1][j] * j, dp[i][j] %= MOD;
            if (j > b)dp[i][j] += dp[i][j - 1] * i, dp[i][j] %= MOD;
            if (i > a && j > b) {
                ll duplication = (i - 1) * (j - 1) % MOD;
                duplication *= dp[i - 1][j - 1], duplication %= MOD;
                dp[i][j] -= duplication, dp[i][j] += MOD, dp[i][j] %= MOD;
            }
        }
    }

    cout << dp[c][d] << endl;
    return 0;
}

Measured memory_bytes: 73740
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_b(pair<int, long long> a, pair<int, long long> b) {
    if(a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    string s, t;
    cin >> s >> t;
    int alf = 'z' - 'a' + 1; // 26
    int ns = s.size();
    int nt = t.size();
    string ss = s + s;
    int nss = 2 * s.size();
    vector<vector<int>> v(
        nss + 1, vector<int>(alf, -1)); // i文字目以降で文字がどこで出現するか
    rep(i, 0, nss) {
        int t = nss - i - 1;
        char tmp = ss[t];
        v[t] = v[t + 1];
        v[t][tmp - 'a'] = t;
    }
    // rep(i, 0, nss) {
    //     rep(j, 0, alf) { cout << v[i][j] << " "; }
    //     cout << endl;
    // }
    int ind = 0;
    long long res = 0LL;
    rep(i, 0, nt) {
        int tt = t[i] - 'a';
        if(v[ind][tt] == -1) {
            cout << -1 << endl;
            return 0;
        }
        ind = v[ind][tt] + 1;
        if(ind > ns) {
            ind -= ns;
            res += ns;
        }
    }
    res += ind;
    cout << res << endl;
}

Measured memory_bytes: 27264
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

string s, ss;
int main() {
	cin >> s;
	reverse(ALL(s));
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'b')ss += 'd';
		if (s[i] == 'd')ss += 'b';
		if (s[i] == 'p')ss += 'q';
		if (s[i] == 'q')ss += 'p';
	}
	reverse(ALL(s));
	cout << (s == ss ? "Yes" : "No") << endl;
}

Measured memory_bytes: 640
///                ..:: In The Name Of God ::..
#include<bits/stdc++.h>

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define error(x) cerr << #x << " = " << (x) << endl;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define Size(x) (int)(x).size()
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;
int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    
    int a,b,c;
    cin >> a >> b >> c;
    if(c>=b/a) cout << b/a << endl;
    else cout << c << endl;
    
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $N);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));
rsort($A);
$ans = 0;
for ($i = 1; $i < $N; $i++) {
    $ans += $A[intdiv($i, 2)];
}
printf("%d", $ans);


Measured memory_bytes: 38100
import sys

a=input().split(" ")
N=int(a[0])
K=int(a[1])
line=input().split(" ")
dp=[]
for i in range(N):
    line[i]=int(line[i])
    dp.append(sys.maxsize)
dp[0]=0
dp[1]=abs(line[1]-line[0])
for j in range(2,N):
    for p in range(1,K+1):
        dp[j]=min(dp[j], dp[j-p]+abs(line[j]-line[j-p]))
print(dp[N-1])

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

vector<int>divisor(int n) {
	vector<int>divisor;
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			divisor.push_back(i);
			if (i * i != n) divisor.push_back(n / i);
		}
	}
	sort(begin(divisor), end(divisor));
	return divisor;
}

main() {
	int n, m;
	cin >> n >> m;
	vector<int>d = divisor(m);
	int ans = 0;
	for (int i = 0; i < d.size(); i++) {
		if (m / d[i] >= n)ans = d[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
t = input()
for i in range(len(s)):
  if s[i] == t[0]:
    j, k =  i + 1, 1
    while k <= len(t):
      j %= len(s)
      if k == len(s): 
        print('Yes')
        exit(0)
      if s[j] != t[k]: 
        break
      k += 1
      j += 1
print('No')


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int e, y;

int main() {
	cin >> e >> y;
	if (e == 0) {
		if (1868 <= y && y <= 1911)cout << 'M' << y - 1867 << endl;
		if (1912 <= y && y <= 1925)cout << 'T' << y - 1911 << endl;
		if (1926 <= y && y <= 1988)cout << 'S' << y - 1925 << endl;
		if (1989 <= y)cout << 'H' << y - 1988 << endl;
	}
	else if (e == 1) {
		cout << 1868 + y-1 << endl;
	}
	else if (e == 2) {
		cout << 1912 + y-1 << endl;
	}
	else if (e == 3) {
		cout << 1926 + y - 1 << endl;
	}
	else {
		cout << 1989 + y - 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <sstream>
#include <algorithm>

int main(int argc, char const *argv[]) {
  std::string search_word;
  std::cin >> search_word;
  int count=0;
  while(1){
    std::string s;
    std::getline(std::cin, s);
    if(s == "END_OF_TEXT")break;
    std::stringstream ss(s);
    std::string str;
    while(getline(ss,str,' ')){
      transform (str.begin (), str.end (), str.begin (), tolower);
      if(str == search_word){
        count++;
      }
    }
  }
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 3188
pInt()=parse(Int64,readline())

A=zeros(Int,3,3)
B=zeros(Bool,3,3)
for i in 1:3
    r=map(x->parse(Int64,x),split(readline()))
    A[i,:]=r
end
N=pInt()
for i in 1:N
    b=pInt()
    B += (A .== b)
end
B=(B.>0)
flag="No"
for i in 1:3
    sum(B[i,:])==3 && (flag="Yes")
    sum(B[:,i])==3 && (flag="Yes")
end
sum(B[i,i] for i in 1:3)==3 && (flag="Yes")
sum(B[i,4-i] for i in 1:3)==3 && (flag="Yes")

print(flag)

Measured memory_bytes: 124952
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Y;
  cin >> N >> Y;
  bool S = true;
  for(int i = 0; i < N + 1; i++) {
    for(int j = 0; j < N + 1 - i; j++) {
      if(10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
        cout << i << " " << j << " " << N - i - j << endl;
        S = false;
        break;
      }
    }
    if(!(S)) break;
  }
  if(S) {
    cout << -1 << " " << -1 << " " << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
using vi = vector<int>;

string str;
string stra;
int id = 0;

void pt(vector<int> v){
  for(int r=0;r<v.size();r++){
    cout << v[r];
  }
  cout << endl;
}

vi number(){
  vi res;
  for (;'0'<=stra[id]&&stra[id]<='9'; id++) {
    res.push_back(stra[id] - '0');
  }
  reverse(res.begin(),res.end());
  return res;
}
int solve(){
  stra = str;
  for (int i = 9; i >= 0; i--) {
    id = 0;
    for (int j = 0; j <(int)str.size(); j++) {
      if (str[j] == 'X') {
        stra[j] = i + '0';
      }
    }
    vi a = number();
    if (stra[id] == '+' ) {
      id++;
    }
    vi b = number();
    
    //a.resize(max(b.size() + 1,a.size()+1),0);
    
    // a.push_back(0);
    // while(a.size()<=b.size()){
    //   a.push_back(0);
    // }

    
    // pt(a);
    int j;
    int k=0;
    int l=0;
    vi ab;
    for(j=0;j<int(a.size())&&j<int(b.size());j++){
      k=0;
      if(a[j]+b[j]+l>=10){
        k++;
        ab.push_back(a[j]+b[j]+l-10);
      }
      else{
        ab.push_back(a[j]+b[j]+l);
      }
      l=k;
    }
    for(;j<int(a.size());j++){
      k=0;
      if(a[j]+l>=10){
        k++;
        ab.push_back(a[j]+l-10);
      }
      else{
        ab.push_back(a[j]+l);
      }
      l=k;
    }
    for(;j<int(b.size());j++){
      k=0;
      if(b[j]+l>=10){
        k++;
        ab.push_back(b[j]+l-10);
      }
      else{
        ab.push_back(b[j]+l);
      }
      l=k;
    }
    if(l>0){
      ab.push_back(l);
    }
    while(a[a.size()-1]==0){
      a.pop_back();
    }
    a=ab;
    /////////
    if (stra[id] == '=') {
      id++;
    }

    vi c = number();
    if (a.size() != c.size()) {
      continue;
    }
    int flag = 0;
    for (int j = 0; j < (int)a.size(); j++) {
      if (a[j] == c[j]) {
        flag++;
      }
    }
    if (flag ==(int)a.size()) {
      return i;
    }

  }
  return -1;
}
int main(){
  cin >> str;
  while(str.size()){
  int ans = solve();
  if (ans >= 0) {
    cout << ans << endl;
  } else {
    cout << "NA" << endl;
  }
  str="";
  cin >> str;
}
  return 0;
}



Measured memory_bytes: 3184
n, m = gets.chomp.split(" ").map(&:to_i)
x = gets.chomp.split(" ").map(&:to_i).sort
sa = []
i = 0
j = 1
arr = []
if n >= m
    puts "0"
else
    sa = n - m
    while true
        if j == m
            break
        end
        arr << x[j] - x[i]
        i += 1
        j += 1
    end
    arr = arr.sort
    i = 0
    (sa.abs).times do
        i += arr.shift
    end
    puts i
end


Measured memory_bytes: 23936
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main(){
  int n;
  while(cin >> n && n!=0){
    vector<int> v(n+1,0);
    v[0]=1;
    for(int i=0;i<n;i++){
      v[i+1]+=v[i];
      if(i<n-1){v[i+2]+=v[i];}
      if(i<n-2){v[i+3]+=v[i];}
    }
    //int型の除算は切り捨て
    //http://bttb.s1.valueserver.jp/wordpress/blog/2017/07/23/競プロのテクニック-割り算の切り上げ、四捨五入/
    //参考にした

    cout << (((v[n]+9)/10)+364)/365 << endl;
  }
}



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

signed main(){
  int N,M;
  cin>>N>>M;
  vector<pair<int,int>> S(N);
  rep(i,N){
    int f,s;
    cin>>f>>s;
    S[i]=make_pair(f,s);
  }
  vector<pair<int,int>> C(M);
  rep(i,M){
    int f,s;
    cin>>f>>s;
    C[i]=make_pair(f,s);
  }
  rep(i,N){
    int ans=0,ne=9999999999999999;
    rep(j,M){
      int A=S[i].first,B=C[j].first,CC=S[i].second,D=C[j].second;
      int nex=abs(A-B)+abs(CC-D);
      if(ne>nex){
        ans=j+1;
        ne=nex;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main() {
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  int ans_wat = 0;
  int ans_sug = 0;
  double ans_rate = -1.0;
  
  for ( int i = 0; i * a * 100 < f ; i++){
    for( int j = 0; j * b * 100 < f - i * a * 100; j++){
      int water = (i * a + j * b )  * 100;
      if(water == 0) continue;
      //int maxsugar = min((e * (water / 100)) ,f - water);
      //if (water){
        for ( int k = 0; water + k * c <= f; k++){
          for( int l = 0; water + k * c + d * l <= f; l++){
          //int l = (maxsugar - c * k ) / d;
          int sugar = k * c + l * d;
          double rate = (100.0 * sugar) / ( water + sugar);
          if (ans_rate < rate && sugar <= e * ( i * a + j * b)){
            ans_wat = water;
            ans_sug = sugar;
            ans_rate = rate;
          }//if k 
          }//4_l
        }//4_k
      //}ifj
    }//4 j
  }//4 i
  cout << ans_wat + ans_sug << " " << ans_sug << endl;  
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

	if n%(a+b) > a {
		fmt.Println(a*(n/(a+b)) + a)
	} else {
		fmt.Println(a*(n/(a+b)) + n%(a+b))
	}

}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    string t;
    cin>>t;
    rep(i, t.size()){
        if(t[i] == '?') t[i] = 'D';
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 3756
def mulmod(x, y, p=10**9 + 7):
    return x * y % p


def combmod(n, k, p=10**9 + 7):
    from functools import reduce
    k = min(k, n - k)
    x = reduce(mulmod, range(n - k + 1, n + 1), 1)
    y = reduce(mulmod, range(1, k + 1), 1)
    return x * pow(y, p - 2, p) % p


def solve(string):
    n, a, b = map(int, string.split())
    return str((pow(2, n, 10**9 + 7) - 1 - combmod(n, a) - combmod(n, b)) % (10**9 + 7))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 3572
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#include<cmath>
#define MAX 100005
typedef long long LL;

using namespace std;

int main()
{
	char a;
	cin >> a;
	if(a <='Z' && a >='A')
		cout << 'A' << endl;
	else 
		cout << 'a' << endl;
	return 0;
}

Measured memory_bytes: 3620
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int n,m;
    cin>>n>>m;
    int a,sum=0;
    rep(i,1,m) cin>>a,sum+=a;
    cout<<(n>=sum?n-sum:-1);
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;
typedef pair<ll, ll> pll;

int main(){
	int n, k; cin >> n >> k;
	vector<pll> v;
	// first: 美味しさ
	// second: ネタの種類
	for( int i = 0; i < n; ++i ){
		ll t, d; cin >> t >> d;
		--t;
		v.emplace_back(d, t);
	}
	sort( v.begin(), v.end(), greater<pll>() );
	ll cnt = 0;
	ll candy = 0;
	bool used[n];
	fill_n( used, n, false );
	priority_queue<ll> pq;
	priority_queue<ll, vector<ll>, greater<ll>> selected;
	for( int i = 0; i < n; ++i ){
		if( used[v[i].second] || cnt == k ){
			pq.push(v[i].first);
		} else {
			candy += v[i].first;
			used[v[i].second] = true;
			selected.push(v[i].first);
			++cnt;
		}
	}
	if( cnt < k ){
		for( int i = cnt; i < k; ++i ){
			candy += pq.top();
			pq.pop();
		}
	}
	ll ans = candy + cnt*cnt;
	for( ll i = cnt-1; i > 0; --i ){
		if( pq.empty() || pq.top() < selected.top() ) break;
		candy = candy - selected.top() + pq.top();
		selected.pop(); pq.pop();
		ans = max(ans, candy+(i*i));
	} 
	cout << ans << endl;
	return 0;
}

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

int main () {
    int N, x;
    cin >> N >> x;
    vector<int> children(N);
    int count = 0;
    for (int i = 0; i < N; i++) {
        cin >> children.at(i);
    }
    sort(children.begin(), children.end());
    for (int i = 0; i < N; i++) {
        if (x >= children.at(i)) {
            count++;
            x -= children.at(i);
            if (x == 0) {
                break;
            }
        }
    }
    if (N <= count && x != 0) {
        count--;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
s = list(input())
K = int(input())
s = list(map(lambda x: ord(x), s))
sub_s = []
for length in range(1, 6):
    for i in range(len(s) - (length - 1)):
        sub_s.append(s[i:i+length])
sub_s.sort()
k = 1
ans = sub_s[0]
for sub in sub_s:
    if ans == sub:
        if k == K:
            break
        continue
    ans = sub
    k += 1
    if k == K:
        break
for c in ans:
    print(chr(c), end="")


Measured memory_bytes: 76392
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

int main(void) {
  
  string O, E;
  cin >> O >> E;
  vector<int> ans;
  for(int i=0; i<O.size()+E.size(); i++) {
    if(i % 2 == 0) cout << O[i/2];
    else cout << E[i/2];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p


p = 10 ** 9 + 7
N = 2000  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


N, K = list(map(int, input().split()))

for k in range(1, K + 1):
    res = cmb(N - K + 1, k, p)
    res *= cmb(K - 1, k - 1, p)
    print(res % p)


Measured memory_bytes: 3572
// B - Ordinary Number
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = 0;
	for (int i = 1; i + 1 < n; i++)
		if ((a[i - 1] < a[i] || a[i + 1] < a[i]) && (a[i - 1] > a[i] || a[i + 1] > a[i]))
			ans++;
	cout << ans << endl;

	return 0;
}


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

int main()
{
    int N, x;
    vector<int> A;
    int ans = 0;
    cin >> N >> x;
    for (int i = 0; i < N; ++i)
    {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < N; ++i)
    {
        if (A[i] > x){
            break;
        }
        x -= A[i];
        ++ans;
    }
    if (x > 0 && ans == N){
        ans -= 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(){
    int x, c = 0;
    int arr[51];

    scanf("%d", &x);
    for(int i= 0; i < x; i++){
        scanf("%d", &arr[i]);
        if(arr[i] != i+1){
            c++;
        }
    }
    if(c > 2)
        printf("NO\n");
    else
        printf("YES\n");

    return 0;
}


Measured memory_bytes: 128
/**
 *    SATAR ALLAH
 *
**/
#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

int main()
{

    long long A,B,C,X,Y;

     cin>>A>>B>>C>>X>>Y;

     long long  ans=100000000000000000;
     for(int i=0;i<=X;i++){

          ans=min(ans, (X-i)*A + 2*i*C + (Y-i)*B*(Y>i)  );
     }

      for(int i=0;i<=Y;i++){

          ans=min(ans, (Y-i)*B + 2*i*C + (X-i)*A*(X>i)  );
     }


     cout<<ans;

    return 0;
}


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

int main() {
    //
    int num;
    string str;
    vector<int> Min(26, 0);
    vector<char> vec(26);
    vec = {'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'};

    cin >> num;

    for (int i = 0; i < num; i++) {
        cin >> str;
        map<char, int> m;
        for (int j = 0; j < str.size(); j++) {
            //
            m[str.at(j)]++;
        }

        if (i == 0) {
            int tmp = 0;
            for (auto itr : m) {
                for (int j = tmp; j < 26; j++) {
                    if (vec.at(j) == itr.first) {
                        Min.at(j) = itr.second;
                        // Min.at(j) = min(Min.at(j), itr.second);
                        tmp = j + 1;
                        // cout <<  tmp << endl;
                        break;
                    } else {
                        Min.at(j) = 0;
                    }
                }
            }
            for (int j = tmp; j < 26; j++) { Min.at(j) = 0; }
        } else {
            int tmp = 0;
            for (auto itr : m) {
                for (int j = tmp; j < 26; j++) {
                    if (vec.at(j) == itr.first) {
                        Min.at(j) = min(Min.at(j), itr.second);
                        tmp = j + 1;
                        // cout << tmp << endl;
                        break;
                    } else {
                        Min.at(j) = 0;
                    }
                }
            }
            for (int j = tmp; j < 26; j++) { Min.at(j) = 0; }
        }
    }
    string kekka;
    for (int i = 0; i < 26; i++) {
        if (Min.at(i) > 0) {
            for (int j = 0; j < Min.at(i); j++) { kekka += vec.at(i); }
        }
    }

    cout << kekka;
    //
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;


int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio
    ll t, i, j, n, x;
    cin>>n>>x>>t;
    ll ans=(n/x)*t;
    if(n%x!=0)
    {
        ans+=t;
    }
    cout<<ans;
}





Measured memory_bytes: 3636