Problem p02868 (C++)

Buggy submission (status: Runtime Error):
#include "./bits/stdc++.h"

#include <iostream>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define linf 122337203685477000

using namespace std;

typedef long long ll;

/*
vector.push_back()
vector<int> hoge(3,-1); {-1,-1,-1}
vector<vector<int>> hogehoge(2,vector<int>(2,-1)); {{-1,-1},{-1,-1}}
cin >>temp;
scanf("%d %d %d",&A,&B,&Q);
sort(a.begin(),a.end());
a.push_back(4000000000000);
a.insert(a.begin(),-1000000000000);
upper_bound(a.begin(),a.end(),x); // list[i] > x のイテレータ取得. *itrで数値化
    std::priority_queue<
      int,
      std::vector<int>,
      decltype(compare) // 比較関数オブジェクトを指定
    > que(comp);
*/
template <typename T> void debug(T arr);
template <typename T> void debug(T arr, int dim);

vector<long long> dijkstra(int n, int start,
                           vector<vector<pair<long long, long long>>> &edge) {
  vector<long long> shortest(n, linf);
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      que;
  shortest[start] = 0LL;
  que.push(pair<long long, long long>(0, start));
  while (!que.empty()) {
    pair<long long, long long> now = que.top();
    que.pop();
    long long v = now.second;
    if (shortest[v] < now.first) {
      continue;
    } else {
      for (int i = 0; i < edge[v].size(); ++i) {
        long long to = edge[v][i].first;
        long long cost = edge[v][i].second;
        long long new_cost = shortest[v] + cost;
        if (new_cost < shortest[to]) {
          shortest[to] = new_cost;
          que.push(pair<long long, long long>(new_cost, to));
        }
      }
    }
  }
  return shortest;
}

int main(void) {
  ll n, m;
  ll l, r, c;
  cin >> n >> m;
  vector<vector<ll>> arr(n, vector<ll>(n, linf));
  vector<vector<pair<long long, long long>>> edge;
  edge.push_back({});
  for (int i = 1; i < n; ++i) {
    vector<pair<long long, long long>> temp;
    temp = {pair<long long, long long>(i - 1, 0)};
    edge.push_back(temp);
  }

  for (int i = 0; i < m; ++i) {
    scanf("%lld %lld %lld", &l, &r, &c);
    edge[l - 1].push_back(pair<long long, long long>(r - 1, c));
  }

  vector<long long> shortest;
  shortest = dijkstra(n, 0, edge);

  if (shortest[n - 1] == linf) {
    cout << -1 << endl;
  } else {
    cout << shortest[n - 1] << endl;
  }
};

template <typename T> void debug(T arr) {
  for (auto col : arr) {
    cout << col << " ";
  }
  cout << endl;
};

template <typename T> void debug(T arr, int dim) {
  for (auto raw : arr) {
    for (auto col : raw) {
      cout << col << " ";
    }
    cout << endl;
  }
};


Fixed submission:
#include "./bits/stdc++.h"

#include <iostream>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define linf 122337203685477000

using namespace std;

typedef long long ll;

/*
vector.push_back()
vector<int> hoge(3,-1); {-1,-1,-1}
vector<vector<int>> hogehoge(2,vector<int>(2,-1)); {{-1,-1},{-1,-1}}
cin >>temp;
scanf("%d %d %d",&A,&B,&Q);
sort(a.begin(),a.end());
a.push_back(4000000000000);
a.insert(a.begin(),-1000000000000);
upper_bound(a.begin(),a.end(),x); // list[i] > x のイテレータ取得. *itrで数値化
    std::priority_queue<
      int,
      std::vector<int>,
      decltype(compare) // 比較関数オブジェクトを指定
    > que(comp);
*/
template <typename T> void debug(T arr);
template <typename T> void debug(T arr, int dim);

vector<long long> dijkstra(int n, int start,
                           vector<vector<pair<long long, long long>>> &edge) {
  vector<long long> shortest(n, linf);
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      que;
  shortest[start] = 0LL;
  que.push(pair<long long, long long>(0, start));
  while (!que.empty()) {
    pair<long long, long long> now = que.top();
    que.pop();
    long long v = now.second;
    if (shortest[v] < now.first) {
      continue;
    } else {
      for (int i = 0; i < edge[v].size(); ++i) {
        long long to = edge[v][i].first;
        long long cost = edge[v][i].second;
        long long new_cost = shortest[v] + cost;
        if (new_cost < shortest[to]) {
          shortest[to] = new_cost;
          que.push(pair<long long, long long>(new_cost, to));
        }
      }
    }
  }
  return shortest;
}

int main(void) {
  ll n, m;
  ll l, r, c;
  cin >> n >> m;
  vector<vector<pair<long long, long long>>> edge;
  edge.push_back({});
  for (int i = 1; i < n; ++i) {
    vector<pair<long long, long long>> temp;
    temp = {pair<long long, long long>(i - 1, 0)};
    edge.push_back(temp);
  }

  for (int i = 0; i < m; ++i) {
    scanf("%lld %lld %lld", &l, &r, &c);
    edge[l - 1].push_back(pair<long long, long long>(r - 1, c));
  }

  vector<long long> shortest;
  shortest = dijkstra(n, 0, edge);

  if (shortest[n - 1] == linf) {
    cout << -1 << endl;
  } else {
    cout << shortest[n - 1] << endl;
  }
};

template <typename T> void debug(T arr) {
  for (auto col : arr) {
    cout << col << " ";
  }
  cout << endl;
};

template <typename T> void debug(T arr, int dim) {
  for (auto raw : arr) {
    for (auto col : raw) {
      cout << col << " ";
    }
    cout << endl;
  }
};