Language: C++

/// In The Name Of God
/// I wish, that I could leave it all behind me / Go to my own world where no one can find me
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define pii pair <int , int>
#define ld long double
#define for2(a,b,c) for(int (a) = (b); (a) < (c); (a)++)
#define setp cout << fixed << setprecision(15)
#define endl "\n"
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define error(x) cerr << #x << " = " << (x) << endl;
#define all(x) (x).begin() , (x).end()

const int maxn = 718;
bool a[maxn][maxn];
int seen[maxn];
vector<PII> w;
PII sz;
int tmp[maxn];
int dp[maxn];
int n;

void dfs(int root,bool h = 0){
    seen[root] = h+1;
    if(h) sz.F ++;
    else sz.S++;
    for2(i,0,n) if(!a[root][i] && !seen[i]) dfs(i,!h);
                else if(!a[root][i] && seen[i] == seen[root] && root != i){
                    cout << -1 << endl;
                    exit(0);
                }
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m; cin >> n >> m;
    for2(i,0,m){
        int v,u; cin >> v >> u; v-- ,u--;
        a[v][u] = a[u][v] = 1;
    }
    for2(i,0,n) if(!seen[i]){
        sz = {0,0};
        dfs(i);
        w.pb(sz);
    }
    dp[0] = 1;
    for(auto x : w){
        for2(i,0,maxn)
            if(i >= x.F) tmp[i] |= dp[i-x.F];
            if(i >= x.S) tmp[i] |= dp[i-x.S];
        }
        for2(i,0,maxn) dp[i] = tmp[i],tmp[i]=0;
    }
    int ans = n*n;
    for2(i,0,n+1) if(dp[i]) ans = min(ans,(i*(i-1)/2) + (n-i)*(n-i-1)/2 );
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:62:16: error: 'i' was not declared in this scope
   62 |             if(i >= x.S) tmp[i] |= dp[i-x.S];
      |                ^
a.cc: At global scope:
a.cc:15:21: error: expected unqualified-id before 'for'
   15 | #define for2(a,b,c) for(int (a) = (b); (a) < (c); (a)++)
      |                     ^~~
a.cc:67:5: note: in expansion of macro 'for2'
   67 |     for2(i,0,n+1) if(dp[i]) ans = min(ans,(i*(i-1)/2) + (n-i)*(n-i-1)/2 );
      |     ^~~~
a.cc:15:44: error: expected constructor, destructor, or type conversion before '<' token
   15 | #define for2(a,b,c) for(int (a) = (b); (a) < (c); (a)++)
      |                                            ^
a.cc:67:5: note: in expansion of macro 'for2'
   67 |     for2(i,0,n+1) if(dp[i]) ans = min(ans,(i*(i-1)/2) + (n-i)*(n-i-1)/2 );
      |     ^~~~
a.cc:15:54: error: expected constructor, destructor, or type conversion before '++' token
   15 | #define for2(a,b,c) for(int (a) = (b); (a) < (c); (a)++)
      |                                                      ^~
a.cc:67:5: note: in expansion of macro 'for2'
   67 |     for2(i,0,n+1) if(dp[i]) ans = min(ans,(i*(i-1)/2) + (n-i)*(n-i-1)/2 );
      |     ^~~~
a.cc:68:5: error: 'cout' does not name a type
   68 |     cout << ans << endl;
      |     ^~~~
a.cc:69:5: error: expected unqualified-id before 'return'
   69 |     return 0;
      |     ^~~~~~
a.cc:70:1: error: expected declaration before '}' token
   70 | }
      | ^