alexjercan/bugnet huggingface dataset:
Problem p02553 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(void) {
  ll a, b, c, d;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
  ll ans = max(max(a * c, a * d), max(b * c, b * d));
  printf("%lld", ans);
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 1e6 + 5;
const int mod = 1e9 + 7;

inline void add_mod(int &a, int b) {
  if ((a + b) >= mod)
    a -= mod;
}

ll f[MAXN][2][2];

int main(void) {
  int n;
  scanf("%d", &n);

  f[0][0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    f[i][0][0] = f[i - 1][0][0] * 8 % mod;
    f[i][0][1] = (f[i - 1][0][1] * 9 + f[i - 1][0][0]) % mod;
    f[i][1][0] = (f[i - 1][1][0] * 9 + f[i - 1][0][0]) % mod;
    f[i][1][1] = (f[i - 1][1][1] * 10 + f[i - 1][0][1] + f[i - 1][1][0]) % mod;
  }
  printf("%lld", f[n][1][1]);
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Runtime Error

// Keep calm and carry on..

/*  Problem :
    URL :

*/

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define pb push_back
#define pi 3.1415926535897932384626
#define mod 1000000007
#define endl '\\n'
#define DEBUG false
#define F first
#define S second
#define loop1(i, a, b) for (ll i = a; i < b; i++)
#define loop2(i, a, b) for (ll i = b - 1; i >= a; i--)
#pragma GCC optimize "trapv"

int main() {
  fast;
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  if (((b * d) > 0) || ((a * c) > 0))
    cout << max(b * d, a * c);
  else {
    if (b * d < 0) {
      cout << max(a * d, c * b);
    } else
      cout << 0;
  }

  return 0;
}


Error: WA

Fixed submission:

// Keep calm and carry on..

/*  Problem :
    URL :

*/

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define pb push_back
#define pi 3.1415926535897932384626
#define mod 1000000007
#define endl '\\n'
#define DEBUG false
#define F first
#define S second
#define loop1(i, a, b) for (ll i = a; i < b; i++)
#define loop2(i, a, b) for (ll i = b - 1; i >= a; i--)
#pragma GCC optimize "trapv"

int main() {
  fast;
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = 1, y = 1;
  if (((b * d) > 0) || ((a * c) > 0))
    cout << max(b * d, a * b);
  else {
    cout << a * c;
  }

  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <vector>
using namespace std;
int main() {

  // B
  long long int a, b, c, d;
  cin >> a >> b >> c >> d;

  long long int x[4];
  x[0] = a * c;
  x[1] = a * d;
  x[2] = b * c;
  x[3] = b * d;
  sort(x, x + 4);

  /*if (x[0] >= x[1] && x[0] >= x[2] && x[0] >= x[3]) {
          cout << x[0] << endl;
  }
  else if (x[1] >= x[0] && x[1] >= x[2] && x[1] >= x[3]) {
          cout << x[1] << endl;
  }
  else if (x[2] >= x[0] && x[2] >= x[1] && x[2] >= x[3]) {
          cout << x[2] << endl;
  }
  else {
          cout << x[3] << endl;

  }*/

  cout << x[3] << endl;

  return 0;

  // A
  /*int x;
  cin >> x;
  if (x == 1) {
          cout << 0;
  }
  else {
          cout << 1;
  }
  cout << endl;
  return 0;
  */
}

Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <vector>
using namespace std;
int main() {

  // B
  long long int a, b, c, d;
  cin >> a >> b >> c >> d;

  long long int x[3];
  x[0] = a * c;
  x[1] = a * d;
  x[2] = b * c;
  x[3] = b * d;
  sort(x, x + 4);
  cout << x[3] << endl;
  return 0;

  // A
  /*int x;
  cin >> x;
  if (x == 1) {
          cout << 0;
  }
  else {
          cout << 1;
  }
  cout << endl;
  return 0;
  */
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>
using namespace std;

int main(void) {
  long long int a, b, c, d, output1, output2, output3, output4, output;
  cin >> a >> b >> c >> d;

  output1 = a * c;
  output2 = a * d;
  output3 = b * c;
  output4 = b * d;

  output = output1;
  if (output1 < output2) {
    output = output2;
  }
  if (output < output3) {
    output = output3;
  }
  if (output < output4) {
    output = output4;
  }

  cout << output << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

int main(void) {
  int a, b, c, d, output;
  cin >> a >> b >> c >> d;
  output = a * c;
  for (int i = a; i <= b; i++) {
    for (int j = c; j <= d; j++) {
      if (output < i * j) {
        output = i * j;
      }
    }
  }
  cout << output << endl;
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans0 = a * c;
  long long ans1 = a * d;
  long long ans2 = b * c;
  long long ans3 = b * d;
  long long ans = max(ans0, max(ans1, max(ans2, ans3)));

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = a * c;
  for (int i = a; i <= b; i++) {
    for (int j = c; j <= d; j++)
      ans = max(ans, i * j);
  }
  cout << ans << endl;

  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {
  long a, b, c, d;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cout << max({a * c, b * d, a * d, b * c}) << endl;
  return 0;
}

Error: 2

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  long a, b, c, d;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  return b * d;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

//
// ABC178 B - Product Max
//

/*
a,b,c,d の絶対値が大きいため、x や
yの値を全通り試すとTLE(実行時間超過)の不正解になってしまいます。
ここでは、候補を絞ることで実行時間に間に合うようにする方法を紹介します。
x×yは y を定数としたとき、 x の一次関数になります。
一次関数の性質より、x がある範囲の中を動くとき、
必ず、x が範囲の左端にあるときと右端にあるときの少なくとも一方で x×y
は最大になります。 （グラフを書いてみると分かりやすいです。） これは y
がどんな値のときでも成り立つため、x=a のケースと
x=bのケースだけ考えれば良いです。 今度は xを定数とすると、同様に、 y=c
のケースと y=dのケースだけ考えれば良いことがわかります。 したがって (x,y)が
(a,c),(a,d),(b,c),(b,d) のケースだけを考えれば良くなり、
a×c,a×d,b×c,b×dの最大値を出力すれば正解できます。
また、a,b,c,dの絶対値が最大で 109 であるため、答えは最大で 1018 になります。
32 ビット整数型（C++であればint型）に収まらないため、64
ビット整数型（C++であればlong long型）などを使うと良いです。
*/

#include <bits/stdc++.h>

using namespace std;

int main() {
  // 標準入力から値を受け取る。
  long long a, b, c, d;
  cin >> a >> b >> c >> d;

  // x * y の最大値を求める
  // ４パターンのうちの最大→最大値
  long long val_max = 0;
  val_max = max(max(a * c, a * d), max(b * c, b * d));

  // 標準出力に結果を出力する。
  cout << val_max << endl;

  // 戻り値
  return (0);
}

Error: TLE

Fixed submission:

//
// ABC178 B - Product Max
//

#include <bits/stdc++.h>

using namespace std;

int main() {
  // 標準入力から値を受け取る。
  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;

  // x * y の最大値を求める
  int64_t val_now = 0;
  int64_t val_max = pow(10, 18) * -1;
  if ((0 <= a) && (0 <= c)) {
    // 常に+同士の掛け算
    // 最大値同士→最大値
    val_max = b * d;
  } else if ((b <= 0) && (d <= 0)) {
    // 常に-の掛け算
    // 最小値同士→最大値
    val_max = a * c;
  } else if ((a <= 0) && (b <= 0) && (0 <= c) && (0 <= d)) {
    // -と+の掛け算
    // 最大と最小→最大値
    val_max = b * c;
  } else if ((0 <= a) && (0 <= b) && (c <= 0) && (d <= 0)) {
    // +と-の掛け算
    // 最小と最大→最大値
    val_max = a * d;
  } else {
    // その他の掛け算
    for (int x = a; x <= b; x++) {
      for (int y = c; y <= d; y++) {
        // x * y を計算する
        val_now = x * y;

        // val_max < val_now なら、最大値を更新する。
        if (val_max < val_now) {
          val_max = val_now;
        }
      }
    }
  }

  // 標準出力に結果を出力する。
  cout << val_max << endl;

  // 戻り値
  return (0);
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  long long int a, b, c, d;
  cin >> a >> b >> c >> d;

  long long int ans = a * c;
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);

  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int max = a * c;
  for (int i = a; i <= b; i++) {
    for (int j = c; j <= d; j++) {
      if (max < i * j) {
        max = i * j;
      }
    }
  }

  cout << max << endl;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << max({a * c, a * d, b * c, b * d}) << endl;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;

  long long max = a * c;

  for (long long x = a; x <= b; x++) {
    for (long long y = c; y <= d; y++) {
      if (max < x * y) {
        max = x * y;
      }
    }
  }

  cout << max << endl;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
#define mod pow(10, 9) + 7
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = max(max(a * c, a * d), max(b * c, b * d));
  cout << ans;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
#define mod pow(10, 9) + 7
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  ll p = INT_MIN;
  ll p1 = 0;
  int k = max(a, b);
  for (int i = min(a, b); i <= k; i++) {
    for (int j = min(c, d); j <= max(c, d); j++) {
      p1 = i * j;
      if (p < p1) {
        p = p1;
      }
    }
  }
  cout << p << '\\n';

  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d, i, j, p, m, s;
  cin >> a >> b >> c >> d;
  long long w, x, y, z;
  w = a * c;
  x = b * c;
  y = a * d;
  z = b * d;
  p = max(w, x);
  m = max(p, y);
  s = max(m, z);
  cout << s;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d, i, j, p, m, s;
  cin >> a >> b >> c >> d;
  long long h = a * c;
  for (i = a; i <= b; i++) {
    for (j = c; j <= d; j++) {
      p = i * j;
      if (p > h) {
        h = p;
      }
    }
  }
  cout << h;
}
Problem p02553 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d, ac, ad, bc, bd;
  cin >> a >> b >> c >> d;
  ac = a * c;
  ad = a * d;
  bc = b * c;
  bd = b * d;
  cout << max(ac, max(ad, max(bc, bd)));
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>

using namespace std;

#define SIZE 50 // Defining max size of array

int main()

{
  int array[SIZE];
  int i, max, min, size;
  // Input size of the array
  cout << "Enter size of the array: ";
  cin >> size;
  // Input array elements
  cout << "\\n Enter " << size << " elements in the array: ";
  for (i = 0; i < size; i++)
    cin >> array[i];
  // Assume first element as maximum and minimum
  max = array[0];
  min = array[0];
  // Find maximum and minimum in all array elements.
  for (i = 1; i < size; i++) {
    // If current element is greater than max
    if (array[i] > max)
      max = array[i];
    // If current element is smaller than min
    if (array[i] < min)
      min = array[i];
  }
  // Print maximum and minimum element
  cout << max * min;
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pvllvll pair<vector<ll>, vector<ll>>
#define ld long double
#define veci vector<int>
#define vecll vector<ll>

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

void solve() {
  ll a[4];
  cin >> a[0] >> a[1] >> a[2] >> a[3];
  ll ans = -1e18;
  ans = max(ans, a[0] * a[2]);
  ans = max(ans, a[0] * a[3]);
  ans = max(ans, a[1] * a[2]);
  ans = max(ans, a[1] * a[3]);
  cout << ans;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  /// cin >> T;
  while (T--)
    solve(), cout << '\\n';
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pvllvll pair<vector<ll>, vector<ll>>
#define ld long double
#define veci vector<int>
#define vecll vector<ll>

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

void solve() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a >= 0 && c >= 0) {
    cout << b * d;
    return;
  }
  if (b <= 0 && d <= 0) {
    cout << a * c;
    return;
  }
  if (a >= 0 && d <= 0) {
    cout << a * d;
    return;
  }
  if (b <= 0 && c >= 0) {
    cout << b * c;
    return;
  }
  assert(0);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  /// cin >> T;
  while (T--)
    solve(), cout << '\\n';
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

int main() {
  long long a, b, c, d;

  cin >> a >> b >> c >> d;

  long long ans = -1000000000000000000;

  long long cnt[4] = {a * c, a * d, b * c, b * d};

  for (long long i = 0; i < 4; i++)
    ans = max(ans, cnt[i]);

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  long long a, b, c, d;

  cin >> a >> b >> c >> d;

  long long ans = -1000000000000000000;

  for (long long i = a; i <= b; i++) {
    for (long long j = c; j <= d; j++) {
      long long cnt = i * j;
      ans = max(cnt, ans);
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded



#include <bits/stdc++.h>
#include <string.h>
#include <vector>
// s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define inf 0x3f3f3f3f
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i / 3][i % 3]

int main() {

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll ans = max(a * c, max(a * d, max(b * c, b * d)));

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:



#include <bits/stdc++.h>
#include <string.h>
#include <vector>
// s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define inf 0x3f3f3f3f
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i / 3][i % 3]

long long int mulmod(long long int a, long long int b) {
  if (MOD <= 1000000009)
    return ((a % MOD) * (b % MOD)) % MOD;

  long long int res = 0;
  while (a > 0) {
    if (a & 1) {
      res += b;
      if (res >= MOD)
        res -= MOD;
    }
    a >>= 1;
    b <<= 1;
    if (b >= MOD)
      b -= MOD;
  }
  return res;
}

int main() {

  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;

  int64_t maxi = INT_MIN;

  for (ll x = a; x <= b; x++) {
    for (ll y = c; y <= d; y++) {
      // long long int ans = mulmod(x,y);
      int64_t ans = mulmod(x, y);
      if (ans > maxi)
        maxi = ans;
    }
  }

  cout << maxi << endl;

  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
long long max(long long a, long long b, long long c, long long d) {
  if (a > b) {
    if (a > c) {
      if (a > d) {
        return a;
      } else {
        return d;
      }
    } else {
      if (c > d) {
        return c;
      } else {
        return d;
      }
    }
  } else {
    if (b > c) {
      if (b > d) {
        return b;
      } else {
        return d;
      }
    } else {
      if (c > d) {
        return c;
      } else {
        return d;
      }
    }
  }
}

int main() {
  long long a, b, c, d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

  printf("%lld", max(a * c, a * d, b * c, b * d));
  return 0;
}


Error: -11

Fixed submission:

#include <stdio.h>
long long max(long long a, long long b, long long c, long long d) {
  if (a > b) {
    if (a > c) {
      if (a > d) {
        return a;
      } else {
        return d;
      }
    } else {
      if (c > d) {
        return c;
      } else {
        return d;
      }
    }
  } else {
    if (b > c) {
      if (b > d) {
        return b;
      } else {
        return d;
      }
    } else {
      if (c > d) {
        return c;
      } else {
        return d;
      }
    }
  }
}

int main() {
  long long a, b, c, d;
  scanf("%lld %lld %lld %lld");

  printf("%lld", max(a * c, a * d, b * c, b * d));
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  long long int a[4], max = -1000000000000000000;
  cin >> a[0] >> a[1] >> a[2] >> a[3];
  for (int i = 0; i < 2; i++) {
    for (int j = 2; j < 4; j++) {
      if (a[i] * a[j] > max)
        max = a[i] * a[j];
    }
  }
  printf("%lld\\n", max);
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int a, b, c, d;
  long long int max = -1000000000000000000;
  cin >> a >> b >> c >> d;
  for (int i = a; i <= b; i++) {
    for (int j = c; j <= d; j++) {
      if (i * j > max)
        max = i * j;
    }
  }
  printf("%d\\n", max);
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
using namespace std;

int main() {
  long long a, b, c, d;
  long long e, f, g, h;
  long long max = -1000000000;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
  max = a * c;
  e = a * c;
  f = a * d;
  g = b * c;
  h = b * d;
  if (e <= f && g <= f && h <= f)
    max = f;
  else if (e <= g && f <= g && h <= g)
    max = g;
  else if (e <= h && f <= h && g <= h)
    max = h;
  printf("%lld", max);
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
using namespace std;

int main() {
  long long a, b, c, d;
  long long max = 0;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

  /*max = a * c;
  if (max < a * d)
      max = a * d;
  else if (max < b * c)
      max = b * c;
  else if(max < b* d)
      max = b * d;*/
  max = -1000000000;
  for (long long x = a; x <= b; x++)
    for (long long y = c; y <= d; y++) {
      if (max < x * y)
        max = x * y;
    }
  printf("%lld", max);
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;

  long long maxNum = -1000000000;
  for (long long x = a; x <= b; x++) {
    for (long long y = c; y <= d; y++) {
      maxNum = max(maxNum, x * y);
    }
  }
  cout << maxNum << endl;
}
Problem p02553 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll z = a * c;
  ll x = a * d;
  ll y = b * c;
  ll t = b * d;
  ll ans1 = max(x, y);
  ll ans2 = max(t, z);
  ll ans = max(ans1, ans2);
  cout << ans;
  return 0;
}


Error: WA

Fixed submission:

#include <iostream>
#define ll long long
using namespace std;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll z = max(a * c, a * d);
  ll y = max(b * c, b / d);
  ll ans = max(z, y);
  cout << ans;
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

// https://atcoder.jp/contests/abc178/tasks/abc178_b
#include <iostream>
#include <vector>
using namespace std;
#define ll long long int
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll mx = a * c;
  if (a <= 0 && c <= 0)
    mx = max(mx, a * c);
  if (b >= 0 && d >= 0)
    mx = max(mx, b * d);
  mx = max(mx, a * d);
  mx = max(mx, b * c);

  cout << mx << "\\n";
}

Error: TLE

Fixed submission:

// https://atcoder.jp/contests/abc178/tasks/abc178_b
#include <iostream>
#include <vector>
using namespace std;
#define ll long long int
int main() {
  ll a[5], b[5], ans;
  cin >> a[0] >> a[1] >> b[0] >> b[1];
  ll mx = (ll)(-1e10);
  for (ll i = a[0]; i <= a[1]; i++) {
    for (ll j = b[0]; j <= b[1]; j++) {
      ans = i * j;
      mx = max(ans, mx);
    }
  }

  cout << mx << "\\n";
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define intvec(name, size)                                                     \\
  vector<int> name;                                                            \\
  name.resize(size);
#define PI 3.14159265359
#define END "\\n"
using namespace std;

int main() {
  long long int a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<long long int> x = {a * c, a * d, b * c, b * d};
  sort(x.begin(), x.end());
  cout << x[3] << END;
  //////////////////////////////////
  //--------end--------
  //
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define intvec(name, size)                                                     \\
  vector<int> name;                                                            \\
  name.resize(size);
#define PI 3.14159265359
#define END "\\n"
using namespace std;

int main() {
  int ans = 0;
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  for (int i = a; i <= b; i++)
    for (int j = c; j <= d; j++)
      if (i * j > ans || ans == 0)
        ans = i * j;
  cout << ans << END;
  //////////////////////////////////
  //--------end--------
  //
  return 0;
}