Language: C++

#include <bits/stdc++.h>
#define F first
//#define S second
#define dq deque
#define vc vector
#define INF (0x3f3f3f3f)
#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))
#define Pb push_back
#define Mp make_pair
#define ll long long
#define _tp template
#define _tyn typename
#define Pf push_front
#define itor iterator
#define sint short int
#define ull unsigned ll
#define pii pair<int,int>
#define uint unsigned int
#define All(x) x.begin(),x.end()
#define B cout << "BreakPoint" << endl;
#define Fin(a) freopen(a,"r",stdin)
#define Fout(a) freopen(a,"w",stdout)
#define Ms(_data) memset(_data,0,sizeof(_data))
#define Msn(_data,_num) memset(_data,_num,sizeof(_data))
#define Fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define O_(x) cout << #x << " " << x << "  ";
#define O(x) cout << #x << " " << x << endl;
using namespace std;
#define Mymax(a,b) if(a<b) a = b
#define Mymin(a,b) if(a>b) a = b
void Print(int _x){printf("%d\n",_x);}
void Print(ll _x){printf("%lld\n",_x);}
_tp<_tyn T>void Print( T _a[] , int _s , int _t ){
    for( int i = _s ; i <= _t ; i++ )
        cout << _a[i] << " ";
   	cout << endl;
}
#define il inline
#define rg register
struct InputReader{
    static const int bs = 100000;
    char buf[bs];
    int p;
    il InputReader():p(bs) {}
    il void Flush(){
        p = 0;
        fread(buf, 1, bs, stdin);
    }
    il char C(){
        if(p >= bs) Flush();
        return buf[p++];
    }
    int Getnum(){
        char ch = C();
        while( ch < '0'  ||  ch > '9' ) ch = C();
        return (int)(ch-'0');
    }
    il int operator() (){
        int ans = 0;
        char ch = C();
        int fu = 1;
        while( ch < '0'  ||  ch > '9' ){
            if( ch == '-' ) fu = -1;
            ch = C();
        }
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10;
            ans += ch-'0';
            ch = C();
        }
        return ans * fu;
    }
    ll Readll(){
        ll ans = 0LL;
        ll fu = 1;
        char ch = C();
        while( ch < '0'  ||  ch > '9' ){
            if( ch == '-' ) fu = -1;
            ch = C();
        }
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10LL;
            ans += ch-'0';
            ch = C();
        }
        return ans * fu;
    }
    il void Readstring( string &x ){
        x.clear();
        char ch = C();
        while( !isdigit(ch)  &&  !isalpha(ch) ) ch = C();
        while( isdigit(ch)  ||  isalpha(ch) ){
            x += ch;
            ch = C();
        }
    }
    il int Readchstr( char c[] ){
        int p = 0;
        char ch = C();
        while( !isdigit(ch)  &&  !isalpha(ch) ) ch = C();
        while( isdigit(ch)  ||  isalpha(ch) ){
            c[p] = ch;
            ch = C();
            p++;
        }
        c[p] = '\0';
        return p;
    }
    il void Readalpha( char &c ){
        c = C();
        while( !isalpha(c) ) c = C();
    }
    il void Specialread( char &c ){
        c = C();
        while( c != 'o'  &&  c != 'x'  &&  c != '?' ) c = C();
    }
}In;
il void Read( int &x ){ x = In(); }
il void Read( int &x, int &y ){ x = In(); y = In(); }
il void Read( int &x1 , int &x2 , int &x3 ){
    x1 = In(); x2 = In(); x3 = In();
}
il void Read( int &x1 , int &x2 , int &x3 , int &x4 ){
    x1 = In(); x2 = In(); x3 = In(); x4 = In();
}
il void Read( ll &x ){ x = In.Readll(); }
il void Read( ll &x, ll &y ){ x = In.Readll(); y = In.Readll(); }
il void Read( ll &x1 , ll &x2 , ll &x3 ){
    x1 = In.Readll(); x2 = In.Readll(); x3 = In.Readll();
}
il void Read( ll &x1 , ll &x2 , ll &x3 , ll &x4 ){
    x1 = In.Readll(); x2 = In.Readll(); x3 = In.Readll(); x4 = In.Readll();
}
clock_t _starttime , _endtime;
il void FILEIO(){
    #ifdef InterestingLSY
        _starttime = clock();
        Fin("in.in");
    #endif
}
#ifdef InterestingLSY
    #include <windows.h>
    #include <psapi.h>
#endif
il void END(){
    #ifdef InterestingLSY
        _endtime = clock();
        double _timeuse = (_endtime-_starttime)* 1000.0 / CLOCKS_PER_SEC;
        printf("\n\nTime usage:\n%.0lf ms\n",_timeuse);
        HANDLE _handle = GetCurrentProcess();
        PROCESS_MEMORY_COUNTERS pmc;
        GetProcessMemoryInfo(_handle,&pmc,sizeof(pmc));
        double _memuse = pmc.PeakPagefileUsage/1024.00/1024.00;
        printf("Memory usage:\n%.1lf MB\n\n",_memuse);
    #endif
    exit(0);
}
#define For(i,j) for( rg int (i) = 1 ; (i) <= (j) ; (i)++ )
#define For0(i,j) for( rg int (i) = 0 ; (i) < (j) ; (i)++ )
#define Forx(i,j,k) for( rg int (i) = (j) ; (i) <= (k) ; (i)++ )
#define Forstep(i,j,k,st) for( rg int (i) = (j) ; (i) <= (k) ; (i) += (st) )
#define fOR(i,j) for( rg int (i) = (j) ; (i) >= 1 ; (i)-- )
#define fOR0(i,j) for( rg int (i) = (j)-1 ; (i) >= 0 ; (i)-- )
#define fORx(i,j,k) for( rg int (i) = (k) ; (i) >= (j) ; (i)-- )
int dx[] = {0,-1,0,1};
int dy[] = {1,0,-1,0};
//			D L U  R
#define Mymod(a,b) if( a >= b ) a -= b;
#define Rmod(a,b) a = (a%b+b)%b
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
#define MAXN 910

int n,m;
bool link[MAXN][MAXN];

int intuan[MAXN];
vc<int> nowt;
int Buildtuan( int st ){	//return:tuansz
	intuan[st] = 1;
	nowt.clear();
	nowt.Pb(st);
	int sz = 1;
	For(u,n){
		if(intuan[u]) continue;
		bool fail = 0;
		For0(j,nowt.size()){
			int v = nowt[j];
			if(!link[u][v]){
				fail = 1;
				break;
			}
		}
		if(fail) continue;
		intuan[u] = 1;
		sz++;
		nowt.Pb(u);
	}
	return sz;
}
int Solve(){
	int sz1 = Buildtuan(1);
	if( sz1 == n ) assert(0);
	int sz2,st;
	For(i,n)
		if(!intuan[i]){
			st = i;
			sz2 = Buildtuan(i);
			break;
		}
	if( sz1+sz2 != n ) return -1;

	Ms(intuan);
	int ssz1 = Buildtuan(1);
	Ms(intuan);
	int ssz2 = Buildtuan(st);
	int cover = ssz1+ssz2-n;
	//cout << sz1 << " " << sz2 << endl;
	//cout << ssz1 << " " << ssz2 << endl;
	//O(cover);
	if( sz1 > sz2 ){while(1);
		int delta = n/2-sz2;
		if( cover <= delta ){
			sz1 -= cover;
			sz2 += cover;
		}else{
			sz1 = n/2;
			sz2 = n-sz1;
		}
	}

	return sz1*(sz1-1)/2 + sz2*(sz2-1)/2;
}

int main(){
	FILEIO();
	Ms(link);
	Ms(intuan);

	Read(n,m);
	if( m == n*(n-1)/2 ){
		while(1)
		int sz1 = n/2,sz2 = n-sz1;
		int ans = sz1*(sz1-1)/2 + sz2*(sz2-1)/2;
		printf("%d\n",ans);
		END();
	}

	For(i,m){
		int x,y;
		Read(x,y);
		link[x][y] = link[y][x] = 1;
	}

	int ans = Solve();
	printf("%d\n",ans);

	END();
}


Compiler output:
a.cc:175:21: error: 'bool link [910][910]' redeclared as different kind of entity
  175 | bool link[MAXN][MAXN];
      |                     ^
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:1:
/usr/include/unistd.h:819:12: note: previous declaration 'int link(const char*, const char*)'
  819 | extern int link (const char *__from, const char *__to)
      |            ^~~~
a.cc: In function 'int Buildtuan(int)':
a.cc:184:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  184 |         For(u,n){
      |             ^
a.cc:158:31: note: in definition of macro 'For'
  158 | #define For(i,j) for( rg int (i) = 1 ; (i) <= (j) ; (i)++ )
      |                               ^
a.cc:187:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  187 |                 For0(j,nowt.size()){
      |                      ^
a.cc:159:32: note: in definition of macro 'For0'
  159 | #define For0(i,j) for( rg int (i) = 0 ; (i) < (j) ; (i)++ )
      |                                ^
a.cc:189:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  189 |                         if(!link[u][v]){
      |                                   ^
a.cc:189:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  189 |                         if(!link[u][v]){
      |                                      ^
a.cc: In function 'int Solve()':
a.cc:205:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  205 |         For(i,n)
      |             ^
a.cc:158:31: note: in definition of macro 'For'
  158 | #define For(i,j) for( rg int (i) = 1 ; (i) <= (j) ; (i)++ )
      |                               ^
a.cc: In function 'int main()':
a.cc:237:12: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
  237 |         Ms(link);
      |            ^
a.cc:23:41: note: in definition of macro 'Ms'
   23 | #define Ms(_data) memset(_data,0,sizeof(_data))
      |                                         ^~~~~
a.cc:237:12: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'void*' [-fpermissive]
  237 |         Ms(link);
      |            ^~~~
      |            |
      |            int (*)(const char*, const char*) noexcept
a.cc:23:26: note: in definition of macro 'Ms'
   23 | #define Ms(_data) memset(_data,0,sizeof(_data))
      |                          ^~~~~
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
a.cc:244:27: error: 'sz1' was not declared in this scope
  244 |                 int ans = sz1*(sz1-1)/2 + sz2*(sz2-1)/2;
      |                           ^~~
a.cc:244:43: error: 'sz2' was not declared in this scope
  244 |                 int ans = sz1*(sz1-1)/2 + sz2*(sz2-1)/2;
      |                                           ^~~
a.cc:249:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  249 |         For(i,m){
      |             ^
a.cc:158:31: note: in definition of macro 'For'
  158 | #define For(i,j) for( rg int (i) = 1 ; (i) <= (j) ; (i)++ )
      |                               ^
a.cc:252:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  252 |                 link[x][y] = link[y][x] = 1;
      |                       ^
a.cc:252:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  252 |                 link[x][y] = link[y][x] = 1;
      |                          ^
a.cc:252:36: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  252 |                 link[x][y] = link[y][x] = 1;
      |                                    ^
a.cc:252:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  252 |                 link[x][y] = link[y][x] = 1;
      |                                       ^
a.cc:252:41: error: assignment of read-only location '*(link + (((sizetype)y) + ((sizetype)x)))'
  252 |                 link[x][y] = link[y][x] = 1;
      |                              ~~~~~~~~~~~^~~