#include <iostream>
#include <stdexcept>
#include <limits>

int multiply(int a, int b) {
    if (a > 0 && b > 0 && a > (std::numeric_limits<int>::max() / b)) {
        throw std::overflow_error("Overflow detected");
    }
    return a * b;
}

int main() {
    try {
        int x = 50000;
        int y = 50000;
        int result = multiply(x, y);
        std::cout << "Result: " << result << std::endl;
    } catch (const std::overflow_error& e) {
        std::cout << "Error: " << e.what() << std::endl;
    }

    return 0;
}
