[ C++ ], Beats 100% on space and time
\n\t#define pi pair<int, int>\n    const int mod = 1e9+7;\n    vector<int> dis, vis, dp;\n    vector<vector<pi>> g;\n    int n;\n\t\n    // FIND SHORTEST PATH F
```\n\t#define pi pair<int, int>\n    const int mod = 1e9+7;\n    vector<int> dis, vis, dp;\n    vector<vector<pi>> g;\n    int n;\n\t\n    // FIND SHORTEST PATH FROM \'n\' to ALL OTHER NODES\n    void dijkstra(int u) {\n        priority_queue<pi, vector<pi>, greater<pi>> pq;\n        dis[u] = 0;\n        pq.push({0, u});\n\n        while(!pq.empty()) {\n            int u = pq.top().second;\n            pq.pop();\n            \n            if(vis[u]) {\n                continue;\n            }\n            vis[u] = 1;\n            for(auto p: g[u]) {\n                int v = p.first, w = p.second;\n                if(dis[u] + w < dis[v]) {\n                    dis[v] = dis[u] + w;\n                    pq.push({dis[v], v});\n                }\n            }\n        }\n    }\n    \n\t// FIND PATHS WITH DECREASING DISTANCES TO \'n\'\n    int dfs(int u) {\n        if(u == n) {\n            return 1;\n        }\n        if(dp[u] != -1) {\n            return dp[u];\n        }\n        \n        dp[u] = 0;\n        for(auto p: g[u]) {\n            int v = p.first;\n            if(dis[v] < dis[u]) {\n                dp[u] = (dp[u] + dfs(v)) % mod;\n            }\n        }\n        return dp[u];\n    }\n    \n    int countRestrictedPaths(int n, vector<vector<int>>& edges) {\n        this->n = n;\n        dis.assign(n+1, INT_MAX);\n        vis.assign(n+1, 0);\n        g.assign(n+1, vector<pi>());\n\n        for(auto e: edges) {\n            int u = e[0], v = e[1], w = e[2];\n            g[u].push_back({v, w});\n            g[v].push_back({u, w});\n        }\n        \n        dijkstra(n);\n        dp.assign(n+1, -1);\n        return dfs(1);\n    }\n```
['Dynamic Programming', 'Depth-First Search', 'Shortest Path']