In some problems, edge weights are up to and paths can have edges. Maximum distance = . This exceeds -bit integer range (). Use long long in C++ or -bit integers in other languages.
Also set initially to a value larger than any possible path, like . Using as "infinity" might not be enough. If you add two distances during relaxation, overflow can silently produce wrong answers.