Problem:
Score : 100 points

Problem Statement

There are S sheep and W wolves.

If the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.

If the wolves will attack the sheep, print unsafe; otherwise, print safe.

Constraints

1 \leq S \leq 100

1 \leq W \leq 100

Input

Input is given from Standard Input in the following format:

S W

Output

If the wolves will attack the sheep, print unsafe; otherwise, print safe.

Sample Input 1

4 5

Sample Output 1

unsafe

There are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.

Sample Input 2

100 2

Sample Output 2

safe

Many a sheep drive away two wolves.

Sample Input 3

10 10

Sample Output 3

unsafe

Solution in C++ (GCC 9.2.1) (judge verdict: Runtime Error)

#include <bits/stdc++.h>
using namespace std;

const int LIM = 2500;
const long long INF = (long long) 1e18;

int C[55], D[55];
int done[55][2505];
long long SP[55][2505];

vector< vector<int> > X[55];
priority_queue< vector<int>, vector< vector<int> >, greater< vector<int> > > Q;

void relax(int ux, int uy, int vx, int vy, int w)
{
    if(SP[vx][vy] > SP[ux][uy] + w)
    {
        SP[vx][vy] = SP[ux][uy] + w;
        Q.push({SP[vx][vy], vx, vy});
    }
}

int main() {
    int n, m, s;
    cin >> n >> m >> s;

    while(m--)
    {
        int u, v, a, b;
        cin >> u >> v >> a >> b;

        X[u].push_back({v, a, b});
        X[v].push_back({u, a, b});
    }

    for (int i=1; i<=n; i++)
        cin >> C[i] >> D[i];

    for (int i=1; i<=n; i++)
        for (int j=0; j<=LIM; j++)
            SP[i][j] = INF;
    
    s = min(s, LIM);
    SP[1][s] = 0;
    Q.push({SP[1][s], 1, s});

    while(!Q.empty()) {
        auto q = Q.top();
        Q.pop();

        int indx = q[1], coins = q[2];

        if(done[indx][coins])
            continue;
        
        done[indx][coins] = 1;

        for (int i=1; coins+i<=LIM && i<=C[indx]; i++)
            if (!done[indx][coins+i])
                relax(indx, coins, indx, coins + i, D[indx]);
        
        for (auto x : X[indx])
            if (x[1] <= coins && !done[ x[0] ][ coins - x[1] ])
                relax(indx, coins, x[0], coins - x[1], x[2]);
    }

    for (int i=2; i<=n; i++)
        cout << *min_element(SP[i], SP[i]+LIM+1) << "\n";

    return 0;
}