Problem p02703 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n) for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int64_t ss[51][2501];
bool ms[51][2501];

struct R {
  int i;
  int64_t v;
  int64_t p;
};

struct C {
  int64_t t;
  int64_t v;
  int64_t p;
  vector<R> rs;
};

struct S {
  int c;
  int v;
  int64_t p;
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(20);

  int n, m;
  cin >> n >> m;
  int64_t is;
  cin >> is;

  vector<C> cs(n + 1);
  FOR_LT(i, 0, m) {
    int u, v;
    cin >> u >> v;
    int64_t a, b;
    cin >> a >> b;
    cs[u].rs.push_back({v, a, b});
    cs[v].rs.push_back({u, a, b});
  }
  FOR_LT(i, 0, n) {
    int64_t a, b;
    cin >> a >> b;
    cs[i + 1].v = a;
    cs[i + 1].p = b;
  }

  auto comp = [](const S &lhs, const S &rhs) { return lhs.p > rhs.p; };
  priority_queue<S, std::vector<S>, decltype(comp)> search(comp);
  search.push({1, (int)min(is, (int64_t)2500), 0});
  while (!search.empty()) {
    S s = search.top();
    search.pop();
    if (ms[s.c][s.v])
      continue;
    ms[s.c][s.v] = true;
    ss[s.c][s.v] = s.p;

    auto &c = cs[s.c];
    for (auto &r : c.rs) {
      if (s.v < r.v)
        continue;
      if (ms[r.i][s.v - r.v])
        continue;
      search.push({r.i, (int)(s.v - r.v), s.p + r.p});
    }

    search.push({s.c, (int)(min(s.v + c.v, (int64_t)2500)), s.p + c.p});
  }

  FOR_LE(i, 2, n) {
    int64_t ans = INT64_MAX;
    FOR_LT(j, 0, 2501) {
      if (ss[i][j] == 0)
        continue;
      ans = min(ans, ss[i][j]);
    }
    cout << ans << endl;
  }

  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n) for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int64_t ss[51][2501];
bool ms[51][2501];

struct R {
  int i;
  int64_t v;
  int64_t p;
};

struct C {
  int64_t t;
  int64_t v;
  int64_t p;
  vector<R> rs;
};

struct S {
  int c;
  int v;
  int64_t p;
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(20);

  int n, m;
  cin >> n >> m;
  int64_t is;
  cin >> is;

  vector<C> cs(n + 1);
  FOR_LT(i, 0, m) {
    int u, v;
    cin >> u >> v;
    int64_t a, b;
    cin >> a >> b;
    cs[u].rs.push_back({v, a, b});
    cs[v].rs.push_back({u, a, b});
  }
  FOR_LT(i, 0, n) {
    int64_t a, b;
    cin >> a >> b;
    cs[i + 1].v = a;
    cs[i + 1].p = b;
  }

  auto comp = [](const S &lhs, const S &rhs) { return lhs.p > rhs.p; };
  priority_queue<S, std::vector<S>, decltype(comp)> search(comp);
  search.push({1, (int)min(is, (int64_t)2050), 0});
  while (!search.empty()) {
    S s = search.top();
    search.pop();
    if (ms[s.c][s.v])
      continue;
    ms[s.c][s.v] = true;
    ss[s.c][s.v] = s.p;

    auto &c = cs[s.c];
    for (auto &r : c.rs) {
      if (s.v < r.v)
        continue;
      if (ms[r.i][s.v - r.v])
        continue;
      search.push({r.i, (int)(s.v - r.v), s.p + r.p});
    }

    search.push({s.c, (int)(s.v + c.v), s.p + c.p});
  }

  FOR_LE(i, 2, n) {
    int64_t ans = INT64_MAX;
    FOR_LT(j, 0, 2501) {
      if (ss[i][j] == 0)
        continue;
      ans = min(ans, ss[i][j]);
    }
    cout << ans << endl;
  }

  return 0;
}