private static int multiply(int x, int y) { long res = (long)x * (long)y; if (res > int.MaxValue) return 0; return (int)res; }