Language: C++

#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

typedef int Weight;
struct Edge{
    int from, to;
    Weight weight;
    int rev;     // 無向グラフの対の辺
    Edge(int from, int to, Weight weight) :
        from(from), to(to), weight(weight) { }
    Edge(int from, int to, Weight weight, int rev) :
        from(from), to(to), weight(weight), rev(rev){ }
};
bool operator < (const Edge &a, const Edge &b){
    if(a.weight != b.weight) return a.weight > b.weight;
    if(a.from != b.from) return a.from > b.from;
    return  a.to > b.to;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void addFlowEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, 0, g[a].size() - 1));
}
void addUndirectedEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, c, g[a].size() - 1));
}

bool isBipartite(const Graph &g, int v, int c, vector<int> &color) {
    color[v] = c;
    for(auto e: g[v]) {
        if (color[e.to] < 0) {
            isBipartite(g, e.to, 1 - c, color);
        } else if(color[e.to] != 1 - c) {
            return false;
        }
    }
    return true;
}

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
    Graph g(N + 1);
    for(int i = 0; i < M; ++i) {
        addUndirectedEdge(g, A[i], B[i], 0);
    }
    vector<int> c(N + 1, -1);
    bool f = isBipartite(g, 1, 0, c);
    if (f) {
        int a = 0;
        for(int i = 1; i <= N; ++i) {
            if (c[i] == 1) {
                a++;
            }
        }
        cout << max(a * (N - a) - M, 0) << endl;
    } else {
        cout << N * (N - 1) / 2 - M << endl;
    }
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}

Compiler output:
a.cc: In function 'void solve(long long int, long long int, std::vector<long long int>, std::vector<long long int>)':
a.cc:61:20: error: no matching function for call to 'max(long long int, int)'
   61 |         cout << max(a * (N - a) - M, 0) << endl;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:61:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   61 |         cout << max(a * (N - a) - M, 0) << endl;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:61:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   61 |         cout << max(a * (N - a) - M, 0) << endl;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~