alexjercan/bugnet huggingface dataset:
Problem p02551 (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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, s, n) for (int i = (s); i <= (int)(n); i++)

int a[200010];
int b[200010];

int main() {
  long long n, q;
  long long ans;
  int x, y, a_min, b_min;

  cin >> n >> q;
  a_min = n - 2;
  b_min = n - 2;
  ans = (n - 2) * (n - 2);
  rep(i, n) a[i] = n - 2;
  rep(i, n) b[i] = n - 2;
  if (q == 0) {
    cout << ans << endl;
    return 0;
  }
  rep(i, q) {
    cin >> x >> y;
    if (x == 1) {
      if (y < a_min + 2) {
        rep2(j, y, a_min + 2) b[j] = b_min;
        a_min = y - 2;
      }
      ans -= b[y];
    } else {
      if (y < b_min + 2) {
        rep2(j, y, b_min + 2) a[j] = a_min;
        b_min = y - 2;
      }
      ans -= a[y];
    }
  }

  cout << ans << 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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, s, n) for (int i = (s); i <= (int)(n); i++)

int a[200010];
int b[200010];

int main() {
  long long n, q;
  long long ans;
  int x, y, a_min, b_min;

  cin >> n >> q;
  a_min = n;
  b_min = n;
  ans = (n - 2) * (n - 2);
  rep(i, n) a[i] = n - 2;
  rep(i, n) b[i] = n - 2;
  if (q == 0) {
    cout << ans << endl;
    return 0;
  }
  rep(i, q) {
    cin >> x >> y;
    if (x == 1) {
      ans -= b[y];
      if (y < b_min) {
        b_min = y;
        rep(j, a_min) a[j] = b_min - 2;
      }
    } else {
      ans -= a[y];
      if (y < a_min) {
        a_min = y;
        rep(j, b_min) b[j] = a_min - 2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02551 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, q;
  cin >> n >> q;
  vector<uint64_t> d1(n - 2, 0);
  vector<uint64_t> d2(n - 2, 0);
  int64_t result = (n - 2) * (n - 2);
  int num;
  uint64_t index;
  uint64_t h = n - 2, w = n - 2;
  uint64_t h_in = n - 2, w_in = n - 2;
  for (int i = 0; i < q; i++) {
    cin >> num >> index;
    if (num == 1) {
      if (index - 2 < h) {
        result -= h_in;
        w_in = index - 2;
        for (int j = index - 1; j < h; j++) {
          d1[j] = h_in;
        }
        h = index - 2;
      } else {
        result -= d1[index - 2];
        d1[index - 2] = 0;
      }
    } else if (num == 2) {
      if (index - 2 < w) {
        result -= w_in;
        h_in = index - 2;
        for (int j = index - 1; j < w; j++) {
          d2[j] = w_in;
        }
        w = index - 2;
      } else {
        result -= d2[index - 2];
        d2[index - 2] = 0;
      }
    }
  }
  cout << result << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, q;
  cin >> n >> q;
  vector<uint64_t> d1(n - 2, n - 2);
  vector<uint64_t> d2(n - 2, n - 2);
  uint64_t result = (n - 2) * (n - 2);
  int num;
  uint64_t index;
  uint64_t h = n - 2, w = n - 2;
  for (int i = 0; i < q; i++) {
    cin >> num >> index;
    if (num == 1) {
      result -= d1[index - 2];
      if (index - 2 < h) {
        for (int j = 0; j < d1[index - 2]; j++) {
          if (d2[j] > index - 2) {
            d2[j] = index - 2;
          } else {
            break;
          }
        }
        d1[index - 2] = 0;
        h = index - 2;
      } else {
        d1[index - 2] = 0;
      }
    } else if (num == 2) {
      result -= d2[index - 2];
      if (index - 2 < w) {
        for (int j = 0; j < d2[index - 2]; j++) {
          if (d1[j] > index - 2) {
            d1[j] = index - 2;
          } else {
            break;
          }
        }
        d2[index - 2] = 0;
        w = index - 2;
      } else {
        d2[index - 2] = 0;
      }
    }
  }
  cout << result << endl;
}
Problem p02552 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int t = 1;
  // cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    cout << (n == 0);
  }
}

Error: WA

Fixed submission:

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

int main() {
  int t = 1;
  // cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    return n == 0;
  }
}
Problem p02552 (C++) — buggy submission, verdict: Time Limit Exceeded

// Code by: A Gokul Karthik
#include <bits/stdc++.h>

#define ll long long int
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define fast std::ios_base::sync_with_stdio(false)
#define debug1(a) cout << a << endl;
#define debug2(a, b) cout << a << ' ' << b << endl;
#define debug3(a, b, c) cout << a << ' ' << b << ' ' << c << endl;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repre(i, a, b) for (int i = a; i <= b; i++)
#define clr1(arr) memset(arr, -1, sizeof(arr));
#define clr0(arr) memset(arr, 0, sizeof(arr));
#define RANGE 255
#define po(a)                                                                  \\
  if (a < 0) {                                                                 \\
    a *= -1;                                                                   \\
  }

using namespace std;

void swap(int *xp, int *yp) {
  int temp = *xp;
  *xp = *yp;
  *yp = temp;
}

void bubbleSort(int arr[], int n) {
  int i, j;
  for (i = 0; i < n - 1; i++)
    for (j = 0; j < n - i - 1; j++)
      if (arr[j] > arr[j + 1])
        swap(&arr[j], &arr[j + 1]);
}

int solve() {
  int x;
  cin >> x;
  if (x == 0) {
    cout << 1 << "\\n";
  }
  if (x == 1) {
    cout << 0 << "\\n";
  }
  return 0;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  t = 1;
  for (int i = 0; i < t; i++) {
    solve();
  }
}


Error: TLE

Fixed submission:

// Code by: A Gokul Karthik
#include <bits/stdc++.h>

#define ll long long int
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define fast std::ios_base::sync_with_stdio(false)
#define debug1(a) cout << a << endl;
#define debug2(a, b) cout << a << ' ' << b << endl;
#define debug3(a, b, c) cout << a << ' ' << b << ' ' << c << endl;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repre(i, a, b) for (int i = a; i <= b; i++)
#define clr1(arr) memset(arr, -1, sizeof(arr));
#define clr0(arr) memset(arr, 0, sizeof(arr));
#define RANGE 255
#define po(a)                                                                  \\
  if (a < 0) {                                                                 \\
    a *= -1;                                                                   \\
  }

using namespace std;

void swap(int *xp, int *yp) {
  int temp = *xp;
  *xp = *yp;
  *yp = temp;
}

void bubbleSort(int arr[], int n) {
  int i, j;
  for (i = 0; i < n - 1; i++)
    for (j = 0; j < n - i - 1; j++)
      if (arr[j] > arr[j + 1])
        swap(&arr[j], &arr[j + 1]);
}

int solve() {
  int x;
  cin >> x;
  if (x == 0) {
    cout << 1 << "\\n";
  }
  if (x == 1) {
    cout << 0 << "\\n";
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  t = 1;
  for (int i = 0; i < t; i++) {
    solve();
  }
}
Problem p02552 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main()

{
  int i;
  cin >> i;

  if (!i)
    cout << 1;
  else
    cout << 0;

  return 0;
}


Error: 1

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main()

{
  int i;
  cin >> i;

  if (i > 0 && i < 1)
    return 0;
  else
    return 1;
}
Problem p02552 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int a;
  cin >> a;
  if (a)
    cout << "0" << endl;
  else
    cout << "1" << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a;
  cin >> a;
  if (a)
    return 0;
  return 1;
}
Problem p02552 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

#define ar array
#define ll long long

const int MAX_N = 1e5 + 1;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;

void solve() {}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  int tc;
  cin >> tc;
  cout << 1 - tc;
  return 0;
}


Error: 1

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define ar array
#define ll long long

const int MAX_N = 1e5 + 1;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;

void solve() {}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  int tc;
  cin >> tc;
  cout << 1 - tc;
  return 1;
}
Problem p02552 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int i;

  cin >> i;
  if (i == 0) {
    cout << 1;
  } else if (i == 1) {
    cout << 0;
  }
}


Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int i;

  cin >> i;
  if (i == 0) {
    return 1;
  } else if (i == 1) {
    return 0;
  }
}
Problem p02552 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int x;
  cin >> x;

  if (x == 1)
    cout << 0;
  else
    cout << 1;

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int x;
  cin >> x;

  if (x == 1)
    return 0;
  else
    return 1;

  cout << x;

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

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

int main() {
  int x;
  cin >> x;
  cout << !x;
}

static int fastio = []() {
#define endl '\\n'
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  return 0;
}();


Error: WA

Fixed submission:

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

int main() {
  int x;
  cin >> x;
  return !x;
}

static int fastio = []() {
#define endl '\\n'
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  return 0;
}();
Problem p02552 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  int ans = 1 - N;
  cout << ans;
  for (long long i = 1; i < 100000; i++) {
    cout << endl;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  int ans = 1 - N;
  cout << ans;
  for (long long i = 1; i < 10000000; i++) {
    cout << endl;
  }
}
Problem p02552 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  bool x;
  cin >> x;
  cout << !x << endl;
  return 0;
}


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


Fixed submission:

#include <cstdio>

using namespace std;

int main() {
  bool x;
  scanf("%d", &x);
  printf("%d\\n", !x);
  return 0;
}
Problem p02552 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int x;
  cin >> x;

  cout << (!x) << endl;
}

Error: WA

Fixed submission:

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

int main() {
  int x;
  cin >> x;

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

/*******************************
 * BASMILLAHHIR RAHMANNIR RAHIM *
 * MD SHAHINUR RAHMAN           *
 * DATE: 12/sep/2020            *
 * DEPT. OF CSE                 *
 * LEADING UNIVERSITY, SYLHET   *
 *******************************/
#include <algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <vector>
#define shahin                                                                 \\
  std::ios_base::sync_with_stdio(false);                                       \\
  std::cin.tie(NULL);
#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
const int nax = 1000 * 1007;
const int mod = 1e9 + 7;

using namespace std;
char wcz[nax];

bool fu(int a, int b) { return (a > b); }

void fun() {
  ll a, b, c, d, sum = 0, S = -10000000000;
  cin >> a >> b >> c >> d;
  cout << max(a * c, max(a * d, max(b * c, b * d)));
}

int main() {
  shahin
  /*  ll tc,i=1;
    cin >> tc;
    while(tc--)
    {
    //cout << "Case " << i << ": ";
        fun();
    //i++;
    }*/
  fun();
}


Error: TLE

Fixed submission:

/*******************************
 * BASMILLAHHIR RAHMANNIR RAHIM *
 * MD SHAHINUR RAHMAN           *
 * DATE: 12/sep/2020            *
 * DEPT. OF CSE                 *
 * LEADING UNIVERSITY, SYLHET   *
 *******************************/
#include <algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <vector>
#define shahin                                                                 \\
  std::ios_base::sync_with_stdio(false);                                       \\
  std::cin.tie(NULL);
#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
const int nax = 1000 * 1007;
const int mod = 1e9 + 7;

using namespace std;
char wcz[nax];

bool fu(int a, int b) { return (a > b); }

void fun() {
  ll a, b, c, d, sum = 0, S = -10000000000;
  cin >> a >> b >> c >> d;
  for (ll i = a; i <= b; i++) {

    for (ll j = c; j <= d; j++) {
      sum = (i * j);
      S = max(sum, S);
      //      cout << i << " "<< j << "="<<sum<< " "<< S<<endl;
    }
  }
  cout << S << endl;
}

int main() {
  shahin
  /*  ll tc,i=1;
    cin >> tc;
    while(tc--)
    {
    //cout << "Case " << i << ": ";
        fun();
    //i++;
    }*/
  fun();
}
Problem p02553 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  long long a, b, c, d;
  long long arr[4];
  long long max;

  cin >> a >> b >> c >> d;
  arr[0] = a * c;
  arr[1] = a * d;
  arr[2] = b * c;
  arr[3] = b * d;

  max = arr[0];
  for (int i = 1; i < 4; i++) {
    if (max < arr[i])
      max = arr[i];
  }
  cout << max << endl;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

void merge(int arr[], int start, int mid, int end) {
  int temp[end - start + 1];
  int i = start;
  int j = mid;
  int k = 0;
  while (i < mid && j <= end) {
    if (arr[i] < arr[j]) {
      temp[k] = arr[i];
      i++;
      k++;
    } else {
      temp[k] = arr[j];
      j++;
      k++;
    }
  }
  while (i < mid) {
    temp[k] = arr[i];
    i++;
    k++;
  }
  while (j <= end) {
    temp[k] = arr[j];
    j++;
    k++;
  }
  k = 0;
  for (int i = start; i <= end; i++) {
    arr[i] = temp[k];
    k++;
  }
}
void mergeSort(int arr[], int start, int end) {

  // cout << "start-" << start << ' ' << end << endl;
  if (start < end) {
    int mid = start + (end - start) / 2;
    mergeSort(arr, start, mid);
    mergeSort(arr, mid + 1, end);
    merge(arr, start, mid + 1, end);
  }
  cout << '\\n';
  for (int i = 0; i <= end; i++)
    cout << arr[i] << ' ';
  cout << '\\n';
}

int main() {
  int size;
  cin >> size;
  int arr[size];
  for (int i = 0; i < size; i++) {
    cin >> arr[i];
  }
  mergeSort(arr, 0, size - 1);

  for (int i = 0; i < size; i++) {
    cout << arr[i] << " ";
  }
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>

namespace adaptor = boost::adaptors;

using namespace std;

class InputConsole {
public:
  template <typename T> static void inputs(vector<T> &vec) {
    string inputString;
    getline(cin, inputString);

    while (!inputString.empty()) {
      int i = 0;
      for (i = 0; i < inputString.length(); i++) {
        if (inputString[i] == ' ') {
          break;
        }
      }
      stringstream ss;
      ss << inputString.substr(0, i);
      T data;
      ss >> data;
      vec.push_back(data);
      inputString.erase(0, i + 1);
    }
  }
};

void Main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long max;
  max = a * c;
  if (max < a * d)
    max = a * d;
  if (max < b * c)
    max = b * c;
  if (max < b * d)
    max = b * d;
  cout << max << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>

namespace adaptor = boost::adaptors;

using namespace std;

class InputConsole {
public:
  template <typename T> static void inputs(vector<T> &vec) {
    string inputString;
    getline(cin, inputString);

    while (!inputString.empty()) {
      int i = 0;
      for (i = 0; i < inputString.length(); i++) {
        if (inputString[i] == ' ') {
          break;
        }
      }
      stringstream ss;
      ss << inputString.substr(0, i);
      T data;
      ss >> data;
      vec.push_back(data);
      inputString.erase(0, i + 1);
    }
  }
};

void Main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int max = INT_MIN;
  for (int i = a; i <= b; ++i) {
    for (int j = c; j <= d; ++j) {
      if (i * j > max) {
        max = i * j;
      }
    }
  }
  cout << max << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long array[3] = {a * d, b * c, b * d};
  long long out = a * c;
  for (long long ar : array) {
    if (ar > out) {
      out = ar;
    }
  }

  cout << out;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int out = b * d;
  for (int i = a; i <= b; i++) {
    for (int j = c; j <= d; j++) {
      int k = i * j;
      if (k > out) {
        out = k;
      }
    }
  }

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

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

int main() {
  // your code goes here
  ll a, b, c, d, p = -1000000000, i, j;
  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 <iostream>
#define ll long long
using namespace std;

int main() {
  // your code goes here
  ll a, b, c, d, p = -1000000000, i, j;
  cin >> a >> b >> c >> d;
  for (i = a; i <= b; i++) {
    for (j = c; j <= d; j++)
      p = max(p, i * j);
  }
  cout << p << endl;
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long a, b, c, d, i, j;
  cin >> a >> b >> c >> d;
  long long max, max1, max2, max3, max4;
  max1 = a * c;
  max2 = a * d;
  max3 = b * c;
  max4 = b * d;
  max = max1;
  if (max < max2)
    max = max2;
  if (max < max3)
    max = max3;
  if (max < max4)
    max = max4;
  cout << max << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

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

    max = a * c;
    i = a;
    while (i <= b) {
      j = c;
      while (j <= d) {
        if (i * j > max)
          max = i * j;
        j++;
      }
      i++;
    }
  }
  cout << max << endl;
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<long long> vec(4);
  vec.at(0) = a * c;
  vec.at(1) = a * d;
  vec.at(2) = b * c;
  vec.at(3) = b * d;
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  cout << vec.at(0) << endl;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)


Fixed submission:

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<int> vec(3);
  vec.at(0) = a * c;
  vec.at(1) = a * d;
  vec.at(2) = b * c;
  vec.at(3) = b * d;
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  cout << vec.at(0) << endl;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

typedef long long LL;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  LL ans1 = (LL)a * c;
  LL ans2 = (LL)a * d;
  LL ans3 = (LL)b * c;
  LL ans4 = (LL)b * d;
  // cout<<ans1<<" "<<ans2<<" "<<ans3<<" "<<ans4<<endl;
  LL ans = max(ans1, ans2);
  ans = max(ans, max(ans3, ans4));
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

typedef long long LL;
int main() {
  int l1, r1, l2, r2;
  cin >> l1 >> r1 >> l2 >> r2;
  LL res = -1e18 - 10;
  for (int i = l1; i <= r1; ++i)
    for (int j = l2; j <= r2; ++j) {
      res = max(res, (LL)i * j);
    }
  cout << res << endl;
  return 0;
}
Problem p02553 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

const int MOD = 1000000007;

// vector<vector<int>> data(3, vector<int>(4));

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

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

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

  printf("%lld", ans);
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

const int MOD = 1000000007;

// vector<vector<int>> data(3, vector<int>(4));

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

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

  ll ans = -INF;

  for (int i = a; i <= b; i++) {
    for (int k = c; k <= d; k++) {
      ans = fmax(ans, i * k);
    }
  }
  cout << ans;
}