Problem p03691 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x << 1)
#define w2 second
#define ins insert
#define rs (x << 1 | 1)
#define mp make_pair
#define pb push_back
#define mid ((l + r) >> 1)
#define sqr(x) ((x) * (x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x) & (-x))
#define SZ(x) (int((x).size()))
#define ms(x, y) memset(x, y, sizeof(x))
#define rep(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define rep2(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define per(i, a, b) for (int(i) = (a); (i) >= (b); (i)--)
#define Rep(p, x) for (int(p) = head[(x)]; (p); (p) = nxt[(p)])
#define Rep2(p, x) for (int(p) = cur[(x)]; (p); (p) = nxt[(p)])
template <class T> inline void read(T &num) {
  num = 0;
  T f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    num = num * 10 + ch - '0', ch = getchar();
  num *= f;
}
inline int getgcd(int x, int y) {
  if (!x)
    return y;
  return getgcd(y % x, x);
}
inline int power(int x, int k, int p) {
  int res = 1;
  for (; k; k >>= 1, x = (ll)x * x % p)
    if (k & 1)
      res = (ll)res * x % p;
  return res;
}
const double pi = acos(-1);
inline void judge() { freopen("input.txt", "r", stdin); }
//********************************head*************************************
const int maxn = 1e2 + 5, maxm = 1e5 + 5;
int n, m, ans;
bitset<maxn> S[maxn];
int x[maxm], y[maxm], ban[maxn];
int main() {
  read(n);
  read(m);
  rep(i, 1, m) read(x[i]), read(y[i]);
  rep(i, 1, n) {
    S[i][i] = 1;
    per(j, m, 1) {
      if (S[i][x[j]] && S[i][y[j]]) {
        ban[i] = 1;
        break;
      } else if (S[i][x[j]])
        S[i][y[j]] = 1;
      else if (S[i][y[j]])
        S[i][x[j]] = 1;
    }
  }
  rep(i, 1, n) rep(j, i + 1, n) if (!ban[i] && !ban[j] && (S[i] & S[j]) == 0u)
      ans++;
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x << 1)
#define w2 second
#define ins insert
#define rs (x << 1 | 1)
#define mp make_pair
#define pb push_back
#define mid ((l + r) >> 1)
#define sqr(x) ((x) * (x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x) & (-x))
#define SZ(x) (int((x).size()))
#define ms(x, y) memset(x, y, sizeof(x))
#define rep(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define rep2(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define per(i, a, b) for (int(i) = (a); (i) >= (b); (i)--)
#define Rep(p, x) for (int(p) = head[(x)]; (p); (p) = nxt[(p)])
#define Rep2(p, x) for (int(p) = cur[(x)]; (p); (p) = nxt[(p)])
template <class T> inline void read(T &num) {
  num = 0;
  T f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    num = num * 10 + ch - '0', ch = getchar();
  num *= f;
}
inline int getgcd(int x, int y) {
  if (!x)
    return y;
  return getgcd(y % x, x);
}
inline int power(int x, int k, int p) {
  int res = 1;
  for (; k; k >>= 1, x = (ll)x * x % p)
    if (k & 1)
      res = (ll)res * x % p;
  return res;
}
const double pi = acos(-1);
inline void judge() { freopen("input.txt", "r", stdin); }
//********************************head*************************************
const int maxn = 4e2 + 5, maxm = 1e5 + 5;
int n, m, ans;
bitset<maxn> S[maxn];
int x[maxm], y[maxm], ban[maxn];
int main() {
  read(n);
  read(m);
  rep(i, 1, m) read(x[i]), read(y[i]);
  rep(i, 1, n) {
    S[i][i] = 1;
    per(j, m, 1) {
      if (S[i][x[j]] && S[i][y[j]]) {
        ban[i] = 1;
        break;
      } else if (S[i][x[j]])
        S[i][y[j]] = 1;
      else if (S[i][y[j]])
        S[i][x[j]] = 1;
    }
  }
  rep(i, 1, n) rep(j, i + 1, n) if (!ban[i] && !ban[j] && (S[i] & S[j]) == 0u)
      ans++;
  cout << ans << endl;
  return 0;
}