Language: C++

/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

void stndrtn() {
#ifdef hitorie
    freopen(".in", "r", stdin);
#endif        
}

uniform_int_distribution<int> d(0, INF32);
mt19937 random;

int rnd(int x) {
    return d(random) % x;    
}

const bool flag = 0;

void maincode() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    ll sum = 0;
    for (int& x : a)
        cin >> x, sum += x;
    if (sum > n)
        cout << -1, exit(0);
    cout << n-sum;           
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    random.seed(chrono::system_clock::now().time_since_epoch().count());
    int ts = 1;
    if (flag) 
        cin >> ts;
    while (ts--)
        maincode(); 
    return 0;
}

Compiler output:
a.cc:27:9: error: 'std::mt19937 random' redeclared as different kind of entity
   27 | mt19937 random;
      |         ^~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:5:
/usr/include/stdlib.h:521:17: note: previous declaration 'long int random()'
  521 | extern long int random (void) __THROW;
      |                 ^~~~~~
a.cc: In function 'int main()':
a.cc:50:12: error: request for member 'seed' in 'random', which is of non-class type 'long int() noexcept'
   50 |     random.seed(chrono::system_clock::now().time_since_epoch().count());
      |            ^~~~
In file included from /usr/include/c++/14/bits/stl_algo.h:65,
                 from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/uniform_int_dist.h: In instantiation of 'std::uniform_int_distribution<_IntType>::result_type std::uniform_int_distribution<_IntType>::operator()(_UniformRandomBitGenerator&, const param_type&) [with _UniformRandomBitGenerator = long int() noexcept; _IntType = int; result_type = int]':
/usr/include/c++/14/bits/uniform_int_dist.h:204:34:   required from 'std::uniform_int_distribution<_IntType>::result_type std::uniform_int_distribution<_IntType>::operator()(_UniformRandomBitGenerator&) [with _UniformRandomBitGenerator = long int() noexcept; _IntType = int; result_type = int]'
  204 |         { return this->operator()(__urng, _M_param); }
      |                  ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:30:13:   required from here
   30 |     return d(random) % x;
      |            ~^~~~~~~~
/usr/include/c++/14/bits/uniform_int_dist.h:291:66: error: 'long int() noexcept' is not a class, struct, or union type
  291 |         typedef typename _UniformRandomBitGenerator::result_type _Gresult_type;
      |                                                                  ^~~~~~~~~~~~~
/usr/include/c++/14/bits/uniform_int_dist.h:293:68: error: 'long int() noexcept' is not a class, struct, or union type
  293 |         typedef typename common_type<_Gresult_type, __utype>::type __uctype;
      |                                                                    ^~~~~~~~
/usr/include/c++/14/bits/uniform_int_dist.h:295:71: error: 'min' is not a member of 'long int() noexcept'
  295 |         constexpr __uctype __urngmin = _UniformRandomBitGenerator::min();
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/c++/14/bits/uniform_int_dist.h:296:71: error: 'max' is not a member of 'long int() noexcept'
  296 |         constexpr __uctype __urngmax = _UniformRandomBitGenerator::max();
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~