Problem p03837 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for (int(i) = a; (i) < (b); ++(i))
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());              // 小さい順
#define rvsort(v) sort(v.begin(), v.end(), greater<int>()); // 大きい順
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define all(c) (c).begin(), (c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout << (p) << endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 1234567890

const int maxn = 1e5 + 10;

// initialization here
//
vi v;
//
// initialization finish

// your function is here
//

//
// your function finished

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  // your code is here
  //

  ll n, m;
  cin >> n >> m;
  ll dis[105][105];
  rep(i, n) rep(j, n) dis[i][j] = INF;
  rep(i, n) dis[i][i] = 0;
  ll aa[105], bb[105], cc[105];

  rep(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    aa[i] = a, bb[i] = b, cc[i] = c;
    dis[a][b] = c;
    dis[b][a] = c;
  }

  rep(k, n) rep(i, n) rep(j, n) {
    dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
  }

  ll count = 0;
  rep(i, m) if (dis[aa[i]][bb[i]] != cc[i]) count++;

  Print(count);
  //
  // your code finished
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for (int(i) = a; (i) < (b); ++(i))
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());              // 小さい順
#define rvsort(v) sort(v.begin(), v.end(), greater<int>()); // 大きい順
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define all(c) (c).begin(), (c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout << (p) << endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 1234567890

const int maxn = 1e5 + 10;

// initialization here
//
vi v;
//
// initialization finish

// your function is here
//

//
// your function finished

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  // your code is here
  //

  ll n, m;
  cin >> n >> m;
  ll dis[105][105];
  rep(i, n) rep(j, n) dis[i][j] = INF;
  rep(i, n) dis[i][i] = 0;
  ll aa[1005], bb[1005], cc[1005];

  rep(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    aa[i] = a, bb[i] = b, cc[i] = c;
    dis[a][b] = c;
    dis[b][a] = c;
  }

  rep(k, n) rep(i, n) rep(j, n) {
    dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
  }

  ll count = 0;
  rep(i, m) if (dis[aa[i]][bb[i]] != cc[i]) count++;

  Print(count);
  //
  // your code finished
  return 0;
}