Language: C++

#include <bits/stdc++.h>

using namespace std;

constexpr size_t N {155555};

int n, m;
int color[N];

vector<int> g[N];

int h = 0;
long long f[N][2];
long long ed[N];

void dfs(int v, int prev = -1) {
//    f[v][0] = 1;
    for (int to : g[v]) {
        if (to == prev) continue;
        if (color[to]) continue;
        color[to] = (color[v] == 1 ? 2 : 1);
        dfs(to, v);
        ed[v] += f[v][0] * f[to][0];
        ed[v] += f[v][1] * f[to][1];
        ed[v] += max(f[to][0] - 1, 0);

        f[v][0] += f[to][1];
        f[v][1] += f[to][0];

        ed[v] += ed[to];
    }
    f[v][0]++;
}

int main() {

#ifdef Alex_PKZDL
    freopen(input_file, "r", stdin);
    freopen(output_file, "w", stdout);
#endif
    ios_base::sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int x, y; cin >> x >> y; --x; --y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    color[0] = 1;
    dfs(0);

    for (int v = 0; v < n; ++v) {
        for (int u : g[v]) {
            if (color[v] == color[u]) {
                cout << 1LL * n * (n - 1) / 2LL - m << endl;
                return 0;
            }
        }
    }

    cout << ed[0] - (m - (n - 1)) << endl;
    return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:25:21: error: no matching function for call to 'max(long long int, int)'
   25 |         ed[v] += max(f[to][0] - 1, 0);
      |                  ~~~^~~~~~~~~~~~~~~~~
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:25:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   25 |         ed[v] += max(f[to][0] - 1, 0);
      |                  ~~~^~~~~~~~~~~~~~~~~
/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:25:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   25 |         ed[v] += max(f[to][0] - 1, 0);
      |                  ~~~^~~~~~~~~~~~~~~~~