Language: C

int n, m, a[200009], b[200009], e[400009], c[100009], s[100009], cnt, col[100009];
bool dfs(int pos) {
	bool ret = true; cnt++;
	for (int i = c[pos]; i < c[pos + 1]; i++) {
		if (col[e[i]] == col[pos]) ret = false;
		if (col[e[i]] == 0) {
			col[e[i]] = 3 - col[pos];
			if (!dfs(e[i])) ret = false;
		}
	}
	return ret;
}
void reader(int *x) {
	for (char c = getchar_unlocked(); 48 <= c && c <= 57; c = getchar()) *x = *x * 10 + c - 48;
}
int main() {
	reader(&n); reader(&m);
	for (int i = 0; i < m; i++) {
		reader(&a[i]); reader(&b[i]);
		c[--a[i]]++; c[--b[i]]++;
	}
	for (int i = 0; i < n; i++) s[i + 1] = s[i] + c[i]; c[0] = 0;
	for (int i = 0; i < n; i++) c[i + 1] = s[i + 1];
	for (int i = 0; i < m; i++) e[s[a[i]]++] = b[i], e[s[b[i]]++] = a[i];
	int c0 = 0, c1 = 0, c2 = 0;
	for (int i = 0; i < n; i++) {
		if (col[i] == 0) {
			col[i] = 1; cnt = 0;
			bool res = dfs(i);
			if (cnt == 1) c0++;
			else if (!res) c1++;
			else c2++;
		}
	}
	printf("%lld\n", 1LL * (c1 + c2) * (c1 + c2) + 1LL * c2 * c2 + 1LL * n * n - 1LL * (n - c0) * (n - c0));
	return 0;
}

Compiler output:
main.c:2:1: error: unknown type name 'bool'
    2 | bool dfs(int pos) {
      | ^~~~
main.c:1:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
  +++ |+#include <stdbool.h>
    1 | int n, m, a[200009], b[200009], e[400009], c[100009], s[100009], cnt, col[100009];
main.c: In function 'dfs':
main.c:3:9: error: unknown type name 'bool'
    3 |         bool ret = true; cnt++;
      |         ^~~~
main.c:3:9: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:3:20: error: 'true' undeclared (first use in this function)
    3 |         bool ret = true; cnt++;
      |                    ^~~~
main.c:3:20: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:3:20: note: each undeclared identifier is reported only once for each function it appears in
main.c:5:50: error: 'false' undeclared (first use in this function)
    5 |                 if (col[e[i]] == col[pos]) ret = false;
      |                                                  ^~~~~
main.c:5:50: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c: In function 'reader':
main.c:14:23: error: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
   14 |         for (char c = getchar_unlocked(); 48 <= c && c <= 57; c = getchar()) *x = *x * 10 + c - 48;
      |                       ^~~~~~~~~~~~~~~~
main.c:14:67: error: implicit declaration of function 'getchar' [-Wimplicit-function-declaration]
   14 |         for (char c = getchar_unlocked(); 48 <= c && c <= 57; c = getchar()) *x = *x * 10 + c - 48;
      |                                                                   ^~~~~~~
main.c:1:1: note: 'getchar' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'
  +++ |+#include <stdio.h>
    1 | int n, m, a[200009], b[200009], e[400009], c[100009], s[100009], cnt, col[100009];
main.c: In function 'main':
main.c:29:25: error: unknown type name 'bool'
   29 |                         bool res = dfs(i);
      |                         ^~~~
main.c:29:25: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:35:9: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   35 |         printf("%lld\n", 1LL * (c1 + c2) * (c1 + c2) + 1LL * c2 * c2 + 1LL * n * n - 1LL * (n - c0) * (n - c0));
      |         ^~~~~~
main.c:35:9: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:35:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:35:9: note: include '<stdio.h>' or provide a declaration of 'printf'