Language: C++

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;

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

//____BY:Rajaram_ms350____   ||   ____rajaram_26____

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

#define DBG 1
#define debug(x) if(DBG) cerr << #x << " is " << x << '\n';
#define ld long double
#define MOD 1000000007
#define MOD1 MOD
#define MOD2 1000000009
#define show(a) for(int i=0;i<a.size();i++) cout<<a[i&1]<<" ";
#define fi first
#define se second
#define nextline "\n"
#define F return
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sot(v) sort(v.begin(),v.end())
#define fats_io() cin.sync_with_stdio(flase);cout.sync_with_stdio(false);
#define PI 3.1415926535
#define long_zero 0ll
#define long_one 1ll
#define rep(i,a,n) for(int i=a;i<n;i++;)
#define per(i,n,a) for(int i=n;i>a;i--)
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define clr(x) memset(x, 0, sizeof(x))
#define itr(it, v) for(auto it = v.begin(); it != v.end(); it++)
#define deb(x) cout << #x << "=" << x << nextline
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << nextline
#define max_heap priority_queue<pii> 
#define min__heap priority_queue<pii,vector<pii>,greater<pii>>

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

typedef long long ll;                           
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef set<int> si;
typedef set<ll> sl;
typedef map<int,int> freq;
typedef multiset<pair<int,pii>>events;

const int MAXN = 2e5 + 500;
const int INF = 1e9 + 23;

int n;
vi adj[MAXN];


//inline int How_many_1(int x) {return __builtin_popcout(x);}
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

vector<int>prefix_function(string s,int n){
    vi dp(n);
    dp[0]=0;
    for(int i=1;i<n;i++){
        int j=dp[i-1];
        while(j>0 &&s[i]!=s[j])
            j=dp[j-1];
        if(s[i]==s[j]) j++;
        dp[i]=j;
        
    }
    return dp;
}
inline int mul(int a, int b, int m = MOD) { return ((a % MOD) * (b % MOD)) % m; }
inline int add(int a, int b, int m = MOD) { return ((a % MOD) + (b % MOD)) % m; }
inline int sub(int a, int b, int m = MOD) { return (a - b + m) % m; }

int fastpow(int a, int b) {
    int res = 1;
    while(b > 0) {
        if(b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
int modinv(int a) {
    return fastpow(a, MOD - 2);
}
void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		adj[u-1].pb(v-1);
		adj[v-1].pb(u-1);
	}
}
void dfs(int u, int par){
	for(int v:adj[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}
 
//================================================================
//Real Code Started from Here;


void solve() {
    //code here \/;
    int n,m;cin>>n,m;
  	int sum=0;
  	int j;
  	rep(i,o,m) {cin>>j;sum+=j;}
  	if(sum>n) cout<<-1<<nextlime;
  	else cout<<sum-j<<nextline;
  	
    
    
    
    
    
    
    
    
    
    
    //look above /\;    
}

//Main Function;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);


/*if No of test case is not given. Remove  all //
 else add // at 144,145,151 */
 solve();
 /*
	int tt;cin>>tt;
	while (tt--) {
		solve();
	}
// */    
return 0;
}
/*
    logic




*/
								

Compiler output:
a.cc: In function 'void solve()':
a.cc:125:15: error: 'o' was not declared in this scope
  125 |         rep(i,o,m) {cin>>j;sum+=j;}
      |               ^
a.cc:31:30: note: in definition of macro 'rep'
   31 | #define rep(i,a,n) for(int i=a;i<n;i++;)
      |                              ^
a.cc:31:39: error: expected ')' before ';' token
   31 | #define rep(i,a,n) for(int i=a;i<n;i++;)
      |                       ~               ^
a.cc:125:9: note: in expansion of macro 'rep'
  125 |         rep(i,o,m) {cin>>j;sum+=j;}
      |         ^~~
a.cc:31:40: error: expected primary-expression before ')' token
   31 | #define rep(i,a,n) for(int i=a;i<n;i++;)
      |                                        ^
a.cc:125:9: note: in expansion of macro 'rep'
  125 |         rep(i,o,m) {cin>>j;sum+=j;}
      |         ^~~
a.cc:126:29: error: 'nextlime' was not declared in this scope; did you mean 'nextline'?
  126 |         if(sum>n) cout<<-1<<nextlime;
      |                             ^~~~~~~~
      |                             nextline