Language: C++

#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 705
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,m,mp[maxn][maxn],cnt,vis[maxn],col[maxn],f;
int t[maxn][2],dp[2][maxn];
bitset <maxn*4> s;

inline void dfs(int u)
{
	t[cnt][col[u]]++; vis[u]=1;
	for(int i=1;i<=n;i++)
	{
		if(i==u) continue;
		if(mp[u][i]==0&&vis[i]==0) col[i]=col[u]^1,dfs(i);
		else if(mp[u][i]==0&&col[i]==col[u]) {f=1; return;}
	}
}

inline int cal(int x,int y){return x*(x-1)/2+y*(y-1)/2;}

int main()
	n=read(); m=read();
	for(int i=1;i<=m;i++) {int u=read(),v=read(); mp[u][v]=mp[v][u]=1;}
	for(int i=1;i<=n;i++) if(!vis[i]) cnt++,dfs(i);
	s[0]=1; dp[0][0]=1; int nw=1;
	for(int i=1;i<=cnt;i++)
	{
		s=(s<<t[i][0])|(s<<t[i][1]);
		for(int j=n;j>=0;j--)
		{
			if(j>=t[i][0]) dp[nw][j]|=dp[nw^1][j-t[i][0]];
			if(j>=t[i][1]) dp[nw][j]|=dp[nw^1][j-t[i][1]];
		}
		nw^=1;
	}
	int ans=inf;
	for(int i=0;i<=n;i++) if(dp[nw][i]) ans=min(ans,cal(i,n-i));
	if(f==1) puts("-1"); else cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc:35:9: error: expected initializer before 'n'
   35 |         n=read(); m=read();
      |         ^
a.cc:35:19: error: 'm' does not name a type; did you mean 'tm'?
   35 |         n=read(); m=read();
      |                   ^
      |                   tm
a.cc:36:9: error: expected unqualified-id before 'for'
   36 |         for(int i=1;i<=m;i++) {int u=read(),v=read(); mp[u][v]=mp[v][u]=1;}
      |         ^~~
a.cc:36:21: error: 'i' does not name a type
   36 |         for(int i=1;i<=m;i++) {int u=read(),v=read(); mp[u][v]=mp[v][u]=1;}
      |                     ^
a.cc:36:26: error: 'i' does not name a type
   36 |         for(int i=1;i<=m;i++) {int u=read(),v=read(); mp[u][v]=mp[v][u]=1;}
      |                          ^
a.cc:37:9: error: expected unqualified-id before 'for'
   37 |         for(int i=1;i<=n;i++) if(!vis[i]) cnt++,dfs(i);
      |         ^~~
a.cc:37:21: error: 'i' does not name a type
   37 |         for(int i=1;i<=n;i++) if(!vis[i]) cnt++,dfs(i);
      |                     ^
a.cc:37:26: error: 'i' does not name a type
   37 |         for(int i=1;i<=n;i++) if(!vis[i]) cnt++,dfs(i);
      |                          ^
a.cc:38:9: error: 's' does not name a type
   38 |         s[0]=1; dp[0][0]=1; int nw=1;
      |         ^
a.cc:38:17: error: 'dp' does not name a type
   38 |         s[0]=1; dp[0][0]=1; int nw=1;
      |                 ^~
a.cc:39:9: error: expected unqualified-id before 'for'
   39 |         for(int i=1;i<=cnt;i++)
      |         ^~~
a.cc:39:21: error: 'i' does not name a type
   39 |         for(int i=1;i<=cnt;i++)
      |                     ^
a.cc:39:28: error: 'i' does not name a type
   39 |         for(int i=1;i<=cnt;i++)
      |                            ^
a.cc:50:9: error: expected unqualified-id before 'for'
   50 |         for(int i=0;i<=n;i++) if(dp[nw][i]) ans=min(ans,cal(i,n-i));
      |         ^~~
a.cc:50:21: error: 'i' does not name a type
   50 |         for(int i=0;i<=n;i++) if(dp[nw][i]) ans=min(ans,cal(i,n-i));
      |                     ^
a.cc:50:26: error: 'i' does not name a type
   50 |         for(int i=0;i<=n;i++) if(dp[nw][i]) ans=min(ans,cal(i,n-i));
      |                          ^
a.cc:51:9: error: expected unqualified-id before 'if'
   51 |         if(f==1) puts("-1"); else cout<<ans<<endl;
      |         ^~
a.cc:51:30: error: expected unqualified-id before 'else'
   51 |         if(f==1) puts("-1"); else cout<<ans<<endl;
      |                              ^~~~
a.cc:52:9: error: expected unqualified-id before 'return'
   52 |         return 0;
      |         ^~~~~~
a.cc:53:1: error: expected declaration before '}' token
   53 | }
      | ^