akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll n, i, a, b, max_od=0, max2_od=0, max_ev=0, max2_ev=0, odi, evi, od2i, ev2i;
    vector<ll> od(100001), ev(100001);

    cin >> n;

    for(i=1; i<=n; i++){
        cin >> a;

        if(i%2==1){
            od[a]++;
        }
        else{
            ev[a]++;
        }    
    }

    for(i=1; i<=100000; i++){
        if(max_od < od[i]){
            max2_od = max_od;
            max_od = od[i];
            odi = i;
        }
        else if(max2_od < od[i]){
            max2_od = od[i];
        }
    }

    for(i=1; i<=100000; i++){
        if(max_ev < ev[i]){
            max2_ev = max_ev;
            max_ev = ev[i];
            evi = i;
        }
        else if(max2_ev < ev[i]){
            max2_ev = ev[i];
        }
    }

    if(odi != evi){
        cout << n-max_od-max_ev << endl;
    }

    else{
        a = max_od+max2_ev;
        b = max2_od+max_ev;

        cout << n-max(a,b) << endl;
    }

    return 0;
}

Measured memory_bytes: 1920
#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 <unordered_set>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
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;
#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 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 floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
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;}
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;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  invar(int, N);
  
  fin(N*N*N);

}

Measured memory_bytes: 384
/**
 * author : Dhakad_123
 * created: 02.06.2020
 **/
#include<bits/stdc++.h>
using namespace std;

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

  int a , b;
  cin >> a >> b;


  cout << a*b << "\n";

  return 0;
}



Measured memory_bytes: 3664
#include <iostream>
#define N 100

using namespace std;

int A[N], n;

void print(){
  int i;
  for(i = 0;i < n;i++){
      cout << A[i];
      if(i != n - 1)
	cout << " ";
    }
    cout << endl;
}

void insertionSort(){
  int i, j, key;
  for(j = 1;j < n;j++){
    key = A[j];
    i = j - 1;
    while(i >= 0 && A[i] > key){
      A[i+1] = A[i];
      i = i - 1;
    }
    A[i+1] = key;
    print();
  }
}

int main(){
  int i, j;
    
  cin >> n;
  for(i = 0;i < n;i++){
    cin >> A[i];
  }
  for(i = 0;i < n;i++){
    cout << A[i];
    if(i != n - 1)
      cout << " ";
  }
  cout << endl;
  insertionSort();
  return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string s;
  int K,a;
  cin >> K >> s;
  a=s.size();
  if(a>K){
  s.erase(K);
    s+="...";
  }
  cout << s;
  return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
 
int box[100005];
int main()
{
    int n,x;
    while (scanf("%d%d",&n,&x)!=EOF)
    {
        for (int i=1;i<=n;i++)
            scanf("%d",&box[i]);
        long long all=0;
        if (box[1]>x)
        {
            all+=box[1]-x;
            box[1]=x;
        }
        for (int i=2;i<=n;i++)
        {
            int k = box[i]+box[i-1]-x;
            if (k>0)
            {
                all+=k;
                box[i]-=k;
            }
        }
        printf("%lld\n",all);
    }
}

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

int main() {
 int X,Y,Z;
 cin >> X >> Y >> Z;
  int l = Z;
  int c = 0;
  for(int i = 0; i<100009;i++){
    if(i%2 == 0){
     l += Y;
     c++;
    }
    else l += Z;
    if(X-l < Y+Z){
      break;
    }
  }
  cout << c << endl;

}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, A[202020];

ll i, j, k, ans;

int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    j = 0;
    fornum(i,0,N){
        if(A[i]==j+1){
            j++;
        }
    }
    if(j>0){
        printf("%lld", N-j);
    }else{
        printf("-1");
    }
    return 0;
}

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll D;
    cin >> D;
    vll C(26);
    for(auto &e : C)
        cin >> e;
    vector<vll> S;
    for(i = 0; i < D; i++) {
        vll si;
        for(j = 0; j < 26; j++) {
            ll s;
            cin >> s;
            si.push_back(s);
        }
        S.push_back(si);
    }
    vll T;
    for(i = 0; i < D; i++) {
        ll t;
        cin >> t;
        t--;
        T.push_back(t);
    }

    ll score = 0;
    vll last(26, 0);
    for(i = 0; i < D; i++) {
        score += S[i][T[i]];
        last[T[i]] = i + 1;
        for(j = 0; j < 26; j++) {
            score -= C[j] * (i + 1 - last[j]);
        }
        cout << score << endl;
    }

    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
//to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int main(void) {

	vint a(6);
	vcin(a, 6);
	vint ans(4);
	rep(i, 6) {
		ans[a[i] - 1]++;
	}
	rop(i, 2) {
		if (ans[i] < 2) {
			cout << "NO" << rt;
			return 0;
		}
	}
	cout << "YES" << rt;

	please AC;
}
//参考：---

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#define last last2

using namespace std;

int num[200005],pre[200005],nxt[200005],len[200005];
bool col[200005],vis[200005];

queue <int> que[2],q2;
int kind[200005];

bool calc(int n,int m) {
  memset(pre,0,sizeof(pre));
  memset(nxt,0,sizeof(nxt));
  memset(len,0,sizeof(len));
  memset(vis,0,sizeof(vis));
  int cur=0;
  while (!que[cur].empty()) que[cur].pop();
  for(int i=1;i<=2*n-1;i++) col[i]=(num[i]>m);
  bool ans=col[1];
  int tot=0,last=1;
  for(int i=2;i<=2*n-1;i++)
    if (col[i]!=col[i-1]) {
    	len[++tot]=i-last;
    	last=i;
	}
  len[++tot]=2*n-last;
  for(int i=1;i<=tot;i++) {
  	pre[i]=i-1;
  	if (i<tot) nxt[i]=i+1; else nxt[i]=0;
  	if (len[i]==1) que[cur].push(i);
  }
  int l=1,r=tot;
  for(int i=1;i<n;i++) {
  	cur^=1;
  	while (!que[cur].empty()) que[cur].pop();
  	while (!q2.empty()) q2.pop();
  	if (len[l]==1&&len[nxt[l]]>1) ans^=1;
  	while (!que[cur^1].empty()) {
  		int x=que[cur^1].front();que[cur^1].pop();
  		if (x==l||x==r||len[x]>1||vis[x]) continue;
  		if (len[pre[x]]>1&&len[nxt[x]]>1) {
		    vis[x]=1;q2.push(x);
		    kind[x]=1;
		  }
		else if (len[pre[x]]>1) {
			vis[x]=1;q2.push(x);
			kind[x]=2;
		}
		else if (len[nxt[x]]>1) {
			vis[x]=1;q2.push(x);
			kind[x]=3;
		}
	  }
  	while (!q2.empty()) {
  		int x=q2.front();q2.pop();
  		if (kind[x]==1) {
  			int p=pre[x],q=nxt[x];
  			nxt[p]=nxt[q];
  			pre[nxt[q]]=p;
  			len[p]=len[p]+len[q]+len[x];
  			if (len[pre[p]]==1) que[cur].push(pre[p]);
  			if (len[nxt[q]]==1) que[cur].push(nxt[q]);
		  }
		else if (kind[x]==2) {
			int p=pre[x],q=nxt[x];
			nxt[p]=q;
			pre[q]=p;
			len[p]=len[p]+len[x];
			if (len[pre[p]]==1) que[cur].push(pre[p]);
			if (len[q]==1) que[cur].push(q);
		}
		else if (kind[x]==3) {
			int p=pre[x],q=nxt[x];
			pre[q]=p;
			nxt[p]=q;
			len[q]=len[q]+len[x];
			if (len[nxt[q]]==1) que[cur].push(nxt[q]);
			if (len[p]==1) que[cur].push(p);
		}
	  }
	len[l]--;len[r]--;
	if (!len[l]) {
		int q=nxt[l];
		pre[q]=nxt[l]=0;
		l=q;
	}
	if (!len[r]) {
		int q=pre[r];
		nxt[q]=pre[r]=0;
		r=q;
	}
  }
  return ans;
}

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=2*n-1;i++) scanf("%d",&num[i]);
  int l=1,r=2*n-1;
  while (l<r) {
  	int m=((l+r)>>1);
  	if (calc(n,m)) l=m+1; else r=m;
  }
  printf("%d\n",l);
  return 0;
}

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

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

typedef long long ll;

using namespace std;

const int INF = 1 << 30;

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

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  vector<int> b(n);
  int aMax = 0;
  rep(i, n) {
    int aa, bb;
    cin >> aa >> bb;
    aMax = max(aMax, aa);
    a.at(i) = aa;
    b.at(i) = bb;
  }

  // dp[i] 体力を i 削るときの最小の消費魔力
  int hh = h + aMax;
  vector<int> dp(hh, INF);
  dp.at(0) = 0;

  for (int i = 0; i < hh; i++) {
    for (int j = 0; j < n; j++) {
      int aa = a.at(j);
      int bb = b.at(j);
      if (i - aa >= 0) {
        chmin(dp.at(i), dp.at(i - aa) + bb);
      }
    }
  }
  int res = INF;
  for (int i = h; i < hh; i++) {
    chmin(res, dp.at(i));
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

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

    ll N, X;
    cin >> N >> X;
    vector<ll> x(N);
    rep(i,0,N) cin >> x[i];

    ll _min(0);
    rep(i,0,N)
       _min = gcd(_min, abs(X-x[i]));

    cout << _min << endl;

    return 0;
}


Measured memory_bytes: 1024
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int D; cin >> D;
    
    string ans;
    if (D == 25) ans = "Christmas";
    else if (D == 24) ans = "Christmas Eve";
    else if (D == 23) ans = "Christmas Eve Eve";
    else if (D == 22) ans = "Christmas Eve Eve Eve";

    cout <<  ans << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def solve():
    W, H, x, y = list(map(int, input().split()))
    ans = W*H/2
    is_separate = 0
    if x==W/2 and y==H/2:
        is_separate = 1
    print(ans, is_separate)


if __name__ == "__main__":
    solve()


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

int main(){
    int n,x;
    int sum=0;
    while(1){
        sum=0;
        cin >> n >> x;
        if(n==0 && x==0) break;
        for(int i=1; i<=n; i++)
            for(int j=i+1; j<=n; j++)
                for(int k=j+1; k<=n; k++){
                    if((i+j+k)==x) sum++;
                }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
# -*- coding: utf-8 -*-

sa = input()
sb = input()
sc = input()

A = list(sa)
B = list(sb)
C = list(sc)

tmp = A.pop(0)

while True:
    if tmp == "a":
        if len(A) == 0:
            print("A")
            exit()
        tmp = A.pop(0)
    elif tmp == "b":
        if len(B) == 0:
            print("B")
            exit()
        tmp = B.pop(0)
    else:
        if len(C) == 0:
            print("C")
            exit()
        tmp = C.pop(0)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n;
    cout<<(n-1+1)*(n-1)/2<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
  int n,k;
  scanf("%d%d\n",&n,&k );
  int a[100000];
  while (n) {
    for (int i = 0; i < n; i++) {
      scanf("%d\n",&a[i] );
    }
    int s = 0;
    for (int i = 0; i < k; i++) {
      s += a[i];
    }
    int ans = s;
    for (int i = k; i < n; i++) {
      s -= a[i - k];
      s += a[i];
      ans = max(ans,s);
    }
    printf("%d\n",ans );
    scanf("%d%d\n",&n,&k );
  }
  return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

ll read(){
	ll x;
	scanf("%lld",&x);
	return x;
}

void print(ll x){
	printf("%lld\n",x);
}

using vi=vector<int>;
#define PB push_back
#define ALL(x) x.begin(),x.end()

int mod;
vi prims;
void InitPrims(){
	int x=mod-1;
	for(int i=2;i*i<=x;i++)if(x%i==0){
		prims.PB(i);
		while(x%i==0)
			x/=i;
	}
	if(x>1)
		prims.PB(x);
}

int pow(int x,int n){
	int res=1;
	while(n){
		if(n&1)res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}

int GetOrder(int x){
	int res=mod-1;
	for(auto p:prims){
		while(res%p==0){
			if(pow(x,res/p)==1)
				res/=p;
			else
				break;
		}
	}
	return res;
}

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

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

void Solve(){
	int n=read();
	int l=1;
	REP(i,n){
		int g=read();
		int o=GetOrder(g);
		l=lcm(l,o);
	}
	int a=read();
	int ans=0;
	int o=GetOrder(a);
	if(l%o==0)
		ans=1;
	print(ans);
}

signed main() {
	mod=read();
	InitPrims();
	int t=read();
	REP(_,t){
		Solve();
	}
    return 0;
}



Measured memory_bytes: 3256
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/23.
//  Copyright © 2019 yuya. All rights reserved.
//

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

int main()
{
    int i;
    int N,M;
    cin >> N >> M;
    
    vector<ll> A(N);
    for(i=0;i<N;i++) cin >> A[i];
    sort(A.begin(), A.end());
    
    vector<pair<ll,ll>> CB(M);
    
    for(i=0;i<M;i++){
        cin >> CB[i].second >> CB[i].first;
    }
    sort(CB.begin(),CB.end());
    
    /*
    ////////////////
    int a;
    for(a=0;a<N;a++) cout << A[a] << " ";
    cout << endl;
    for(a=0;a<M;a++) cout << CB[a].first << " ";
    cout << endl;
    for(a=0;a<M;a++) cout << CB[a].second << " ";
    cout << endl;
    ////////////////
    */
    
    ll j;
    j=M-1;
    for(i=0;i<N;i++){
        if( CB[j].first <= A[i] ){
            break;
        } else {
            A[i] = CB[j].first;
            if(CB[j].second == 1){
                j--;
            } else {
                CB[j].second--;
            }
        }
        
        /*
        ////////////////
        int a;
        for(a=0;a<N;a++) cout << A[a] << " ";
        cout << endl;
        ////////////////
        */
    }
    
    ll sum=0;
    sum = accumulate(A.begin(), A.end(), sum);
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int n, y;
int x1, x2, x3;

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

	x1 = x2 = x3 = -1;
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= n; ++j)
		{
			int k = n - i - j;

			if (k >= 0)
			{
				int kq = i * 10000 + j * 5000 + k * 1000;
				if (kq == y)
				{
					x1 = i;
					x2 = j;
					x3 = k;
				}
			}
		}

	cout << x1 << " " << x2 << " " << x3 << endl;

	return 0;
}

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

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n, m;
int num[20000];

int main() {
    while (cin >> n >> m) {
        if (n == 0 && m == 0) break;
        memset(num, 0, sizeof(num));
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < m; ++j) {
                int a; cin >> a;
                if (a == 1) num[j] += (1<<i);
            }
        
        int res = 0;
        for (int bit = 0; bit < (1<<n); ++bit) {
            int tmp = 0;
            for (int i = 0; i < m; ++i) {
                int nnum = num[i] ^ bit;
                int con = __builtin_popcount(nnum);
                tmp += max(con, n-con);
            }
            chmax(res, tmp);
        }
        
        cout << res << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1248
def main():
    a, b = map(int, input().split())
    al = int(a / 0.08 + 0.5)
    bl = int(b / 0.1)
    au = al + 12 - a % 2
    bu = bl + 9
    if bu < al or au < bl:
        print(-1)
    else:
        print(max(al, bl))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll X,Y; cin>>X>>Y;
  ll low=X*2;
  ll high=X*4;
  if(Y>=low && Y<=high && Y%2==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3636
import io.StdIn.{readInt, readLine}
import math.max
object Main extends App {
  val n = readInt
  val as = readLine.split(" ").map(_.toLong)

  def traverse(list: List[Long], max_tmp: Long, sum: Long): Long = list match {
    case Nil  => sum
    case head::tail => traverse(tail, max(max_tmp, head), sum+max(0, max_tmp-head))
  }

  val result = traverse(as.toList, 0, 0)
  println(result)
}

Measured memory_bytes: 85960
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")




int main() {

    ll n; cin >> n;
    ll sum = 0;
    ll count = 0;
    ll Min = 10000000000;
    vector<ll> a(n);

    rep(i,n){
        cin >> a[i];
        Min = min(Min,abs(a[i]));
        sum += abs(a[i]);
        if(a[i] < 0) count ++;
    }

    if(count%2 == 0) cout << sum;
    else cout << sum-2*Min;
    return 0;
}


Measured memory_bytes: 4028
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static int N;

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

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

    static int solve() {
        int[] divs = new int[N+1];
        for (int x = 1; x <= N; x++) {
            if( x % 2 == 0 ) continue;

            for (int d = 1; d <= N; d++) {
                if ( x % d == 0 ) {
                    divs[x]++;
                }
            }
        }
        int ans = 0;
        for (int i = 0; i <= N; i++) {
            if( divs[i] == 8 ) ans++;
        }
        return ans;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

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

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

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

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


Measured memory_bytes: 22868
#include<stdio.h>
 int main(void)
 {
     int N,K,S=1,i;

     scanf("%d",&N);
     scanf("%d",&K);

     for(i=0;i<N;i++){
       if(S*2>S+K) S=S+K;
       else S=S*2;
     }

     printf("%d\n",S);

     return 0;
 }


Measured memory_bytes: 128
#include <cstdio>
#include <vector>
using namespace std;
int dp[2][10001][2];
int main(){
    int N;
    scanf("%d",&N);
    if(N==2){
        int cut;
        scanf("%d",&cut);
        printf("%d\n",cut);
    }else{
        dp[0][1][0]=dp[0][1][1]=0;
        int cut;
        for(int i=1;i<N;i++){
            scanf("%d",&cut);
            int bef=(i-1)%2,now=i%2;
            for(int j=1;j<=i;j++){
                if(j==1){
                    if(i==1) dp[now][j][0]=cut;
                    else dp[now][j][0]=dp[bef][j][0];
                }
                else if(j<i) dp[now][j][0]=min(dp[bef][j][0],dp[bef][j][1]+cut);
                else dp[now][j][0]=cut;
                if(j==1){
                    if(i==1) dp[now][j+1][1]=0;
                    else dp[now][j+1][1]=dp[bef][j][0]+cut;
                }else if(j<i) dp[now][j+1][1]=min(dp[bef][j][0]+cut,dp[bef][j][1]);
                else dp[now][j+1][1]=0;
            }
        }
        printf("%d\n",min(dp[(N-1)%2][N/2][0],dp[(N-1)%2][N/2][1]));
    }
}

Measured memory_bytes: 872
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    int n; cin >> n;
    vector<int>d(n);
    rep(i,n) cin >> d[i];

    sort(d.begin(),d.end());
    if(d[n/2]==d[n/2-1]){
        cout << 0 << endl;
        return 0;
    }
    int ans = d[n/2]-d[n/2-1];
    cout << ans << endl;
    return 0;
}




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

using namespace std;
typedef long long ll;

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

  if (n % 2 == 1)
  {
    cout << 0 << endl;
    return 0;
  }

  if (n < 10)
  {
    cout << 0 << endl;
    return 0;
  }

  ll fives = 0;
  for (ll i = 10; i <= n; i *= 5)
  {
    fives += (n / i);
  }
  cout << fives << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        boolean result = (C1.charAt(0) == C2.charAt(2) &&
                C1.charAt(1) == C2.charAt(1) &&
                C1.charAt(2) == C2.charAt(0));

        System.out.println(result ? "YES" : "NO");
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,a[110],k,t=1e18;
  cin>>n;
  fr(i,n) cin>>a[i];
  for(ll i=-100;i<=100;i++){
    k=0;
    fr(j,n) k+=(a[j]-i)*(a[j]-i);
    t=min(t,k);
  }
  cout<<t<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define ar array
#define mxn 200006
#define mod 1000000007
#define ld long double
#define pb push_back
#define inf 1e9+5
#define fi first
#define se second
typedef long long int ll;
using namespace std;
int main(void){
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	fast;
	int n;
	cin>>n;
	cout<<1-n;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(int argc, const char *argv[])
{
    int num,i;
    char ch;
    int count[26];
    char s[26] = {'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'};
    
    for(i=0;i<26;i++){  //カウントの初期化
        count[i]=0;
    }
    
    while(scanf("%c",&ch) != EOF){
        
        if(ch == EOF)break;
        
        if('A' <= ch && ch <= 'Z'){  //大文字を小文字に変換
            ch = (ch + 'a') - 'A';
        }
        
        if('a'<= ch && ch <= 'z'){  //小文字を変数に当てはめ、カウント
            num = ch - 'a';
            count[num]++;
            
        }
        
    }
    for(i=0; i<26; i++){
        printf("%c : %d\n",s[i],count[i]);  //全てのアルファベットが入った配列とそのカウント数の表示
    }
    return 0;
}



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

int main() {
  int N, K; cin >> N >> K;
  auto A = vector<int>(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  int c = N;
  for (int i = 0; i < N; ++i) {
    c -= (K - !!i);
    if (c <= 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 640
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func min(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func main() {
	x := nextInt()
	fmt.Println(1 - x)
}


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

using namespace std;

int main() {
	
	int N;
	scanf("%d", &N);
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}

	sort(a.begin(), a.end());

	cout << a.back() - a.front() << endl;


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
    int i,dice[7];
    char order[101];
     
    for(i=1;i<7;i++)
        scanf("%d", &dice[i]);
     
    scanf("%s", order);
     
    for(i=0;order[i]!='\0';i++){
         
        dice[0] = dice[1];
         
        switch(order[i]){
                 
            case 'E':
                dice[1] = dice[4];
                dice[4] = dice[6];
                dice[6] = dice[3];
                dice[3] = dice[0]; 
                break;
             
            case 'N':
                dice[1] = dice[2];
                dice[2] = dice[6];
                dice[6] = dice[5];
                dice[5] = dice[0]; 
                break;
             
            case 'S':
                dice[1] = dice[5];
                dice[5] = dice[6];
                dice[6] = dice[2];
                dice[2] = dice[0]; 
                break;
                 
            case 'W':
                dice[1] = dice[3];
                dice[3] = dice[6];
                dice[6] = dice[4];
                dice[4] = dice[0]; 
                break;
 
        }
    }
     
    printf("%d\n", dice[1]);
     
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, T;
    cin >> N >> T;
    ll ans = T;
    ll t, t_b = 0;
    rep(0, i, N)
    {
        cin >> t;
        ans += min(t - t_b, T);
        t_b = t;
    }
    cout << ans << endl;
}

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

int main() {
    int S, W;
    cin >> S >> W;
    if (S <= W) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
def main():
    S = input()
    dp = [[0] * 4 for _ in range(len(S) + 5)]
    dp[0][0] = 1
    MOD = 10 ** 9 + 7

    for i in range(len(S)):
        for j in range(4):
            if S[i] == '?':
                dp[i+1][j] += dp[i][j] * 3
            else:
                dp[i+1][j] = dp[i][j]

            dp[i+1][j] %= MOD

        if S[i] == 'A' or S[i] == '?':
            dp[i+1][1] += dp[i][0]
            dp[i+1][1] %= MOD
        if S[i] == 'B' or S[i] == '?':
            dp[i+1][2] += dp[i][1]
            dp[i+1][2] %= MOD
        if S[i] == 'C' or S[i] == '?':
            dp[i+1][3] += dp[i][2]
            dp[i+1][3] %= MOD

    print(dp[len(S)][3])

if __name__ == "__main__":
    main()

Measured memory_bytes: 54252
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 6223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

int N, M, S;
const int MAX = 2500000;
struct edge { int to, cost; };
vector<vector<edge> > G;
VI d;

void dikstra(int s) {
	priority_queue<pii, vector<pii>, greater<pii> >que;
	REP(i, MAX)d[i] = LLINF;
	d[s] = 0;
	que.push(pii(0, s));
	while (!que.empty()) {
		pii p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		REP(i, G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(pii(d[e.to], e.to));
			}
		}
	}
}

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


	G.resize(MAX);
	d.resize(MAX);

	cin >> N >> M >> S;
	chmin(S, 5000LL);
	int k = 0;
	map<pii, int>mp;
	REP(i, N) {
		eREP(j, 5000) mp[pii(i, j)] = k++;
	}
	REP(i, M) {
		int u, v, a, b; cin >> u >> v >> a >> b;
		u--; v--;
		eFOR(j,a, 5000) {
			G[mp[pii(u, j)]].push_back((edge) { mp[pii(v, j - a)], b });
			G[mp[pii(v, j)]].push_back((edge) { mp[pii(u, j - a)], b });
		}
	}

	REP(i, N) {
		int c, d; cin >> c >> d;
		eREP(j, 5000 - c) {
			G[mp[pii(i, j)]].push_back((edge) { mp[pii(i, j + c)], d });
		}
	}

	dikstra(mp[pii(0, S)]);

	FOR(i, 1, N) {
		int ans = LLINF;
		eREP(j, 5000) chmin(ans, d[mp[pii(i, j)]]);
		cout << ans << endl;
	}

	return 0;
}



Measured memory_bytes: 130156
//API???????????????
import java.util.Scanner;
import java.io.IOException;
class Main {
  	public static void main(String[] args) throws IOException{
		Scanner scan = new Scanner(System.in);
		int m = scan.nextInt();

		Node root = null;
		for(int i = 0;i < m;i++){
			String str = scan.next();
			if(str.equals("insert")){
				int temp = scan.nextInt();
				Node node = new Node(temp);
				if(root == null){
					root = node;
					continue;
				}
				insert(root, node);
			}else if(str.equals("find")){
				int temp = scan.nextInt();
				if(root.search(temp)){
					System.out.println("yes");
				}else{
					System.out.println("no");
				}
			}else if(str.equals("print")){
				Print(root);
			}
		}
	}
	
	public static void insert(Node T, Node Z){
		Node parent = T;
		for(;;){
			if(Z.id < parent.id){
				if(parent.left == null){
					parent.left = Z;
					break;
				}
				parent = parent.left;
			}else{
				if(parent.right == null){
					parent.right = Z;
					break;
				}
				parent = parent.right;
			}
		}
	}
	
	public static void Print(Node root){
		StringBuilder sb = new StringBuilder();
		root.intermediateOrderCrawl(sb);
		System.out.println(sb.toString());
		sb = new StringBuilder();
		root.precedingOrderCrawl(sb);
		System.out.println(sb.toString());
	}
}

class Node{
	int id;
	Node parent;
	Node left;
	Node right;
	
	public Node(int id) {
		this.id = id;
	}
	
	public void intermediateOrderCrawl(StringBuilder sb){
		if(left != null) left.intermediateOrderCrawl(sb);
		sb.append(" " + String.valueOf(id));
		if(right != null) right.intermediateOrderCrawl(sb);
	}
	
	public void precedingOrderCrawl(StringBuilder sb){
		sb.append(" " + String.valueOf(id));
		if(left != null) left.precedingOrderCrawl(sb);
		if(right != null) right.precedingOrderCrawl(sb);
	}
	
	public boolean search(int i){
		if(i == id){
			return true;
		}else if(i < id){
			if(left == null){
				return false;
			}
			return left.search(i);
		}else{
			if(right == null){
				return false;
			}
			return right.search(i);
		}
	}
}

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

using namespace std;

int main()
{
  int n;
  cin>>n;
  
  int a[n];
  //cout<<"hello"<<endl;
  for(int i=0;i<n;i++)
    cin>>a[i];
  
  if(n==1)
    return a[0];
  
  int dp[n];
  
  memset(dp,0,sizeof(dp));
  
  //dp[0]=a[0];
  dp[1]=abs(a[0]-a[1]);
  
  
  for(int i=2;i<n;i++)
  {
    dp[i] = abs(a[i] - a[i-1]) + dp[i-1];
    dp[i] = min(dp[i],abs(a[i]-a[i-2])+dp[i-2]);
  }
  
  cout<<dp[n-1]<<endl;
  
}

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

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

  char t[h][w];
  int dp[h][w];

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){

      cin >> t[i][j];

      if(i == 0 && j == 0) dp[i][j] = 0;
      else if(i == 0) dp[i][j] = dp[i][j - 1] + (t[i][j] - '0');

      else if(j == 0) dp[i][j] = dp[i - 1][j] + (t[i][j] - '0');

      else dp[i][j] = min(dp[i][j-1], dp[i - 1][j]) + (t[i][j] - '0');

    }

  }

  cout << dp[h-1][w-1] << endl;

  return 0;

}




Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define pii pair<ll,ll>
#define piii pair<pii, int>
#define pb push_back
#define fs first
#define sc second
#define ppb pop_back
//#define LOCAL
//#define endl "\n"
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl

#define fifo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f(i,a,b) for(int (i)=(a);(i)<=(b);++(i))
#define fd(i,a,b) for(int i=(a);i>=(b);--i)
const ll mod = 1e9+7;

// x>>1 is x/2  and x<<1 is x*2 



void solve()
{
	int n,m;
	cin>>n>>m;

	for(int i=0,x;i<m;i++)
	{
		cin>>x;
		n-=x;
	}

	cout<<max(-1,n)<<endl;
}

int main()
{
	fifo
	int total=1;
	//cin>>total;
	for(int testcase=1;testcase<=total;testcase++)
	{
		solve();
	}



}


Measured memory_bytes: 3652
//Radhe Radhe
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include<boost/math/common_factor.hpp>
#include <ext/numeric>
using namespace __gnu_cxx;
using namespace std;
#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define array(a,n) int a[n]; for(int i=0;i<n;i++) cin>>a[i];
#define loop(i,a,b,x) for(int i=a;i<b;i+=x)
const int MOD = 1000000007;
const int N = 10001;
//const int N = (2 * (1e5)) + 2;



int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
  
    int t = 1;
    //cin >> t;
    while (t--) {
        int n, k; cin >> n >> k;
        int h[n];
        for (int i = 0; i < n; i++) {
            cin >> h[i];
        }
        vector<int> dp(n, INT_MAX);
        dp[0] = 0;
        dp[1] = abs(h[1] - h[0]);
        for (int i = 2; i < n; i++) {
            for (int j = i - 1, jump = 0; j  >= 0 && jump < k; j--, jump++) {
                dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
            }
        }
        cout << dp[n - 1];

    }
    return 0;

}






Measured memory_bytes: 4784
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       	ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl        "\n"
#define MOD         1000000007

typedef long long int  ll;


int main()
{
	FAST;
	int n;
	cin >> n;
	
	int ans =1;
    for(int i=2 ; i<=n ; i++)
        ans = (1ll * ans * i )%MOD;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
# coding:utf-8

import sys
import math
INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    a, b = LS()

    is_square = False
    n = int(a + b)
    t = 1
    while t ** 2 <= n:
        if t ** 2 == n:
            is_square = True
        t += 1

    return 'Yes' if is_square else 'No'


print(main())


Measured memory_bytes: 3064
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
vector<string> s;
bool visited[10][10];
   int h,w;
bool dfs(int y,int x){
    for(int i=0;i<2;i++){
        int ny,nx;
        if(i==0){ny=y-1;nx=x;}
        else { ny=y;nx=x-1;}
        if(ny<0||nx<0)continue;
        if(visited[ny][nx])return false;
    }
    visited[y][x]=false;
    for(int i=0;i<2;i++){
        int ny,nx;
        if(i==0){ny=y+1;nx=x;}
        else {ny=y;nx=x+1;}
        if(ny>=h||nx>=w||s.at(ny).at(nx)=='.')continue;
        return dfs(ny,nx);
    }
    if(y!=h-1||x!=w-1)return false;
    return true;
}

int main(){
    cin>>h>>w;
    s.resize(h);
    for(int i=0;i<h;i++)cin>>s.at(i);
for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(s.at(i).at(j)=='#')visited[i][j]=true;
    if(dfs(0,0)){
        for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(visited[i][j]){cout<<"Impossible"<<endl;return 0;}
        cout<<"Possible"<<endl;
    }
    else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 256
// AtCoder Beginner Contest 110 - Problem C: String Transformation (https://abc110.contest.atcoder.jp/tasks/abc110_c)
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

#define REP(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define REPN(i, N) for (int (i) = 0; (i) < N; (i)++)
#define DEC(i, b, a) for (int (i) = (b); (i) >= (a); (i)--)
#define DECN(i, N) for (int (i) = N - 1; (i) >= 0; (i)--)

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : (vec)) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

const int MAX { 2000010 };
const int oo { 2000000010 };
const int MOD { 1000000007 };

char histA[26], histB[26];

void solve(const string& S, const string& T)
{
    for (const auto& c : S)
        ++histA[c - 'a'];

    for (const auto& c : T)
        ++histB[c - 'a'];

    vector<int> xs, ys;

    REPN(i, 26)
    {
        if (histA[i])
            xs.push_back(histA[i]);

        if (histB[i])
            ys.push_back(histB[i]);
    }

    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());

    auto ans = (xs == ys ? "Yes" : "No");

    cout << ans << endl;
}

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

    string S, T;
    cin >> S >> T;

    solve(S, T);

    return 0;
}


Measured memory_bytes: 916
import math

L,S,H,M = map(int,input().split())


H = math.radians((H / 12)* 360 + M / 60 * 30)
M = math.radians(M / 60 * 360)


ax,ay = L * math.cos(H), L * math.sin(H)
bx,by = S * math.cos(M), S * math.sin(M)

print(math.sqrt((ax - bx) ** 2 + (ay - by) ** 2))


Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, n) for (int i = 1; i <= (n); i++)
#define pp(v) cout << #v << "=" << (v) << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int main() {
  int n; cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  sort(p.begin(), p.end());

  p[n-1] /= 2;
  int sum = 0;
  rep(i,n) sum += p[i];
  
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll gcd2(ll a,ll b){
	while(b!=0){
		ll w=a%b;
		a=b;
		b=w;
	}
	return a;
}
int main(){
	int m,n;
	while(cin>>m>>n) cout<<gcd2(m,n)<<"\n";
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


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

Measured memory_bytes: 256
#include <stdio.h>
int main(){
 int a,b,c;
 scanf("%d %d %d",&a,&b,&c);
 printf("%d %d %d\n",((a<b)&&(a<c))?a:(b<c)?b:c,(a-b)*(a-c)<0?a:(b-a)*(b-c)<0?b:c,(a>b)&&(a>c)?a:(b>c)?b:c);
 return 0;
}

Measured memory_bytes: 596