prithivMLmods/Coder-Stat huggingface dataset:
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(), v.end()
int main() {
  int N;
  cin >> N;
  ll ans = 1;
  while (1) {
    if (ans % 2 == 0 && ans % N == 0) {
      cout << ans << endl;
      break;
    } else {
      ans++;
      continue;
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(), v.end()
int main() {
  int N;
  cin >> N;
  if (N % 2 == 0) {
    cout << N << endl;
  } else {
    cout << 2 * N << endl;
  }
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= 1e9; i++) {
    if (i % 2 == 0 && i & n == 0) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if (n % 2 == 0) {
    cout << n << endl;
  } else
    cout << n * 2 << endl;

  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  int i = 2;
  while (i % n)
    i += 2;
  printf("%d\n", i);
  return 0;
}

Fixed submission:
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  printf("%d\n", !(n % 2) ? n : n * 2);
  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define RFOR(i, a, b) for (long long i = (b - 1); i >= a; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr, mp) for (auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x) cout << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cout << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<P> Graph;

int main() {
  ll N;
  cin >> N;
  ll i = 2;
  for (;;) {
    if (i % N == 0) {
      cout << i << endl;
      return 0;
    }
    i += 2;
  }
  return 0;
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define RFOR(i, a, b) for (long long i = (b - 1); i >= a; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr, mp) for (auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x) cout << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cout << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<P> Graph;

int main() {
  ll N;
  cin >> N;
  if (N % 2 == 0)
    cout << N << endl;
  else
    cout << N * 2 << endl;
  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long n;
  cin >> n;

  long long p = n;
  while (p % 2 != 0)
    p++;
  while (p % n != 0)
    p += 2;

  cout << p << endl;

  return 0;
}

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

int main() {
  long long n;
  cin >> n;

  if (n % 2 == 0)
    cout << n << endl;
  else
    cout << n * 2 << endl;

  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>

int main() {
  int N;
  std::cin >> N;

  for (int i = 2; i < 10e9; i += 2) {
    if (i % N != 0)
      continue;

    std::cout << i << std::endl;
    break;
  }

  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>

int main() {
  int N;
  std::cin >> N;

  if (N % 2 == 0)
    std::cout << N << std::endl;
  else
    std::cout << N * 2 << std::endl;

  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

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

  for (int i = 2;; i += 2) {
    if (i % n == 0) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

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

  if (n & 1)
    n *= 2;

  cout << n << endl;

  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>

using namespace std;

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

  int i = 2;
  while (1) {
    if (i % N == 0) {
      cout << i << endl;
      return 0;
    }
    i += 2;
  }
}


Fixed submission:
#include <iostream>
#include <string>

using namespace std;

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

  if (N % 2 == 0)
    cout << N << endl;
  else
    cout << N * 2 << endl;

  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  int N;
  int i;
  cin >> N;
  for (i = 1; i < 2147483647; i++) {
    if (i % 2 == 0 && i % N == 0)
      break;
  }
  cout << i << "\n";
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int N;
  int i;
  cin >> N;
  for (i = N; i < 2147483647; i++) {
    if (i % 2 == 0 && i % N == 0)
      break;
  }
  cout << i << "\n";
}
Problem p03307 (Python)

Buggy submission (status: Runtime Error):
N = input()

if N % 2 != 0:
    answer = N * 2
    print(answer)
else:
    print(N)


Fixed submission:
N = int(input())

if N % 2 != 0:
    answer = N * 2
    print(answer)
else:
    print(N)
Problem p03307 (Python)

Buggy submission (status: Runtime Error):
N = int(input())

A = list(map(int, input().split()))

print(max(A) - min(A))


Fixed submission:
N = int(input())

if N % 2 == 0:
    print(N)
else:
    print(N * 2)
Problem p03307 (Python)

Buggy submission (status: Runtime Error):
number = int(input())
nums = list(map(int, input().split(" ")))

print(max(nums) - min(nums))


Fixed submission:
n = int(input())
print(n + n * (n % 2))
Problem p03307 (Python)

Buggy submission (status: Runtime Error):
n = int(input())

if n < 1 or n > 10:
    raise ValueError

print(2 * n if n % 2 != 0 else n)


Fixed submission:
n = int(input())

print(2 * n if n % 2 != 0 else n)
Problem p03307 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
N1 = []

for n in range(1, (N + 1)):
    N1.append(2 * n)

for i in N1:
    if i % N == 0:
        print(i)
        break


Fixed submission:
N = int(input())
if N % 2 == 0:
    print(N)
else:
    print(2 * N)
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  for (int i = 2; i <= 2000000000; i += 2) {
    if (i % N == 0) {
      cout << i << endl;
      return 0;
    }
  }
}

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

int main() {
  int N;
  cin >> N;
  if (N % 2 == 1)
    cout << 2 * N << endl;
  else
    cout << N << endl;
}
Problem p03307 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())

for i in range(2, 10**9, 2):
    if i % n == 0:
        print(i)


Fixed submission:
n = int(input())

if n % 2 == 0:
    print(n)
else:
    print(n * 2)
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red                                                                    \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define Rep(i, a, b) for (int i = a; i <= b; i++)
#define pii pair<int, int>
typedef vector<int> vi;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = (int)2e5 + 5;

void solve() {
  int n;
  cin >> n;
  for (int i = max(2, n);; i++) {
    if (i % 2 == 0 && i % n == 0) {
      cout << i;
      return;
    }
  }
}

int main() {
  Red;
  int t = 1;
  // cin>>t;
  while (t--)
    solve();
  return 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(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red                                                                    \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define Rep(i, a, b) for (int i = a; i <= b; i++)
#define pii pair<int, int>
typedef vector<int> vi;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = (int)2e5 + 5;

void solve() {
  int n;
  cin >> n;
  cout << n * 2 / __gcd(2, n);
}

int main() {
  Red;
  int t = 1;
  // cin>>t;
  while (t--)
    solve();
  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A;
  cin >> A;
  if (A % 0 == 0) {
    cout << A << endl;
  } else {
    cout << A * 2 << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A;
  cin >> A;
  if (A % 2 == 0) {
    cout << A << endl;
  } else {
    cout << A * 2 << endl;
  }
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N;

  cin >> N;

  for (int i = 2; i <= 10000000000; i++) {
    if (i % 2 == 0 && i % N == 0) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N;

  cin >> N;

  if (N % 2 == 0) {
    cout << N << endl;
  } else {
    cout << N * 2 << endl;
  }

  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
  int a, b;
  scanf("%d", &a);
  int i;
  for (i = 1; i < 1000000000; i++) {
    if (i % a == 0) {
      if (i % 2 == 0) {
        cout << i << "\n";
        return 0;
      }
    }
  }
  return 0;
}


Fixed submission:
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
  int a, b;
  scanf("%d", &a);
  int i;
  for (i = a; i < 10000000000; i *= 2) {
    if (i % a == 0) {
      if (i % 2 == 0) {
        cout << i << "\n";
        return 0;
      }
    }
  }
  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main(void) {
  int n, i;
  cin >> n;
  for (i = n; i < 10000000000; i++) {
    if (i % 2 == 0 && i % n == 0) {
      cout << i << endl;
      break;
    }
  }
}

Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  int n, i;
  cin >> n;
  for (i = n; i <= 2000000000; i++) {
    if (i % 2 == 0 && i % n == 0) {
      cout << i << endl;
      break;
    }
  }
}
Problem p03307 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int ans;
  vector<int> A(N);

  for (int i = 0; i <= N - 1; i++) {
    cin >> A[i];
  }
  int max = *max_element(A.begin(), A.end());
  int min = *min_element(A.begin(), A.end());
  ans = max - min;
  cout << ans;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int ans = 0;
  ans = (2 * N) / (__gcd(2, N));
  cout << ans;
  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  int a;
  // 整数の入力
  scanf("%d", &a);
  if (a % 2 == 0) {
    printf("%d %s\n", a);
    return 0;
  }
  printf("%d \n", a * 2);
  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  int a;
  // 整数の入力
  scanf("%d", &a);
  if (a % 2 == 0) {
    printf("%d \n", a);
    return 0;
  }
  printf("%d \n", a * 2);
  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
  ll n, tot;
  cin >> n;
  for (ll i = n;; i++) {
    if (i % 2 == 0 && i % n == 0) {
      tot = i;
      break;
    }
  }
  cout << tot << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
  ll n, tot;
  cin >> n;
  for (ll i = n;; i *= 2) {
    if (i % 2 == 0 && i % n == 0) {
      tot = i;
      break;
    }
  }
  cout << tot << endl;

  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
#define ull unsigned long long
#define ui unsigned int
#define ll long long
#define sf(n) scanf("%d", &n)
#define pf(n) printf("%d", n)
int main() {
  ll n, m;
  cin >> n;
  m = n;
  if (n & 1)
    n++;
  for (ll i = n;; i += 2) {
    if (i % 2 == 0 && i % m == 0) {
      cout << i << el;
      break;
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
#define ull unsigned long long
#define ui unsigned int
#define ll long long
#define sf(n) scanf("%d", &n)
#define pf(n) printf("%d", n)
int main() {
  ll n, m;
  cin >> n;
  if (n % 2 == 0)
    cout << n << el;
  else
    cout << 2 * n << el;
  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

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

  for (int i = 1;; i++) {
    if (i % 2 == 0 && i % num == 0) {
      cout << i << endl;
      break;
    }
  }
}

Fixed submission:
#include <iostream>
using namespace std;

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

  if (num % 2 == 0) {
    cout << num << endl;
  }

  else {
    for (int i = 1;; i++) {
      if ((num * i) % 2 == 0) {
        cout << num * i << endl;
        break;
      }
    }
  }
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= 2 * N; i++) {
    if (i % 2 == 0 && i % N == 0) {
      cout << i << endl;
      return 0;
    }
  }
}

Fixed submission:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  if (N % 2 != 0) {
    cout << 2 * N << endl;
    return 0;
  } else
    cout << N << endl;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n;
  cin >> n;
  for (int i = max(2, n);; i++) {
    if (i % 2 == 0 && i % n == 0) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n;
  cin >> n;
  int I = max(2, n);
  if (n == 1) {
    cout << 2 << endl;
    return 0;
  }
  for (int i = 1;; i++) {
    if (n * i % 2 == 0) {
      cout << n * i << endl;
      return 0;
    }
  }

  return 0;
}
Problem p03307 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())

i = N
while True:
    if i % 2 == 0 and i % N == 0:
        print(i)
        break
    i += 1


Fixed submission:
N = int(input())

i = N
while True:
    if i % 2 == 0 and i % N == 0:
        print(i)
        break
    i += N
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;

int main(void) {
  int n;
  cin >> n;
  for (int i = 2;; i += 2) {
    if (i % n == 0) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;

int main(void) {
  int n;
  cin >> n;
  if (n % 2 == 0) {
    cout << n << endl;
  } else {
    cout << n * 2 << endl;
  }
  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

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

  int ans = 0;
  for (int i = 1;; ++i) {
    if (i % 2 == 0 && i % N == 0) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

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

  if (N % 2 == 0)
    cout << N << endl;
  else
    cout << N * 2 << endl;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
using namespace std;

int main() {
  int N;
  cin >> N;
  for (int i = 2; i <= pow(10, 9); i++) {
    if (i % 2 == 0 && i % N == 0) {
      cout << i << endl;
      return 0;
    }
  }
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;

int main() {
  int N;
  cin >> N;
  if (N % 2 == 0)
    cout << N << endl;
  else
    cout << 2 * N << endl;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main(void) {
  int n;
  cin >> n;
  int i = 1;
  while (1) {
    if ((i % 2 == 0) && (i % n == 0))
      break;
  }
  cout << i << endl;
}

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

int main(void) {
  int n;
  cin >> n;

  if (n % 2 == 0)
    cout << n << endl;
  else
    cout << 2 * n << endl;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N;
  long long int res;
  cin >> N;
  for (int i = N;; i++) {
    if (i % 2 == 0)
      if (i % N == 0) {
        res = i;
        break;
      }
  }

  cout << res;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef int Int;
#define int long long
#define INF 0x3f3f3f3f
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) {}
Int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << 2 * n / gcd(2, n) << endl;
  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

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

  int X = N;
  for (int i = 1; i < 2 * N; i++) {
    if (X % N != 0 || X % 2 != 0)
      X++;
    else
      break;
  }

  cout << X << endl;
}

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

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

  if (N % 2 == 0)
    cout << N << endl;
  else
    cout << 2 * N << endl;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int binary(int bina) {
  int ans = 0;
  for (int i = 0; bina > 0; i++) {
    ans = ans + (bina % 2) * pow(10, i);
    bina = bina / 2;
  }
  return ans;
}
long comb(int n, int r) {
  long ans = 1;
  for (int i = n; i > n - r; --i) {
    ans = ans * i;
  }
  for (int i = 1; i < r + 1; ++i) {
    ans = ans / i;
  }
  return ans;
}
using namespace std;
/*int main(){
    int n;std::cin >> n;
    int keta=0;
    while(true){
        keta++;
        if(n/10==0)break;
        n=n/10;
    }
    keta=keta-1;
    if(n>=7)n=3;
    else if(n>=5)n=2;
    else if(n>=3)n=1;
    int k=0;
    for(int i=3;i<=keta;i++){
        k+=comb(i-1,2);
        std::cout << k << std::endl;
    }std::cout << k << std::endl;
    k+=n*(keta);

    std::cout << k << std::endl;

}


*/
int main() {
  int n, b, c;
  std::cin >> n;
  int i = 1;
  while (true) {
    if (i % 2 == 0 && i % n == 0) {
      std::cout << i << std::endl;
      return 0;
    }
    i++;
  }
}

Fixed submission:
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int binary(int bina) {
  int ans = 0;
  for (int i = 0; bina > 0; i++) {
    ans = ans + (bina % 2) * pow(10, i);
    bina = bina / 2;
  }
  return ans;
}
long comb(int n, int r) {
  long ans = 1;
  for (int i = n; i > n - r; --i) {
    ans = ans * i;
  }
  for (int i = 1; i < r + 1; ++i) {
    ans = ans / i;
  }
  return ans;
}
using namespace std;
/*int main(){
    int n;std::cin >> n;
    int keta=0;
    while(true){
        keta++;
        if(n/10==0)break;
        n=n/10;
    }
    keta=keta-1;
    if(n>=7)n=3;
    else if(n>=5)n=2;
    else if(n>=3)n=1;
    int k=0;
    for(int i=3;i<=keta;i++){
        k+=comb(i-1,2);
        std::cout << k << std::endl;
    }std::cout << k << std::endl;
    k+=n*(keta);

    std::cout << k << std::endl;

}


*/
int main() {
  int n, b, c;
  std::cin >> n;
  int i = 1;
  std::cout << (n % 2 == 0 ? n : n + n) << std::endl;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  rep(i, 1999999998) {
    if ((i + 1) % 2 == 0 && (i + 1) % n == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  if (n % 2 == 0)
    cout << n << endl;
  else
    cout << n * 2 << endl;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n;
  cin >> n;
  for (int i = 2; i <= 10000000000; i += 2) {
    if (i % n == 0) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n;
  cin >> n;
  if (n % 2 == 0)
    cout << n << endl;
  else
    cout << n * 2 << endl;
  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using ll = unsigned long long;
using namespace std;

int main(void) {
  int n;
  cin >> n;

  int ans = n;
  while (true) {
    if (ans % 2 == 0 & ans % n == 0) {
      cout << ans << endl;
      return 0;
    }
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using ll = unsigned long long;
using namespace std;

int main(void) {
  int n;
  cin >> n;

  int ans = n;
  while (true) {
    if (ans % 2 == 0 & ans % n == 0) {
      cout << ans << endl;
      return 0;
    } else {
      ans++;
    }
  }

  return 0;
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  for (int i = 1; i < 20 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10; i++)
    if (i % N == 0) {
      if (i % 2 == 0) {
        cout << i << endl;
        break;
      }
    }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  if (N % 2 == 0) {
    cout << N << endl;
  } else {
    cout << 2 * N << endl;
  }
}
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int i = 1;
  while (1) {
    if (i % 2 == 0 && i % n == 0) {
      cout << i << "\n";
      return 0;
    }
    i++;
  }
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  if (n % 2 == 0)
    cout << n << "\n";
  else
    cout << n * 2 << "\n";
  return 0;
}
Problem p03307 (Python)

Buggy submission (status: Runtime Error):
def run(n):
    if n % 2 == 0:
        return n
    else:
        return n * 2


def read_line():
    n = map(int, input().split())
    return n


def main():
    n = read_line()
    print(run(n))


if __name__ == "__main__":
    main()


Fixed submission:
def run(n):
    if n % 2 == 0:
        return n
    else:
        return n * 2


def read_line():
    n = int(input())
    return n


def main():
    n = read_line()
    print(run(n))


if __name__ == "__main__":
    main()
Problem p03307 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
using namespace std;

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

  int i = 1;
  for (; i < 1000000000; i++) {
    if (i % 2 == 0 && i % N == 0) {
      break;
    }
  }

  cout << i << endl;
}

Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;

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

  int i = N;
  for (; i < 1000000000; i += N) {
    if (i % 2 == 0) {
      break;
    }
  }

  cout << i << endl;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

int main() {
  int n, *a;
  cin >> n;
  a = new int[n];
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  int j;
  for (i = 0; i < n; i++) {
    for (j = n - 1; j > i; j++) {
      if (a[j] < a[j - 1]) {
        int tmp = a[j];
        a[j] = a[j - 1];
        a[j - 1] = tmp;
      }
    }
  }
  cout << a[n - 1] - a[0];
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int n, *a;
  cin >> n;
  a = new int[n];
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  int j;
  for (i = 0; i < n; i++) {
    for (j = n - 1; j > i; j--) {
      if (a[j] < a[j - 1]) {
        int tmp = a[j];
        a[j] = a[j - 1];
        a[j - 1] = tmp;
      }
    }
  }
  cout << a[n - 1] - a[0];
  return 0;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define f(i, a, b) for (int i = a; i < b; i++)
#define fr(i, a, b) for (int i = a; i >= b; i--)
#define fp(i, a, b, p) for (int i = a; i < b; i += p)
#define SZ(x) (int)x.size()

typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<long long> vl;

int main() {
  int n;

  cin >> n;

  vi v;

  f(i, 0, n) { cin >> v[i]; }

  sort(all(v));

  cout << v[n - 1] - v[0] << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define f(i, a, b) for (int i = a; i < b; i++)
#define fr(i, a, b) for (int i = a; i >= b; i--)
#define fp(i, a, b, p) for (int i = a; i < b; i += p)
#define SZ(x) (int)x.size()

typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<long long> vl;

int main() {
  int n;

  cin >> n;

  vi v(n);

  f(i, 0, n) { cin >> v[i]; }

  sort(all(v));

  cout << v[n - 1] - v[0] << endl;

  return 0;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  cout << A.back() - A[0] << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  cout << A.back() - A[0] << endl;
  return 0;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int min = A.at(0), Max = A.at(0);
  for (int i = 1; i < N; i++) {
    if (min > A.at(i)) {
      min = A.at(i);
    }

    if (Max < A.at(i)) {
      Max = A.at(i);
    }
  }
  cout << Max - min << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int min = A.at(0), Max = A.at(0);
  for (int i = 1; i < N; i++) {
    if (min > A.at(i)) {
      min = A.at(i);
    }

    if (Max < A.at(i)) {
      Max = A.at(i);
    }
  }
  cout << Max - min << endl;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>

const int MAX = 1000000005;
int A[MAX];

int main() {
  int N, i;
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  int a = A[0], b = A[0];
  for (i = 1; i < N; i++) {
    if (A[i] < a) {
      a = A[i];
    }
    if (A[i] > b) {
      b = A[i];
    }
  }
  printf("%d", b - a);
  return 0;
}


Fixed submission:
#include <cstdio>

const int MAX = 105;
int A[MAX];

int main() {
  int N, i;
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  int a = A[0], b = A[0];
  for (i = 1; i < N; i++) {
    if (A[i] < a) {
      a = A[i];
    }
    if (A[i] > b) {
      b = A[i];
    }
  }
  printf("%d", b - a);
  return 0;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main() {
  ll n;
  vector<ll> a(n);
  rep(i, n) in(a[i]);
  sort(all(a));
  out(a[n - 1] - a[0]);
  memi;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main() {
  ll n;
  in(n);
  vector<ll> a(n);
  rep(i, n) in(a[i]);
  sort(all(a));
  out(a[n - 1] - a[0]);
  memi;
}
Problem p03308 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for (ll i = 0; i < n; i++)

void stoogesort(vector<int> &a, int l, int r) {
  if (a[l] > a[r]) {
    swap(a[l], a[r]);
  }
  if (r - l + 1 >= 3) {
    int t = (r - l + 1) / 3;
    stoogesort(a, l, r - t);
    stoogesort(a, l + t, r);
    stoogesort(a, l, r - t);
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) { cin >> a[i]; }
  REP(i, 5000) {
    stoogesort(a, 0, n - 1);
    cerr << i << endl;
  }
  cout << a[n - 1] - a[0] << endl;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for (ll i = 0; i < n; i++)

void stoogesort(vector<int> &a, int l, int r) {
  if (a[l] > a[r]) {
    swap(a[l], a[r]);
  }
  if (r - l + 1 >= 3) {
    int t = (r - l + 1) / 3;
    stoogesort(a, l, r - t);
    stoogesort(a, l + t, r);
    stoogesort(a, l, r - t);
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) { cin >> a[i]; }
  REP(i, 100) {
    stoogesort(a, 0, n - 1);
    cerr << i << endl;
  }
  cout << a[n - 1] - a[0] << endl;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout << (s) << endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))

int main() {
  ll N, a[N];
  cin >> N;
  rep(i, N) cin >> a[i];
  sort(a, a + N);
  p(a[N - 1] - a[0]);
}

Fixed submission:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout << (s) << endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))

int main() {
  ll N, a[101];
  cin >> N;
  rep(i, N) cin >> a[i];
  sort(a, a + N);
  p(a[N - 1] - a[0]);
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n;
  int a[10000000000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int mn = a[0], mx = a[0];
  for (int i = 1; i < n; i++) {
    if (mn > a[i])
      mn = a[i];
    if (mx < a[i])
      mx = a[i];
  }
  cout << mx - mn << endl;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n;
  int a[110];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int mn = a[0], mx = a[0];
  for (int i = 1; i < n; i++) {
    if (mn > a[i])
      mn = a[i];
    if (mx < a[i])
      mx = a[i];
  }
  cout << mx - mn << endl;
}
Problem p03308 (Python)

Buggy submission (status: Runtime Error):
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a)
    return str(abs(a[0] - a[-1]))


if __name__ == "__main__":
    print(solve([input(), input()]))


Fixed submission:
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a)
    return str(abs(a[0] - a[-1]))


if __name__ == "__main__":
    print(solve("\n".join([input(), input()])))
Problem p03308 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
A = list(map(int, input().spllit()))
print(max(A) - min(A))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
print(max(A) - min(A))
Problem p03308 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
a = map(int, input().split())
print(max(a) - min(a))


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
print(max(a) - min(a))
Problem p03308 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
As = map(int, input().split())
max_diff = -float("inf")
for i in range(N):
    for j in range(i + 1, N):
        max_diff = max(max_diff, abs(As[i] - As[j]))
print(max_diff)


Fixed submission:
N = int(input())
As = list(map(int, input().split()))
max_diff = -float("inf")
for i in range(N):
    for j in range(i + 1, N):
        max_diff = max(max_diff, abs(As[i] - As[j]))
print(max_diff)
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  vector<int> intArray;

  for (int i = 0; i < N; i++) {
    int temp;
    cin >> temp;
    intArray.emplace_back(temp);
  }
  sort(intArray.begin(), intArray.end());
  cout << intArray[intArray.size() - 1] - intArray[0] << endl;
}


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

int main() {
  int N;
  vector<int> intArray;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int temp;
    cin >> temp;
    intArray.emplace_back(temp);
  }
  sort(intArray.begin(), intArray.end());
  cout << intArray[intArray.size() - 1] - intArray[0] << endl;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
using namespace std;
#include <stdio.h>
int main(void) {
  // ソート（並び替え）
  int N, a[100];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", a[100]);
  }
  sort(a, a + N); // 小さい順に並び変えられる

  printf("%d", a[N - 1] - a[0]);

  return 0;
}

Fixed submission:
#include <algorithm>
using namespace std;
#include <stdio.h>
int main(void) {
  // ソート（並び替え）
  int N, a[100];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + N); // 小さい順に並び変えられる

  printf("%d", a[N - 1] - a[0]);

  return 0;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  int N;
  int A[N];
  int max = 0;
  int min = 1000000000;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    if (A[i] > max)
      max = A[i];
    if (A[i] < min)
      min = A[i];
  }
  cout << max - min << endl;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int N;
  long long int A[201];
  long long int max = 0;
  long long int min = 1000000000;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    if (A[i] > max)
      max = A[i];
    if (A[i] < min)
      min = A[i];
  }
  cout << max - min << endl;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  const int Min = 1000000001;
  const int Max = -1;
  int n;
  int a[100000001];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int res = Min;
  int ress = Max;
  for (int i = 0; i < n; i++) {
    if (res > a[i]) {
      res = a[i];
    }
    if (ress < a[i]) {
      ress = a[i];
    }
  }
  cout << ress - res << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  const int Min = 1000000001;
  const int Max = -1;
  int n;
  int a[1000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int res = Min;
  int ress = Max;
  for (int i = 0; i < n; i++) {
    if (res > a[i]) {
      res = a[i];
    }
    if (ress < a[i]) {
      ress = a[i];
    }
  }
  cout << ress - res << endl;
  return 0;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  int x;
  vector<int> nums;
  for (int i = 3; i < n; ++i) {
    cin >> x;
    nums.push_back(x);
  }
  sort(nums.begin(), nums.end());
  cout << nums[nums.size() - 1] - nums[0] << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int x;
  vector<int> nums;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    nums.push_back(x);
  }
  sort(nums.begin(), nums.end());
  cout << nums[nums.size() - 1] - nums[0] << endl;
  return 0;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

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

  vector<int> data(n);
  for (int i = 0; i < n; i++) {
    cin >> data.at(n);
  }

  sort(data.begin(), data.end());

  cout << data.at(n - 1) - data.at(0) << endl;
}

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

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

  vector<int> data(n);
  for (int i = 0; i < n; i++) {
    cin >> data.at(i);
  }

  sort(data.begin(), data.end());

  cout << data.at(n - 1) - data.at(0) << endl;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);

  for (int i = 0; i < n; i++)
    cin >> a.at(i);

  sort(a.begin(), a.end());

  cout << a.at(n) - a.at(0) << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);

  for (int i = 0; i < n; i++)
    cin >> a.at(i);

  sort(a.begin(), a.end());

  cout << a.back() - a.at(0) << endl;
}
Problem p03308 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n;
  int a[n];
  int out;
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d\n", &a[i]);
  }
  sort(a, a + n);
  out = a[n - 1] - a[0];
  printf("%d\n", out);
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n;
  int a[100];
  int out;
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d\n", &a[i]);
  }
  sort(a, a + n);
  out = a[n - 1] - a[0];
  printf("%d\n", out);
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main(void) {
  int max, min, i, n, a[1000000000];
  scanf("%d", &n);
  scanf("%d", &a[0]);
  max = min = a[0];
  for (i = 1; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > max)
      max = a[i];
    else if (a[i] < min)
      min = a[i];
  }
  printf("%d\n", max - min);
  return 0;
}


Fixed submission:
#include <stdio.h>
int main(void) {
  int max, min, i, n, a[10000];
  scanf("%d", &n);
  scanf("%d", &a[0]);
  max = min = a[0];
  for (i = 1; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > max)
      max = a[i];
    else if (a[i] < min)
      min = a[i];
  }
  printf("%d\n", max - min);
  return 0;
}
Problem p03308 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

int main() {
  int n, a[100], i, max, min;

  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (i = 0) {
      max = a[i];
      min = a[i];
    }

    if (max < a[i])
      max = a[i];

    if (min > a[i])
      min = a[i];
  }

  cout << max - min << endl;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int n, a[100], i, max, min;

  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0) {
      max = a[i];
      min = a[i];
    }

    if (max < a[i])
      max = a[i];

    if (min > a[i])
      min = a[i];
  }

  cout << max - min << endl;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstdlib>
int main() {
  int n;
  scanf("%d", &n);
  int a[1000000];
  for (int i = 0; i < n; i++)
    scanf("%d", &n);
  std::sort(a, a + n);
  printf("%d\n", a[n - 1] - a[0]);
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstdlib>
int main() {
  int n;
  scanf("%d", &n);
  int a[1000000];
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  std::sort(a, a + n);
  printf("%d\n", a[n - 1] - a[0]);
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  auto lo = min_element(v.begin(), v.end());
  auto hi = max_element(v.begin(), v.end());
  if (!distance(lo, hi)) {
    v.erase(v.begin() + *lo);
    lo = min_element(v.begin(), v.end());
    hi = max_element(v.begin(), v.end());
  }
  int d = abs(*lo - *hi);
  cout << d << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  auto lo = min_element(v.begin(), v.end());
  auto hi = max_element(v.begin(), v.end());
  int d = abs(*lo - *hi);
  cout << d << endl;
  return 0;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  cout << v[n - 1] - v[0] << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  cout << v[n - 1] - v[0] << endl;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  int A[N];
  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> A[i];

  sort(A, A + N);

  cout << A[N - 1] - A[0] << endl;
}


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

int main() {
  int N;
  int A[100];
  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> A[i];

  sort(A, A + N);

  cout << A[N - 1] - A[0] << endl;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>
int main(void) {
  int N = 0;
  std::vector<int> A(N);
  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
  }
  std::sort(A.begin(), A.end());
  std::cout << A[N - 1] - A[0];
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
int main(void) {
  int N = 0;
  std::cin >> N;
  std::vector<int> A(N);
  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
  }
  std::sort(A.begin(), A.end());
  std::cout << A[N - 1] - A[0];
  return 0;
}
Problem p03308 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a;
  int ans = 0;
  cin >> a.at(0);
  int mi = a.at(0);
  int ma = mi;
  for (int i = 1; i < N; i++) {
    cin >> a.at(i);
    ma = max(ma, a.at(i));
    mi = min(mi, a.at(i));
  }
  cout << ma - mi << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  int ans = 0;
  cin >> a.at(0);
  int mi = a.at(0);
  int ma = mi;
  for (int i = 1; i < N; i++) {
    cin >> a.at(i);
    ma = max(ma, a.at(i));
    mi = min(mi, a.at(i));
  }
  cout << ma - mi << endl;
}