alexjercan/bugnet huggingface dataset:
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;
  cout << max(max(a * c, a * d), max(b * c, b * d)) << "\\n";
}

Error: TLE

Fixed submission:

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

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

  int ans = -100000;
  for (int i = a; i < b + 1; i++) {
    for (int j = c; j < d + 1; j++) {
      ans = max(ans, i * j);
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  long int a, b, c, d, p, i, j;
  cin >> a >> b >> c >> d;
  p = a * c;
  for (i = a; i <= b; i = i + (b - a)) {
    for (j = c; j <= d; j = j + (d - c)) {
      if (p < (i * j))
        p = (i * j);
      if (j == d)
        break;
    }
    if (i == b)
      break;
  }
  cout << p;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long int a, b, c, d, p, i, j;
  cin >> a >> b >> c >> d;
  p = a * c;
  for (i = a; i <= b; i = i + (b - a)) {
    for (j = c; j <= d; j = j + (d - c)) {
      if (p < (i * j))
        p = (i * j);
      if (j == d)
        break;
    }
  }
  cout << p;
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d = 0;
  cin >> a >> b >> c >> d;
  int imax = -100000000;
  for (int i = a; i <= b; i++) {
    for (int j = c; j <= d; j++) {
      imax = max(imax, i * j);
    }
  }
  cout << imax;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  long long int a, b, c, d;
  scanf("%lld %lld %lld %lld\\n", &a, &b, &c, &d);
  long long int num = a * c;
  if (b * c > num) {
    num = b * c;
  }
  if (a * d > num) {
    num = a * d;
  }
  if (b * d > num) {
    num = b * d;
  }
  printf("%lld", num);
}


Error: TLE

Fixed submission:

#include <stdio.h>

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

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

Error: TLE

Fixed submission:

/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main() {
  int a, b, c, d;
  int p = INT_MIN;
  cin >> a >> b >> c >> d;
  for (int x = a; x <= b; x++)
    for (int y = c; y <= d; y++)
      p = max(p, x * y);
  cout << p;

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = a * c;
  // ans=max(ans,a*c);
  ans = max(ans, b * c);
  ans = max(ans, a * d);
  ans = max(ans, b * d);
  cout << ans;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = INT_MIN;
  // ans=max(ans,a*c);
  // ans=max(ans,b*c);
  // ans=max(ans,a*d);
  // ans=max(ans,b*d);
  for (ll i = min(a, b); i <= max(a, b); i++) {
    for (ll j = min(c, d); j <= max(c, d); j++) {
      ans = max(ans, i * j);
    }
  }
  cout << ans;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <iostream>
#define int long long int
#define e 1000000007
using namespace std;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  // cin>>t;
  while (t--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int a1 = a * c;
    int a2 = b * d;
    int a3 = a * d;
    int a4 = b * c;

    cout << max({a1, a2, a3, a4});
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
#define int long long int
#define e 1000000007
using namespace std;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  // cin>>t;
  while (t--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<int> v1;
    for (int i = a; i <= b; i++) {
      v1.push_back(i);
    }
    vector<int> v2;
    for (int i = c; i <= d; i++) {
      v2.push_back(i);
    }

    vector<int> m;
    for (int i = 0; i < v1.size(); i++) {
      for (int j = 0; j < v2.size(); j++) {
        m.push_back(v1[i] * v2[j]);
      }
    }

    cout << *max_element(m.begin(), m.end());
  }
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define IOS                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x, y) memset(x, y, sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = a; i >= (b); --i)
using namespace std;
int dt[][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {0, 0}};
// typedef pair<int, int> P;
// priority_queue<int, vector<int>, greater<int> > q;
int main() {
  IOS;
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll res1, res2, res3, res4;
  res1 = a * c;
  res2 = a * d;
  res3 = b * c;
  res4 = b * d;
  ll ans = -0x3f3f3f3f3f3f3f3f;
  ans = max(ans, res1);
  ans = max(ans, res2);
  ans = max(ans, res3);
  ans = max(ans, res4);
  if ((a <= 0 && b >= 0) || (c <= 0 && d >= 0))
    ans = max(ans, 1LL * 0);
  cout << ans;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define IOS                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x, y) memset(x, y, sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = a; i >= (b); --i)
using namespace std;
int dt[][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {0, 0}};
// typedef pair<int, int> P;
// priority_queue<int, vector<int>, greater<int> > q;
int main() {
  IOS;
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll res = -0x3f3f3f3f3f3f3f3f;
  rep(i, a, b) {
    rep(j, c, d) { res = max(res, 1LL * i * j); }
  }
  cout << res;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;

int main() {

  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;
  int64_t Max = -1000000000000000000;

  if (a < 0 && c < 0) {
    Max = max(Max, a * c);
  }
  if (b > 0 && d > 0) {
    Max = max(Max, b * d);
  }
  Max = max(Max, max(a * d, b * c));

  cout << Max << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;

int main() {

  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;
  int64_t Max = -1000000000;
  Max = a * c;

  for (int i = a; i <= b; i++) {
    for (int j = c; j <= d; j++) {
      if (i < 0 && j < 0) {
        Max = max(Max, (int64_t)(a * c));
        i = j = -1;
        continue;
      }
      if (i > 0 && j > 0) {
        Max = max(Max, (int64_t)(b * d));
        break;
      }
      Max = max(Max, (int64_t)(i * j));
    }
  }

  cout << Max << endl;

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

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define endl "\\n"
#define rep(i, a, n) for (int i = a; i < n; i++)
const int mod = 1e9 + 7;
void solve() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a == b and c == d) {
    cout << a * c;
  }
  // else if (b >= 0 and d >= 0) {
  // 	if (a > 0 and c > 0)
  // 		cout << b*d;
  // 	if (a < 0 and c < 0)
  // 		cout << max(a * c, b * d);
  // 	if ((a > 0 and c < 0) or (a<0 and c>0))
  // 		cout << b*d;
  // }
  else {
    int max1 = a * c;
    int max2 = a * d;
    max2 = max(max1, max2);
    max1 = b * c;
    max2 = max(max1, max2);
    max1 = b * d;
    max2 = max(max1, max2);
    cout << max2;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);
#endif
  int t;
  t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define endl "\\n"
#define rep(i, a, n) for (int i = a; i < n; i++)
const int mod = 1e9 + 7;
void solve() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a == b and c == d) {
    cout << a * c;
  } else if (b >= 0 and d >= 0) {
    if (a > 0 and c > 0)
      cout << b * d;
    if (a < 0 and c < 0)
      cout << max(a * c, b * d);
    if ((a > 0 and c < 0) or (a < 0 and c > 0))
      cout << b * d;
  }
  // else if (b > 0 and d < 0) {
  // 	cout << a*d;
  // }
  // else if (b<0 and d>0) {
  // 	cout << b*c;
  // }
  else {
    int max1 = INT_MIN;
    rep(i, a, b + 1) {
      rep(j, c, d + 1) { max1 = max(i * j, max1); }
    }
    cout << max1;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);
#endif
  int t;
  t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll x, y;
  ll maxi = -1e18;
  maxi = max({maxi, a * c, b * d, a * d, b * c});
  cout << maxi;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans1 = b * d;
  ll ans2 = b * d;
  ll x = b;
  ll y = d;
  ll ans3 = a * c;
  while (x > a) {
    x--;
    ans1 = max(ans1, x * d); // a<x<b; c<y<d
  }
  ans1 = max(ans1, ans3);
  while (y > c) {
    y--;
    ans2 = max(ans2, y * b);
  }
  ans2 = max(ans2, ans3);
  cout << max(ans1, ans2);
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long a, b, c, d;
  long long val, maxnum;
  cin >> a >> b >> c >> d;
  if (a >= 0) {
    if (c >= 0) {
      maxnum = b * d;
    } else if (c < 0 && d >= 0) {
      maxnum = b * d;
    } else if (d < 0) {
      maxnum = a * d;
    }
  } else if (a < 0 && b >= 0) {
    if (c >= 0) {
      maxnum = b * d;
    } else if (c < 0 && d >= 0) {
      maxnum = max(a * c, b * d);
    } else if (d < 0) {
      maxnum = a * c;
    }
  } else if (b < 0) {
    if (c >= 0) {
      maxnum = b * c;
    } else if (c < 0 && d >= 0) {
      maxnum = a * c;
    } else if (d < 0) {
      maxnum = a * c;
    }
  }
  cout << maxnum << endl;
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c, d, kei, kei1, kei2, kei3;
  cin >> a >> b >> c >> d;
  kei = a * c;
  kei1 = a * d;
  kei2 = b * c;
  kei3 = b * d;

  kei = max(kei, kei1);
  kei1 = max(kei2, kei3);
  cout << max({kei1, kei});
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c, d, kei, kei1;
  cin >> a >> b >> c >> d;
  kei1 = a * c;
  for (int i = a; i <= b; i++) {
    for (int m = c; m <= d; m++) {
      kei = i * m;
      if (kei > kei1) {
        kei1 = kei;
      }
    }
  }

  cout << max({kei1, kei});
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  long long int a, b, c, d;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  long long int prod[4];
  int i;
  prod[0] = a * c;
  prod[1] = a * d;
  prod[2] = b * c;
  prod[3] = b * d;
  long long int maxi = prod[0];
  for (i = 0; i < 4; i++) {
    if (maxi <= prod[i]) {
      maxi = prod[i];
    }
  }
  cout << maxi << endl;
  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<int> prod;
  int i;
  prod[0] = a * c;
  prod[1] = a * d;
  prod[2] = b * c;
  prod[3] = b * d;
  cout << max(max(prod[0], prod[1]), max(prod[2], prod[3])) << endl;
  /*for(i=0;i<4;i++){
          if(max>=prod[i]){
                  max = prod[i];
          }
  }
  cout << max << endl;
  */
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long int
#define FastIO                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
using namespace std;

int main(void) {
  FastIO;

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll p[4];
  p[0] = a * c;
  p[1] = a * d;
  p[2] = b * c;
  p[3] = b * d;
  sort(p, p + 4);
  cout << p[3];
  return 0;
}

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


Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
#define FastIO                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
using namespace std;

int main(void) {
  FastIO;

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll p[3];
  p[0] = a * c;
  p[1] = a * d;
  p[2] = b * c;
  p[3] = b * d;
  sort(p, p + 4);
  cout << p[3];
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
  ll a[4];
  cin >> a[0] >> a[1] >> a[2] >> a[3];
  vector<ll> b;
  b.push_back(a[0] * a[2]);
  b.push_back(a[0] * a[3]);
  b.push_back(a[1] * a[2]);
  b.push_back(a[1] * a[3]);
  sort(b.begin(), b.end());
  cout << b[3] << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
  ll a[4];
  while (1) {
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    vector<ll> b;
    b.push_back(a[0] * a[2]);
    b.push_back(a[0] * a[3]);
    b.push_back(a[1] * a[2]);
    b.push_back(a[1] * a[3]);
    sort(b.begin(), b.end());
    cout << b[3] << endl;
  }
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c, d;
  cin >> a >> b >> c >> d;
  long long int a1 = a * c;
  long long int a2 = a * d;
  long long int a3 = b * c;
  long long int a4 = b * d;
  long long int x = max(a1, a2);
  long long int y = max(a3, a4);
  long long int z = max(x, y);
  cout << z << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<long long int> v1;
  vector<long long int> v2;
  for (int i = a; i <= b; i++) {
    v1.push_back(i);
  }
  for (int i = c; i <= d; i++) {
    v2.push_back(i);
  }
  long long int res = v1[0] * v2[0];
  for (int i = 0; i < v1.size(); i++) {
    for (int j = 0; j < v2.size(); j++) {
      if (v1[i] * v2[j] >= res) {
        res = v1[i] * v2[j];
      }
    }
  }
  cout << res << endl;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>

using namespace std;

int main() {
  long long a, b, c, d, max;
  vector<long long> ans(4);
  cin >> a >> b >> c >> d;
  /*
  for (i = a; i <= b; i++)
  {
      for (j = c; j <= d; j++)
      {
          tmp = i * j;
          if (tmp >= max)
          {
              max = tmp;
          }
      }
  }
  */
  ans[0] = a * c;
  ans[1] = a * d;
  ans[2] = b * c;
  ans[3] = b * d;
  max = ans[0];
  for (int i = 0; i < 4; i++) {
    if (ans[i] >= max)
      max = ans[i];
  }
  cout << max << endl;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  long long a, b, c, d, max = -1e9;
  long long i, j, tmp = 0;
  cin >> a >> b >> c >> d;
  if (abs(a) > abs(b) && abs(c) > abs(d)) {
    max = a * c;
  } else {
    for (i = a; i <= b; i++) {
      for (j = c; j <= d; j++) {
        tmp = i * j;
        if (tmp >= max) {
          max = tmp;
        }
      }
    }
  }
  cout << max << endl;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;
using ll = long long;

int main() {
  ll a[2], b[2];
  cin >> a[0] >> a[1] >> b[0] >> b[1];

  ll m = -1e18;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      m = max(m, a[i] * b[j]);
    }
  }
  cout << m;
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;
using ll = long long;
int main() {
  ll a[2], b[2];
  cin >> a[0] >> a[1] >> b[0] >> b[1];

  ll m = -1e9;
  for (ll i = a[0]; i <= a[1]; i++) {
    for (ll j = b[0]; j <= b[1]; j++) {
      m = max(m, i * j);
    }
  }
  cout << m;
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

#define l long long int

int main() {
  l a, b, c, d;
  cin >> a >> b >> c >> d;
  l k;
  /**if(b<a){
   k=b;
   b=a;
   a=k;
  }
  if(d<c){
   k=d;
   d=c;
   c=k;
  }
  k=a*c;
  l x;
  for(int i=a;i<=b;i++){
   for(int j=c;j<=d;j++){
       x=i*j;
      // cout<<x<<" ";
       if(x>k){
           k=x;
       }
   }
  }
  cout<<k;**/
  l m, n, o, p;
  m = a * c;
  n = a * d;
  o = b * c;
  p = b * d;
  if (m >= n && m >= o && m >= p) {
    cout << m;
  } else if (n >= m && n >= o && n >= p) {
    cout << n;
  } else if (o >= n && o >= m && o >= p) {
    cout << o;
  } else {
    cout << p;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

#define l long long int

int main() {
  l a, b, c, d;
  cin >> a >> b >> c >> d;
  l k;
  if (b < a) {
    k = b;
    b = a;
    a = k;
  }
  if (d < c) {
    k = d;
    d = c;
    c = k;
  }
  k = a * c;
  l x;
  for (int i = a; i <= b; i++) {
    for (int j = c; j <= d; j++) {
      x = i * j;
      // cout<<x<<" ";
      if (x > k) {
        k = x;
      }
    }
  }
  cout << k;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <fstream>
#include <regex>
#include <unordered_set>

#define ll long long

#define MOD 1000000007

using namespace std;

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a, b, c, d;

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

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

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <fstream>
#include <regex>
#include <unordered_set>

#define ll long long

using namespace std;

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a, b, c, d;

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

  ll maxNum = LLONG_MIN;
  for (ll x = a; x <= b; x++) {
    for (ll y = c; y <= d; y++) {
      maxNum = max(x * y, maxNum);
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int, int>;
using pq = priority_queue<int>;
typedef long long ll;

int main() {
  long a, b, c, d;
  long max = LONG_MIN;
  cin >> a >> b >> c >> d;
  long A, B, C, D;
  A = a * c;
  B = a * d;
  C = b * c;
  D = b * d;
  priority_queue<long> pq;
  pq.push(A);
  pq.push(B);
  pq.push(C);
  pq.push(D);
  cout << pq.top() << endl;
  return (0);
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int, int>;
using pq = priority_queue<int>;
typedef long long ll;

int main() {
  long a, b, c, d;
  long max = LONG_MIN;
  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;
    }
  }
  cout << max << endl;
  return (0);
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int a, b, c, d, i, j, p1, p2, p3, p4;
  long long m = -1e9;
  cin >> a >> b >> c >> d;
  p1 = a * c, p2 = a * d, p3 = b * c, p4 = b * d;
  m = max(p1, p2);
  m = max(p3, m);
  m = max(p4, m);
  cout << m;

  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int a, b, c, d, i, j, s;
  long long m = -1e9;
  cin >> a >> b >> c >> d;
  for (i = a; i <= b; i++) {
    for (j = c; j <= d; j++) {
      s = i * j;
      m = max(s, m);
    }
  }
  cout << m;

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

#include <bits/stdc++.h>
#include <string>

using namespace std;

long int a, b, c, d;

void solve() {
  long int ans = a * c;
  if (a * d > ans) {
    ans = a * d;
  }

  if (b * c > ans) {
    ans = b * c;
  }

  if (b * d > ans) {
    ans = b * d;
  }

  cout << ans;
}

int main() {
  cin >> a >> b >> c >> d;
  solve();
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <string>

using namespace std;

long int a, b, c, d;

int solve() {
  long int ans = a * c;
  if (a * d > ans) {
    ans = a * d;
  }

  if (b * c > ans) {
    ans = b * c;
  }

  if (b * d > ans) {
    ans = b * d;
  }

  cout << ans;
}

int main() {
  cin >> a >> b >> c >> d;
  solve();
}