With this new code, I receive the same anwsers as statefull's had tested before -with the exception of the 787843 case, that seems not to finish... #include <stdio.h> using namespace std; int main() { unsigned long int i, j, n; while (scanf("%ld %ld",&i,&j)==2) { unsigned long int...