Problem p03615 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL << 29;
const ll mod = 998244353;
#define rep(i, n) for (int(i) = 0; (i) < (ll)(n); ++(i))
#define repd(i, n, d) for (ll(i) = 0; (i) < (ll)(n); (i) += (d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair((x), (y))
#define mset(m, v) memset((m), (v), sizeof(m))
#define chmin(X, Y) ((X) > (Y) ? X = (Y), true : false)
#define chmax(X, Y) ((X) < (Y) ? X = (Y), true : false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end())
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  int n = v.size();
  rep(i, n) os << v[i] << (i == n - 1 ? "" : " ");
  return os;
}
#define N 210
int x[N], y[N];
ll c[N][N];
map<P, bool> used[N];

int comb(int n, int k) {
  if (c[n][k])
    return c[n][k];
  if (k == n || k == 0)
    return c[n][k] = 1;
  return c[n][k] = (comb(n - 1, k - 1) + comb(n - 1, k)) % mod;
}

int main() {
  int n;
  cin >> n;
  ll res = -(1 + n + n * (n - 1) / 2), t = 1;
  int m = n;
  while (m--)
    (t <<= 1) %= mod;
  res += t;
  rep(i, n) { cin >> x[i] >> y[i]; }
  rep(i, n) for (int j = i + 1; j < n; j++) {
    int cnt = 2;
    int xx = x[j] - x[i], yy = y[j] - y[i];
    int g = __gcd(xx, yy);
    xx /= g;
    yy /= g;
    if (xx < 0) {
      xx *= -1;
      yy *= -1;
    }
    P p = P(xx, yy);
    if (used[i][p])
      continue;
    used[i][p] = used[j][p] = true;
    for (int k = j + 1; k < n; k++) {
      int xx2 = x[k] - x[i], yy2 = y[k] - y[j];
      int g2 = __gcd(xx2, yy2);
      xx2 /= g2;
      yy2 /= g2;
      if (xx2 < 0) {
        xx2 *= -1;
        yy2 *= -1;
      }
      P p2 = P(xx2, yy2);
      if (used[k][p2])
        continue;
      if (xx == xx2 && yy == yy2) {
        used[k][p2] = true;
        cnt++;
      }
    }
    for (int k = 3; k <= cnt; k++) {
      (res -= comb(cnt, k)) %= mod;
    }
    cerr << cnt << endl;
  }
  cout << (res + mod) % mod << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL << 29;
const ll mod = 998244353;
#define rep(i, n) for (int(i) = 0; (i) < (ll)(n); ++(i))
#define repd(i, n, d) for (ll(i) = 0; (i) < (ll)(n); (i) += (d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair((x), (y))
#define mset(m, v) memset((m), (v), sizeof(m))
#define chmin(X, Y) ((X) > (Y) ? X = (Y), true : false)
#define chmax(X, Y) ((X) < (Y) ? X = (Y), true : false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end())
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  int n = v.size();
  rep(i, n) os << v[i] << (i == n - 1 ? "" : " ");
  return os;
}
#define N 210
int x[N], y[N];
ll c[N][N];
map<P, bool> used[N];

int comb(int n, int k) {
  if (c[n][k])
    return c[n][k];
  if (k == n || k == 0)
    return c[n][k] = 1;
  return c[n][k] = (comb(n - 1, k - 1) + comb(n - 1, k)) % mod;
}

int main() {
  int n;
  cin >> n;
  ll res = -(1 + n + n * (n - 1) / 2), t = 1;
  int m = n;
  while (m--)
    (t <<= 1) %= mod;
  res += t;
  rep(i, n) { cin >> x[i] >> y[i]; }
  rep(i, n) for (int j = i + 1; j < n; j++) {
    int cnt = 2;
    int xx = x[j] - x[i], yy = y[j] - y[i];
    int g = __gcd(xx, yy);
    xx /= g;
    yy /= g;
    if (xx < 0) {
      xx *= -1;
      yy *= -1;
    }
    P p = P(xx, yy);
    if (used[i][p])
      continue;
    used[i][p] = used[j][p] = true;
    for (int k = j + 1; k < n; k++) {
      int xx2 = x[k] - x[i], yy2 = y[k] - y[i];
      int g2 = __gcd(xx2, yy2);
      xx2 /= g2;
      yy2 /= g2;
      if (xx2 < 0) {
        xx2 *= -1;
        yy2 *= -1;
      }
      P p2 = P(xx2, yy2);
      if (used[k][p2])
        continue;
      if (xx == xx2 && yy == yy2) {
        used[k][p2] = true;
        cnt++;
      }
    }
    for (int k = 3; k <= cnt; k++) {
      (res -= comb(cnt, k)) %= mod;
    }
    cerr << cnt << endl;
  }
  cout << (res + mod) % mod << endl;
  return 0;
}