criyle/codenet-compile-errors huggingface dataset:
Language: C++

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

vector<int> G[100000];
int color[100000];

bool dfs(int v, int c) {
  color[v] = c;
  for (int i = 0; i < G[v].size(); i++) {
    if (color[G[v][i]] == c) {return false;}
    if (color[G[v][i]] == 0 && !dfs(G[v][i], -c)) {return false;}
  }
  return true;
}


int main() {
  memset(color, 0, 100000);
  
  int N, M;
  cin >> N >> M;
  set<int> s;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    s.push(a), s.push(b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  int ans;
  
  if (!dfs(s, 1)) {
    ans = N*(N-1)/2 - M;
  } else {
    int whites = 0;
    for (auto it = s.begin(); it != s.end(); it++) {
      if (color[*it] == 1) {whites++;}
    }
    ans = whites*(N-whites) - M;
  }
  
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:7: error: 'class std::set<int>' has no member named 'push'
   27 |     s.push(a), s.push(b);
      |       ^~~~
a.cc:27:18: error: 'class std::set<int>' has no member named 'push'
   27 |     s.push(a), s.push(b);
      |                  ^~~~
a.cc:34:12: error: cannot convert 'std::set<int>' to 'int'
   34 |   if (!dfs(s, 1)) {
      |            ^
      |            |
      |            std::set<int>
a.cc:7:14: note:   initializing argument 1 of 'bool dfs(int, int)'
    7 | bool dfs(int v, int c) {
      |          ~~~~^
Language: C++

/* is_bipartite.cpp
    二部グラフ判定を深さ優先探索（DFS）で行う

    not verified: AtCoder CODE FESTIVAL 2017 qual B  C - 3 Steps
        https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_c
*/
#include <bits/stdc++.h>
using namespace std;

struct Edge {
    long long to;
};
using Graph = vector<vector<Edge>>;

bool dfs(const Graph &G, int v, int c, pair<int, int> &num, vector<int> &color) {
    bool ret = true;
    color[v] = c;
    if (c == 1) {
        num.first++;
    } else if (c == -1) {
        num.second++;
    }
    for (auto e : G[v]) {
        if (color[e.to] == 0 && !dfs(G, e.to, -c, num, color)) {
            ret = false;
        } else if (color[e.to] == c) {
            ret = false;
        }
    }
    return ret;
}

/* is_bipartite(G,nums): 二部グラフかどうか
 nums[i] := i 番目の連結成分の {左ノード数, 右ノード数}, 「dir = 1: 左、-1: 右」
*/
int is_bipartite(const Graph &G, vector<pair<int, int>> &nums) {
    bool ret = true;
    int N = G.size();
    vector<int> color(N, 0);
    for (int i = 0; i < N; i++) {
        if (color[i] == 0) {
            pair<int, int> num = {0, 0};
            if (!dfs(G, i, 1, num, color)) {
                ret = false;
            }
            nums.push_back(num);
        }
    }
    return ret;
}

int main() {
    int N, M;
    cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back({b});
        G[b].push_back({a});
    }

    vector<pair<int, int>> nums;
    if (is_bipartite(G, nums)) { // 完全二部グラフ
        ll ans = 0;
        for (auto i : nums) {
            ans += i.first * i.second;
        }
        cout << ans - M << endl;
    } else { // 完全グラフ
        cout << N * (N - 1) / 2 - M << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:9: error: 'll' was not declared in this scope
   66 |         ll ans = 0;
      |         ^~
a.cc:68:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   68 |             ans += i.first * i.second;
      |             ^~~
      |             abs
a.cc:70:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   70 |         cout << ans - M << endl;
      |                 ^~~
      |                 abs
Language: C++

#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD (1'000'000'007)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int color[100005];
bool is_bipartite_graph(vector<vector<int>> &graph, int c, int p){
    color[p]=c;
    for(int cc : graph[p]){
        if(color[cc]==c) return false;
        if(color[cc]==0) if(!dfs(graph, -c, cc)) return false;
    }
    return true;
}

int main(void)
{
    int n,m;
    cin >> n >> m;
    vector<vector<int>> graph(n, vector<int>());
    REP(i, m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        graph[a].pb(b);
        graph[b].pb(a);
    }

    ll ans=0;
    if(is_bipartite_graph(1,0)){
        ll w=0;
        REP(i, n){
            if(color[i]==1) w++;
        }
        ans = w * (n-w) - m; 
    }else{
        ans = (ll)n*(n-1)/2 - m;
    }

    pr(ans);
}

Compiler output:
a.cc: In function 'bool is_bipartite_graph(std::vector<std::vector<int> >&, int, int)':
a.cc:36:30: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   36 |         if(color[cc]==0) if(!dfs(graph, -c, cc)) return false;
      |                              ^~~
      |                              ffs
a.cc: In function 'int main()':
a.cc:55:27: error: invalid initialization of non-const reference of type 'std::vector<std::vector<int> >&' from an rvalue of type 'int'
   55 |     if(is_bipartite_graph(1,0)){
      |                           ^
a.cc:32:46: note: in passing argument 1 of 'bool is_bipartite_graph(std::vector<std::vector<int> >&, int, int)'
   32 | bool is_bipartite_graph(vector<vector<int>> &graph, int c, int p){
      |                         ~~~~~~~~~~~~~~~~~~~~~^~~~~
Language: C++

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

vector<int> G[100'010];
int color[100'010];//0:未踏 1:白 -1:黒

bool dfs(int v, int c){
  bool res = true;
  color[v] = c;
  for(int nv:G[v]){
    if(color[nv] == 0){
      res = !res || dfs(nv, -c);
    }else{
      if(color[nv] == color[v]){
        return false;
      }else{
        continue;
      }
    }
  }
  return res;
}
  
int main(){
  
  int n,m;
  cin>>n>>m;
  int a[m],b[m];
  REP(i,m){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  bool flag = dfs(0, 1);
  long long b = 0;
  long long ans;
  if(flag){
    REP(i,n){
      if(color[i] == 1){
        b++;
      }
    }
    ans = b*((long long)n-b) - (long long)m;
  }else{
    ans = (long long)n*((long long)n-1) - (long long)m;
  }
  cout<<ans<<endl;   
  return 0; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:83:13: error: conflicting declaration 'long long int b'
   83 |   long long b = 0;
      |             ^
a.cc:75:12: note: previous declaration as 'int b [m]'
   75 |   int a[m],b[m];
      |            ^
a.cc:88:9: error: lvalue required as increment operand
   88 |         b++;
      |         ^
a.cc:91:26: error: invalid operands of types 'long long int' and 'int [m]' to binary 'operator-'
   91 |     ans = b*((long long)n-b) - (long long)m;
      |              ~~~~~~~~~~~~^~
      |              |            |
      |              |            int [m]
      |              long long int
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,m,to[200001],next[200001],tot,col[100001],head[100001],sum[3],cnt;
long long ans;
bool vis[100001],flag;
void add(int u,int v){to[++tot]=v,next[tot]=head[u],head[u]=tot;}
void dfs(int x,int color){
    ++cnt;
    col[x]=color;
    sum[color]++;
    vis[x]=true;
    for(int i=head[x];i;i=next[i]){
        if(!vis[to[i]])dfs(to[i],3-color);
        else if(col[x]==col[to[i]])flag=true;
    }
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    for(int i=1;i<=n;i++)if(!vis[i]){
        dfs(i,1);
        if(!flag)ans+=1LL*sum[1]*sum[2];
        else ans+=1LL*cnt*(cnt-1)/2;
        sum[1]=sum[2]=flag=cnt=0;
    }
    printf("%lld\n",ans-m);
    return 0;
}

Compiler output:
a.cc: In function 'void add(int, int)':
a.cc:6:35: error: reference to 'next' is ambiguous
    6 | void add(int u,int v){to[++tot]=v,next[tot]=head[u],head[u]=tot;}
      |                                   ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:20: note:                 'int next [200001]'
    3 | int n,m,to[200001],next[200001],tot,col[100001],head[100001],sum[3],cnt;
      |                    ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:12:27: error: reference to 'next' is ambiguous
   12 |     for(int i=head[x];i;i=next[i]){
      |                           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:20: note:                 'int next [200001]'
    3 | int n,m,to[200001],next[200001],tot,col[100001],head[100001],sum[3],cnt;
      |                    ^~~~
Language: C++

#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
using Graph = vector<vector<int>>;

// 二部グラフ判定
vector<int> color;
bool dfs(const Graph &G, int v, int cur = 0) {
    color[v] = cur;
    for (auto next_v : G[v]) {
        // 隣接頂点がすでに色確定していた場合
        if (color[next_v] != -1) {
            if (color[next_v] == cur) return false; // 同じ色が隣接したらダメ
            continue;
        }

        // 隣接頂点の色を変えて、再帰的に探索 (一回でも false が返ってきたら false)
        if (!dfs(G, next_v , 1 - cur)) return false;
    }
    return true;
}

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    // 探索
    color.assign(N, -1);
    bool is_bipartite = true;
    for (int v = 0; v < N; ++v) {
        if (color[v] != -1) continue; // v が探索済みだったらスルー
        if (!dfs(G, v)) is_bipartite = false;
    }
    int sum = 0;
    rep(i,n){
        sum += color[v];
    }
    if(is_bipartite){
      cout << sum*(N-sum)-M << endl;
    }else{
      cout << (N*(N-1))/2 - M << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:11: error: 'n' was not declared in this scope
   53 |     rep(i,n){
      |           ^
a.cc:12:39: note: in definition of macro 'rep'
   12 | #define rep(i,n) for(int i=0; i<(int)(n);i++)
      |                                       ^
a.cc:54:22: error: 'v' was not declared in this scope
   54 |         sum += color[v];
      |                      ^
Language: C++

#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

bool dfs(vvi &Graph,vi &color,int v,int clr){
  color.at(v) = clr;
  for(int next : Graph.at(v)){
    if(color.at(next) != 0){
      if(color.at(next) == clr) return false;
      continue;
    }
    if(!dfs(Graph,color,next,clr*-1)) return false;
  }
  return true;
}

int main(){
  int n,m;
  cin >> n >> m;
  vvi Graph(n);
  vi color(n,0);
  int a,b;
  rep(i,m){
    cin >> a >> b;
    Graph.at(a-1).push_back(b-1);
    Graph.at(b-1).push_back(a-1);
  }
  for (int v = 0; v < n; ++v) {
    if (color.at(v) != 0) continue; // v が探索済みだったらスルー
    if (!dfs(Graph,color,v,0)) two = false;
  }
  bool two = dfs(Graph,color,0,1);
  int sum = 0;
  rep(i,n){
    sum += color.at(i);
  }
  int s = (n + sum) / 2;
  int t = (n - sum) / 2;
  if(two){
    cout << s*t-m << endl;
  }else{
    cout << (n*(n-1))/2 - m << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:32: error: 'two' was not declared in this scope
   39 |     if (!dfs(Graph,color,v,0)) two = false;
      |                                ^~~
Language: C++

#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

bool dfs(vvi &Graph,vi &color,int v,int clr){
  color.at(v) = clr;
  for(int next : Graph.at(v)){
    if(color.at(next) != 0){
      if(color.at(next) == clr) return false;
      continue;
    }
    if(!dfs(Graph,color,next,clr*-1)) return false;
  }
  return true;
}

int main(){
  int n,m;
  cin >> n >> m;
  vvi Graph(n);
  vi color(n,0);
  int a,b;
  rep(i,m){
    cin >> a >> b;
    Graph.at(a-1).push_back(b-1);
    Graph.at(b-1).push_back(a-1);
  }
  for (int v = 0; v < N; ++v) {
    if (color.at(v) != 0) continue; // v が探索済みだったらスルー
    if (!dfs(Graph,color,v,0)) two = false;
  }
  bool two = dfs(Graph,color,0,1);
  int sum = 0;
  rep(i,n){
    sum += color.at(i);
  }
  int s = (n + sum) / 2;
  int t = (n - sum) / 2;
  if(two){
    cout << s*t-m << endl;
  }else{
    cout << (n*(n-1))/2 - m << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:23: error: 'N' was not declared in this scope
   37 |   for (int v = 0; v < N; ++v) {
      |                       ^
a.cc:39:32: error: 'two' was not declared in this scope
   39 |     if (!dfs(Graph,color,v,0)) two = false;
      |                                ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,m,to[200001],next[200001],tot,col[100001],head[100001],sum[3],cnt;
long long ans;
bool vis[100001],flag;
void add(int u,int v){to[++tot]=v,next[tot]=head[u],head[u]=tot;}
void dfs(int x,int color){
	++cnt;
	col[x]=color;
	sum[color]++;
	vis[x]=true;
	for(int i=head[x];i;i=next[i]){
		if(!vis[to[i]])dfs(to[i],3-color);
		else if(col[x]==col[to[i]])flag=true;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	for(int i=1;i<=n;i++)if(!vis[i]){
		dfs(i,1);
		if(!flag)ans+=sum[1]*sum[2];
		else ans+=1LL*cnt*(cnt-1)/2;
		sum[1]=sum[2]=flag=cnt=0;
	}
	printf("%lld\n",ans-m);
	return 0;
}

Compiler output:
a.cc: In function 'void add(int, int)':
a.cc:6:35: error: reference to 'next' is ambiguous
    6 | void add(int u,int v){to[++tot]=v,next[tot]=head[u],head[u]=tot;}
      |                                   ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:20: note:                 'int next [200001]'
    3 | int n,m,to[200001],next[200001],tot,col[100001],head[100001],sum[3],cnt;
      |                    ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:12:31: error: reference to 'next' is ambiguous
   12 |         for(int i=head[x];i;i=next[i]){
      |                               ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:20: note:                 'int next [200001]'
    3 | int n,m,to[200001],next[200001],tot,col[100001],head[100001],sum[3],cnt;
      |                    ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,m,to[200001],next[200001],tot,col[100001],head[100001],sum[3],cnt;
long long ans;
bool vis[100001],flag;
void add(int u,int v){to[++tot]=v,next[tot]=head[u],head[u]=tot;}
void dfs(int x,int color){
	++cnt;
	col[x]=color;
	sum[color]++;
	vis[x]=true;
	for(int i=head[x];i;i=next[i]){
		if(!vis[to[i]])dfs(to[i],3-color);
		else if(col[x]==col[to[i]])flag=true;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	for(int i=1;i<=n;i++)if(!vis[i]){
		dfs(i,1);
		if(!flag)ans+=sum[1]*sum[2];
		else ans+=cnt*(cnt-1)/2;
		sum[1]=sum[2]=flag=cnt=0;
	}
	printf("%lld\n",ans-m);
	return 0;
}

Compiler output:
a.cc: In function 'void add(int, int)':
a.cc:6:35: error: reference to 'next' is ambiguous
    6 | void add(int u,int v){to[++tot]=v,next[tot]=head[u],head[u]=tot;}
      |                                   ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:20: note:                 'int next [200001]'
    3 | int n,m,to[200001],next[200001],tot,col[100001],head[100001],sum[3],cnt;
      |                    ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:12:31: error: reference to 'next' is ambiguous
   12 |         for(int i=head[x];i;i=next[i]){
      |                               ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:20: note:                 'int next [200001]'
    3 | int n,m,to[200001],next[200001],tot,col[100001],head[100001],sum[3],cnt;
      |                    ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,m,to[200001],next[200001],tot,col[100001],head[100001],sum[3],cnt;
long long ans;
bool vis[100001],flag;
void add(int u,int v){to[++tot]=v,next[tot]=head[u],head[u]=tot;}
void dfs(int x,int color){
	++cnt;
	col[x]=color;
	sum[color]++;
	vis[x]=true;
	for(int i=head[x];i;i=next[i]){
		if(!vis[to[i]])dfs(to[i],3-color);
		else if(col[x]==col[to[i]])flag=true;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	for(int i=1;i<=n;i++)if(!vis[i]){
		dfs(i,1);
		if(!flag)ans+=sum[1]*sum[2];
		else ans+=cnt*(cnt-1)/2;
		sum[1]=sum[2]=flag=cnt=0;
	}
	printf("%lld",ans-m);
}

Compiler output:
a.cc: In function 'void add(int, int)':
a.cc:6:35: error: reference to 'next' is ambiguous
    6 | void add(int u,int v){to[++tot]=v,next[tot]=head[u],head[u]=tot;}
      |                                   ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:20: note:                 'int next [200001]'
    3 | int n,m,to[200001],next[200001],tot,col[100001],head[100001],sum[3],cnt;
      |                    ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:12:31: error: reference to 'next' is ambiguous
   12 |         for(int i=head[x];i;i=next[i]){
      |                               ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:20: note:                 'int next [200001]'
    3 | int n,m,to[200001],next[200001],tot,col[100001],head[100001],sum[3],cnt;
      |                    ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using Edge = pair<int,int>;
using Graph = vector<vector<int> >;
#define INF 1000000007
typedef long long ll;


vector<int> color;
bool dfs(const Graph &G,int v,int c = 0){
    color[v] = c;
    for(auto e : G[v]){

        /* 
        if(color[e] != -1){
            if(color[e] == c)return false;
            else continue;
        }
        if(!dfs(G,e, 1-c) )return false;*/

    if(color[e] == c){
            return false;
        }
        if(color[e] == -1 && !dfs(G,e, 1-c) ){
            return false;
        }

    }
    return true;
}

int main(){
    int N,M;cin >> N >> M;
    Graph G(N);
    color.assign(N,-1);
    ll res = 0;
    ll w = 0,b = 0;
    for(int i = 0 ; i < M ; i++){
        int u,v;cin>>u>>v;
        u--;v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    bool is_bipartite = true;
    for (int v = 0; v < N; ++v) {
        if (color[v] != -1) continue; // v が探索済みだったらスルー
        if (!dfs(G, v)) is_bipartite = false;
    }

    if(is_bipartite){
         for(int i=0; i<n; i++){
            if(color[i] == 1){
                b++;
            }else if(color[i] == 0){
                w++;
            }
        }
        cout << b*w-M << endl;
    }else{
        cout << ((N*(N-1))/2)-M << endl;//完全グラフ
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:25: error: 'n' was not declared in this scope
   52 |          for(int i=0; i<n; i++){
      |                         ^
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>

using namespace std;
#define int long long

vector<int> g[101010];
int memo[101010];
bool flag = 0;
int cnt[2];

void dfs(int v, int color) {
    for (int nv : g[v]) {
        if (memo[nv] == color) {
            flag = 1;
            continue;
        } else if (memo[nv] == (color + 1) % 2) {
            continue;
        } else if (memo[nv] == -1) {
            int new_color = (color + 1) % 2;
            memo[nv] = new_color;
            cnt[new_color] += 1;
            dfs(nv, new_color);
        }
    }
}

unsigned main() {
    int n, m;
    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for (int i = 0; i < n; i++) {
        memo[i] = -1;
    }
    memo[0] = 0;
    cnt[0] = 1;
    cnt[1] = 0;
    dfs(0, 0);
    if (flag) {
        cout << n * (n-1) / 2 - m << endl;
    } else {
        cout << cnt[0] * cnt[1] - m << endl;
    }

   
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>

using namespace std;

#define int long long

vector<int> g[101010];
int memo[101010];
bool flag = 0;
int cnt[2];

void dfs(int v, int color) {
    for (int nv : g[v]) {
        if (memo[nv] == color) {
            flag = 1;
            continue;
        } else if (memo[nv] == (color + 1) % 2) {
            continue;
        } else if (memo[nv] == -1) {
            int new_color = (color + 1) % 2;
            memo[nv] = new_color;
            cnt[new_color] += 1;
            dfs(nv, new_color);
        }
    }
}

int main() {
    int n, m;
    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for (int i = 0; i < n; i++) {
        memo[i] = -1;
    }
    memo[0] = 0;
    cnt[0] = 1;
    cnt[1] = 0;
    dfs(0, 0);
    if (flag) {
        cout << n * (n-1) / 2 - m << endl;
    } else {
        cout << cnt[0] * cnt[1] - m << endl;
    }

   
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repf(i,j,n) for(int i=(j);i<(n);i++)


vector<vector<int>>g;
set<pair<int,int>>s;

void add_edge(int a,int b){
	g[a].push_back(b);
	g[b].push_back(a);
}
void use(int a,int b){
	used[a][b]=true,used[b][a]=true;
}


int main(){
	int n,m;cin>>n>>m;
	g.resize(n);
	rep(i,m){
		int x,y;cin>>x>>y;x--;y--;
		add_edge(x,y);
		if(x>y)swap(x,y);
		s.insert(make_pair(x,y));
	}
	rep(i,n)rep(j,g[i].size())repf(k,j+1,g[i].size()){
	int a=g[i][j],b=g[i][k];
	if(a>b)swap(a,b);
	s.insert(make_pair(a,b));		

	}
	int ret=n*(n-1)/2-s.size();
	cout<<ret<<endl;
//	rep(i,n){
//		cout<<i<<" ";
//	rep(j,g[i].size)cout<<
	
}

Compiler output:
a.cc: In function 'void use(int, int)':
a.cc:15:9: error: 'used' was not declared in this scope; did you mean 'use'?
   15 |         used[a][b]=true,used[b][a]=true;
      |         ^~~~
      |         use
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repf(i,j,n) for(int i=(j);i<(n);i++)


vector<vector<int>>g;
vector<vector<bool>>used;

void add_edge(int a,int b){
	g[a].push_back(b);
	g[b].push_back(a);
}
void use(int a,int b){
	used[a][b]=true,used[b][a]=true;
}


int main(){
	int n,m;cin>>n>>m;
	g.resize(n);
	used=vector<vector<bool>>(n,vector<bool>(n,false));
	int cnt=0;
	rep(i,m){
		int x,y;cin>>x>>y;x--;y--;
		use(x,y);
		add_edge(x,y);
	}
	rep(i,n)rep(j,g[i].size())repf(k,j+1,g[i].size()){
		if(!used[g[i][j]][g[i][k]){cnt++;use(g[i][j],g[i][k]);}
	}
	int ret=n*(n-1)/2-m-cnt;
//	cout<<ret<<endl;
//	rep(i,n){
//		cout<<i<<" ";
//	rep(j,g[i].size)cout<<
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:42: error: expected ']' before ')' token
   30 |                 if(!used[g[i][j]][g[i][k]){cnt++;use(g[i][j],g[i][k]);}
      |                                          ^
      |                                          ]
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repf(i,j,n) for(int i=(j);i<(n);i++)


vector<vector<int>>g;
vector<vector<bool>used;

void add_edge(int a,int b){
	g[a].push_back(b);
	g[b].push_back(a);
}
void use(int a,int b){
	used[a][b]=true,used[b][a]=true;
}


int main(){
	int n,m;cin>>n>>m;
	g.resize(n);
	used=vector<vector<bool>>(n,vector<bool>(n,false));
	int cnt=0;
	rep(i,m){
		int x,y;cin>>x>>y;x--;y-;
		use(x,y);
		add_edge(x,y);
	}
	rep(i,n)rep(j,g[i].size())repf(k,j+1,g[i].size()){
		if(!used[j][k]){cnt++;use[j][k];}
	}
	int ret=n*(n-1)/2-m-cnt;
	cout<<ret<<endl;
	
}

Compiler output:
a.cc:8:20: error: template argument 1 is invalid
    8 | vector<vector<bool>used;
      |                    ^~~~
a.cc:8:20: error: template argument 2 is invalid
a.cc: In function 'void use(int, int)':
a.cc:15:9: error: 'used' was not declared in this scope; did you mean 'use'?
   15 |         used[a][b]=true,used[b][a]=true;
      |         ^~~~
      |         use
a.cc: In function 'int main()':
a.cc:22:9: error: 'used' was not declared in this scope; did you mean 'use'?
   22 |         used=vector<vector<bool>>(n,vector<bool>(n,false));
      |         ^~~~
      |         use
a.cc:25:41: error: expected primary-expression before ';' token
   25 |                 int x,y;cin>>x>>y;x--;y-;
      |                                         ^
a.cc:30:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |                 if(!used[j][k]){cnt++;use[j][k];}
      |                                            ^
a.cc:30:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |                 if(!used[j][k]){cnt++;use[j][k];}
      |                                               ^
Language: C

#include <stdio.h>
#include <stdlib.h>
#define NMAX 100000
struct node {
  int id;
  struct node *next;
};
struct node *list[NMAX];
void Insert(int a, int b);
int Dfs(int v, int c, int *color);
int main(void)
{
  int i, n, m, a, b, color[NMAX] = {0};
  long long int wb[2] = {0};
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) list[i] = NULL;
  for (i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    Insert(a - 1, b - 1);
  }
  if (!Dfs(0, 1, color))
    printf("%lld\n", (long long int)(n - 1) * n / 2 - m);
    return 0;
  }
  for (i = 0; i < n; i++) {
     wb[(color[i]+1)/2]++;
     free(list[i]);
  }
  printf("%lld\n", wb[0] * wb[1] - m);
}

void Insert(int a, int b)
{
  struct node *p = (struct node*)malloc(sizeof(struct node));
  p->id = b;
  p->next = list[a];
  list[a] = p;
  p = (struct node*)malloc(sizeof(struct node));
  p->id = a;
  p->next = list[b];
  list[b] = p;
}

int Dfs(int v, int c, int *color)
{
  struct node *n;
  color[v] = c;
  for (n = list[v]; n != NULL; n = n->next) {
    if (color[n->id] == c) return 0;
    else if (color[n->id] == 0 && !Dfs(n->id, -c, color)) return 0;
  }
  return 1;
}

Compiler output:
main.c:25:3: error: expected identifier or '(' before 'for'
   25 |   for (i = 0; i < n; i++) {
      |   ^~~
main.c:25:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
   25 |   for (i = 0; i < n; i++) {
      |                 ^
main.c:25:23: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   25 |   for (i = 0; i < n; i++) {
      |                       ^~
main.c:29:10: error: expected declaration specifiers or '...' before string constant
   29 |   printf("%lld\n", wb[0] * wb[1] - m);
      |          ^~~~~~~~
main.c:29:20: error: unknown type name 'wb'
   29 |   printf("%lld\n", wb[0] * wb[1] - m);
      |                    ^~
main.c:30:1: error: expected identifier or '(' before '}' token
   30 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
int N, M;
vector<int> E[101010];
int C[101010];
int num[101010];

void dfs(int cur, int col) {
    if(C[cur] != -1) {
        if(C[cur] != col) {
            //二部グラフではない
            cout << 1LL * N * (N - 1) / 2 - M << endl;
            return;
        }
    } else if(C[cur] == -1) {
        C[cur] = col;
        num[col]++;
        REP(i, E[cur].size()) { dfs(E[i], col ^ 1); }
    }
}
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    REP(i, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    memset(C, -1, sizeof(int));
    REP(i, M) {
        E[A[i]].push_back(B[i]);
        E[B[i]].push_back(A[i]);
    }
    dfs(0, 0);
    cout << 1LL * num[0] * num[1] - M << endl;
}
// http://kmjp.hatenablog.jp/entry/2017/10/09/0900

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:46:40: error: cannot convert 'std::vector<int>' to 'int'
   46 |         REP(i, E[cur].size()) { dfs(E[i], col ^ 1); }
      |                                     ~~~^
      |                                        |
      |                                        std::vector<int>
a.cc:36:14: note:   initializing argument 1 of 'void dfs(int, int)'
   36 | void dfs(int cur, int col) {
      |          ~~~~^~~
Language: C++

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

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

typedef long long ll;

template <class T = ll> T in() { T x; cin >> x; return (x); }

vector<int> A[10005];
int color[100005];
bool Odd = false;
int num = 1;

void odd(int pos) {
	for (auto x : A[pos]) {
		if (color[x] == -1) {
			color[x] = (color[pos] + 1) % 2;
			if (color[x] == 0) num++;
			odd(x);
		} else if (color[x] == color[pos]) {
			Odd = true;
		}
	}
	return;
}

signed main() {
	int n,m;
	cin >> n >> m;
	REP (i,m) {
		int x = in()-1,y = in()-1;
		A[x].pb(y);
		A[y].pb(x);
	}
	REP (i,100005) {
		color[i] = -1;
	}

	color[0] = 0;
	odd(0);

	int ans = 0;
	if (Odd) {
		ans = n * (n - 1) / 2 - m;
	} else {
		ans = (n - num) * num - m;
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:22: error: 'class std::vector<long long int>' has no member named 'pb'
   35 |                 A[x].pb(y);
      |                      ^~
a.cc:36:22: error: 'class std::vector<long long int>' has no member named 'pb'
   36 |                 A[y].pb(x);
      |                      ^~
Language: C++

//
// Created by 田代真生 on 2019-03-16.
//
#include <iostream>
#include <vector>
using namespace std;

vector <int> colors(100000);
vector <double> G[100000];
bool dfs(int v, int c, int N) {
    colors[v] = c;
    for (auto i:G[v]) {
        if (colors[i] == c) {
            return false;
        } else if (colors[i] == 0 && !dfs(i, -c, N)) {
            return false;
        }
    }
    return true;
}

int main(){
    double N;
    double M;
    int a;
    int b;
    double CNT;
    cin >> N >> M;
    for (int i=0; i<M; i++){
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    fill(colors.begin(), colors.begin()+N, 0);
    if (dfs(0,1,N)){
        CNT = count(colors.begin(), colors.begin() + N, 1);
        cout << CNT * (N - CNT) - M << endl;
    }
    else{
        cout << (N - 1) * N / 2 - M << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:15: error: 'count' was not declared in this scope
   38 |         CNT = count(colors.begin(), colors.begin() + N, 1);
      |               ^~~~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;

vector <int> colors(100000,0);
vector <int> G[100000];
bool dfs(int v, int c, int N) {
    colors[v] = c;
    for (auto i:G[v]) {
        if (colors[i] == c) {
            return false;
        } else if (colors[i] == 0 && !dfs(i, -c, N)) {
            return false;
        }
    }
    return true;
}

int main(){
    int N;
    int M;
    int a;
    int b;
    double CNT;
    cin >> N >> M;
    for (int i=0; i<M; i++){
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if (dfs(0,1,N)){
        CNT = count(colors.begin(), colors.begin() + N, 1);
        cout << CNT * (N - CNT) - M << endl;
    }
    else{
        cout << (N - 1) * N / 2 - M << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:15: error: 'count' was not declared in this scope
   34 |         CNT = count(colors.begin(), colors.begin() + N, 1);
      |               ^~~~~
Language: C++


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>

std::vector<int> graph[200010];

int come[200010];
int flag=0;
int sum=0;

int tansaku(int x){
	int i;
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>

std::vector<int> graph[200010];

int come[200010];
int flag=0;
int sum=0;

int tansaku(int x){
	int i;
	sum=sum+come[x];
//	printf("come[%d]=%d\n",x,come[x]);
	for(i=0;i<graph[x].size();i++){
		if(come[graph[x][i]]==-1){
			come[graph[x][i]]=(come[x]+1)%2;
			tansaku(graph[x][i]);
		}else{
			if(come[graph[x][i]]!=(come[x]+1)%2){
				flag=1;
			}
		}
	}
	return 0;
}

int main(void)
{
	//変数の宣言
	int n,m;
	int a,b;

	//よく使う変数
	int i,j,k,l;
	//int flag=0;
	long int ans=0;
	int count=0;
	long int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d %d",&n,&m);
	
	for(i=0;i<m;i++){
		scanf("%d %d",&a,&b);
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	for(i=0;i<100010;i++){
		come[i]=-1;
	}

//	printf("nは%dです\n", n);
//	printf("tag1 reading OK\n");
	//実際の処理
	
	come[1]=1;
	tansaku(1);

	if(flag==1){
		ans=(long)n*(n-1)/2-m;
	}else{
		ans=(long)sum*(n-sum)-m;
	}

//	printf("tag2 calculate OK\n");
	//出力
	
//	printf("flag=%d\n",flag);
	printf("%ld",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}


	sum=sum+come[x];
//	printf("come[%d]=%d\n",x,come[x]);
	for(i=0;i<graph[x].size();i++){
		if(come[graph[x][i]]==-1){
			come[graph[x][i]]=(come[x]+1)%2;
			tansaku(graph[x][i]);
		}else{
			if(come[graph[x][i]]!=(come[x]+1)%2){
				flag=1;
			}
		}
	}
	return 0;
}

int main(void)
{
	//変数の宣言
	int n,m;
	int a,b;

	//よく使う変数
	int i,j,k,l;
	//int flag=0;
	long int ans=0;
	int count=0;
	long int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d %d",&n,&m);
	
	for(i=0;i<m;i++){
		scanf("%d %d",&a,&b);
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	for(i=0;i<100010;i++){
		come[i]=-1;
	}

//	printf("nは%dです\n", n);
//	printf("tag1 reading OK\n");
	//実際の処理
	
	come[1]=1;
	tansaku(1);

	if(flag==1){
		ans=n*(n-1)/2-m;
	}else{
		ans=sum*(n-sum)-m;
	}

//	printf("tag2 calculate OK\n");
	//出力
	
//	printf("flag=%d\n",flag);
	printf("%ld",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Compiler output:
a.cc: In function 'int tansaku(int)':
a.cc:28:19: error: a function-definition is not allowed here before '{' token
   28 | int tansaku(int x){
      |                   ^
a.cc:46:1: error: a function-definition is not allowed here before '{' token
   46 | {
      | ^
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

class UnionFind {
    vector<int> par;
    int n;
public:
    UnionFind(int n) : par(n, -1) {}
    int find(int x) {
        if (par[x] < 0) return x;
        return par[x] = find(par[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
};

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

    ll n, m;
    cin >> n >> m;

    UnionFind uf(2*n);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b+n);
        uf.unite(a+n, b);
    }

    if (uf.find(0i) == uf.find(n)) {
        cout << (n*(n-1)/2)-m;
        return 0;
    }

    ll c = 1;
    for (int i = 1; i < n; i++) {
        if (uf.find(0) == uf.find(i)) c++;
    }
    cout << c*(n-c)-m;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:16: error: cannot convert '__complex__ int' to 'int'
   48 |     if (uf.find(0i) == uf.find(n)) {
      |         ~~~~~~~^~~~
a.cc:16:18: note:   initializing argument 1 of 'int UnionFind::find(int)'
   16 |     int find(int x) {
      |              ~~~~^
Language: C++

/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define P pair<ll, ll>
#define int ll

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int const MAX_V = 100000;

int V, E;

vector<int> G[MAX_V];
int colors[MAX_V];

bool dfs(int v, int c) {
    colors[v] = c;

    for (int i = 0; i < G[v].size(); i++) {
        if (colors[G[v][i]] == c) return false;
        if (colors[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
    }

    return true;
}


int main() {
    cin >> V >> E;

    for (int i = 0; i < E; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        G[a].push_back(b);
        G[b].push_back(a);
    }

    fill(colors, colors + V, 0);

    bool is_bin = dfs(0, 1);

    if (is_bin) {
        int minus_num = 0;
        int one_num = 0;
        for (int i = 0; i < V; i++) {
            if (colors[i] == 1) one_num++;
            if (colors[i] == -1) minus_num++;
        }
        cout << minus_num * one_num - E << endl;
    } else {
        cout << V * (V - 1) / 2 - E << endl;
    }

    return 0;
}

Compiler output:
a.cc:33:13: error: '::main' must return 'int'
   33 | #define int ll
      |             ^~
a.cc:64:1: note: in expansion of macro 'int'
   64 | int main() {
      | ^~~
Language: C++

//
//  code_festival_2017_equal_B.cpp
//  
//
//  Created by Yoshida Satoshi on 2018/11/06.
//

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>

#define MAX 100005

typedef long long ll;

using namespace std;

struct Graph
{
    ll n,m,a,b;
    vector<ll> v[MAX];
    ll c[MAX]={};
    ll odd=0;
    ll even=0;
    bool flag=false;//false<->2部ぐらふ
    
    void input()
    {
        cin>>n>>m;
        for(ll i=0;i<m;i++)
        {
            cin>>a>>b;
            v[a].push_back(b);
            v[b].push_back(a);
        }
    }
    
    void dfs(ll x,ll col)
    {
        if(flag) return;
        for(ll i=0;i<v[x].size();i++)
        {
            ll y=v[x][i];
            if(c[y]==0)
            {
                c[y]=col;
                if(col==1) even++;
                    else       odd++;
                dfs(y,-1*col);
            }
            else if(c[y]!=col)
            {
                flag=true;break;
            }
        }
    }
    
    void solve()
    {
        dfs(1,1);
        ll ans;
        if(flag) ans=(n*(n-1))/2-m;
        else     ans=odd*even-m;
        
        cout<<ans<<endl;
    }
    
};

ll main()
{
    Graph g;
    
    g.input();
    
    g.solve();
    
    return 0;
}


Compiler output:
a.cc:72:1: error: '::main' must return 'int'
   72 | ll main()
      | ^~
Language: C++

#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const int MAX_V=100000;

vector <int> G[MAX_V];
ll V;

int color[MAX_V];

//頂点を１と−１で塗る
bool dfs(int v,int c){
    color[v] = c;
    rep(i, 0, G[v].size()){
        //隣接している頂点が同じ色ならfalse
        if (color[G[v][i]] == c) return false;
        //隣接している頂点がまだ塗られていないなら-cで塗る
        if (color[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
    }
    //すべて塗れたらtrue
    return true;
}

int main() {
    int M;
    cin >> V >> M;
    rep(i, 0, M){
        int a,b;
        cin >> a >> b;
        G[a-1].push_back(b-1);  G[b-1].push_back(a-1);
    }
    if (dfs(0,1)){
        ll int cnt=0;
        rep(i, 0, V){
            if (color[i] == 1) cnt++;
        }
        printf("%lld\n", cnt*(V-cnt)-M);
    }
    else {
        printf("%lld\n", V*(V-1)/2-M);
    }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:38:9: error: two or more data types in declaration of 'cnt'
   38 |         ll int cnt=0;
      |         ^~
a.cc:40:32: error: 'cnt' was not declared in this scope; did you mean 'int'?
   40 |             if (color[i] == 1) cnt++;
      |                                ^~~
      |                                int
a.cc:42:26: error: 'cnt' was not declared in this scope; did you mean 'int'?
   42 |         printf("%lld\n", cnt*(V-cnt)-M);
      |                          ^~~
      |                          int
Language: C++

#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
 
#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
typedef long long ll;
using namespace std;

int n,m,a,b,ev,od,g[100000];
vector<int>v[100000];

int dfs(int x){
	if(g[x]==1)ev++;
	else od++;
	lp(v[x].size()){
		if(g[v[x][i]]==g[x])
			return -1;
		else if(g[v[x][i]]==0) {
			g[v[x][i]]=-g[x];
			if(dfs(v[x][i])==-1)
				return -1;
		}
	}
	return 0;
}

int main(){
	cin>>n>>m;
	lp(m){
		cin>>a>>b;
		v[a-1].push_back(b-1);
		v[b-1].push_back(a-1);
	}
	lp(n)
		g[i]=0;
	g[0]=1;
	od=0;
	ev=0;
	if(dfs(0)==-1){
		cout<<ll(n)*ll(n-1)/2-m<<endl;
	}
	else {
		cout<<ll(od)*ll(ev)-m<<endl;
	}
	return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:60:18: error: expected '}' at end of input
   60 |         return 0;
      |                  ^
a.cc:42:11: note: to match this '{'
   42 | int main(){
      |           ^