prithivMLmods/Coder-Stat huggingface dataset:
Problem p02779 (Python)

Buggy submission (status: Time Limit Exceeded):
def main():
    n = int(input())
    A = list(map(int, input().split()))

    for i in range(n):
        a = A.pop()
        if a in A:
            print("NO")
            return
    print("YES")


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    A = list(map(int, input().split()))

    A_set = set(A)
    if len(A) == len(A_set):
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()
Problem p02779 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
a = input().split()
flag = False
for i in range(n):
    for j in range(i + 1, n):
        if a[i] == a[j]:
            flag = True
            break
    if flag:
        break

if flag:
    print("NO")
else:
    print("YES")


Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
if len(a) != len(set(a)):
    print("NO")
else:
    print("YES")
Problem p02779 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in a:
    if a.count(i) >= 2:
        print("NO")
        exit()
print("YES")


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = set(a)
a.sort()
if len(a) != len(b):
    print("NO")
else:
    print("YES")
Problem p02779 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
num_list = list(map(int, input().split()))
out = "YES"
for j in range(len(num_list)):
    for k in num_list[j + 1 :]:
        out = "NO" if num_list[j] == k else out
print(out)


Fixed submission:
n = int(input())
num_list = list(map(int, input().split()))
out = "YES" if len(num_list) == len(set(num_list)) else "NO"
print(out)
Problem p02779 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

answer = "YES"
for i in range(N):
    c = A.count(A[i])
    if c >= 2:
        answer = "NO"
        break

print(answer)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))

answer = "YES"
AA = sorted(A)
for i in range(N - 1):
    if AA[i] == AA[i + 1]:
        answer = "NO"
        break

print(answer)
Problem p02779 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  bool a = true;
  vector<int> wtf(N);
  for (int i = 0; i < N; i++) {
    cin >> wtf.at(i);
  }
  sort(wtf.begin(), wtf.end());
  for (int i = 0; i < N; i++) {
    if (wtf.at(i) == wtf.at(i + 1)) {
      a = false;
      break;
    }
  }
  if (a == true) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  bool a = true;
  vector<int> wtf(N);
  for (int i = 0; i < N; i++) {
    cin >> wtf.at(i);
  }
  sort(wtf.begin(), wtf.end());
  for (int i = 0; i < N - 1; i++) {
    if (wtf.at(i) == wtf.at(i + 1)) {
      a = false;
      break;
    }
  }
  if (a == true) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}
Problem p02779 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1e9 + 7;

int main(void) {
  int N;
  vector<int> A;
  int i, j;

  cin >> N;

  A.resize(N);

  rep(i, 0, N - 1) {
    cin >> A[i];
    rep(j, 0, i - 1) {
      if (A[i] == A[j]) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }

  cout << "YES" << endl;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1e9 + 7;

int main(void) {
  int N;
  vector<int> A;
  int i, j;

  cin >> N;

  A.resize(N);

  rep(i, 0, N - 1) { cin >> A[i]; }

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

  rep(i, 1, N - 1) {
    if (A[i] == A[i - 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
}
Problem p02779 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> d(1000000000);
  rep(i, n) { d[a[i]]++; }
  rep(i, n) {
    if (d[i] >= 2) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  rep(i, n - 1) {
    if (a[i] == a[i + 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
Problem p02779 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) { cin >> a.at(i); }
  rep(i, n) {
    for (int j = i + 1; j < n; j++) {
      if (a.at(i) == a.at(j)) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) { cin >> a.at(i); }
  sort(a.begin(), a.end());
  rep(i, n - 1) {
    if (a.at(i) == a.at(i + 1)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
Problem p02779 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
using namespace std;
int A[200000] = {0};
int N;
int main(void) {
  cin >> N;

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

  std::sort(A, A + N);

  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      if (A[i] == A[j]) {
        cout << "NO";
        return 0;
      }
    }
  }

  cout << "YES";

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;
int A[200000] = {0};
int N;
int main(void) {
  cin >> N;

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

  std::sort(A, A + N);

  for (int i = 0; i < N - 1; i++) {
    if (A[i] == A[i + 1]) {
      cout << "NO";
      return 0;
    }
  }

  cout << "YES";

  return 0;
}
Problem p02779 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
  int N;
  cin >> N;
  vector<int> cnt(N);
  for (int i = 1; i <= N; ++i)
    cin >> cnt[i];
  cnt[0] = 0;
  sort(all(cnt));
  for (int j = 1; j <= N; ++j) {
    if (cnt[j - 1] == cnt[j]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
  int N;
  cin >> N;
  vector<int> cnt(N + 1);
  for (int i = 1; i <= N; ++i)
    cin >> cnt[i];
  cnt[0] = 0;
  sort(all(cnt));
  for (int j = 1; j <= N; ++j) {
    if (cnt[j - 1] == cnt[j]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
Problem p02779 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int n, a[100004];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (int i = 2; i <= n; i++)
    if (a[i] == a[i - 1]) {
      cout << "NO";
      return 0;
    }
  cout << "YES";
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int n, a[200004];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (int i = 2; i <= n; i++)
    if (a[i] == a[i - 1]) {
      cout << "NO";
      return 0;
    }
  cout << "YES";
}
Problem p02779 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<string> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      if (A[i] == A[j]) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N - 1; ++i) {
    if (A[i] == A[i + 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
Problem p02779 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cctype>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int findIndex(vector<long> vec, long value) {
  vector<long>::iterator iter = std::find(vec.begin(), vec.end(), value);
  size_t index = distance(vec.begin(), iter);
  if (index == vec.size()) {
    return -1;
  }
  return index;
}

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

  vector<long> vec(n);
  for (long i = 0; i < n; i++) {
    long a;
    cin >> a;
    vec[i] = a;
  }

  for (long i = 0; i < n; i++) {
    long b = vec[i];
    for (long j = i + 1; j < n; j++) {
      if (b == vec[j]) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }

  cout << "YES" << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cctype>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int findIndex(vector<long> vec, long value) {
  vector<long>::iterator iter = std::find(vec.begin(), vec.end(), value);
  size_t index = distance(vec.begin(), iter);
  if (index == vec.size()) {
    return -1;
  }
  return index;
}

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

  vector<long> vec(n);
  for (long i = 0; i < n; i++) {
    long a;
    cin >> a;
    vec[i] = a;
  }

  sort(vec.begin(), vec.end(), greater<int>()); // 降順

  for (long i = 0; i < n - 1; i++) {
    if (vec[i] == vec[i + 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
  return 0;
}
Problem p02779 (C++)

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

string s, t;
int n;
int judge = 1;
string u;
vector<int> a(200000);

int main(int argc, char const *argv[]) {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end(), greater<int>());
  // for(int i = 0; i<n;i++) cout << a.at(i) << endl;

  for (int i = 0; i < n; ++i) {
    if (a.at(i) == a.at(i + 1)) {
      judge = 0;
      break;
    }
  }

  if (judge == 1)
    cout << "YES" << endl;
  if (judge == 0)
    cout << "NO" << endl;
  return 0;
}

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

string s, t;
int n;
int judge = 1;
string u;
vector<int> a(200010);

int main(int argc, char const *argv[]) {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end(), greater<int>());
  // for(int i = 0; i<n;i++) cout << a.at(i) << endl;

  for (int i = 0; i < n; ++i) {
    if (a.at(i) == a.at(i + 1)) {
      judge = 0;
      break;
    }
  }

  if (judge == 1)
    cout << "YES" << endl;
  if (judge == 0)
    cout << "NO" << endl;
  return 0;
}
Problem p02779 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#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());

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[i] == a[j]) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }

  cout << "YES" << endl;
}


Fixed submission:
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#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());

  for (int i = 0; i < n; i++) {
    if (a[i] == a[i + 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
}
Problem p02779 (C++)

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

void solve() { return; }

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  int n, aux;
  map<int, int> ma;
  bool t = true;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> aux;
    if (ma[aux] != 0)
      t = false;
    ma[aux]++;
  }

  cout << (t ? "YES" : "NO") << endl;

  return 0;
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

void solve() { return; }

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int n, aux;
  map<int, int> ma;
  bool t = true;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> aux;
    if (ma[aux] != 0)
      t = false;
    ma[aux]++;
  }

  cout << (t ? "YES" : "NO") << endl;

  return 0;
}
Problem p02779 (C++)

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define urng(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed

int main() {
  int n, b, ans = 0;
  // string s;
  cin >> n;
  vector<int> a(n);
  // if(1) {}
  //((a == b)? "Yes" : "No")
  rep(i, n) cin >> a.at(i);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a.at(i) == a.at(j)) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define urng(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed

int main() {
  int n, b, ans = 0;
  // string s;
  cin >> n;
  vector<int> a(n);
  // if(1) {}
  //((a == b)? "Yes" : "No")
  rep(i, n) cin >> a.at(i);
  sort(all(a));
  for (int i = 1; i < n; i++) {
    if (a.at(i) == a.at(i - 1)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
Problem p02779 (C++)

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

int main() {
  long long int n, c = 0;
  cin >> n;
  vector<long long int> a(100000);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), std::greater<>());
  for (int i = 0; i < n - 1; i++) {
    if (a[i] == a[i + 1]) {
      c = 1;
    }
  }
  if (c == 1) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}

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

int main() {
  long long int n, c = 0;
  cin >> n;
  vector<long long int> a(1000000);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), std::greater<>());
  for (int i = 0; i < n - 1; i++) {
    if (a[i] == a[i + 1]) {
      c = 1;
    }
  }
  if (c == 1) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}
Problem p02779 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
long long int n, arr[10 ^ 9];
int main() {
  int flag;
  flag = 1;
  long long int i;
  scanf("%lld", &n);
  for (i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
  }
  sort(arr, arr + n);
  for (i = 0; i < n; i++) {
    if (arr[i] == arr[i + 1]) {
      flag = 0;
      printf("NO");
      break;
    }
    // scanf("%lld",&arr[i]);
  }
  if (flag == 1) {
    printf("YES");
  }
  printf("\n");
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
long long int n, arr[100000000];
int main() {
  int flag;
  flag = 1;
  long long int i;
  scanf("%lld", &n);
  for (i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
  }
  sort(arr, arr + n);
  for (i = 0; i < n; i++) {
    if (arr[i] == arr[i + 1]) {
      flag = 0;
      printf("NO");
      break;
    }
    // scanf("%lld",&arr[i]);
  }
  if (flag == 1) {
    printf("YES");
  }
  printf("\n");
  return 0;
}
Problem p02779 (C++)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < n; i++) {
    if (count(a.begin() + i, a.end(), a.at(i)) != 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

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());
  for (int i = 0; i < n - 1; i++) {
    if (a.at(i) == a.at(i + 1)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
Problem p02779 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 7;
int a[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  bool bl = true;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++a[x];
    if (a[x] > 1)
      bl = false;
  }
  bl ? cout << "YES\n" : cout << "NO\n";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 7;
unordered_map<int, int> a;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  bool bl = true;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++a[x];
    if (a[x] > 1)
      bl = false;
  }
  bl ? cout << "YES\n" : cout << "NO\n";
  return 0;
}
Problem p02779 (C++)

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

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define FORd(i, a, b) for (int i = a; i >= b; i--)
#define fi first
#define se second
#define II pair<ll, ll>

const int maxn = 2e5 + 10;
const ll maxN = 1e18 + 10;

ll ST[maxn], a[maxn];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> dd(maxn, 0);
  FOR(i, 1, n) {
    int h;
    cin >> h;
    if (dd[h] == 1) {
      cout << "NO";
      exit(0);
    }
    dd[h] = 1;
  }
  cout << "YES";
}


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

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define FORd(i, a, b) for (int i = a; i >= b; i--)
#define fi first
#define se second
#define II pair<ll, ll>

const int maxn = 2e5 + 10;
const ll maxN = 1e18 + 10;

ll ST[maxn], a[maxn];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  map<ll, ll> dd;
  FOR(i, 1, n) {
    int h;
    cin >> h;
    if (dd[h] == 1) {
      cout << "NO";
      exit(0);
    }
    dd[h] = 1;
  }
  cout << "YES";
}
Problem p02779 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#define ll long long
using namespace std;
struct dog {
  string a;
  int b;
};
int main() {
  // dog shiba; dog pa;
  // cin >> shiba.a >> pa.a;
  // cin >> shiba.b >> pa.b;
  // string key;
  // cin >> key;
  // if (shiba.a == key)shiba.b -= 1;
  // else if (pa.a == key)pa.b -= 1;
  // cout << shiba.b << " " << pa.b;

  // string key;
  // cin >> key;
  // for (int i = 0; i < key.length(); i++)
  //{
  //	cout << "x";
  // }

  int n;
  cin >> n;
  vector<ll> dog;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    dog.push_back(a);
  }
  sort(dog.begin(), dog.end());
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (dog[i] == dog[j]) {
        cout << "NO";
        exit(0);
      }
    }
  }

  cout << "YES";
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#define ll long long
using namespace std;
struct dog {
  string a;
  int b;
};
int main() {
  // dog shiba; dog pa;
  // cin >> shiba.a >> pa.a;
  // cin >> shiba.b >> pa.b;
  // string key;
  // cin >> key;
  // if (shiba.a == key)shiba.b -= 1;
  // else if (pa.a == key)pa.b -= 1;
  // cout << shiba.b << " " << pa.b;

  // string key;
  // cin >> key;
  // for (int i = 0; i < key.length(); i++)
  //{
  //	cout << "x";
  // }

  int n;
  cin >> n;
  vector<ll> dog;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    dog.push_back(a);
  }
  sort(dog.begin(), dog.end());
  for (int i = 0; i + 1 < n; i++) {
    if (dog[i] == dog[i + 1]) {
      cout << "NO";
      exit(0);
    }
  }

  cout << "YES";
}
Problem p02779 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll, ll> pii;
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 1e18;
const ll mod = 1000000007;
int vis[maxn], n;
bool flg = 1;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (vis[x])
      flg = 0;
    vis[x] = 1;
  }
  puts(flg ? "YES" : "NO");
  return 0;
};

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll, ll> pii;
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 1e18;
const ll mod = 1000000007;
int n;
map<int, int> vis;
bool flg = 1;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (vis[x])
      flg = 0;
    vis[x] = 1;
  }
  puts(flg ? "YES" : "NO");
  return 0;
};
Problem p02779 (C++)

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

using namespace std;

long long z[2323];
int n, m;
int main() {
  bool flag = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m;
    z[i] = m;
  }
  sort(z, z + n);
  for (int i = 0; i < n - 1; i++) {
    if (z[i] == z[i + 1])
      flag = 1;
  }
  if (flag == 1)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}

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

using namespace std;

long long z[0x3f3f3f];
int n, m;
int main() {
  bool flag = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m;
    z[i] = m;
  }
  sort(z, z + n);
  for (int i = 0; i < n - 1; i++) {
    if (z[i] == z[i + 1])
      flag = 1;
  }
  if (flag == 1)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
Problem p02779 (C++)

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

using namespace std;

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

  vector<int> A(N);
  int l, ii = 0;
  while (cin >> l) {
    A[ii] = l;
    ii++;
  }

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

  string answer = "YES";
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (A[i] == A[j]) {
        answer = "NO";
        break;
      }
    }
  }

  cout << answer << endl;
  return 0;
}

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

using namespace std;

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

  vector<int> A(N);
  int l, ii = 0;
  while (cin >> l) {
    A[ii] = l;
    ii++;
  }

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

  string answer = "YES";
  for (int i = 0; i < N - 1; i++) {
    if (A[i] == A[i + 1]) {
      answer = "NO";
      break;
    }
  }

  cout << answer << endl;
  return 0;
}
Problem p02779 (C++)

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

int main() {
  int N;

  cin >> N;

  vector<double> A;
  set<double> A_set;

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    A_set.insert(A.at(i));
  }

  if (A.size() == A_set.size()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

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

int main() {
  int N;

  cin >> N;

  vector<double> A(N);
  set<double> A_set;

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    A_set.insert(A.at(i));
  }

  if (A.size() == A_set.size()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
Problem p02779 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <random>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> v{istream_iterator<int>(cin), istream_iterator<int>()};

  std::sort(v.begin(), v.end() - 1);
  rep(i, int(v.size())) {
    if (int(v.at(i)) == v.at(i + 1)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <random>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> v{istream_iterator<int>(cin), istream_iterator<int>()};

  std::sort(v.begin(), v.end());
  rep(i, int(v.size()) - 1) {
    if (int(v.at(i)) == v.at(i + 1)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
Problem p02779 (C++)

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

int main() {
  int n;
  cin >> n;
  vector<bool> arr(1e7);
  bool dis = 1;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (arr[t]) {
      dis = 0;
    }
    arr[t] = 1;
  }
  if (dis)
    cout << "YES";
  else
    cout << "NO";
}


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

int main() {
  int n;
  cin >> n;
  map<int, int> arr;
  bool dis = 1;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (arr[t]) {
      dis = 0;
    }
    arr[t] = 1;
  }
  if (dis)
    cout << "YES";
  else
    cout << "NO";
}
Problem p02779 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, s = 0, a[100000];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (i = 0; i < n; i++) {
    if (a[i] != a[i + 1]) {
      s++;
    }
  }
  if (s == n) {
    cout << "YES" << endl;
    ;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, s = 0, a[200110];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (i = 0; i < n; i++) {
    if (a[i] != a[i + 1]) {
      s++;
    }
  }
  if (s == n) {
    cout << "YES" << endl;
    ;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
Problem p02779 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) { cin >> a[i]; }
  rep(i, N) {
    rep(j, N) {
      if (a[i] == a[j] && i != j) {
        cout << "NO" << endl;
        return 0;
      } else {
        continue;
      }
    }
  }
  cout << "YES" << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) { cin >> a[i]; }
  sort(a.begin(), a.end());
  rep(i, N - 1) {
    if (a[i] == a[i + 1]) {
      cout << "NO" << endl;
      return 0;
    } else {
      continue;
    }
  }
  cout << "YES" << endl;
}
Problem p02779 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

#define MOD 1000000007

int main() {
  ll n;
  vector<bool> as = {};

  cin >> n;
  as.resize(100000001, false);

  for (auto i = 0; i < n; i++) {
    ll a;
    cin >> a;

    if (as[a]) {
      cout << "NO" << endl;
      return 0;
    } else {
      as[a] = true;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

#define MOD 1000000007

int main() {
  ll n;
  vector<bool> as = {};

  cin >> n;
  as.resize(1000000001, false);

  for (auto i = 0; i < n; i++) {
    ll a;
    cin >> a;

    if (as[a]) {
      cout << "NO" << endl;
      return 0;
    } else {
      as[a] = true;
    }
  }
  cout << "YES" << endl;
  return 0;
}
Problem p02780 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define repeat(i, n) for (ll(i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N, 0);
  vector<double> expect(N, 0.0), list(N, 0.0);
  double result = 0.0;

  repeat(i, N) {
    cin >> p[i];
    expect[i] = (double)(1 + p[i]) / 2.0;
  }

  list[0] = 0;
  for (int i = 1; i <= N; i++) {
    list[i] = list[i - 1] + expect[i - 1];
  }
  for (int i = K; i <= N; i++) {
    result = max(result, list[i] - list[i - K]);
  };

  cout << fixed << setprecision(10) << result << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define repeat(i, n) for (ll(i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N, 0);
  vector<double> expect(210000, 0.0), list(210000, 0.0);
  double result = 0.0;

  repeat(i, N) {
    cin >> p[i];
    expect[i] = (double)(1 + p[i]) / 2.0;
  }

  list[0] = 0;
  for (int i = 1; i <= N; i++) {
    list[i] = list[i - 1] + expect[i - 1];
  }
  for (int i = K; i <= N; i++) {
    result = max(result, list[i] - list[i - K]);
  };

  cout << fixed << setprecision(10) << result << endl;
  return 0;
}
Problem p02780 (C++)

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<double> p(N);
  for (int i = 0; i < N; ++i)
    cin >> p[i];
  vector<double> sum(N + 1);
  sum[0] = 0;
  for (int i = 0; i < N; ++i) {
    double e = (p[i] * (p[i] + 1)) / 2;
    e /= p[i];
    sum[i + 1] = sum[i] + e;
  }

  double ans = -1.;
  for (int i = 0; i < N - 2; ++i) {
    ans = max(ans, sum[i + K] - sum[i]);
  }

  printf("%.10lf\n", ans);
  return 0;
}


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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<double> p(N);
  for (int i = 0; i < N; ++i)
    cin >> p[i];
  vector<double> sum(N + 1);
  sum[0] = 0;
  for (int i = 0; i < N; ++i) {
    double e = (p[i] * (p[i] + 1)) / 2;
    e /= p[i];
    sum[i + 1] = sum[i] + e;
  }

  double ans = -1.;
  for (int i = 0; i < N - K + 1; ++i) {
    ans = max(ans, sum[i + K] - sum[i]);
  }

  printf("%.10lf\n", ans);
  return 0;
}
Problem p02780 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x, y) x = max(x, y)
#define mins(x, y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1 << 29);

int main() {

  double N, K;
  cin >> N >> K;

  vector<double> p(N);
  REP(i, N) cin >> p[i];

  double temp = 0;
  double sum = 0;
  for (double i = 0; i < N - K + 1; i++) {
    double kari = 0;
    for (double j = i; j < i + K; j++) {
      kari += p[j];
    }
    // cout << kari << endl;

    if (kari > sum) {
      sum = kari;
      temp = i;
    }
  }

  double ans = 0;
  ans = (sum + K) / 2;
  printf("%.15f\n", ans);

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x, y) x = max(x, y)
#define mins(x, y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1 << 29);

int main() {

  double N, K;
  cin >> N >> K;

  vector<double> p(N);
  REP(i, N) cin >> p[i];

  double temp = 0;
  double sum = 0;
  for (int i = 0; i < K; i++) {
    sum += p[i];
  }
  temp = sum;
  for (double i = K; i < N; i++) {
    temp -= p[i - K];
    temp += p[i];
    if (temp > sum)
      sum = temp;
  }

  double ans = 0;
  ans = (sum + K) / 2;
  printf("%.15f\n", ans);

  return 0;
}
Problem p02780 (C++)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

int main() {
  int n, k;
  cin >> n >> k;
  vector<long double> p(n), s(n), a(n);
  s[0] = 0;
  rep(i, n) {
    long double temp;
    cin >> temp;
    p[i] = (1 + temp) / 2;
  }
  for (int i = 1; i < n + 1; i++) {
    s[i] = s[i - 1] + p[i - 1];
  }
  long double ans = 0;
  for (int i = 0; i < n - k + 1; i++) {
    ans = ans > s[i + k] - s[i] ? ans : s[i + k] - s[i];
  }
  // rep(i,n) cout << a[i] << endl;
  cout << fixed << setprecision(12);
  cout << ans << endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

int main() {
  int n, k;
  cin >> n >> k;
  vector<long double> p(n), s(n + 1), a(n);
  s[0] = 0;
  rep(i, n) {
    long double temp;
    cin >> temp;
    p[i] = (1 + temp) / 2;
  }
  for (int i = 1; i < n + 1; i++) {
    s[i] = s[i - 1] + p[i - 1];
  }
  long double ans = 0;
  for (int i = 0; i < n - k + 1; i++) {
    ans = ans > s[i + k] - s[i] ? ans : s[i + k] - s[i];
  }
  // rep(i,n) cout << a[i] << endl;
  cout << fixed << setprecision(12);
  cout << ans << endl;
}
Problem p02780 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int a[200005], n, k;
double ans, num;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = 1; i <= k; i++)
    num += a[i];
  ans = num;
  for (int i = 2; i < n; i++) {
    num -= a[i - 1];
    num += a[i + k - 1];
    ans = max(ans, num);
  }
  printf("%10.12f", (ans + k) / 2);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int a[2000005], n, k;
double ans, num;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = 1; i <= k; i++)
    num += a[i];
  ans = num;
  for (int i = 2; i < n; i++) {
    num -= a[i - 1];
    num += a[i + k - 1];
    ans = max(ans, num);
  }
  printf("%10.12f", (ans + k) / 2);
  return 0;
}
Problem p02780 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n); i >= 0; i--)
#define revrepr(i, a, b) for (int i = (a); i >= b; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9 + 7;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++)
    cin >> v.at(i);
  return is;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<double> p(n);
  cin >> p;
  double maxi = 0;
  rep(i, n - k + 1) {
    double res = 0;
    rep(j, k) { res += (p.at(i + j) + 1) / 2.0; }
    chmax(maxi, res);
  }
  printf("%.10lf\n", maxi);
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n); i >= 0; i--)
#define revrepr(i, a, b) for (int i = (a); i >= b; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9 + 7;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++)
    cin >> v.at(i);
  return is;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<double> p(n);
  cin >> p;
  double maxi = 0;
  double sum = 0;
  rep(i, n) {
    sum += (p.at(i) + 1) / 2;
    if (i < k - 1)
      continue;

    if (k <= i) {
      sum -= (p.at(i - k) + 1) / 2;
    }
    chmax(maxi, sum);
  }
  printf("%.10lf\n", maxi);
}
Problem p02780 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N, K, mx_pk = 0;
  cin >> N >> K;
  vector<int> p(N);
  rep(i, N) cin >> p.at(i);
  rep(i, N - K + 1) {
    int tmp = 0;
    for (int j = i; j < i + K; j++) {
      tmp += p.at(j);
    }
    mx_pk = max(mx_pk, tmp);
  }
  cout << fixed << setprecision(10) << (mx_pk + K) / 2.0 << endl;
}


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

int main() {
  int N, K, mx_pk = 0;
  cin >> N >> K;
  vector<int> p(N + 1, 0), p_sum(N + 1, 0);
  rep(i, N) cin >> p.at(i + 1);
  rep(i, N) p_sum.at(i + 1) = p_sum.at(i) + p.at(i + 1);

  for (int i = N; i - K >= 0; i--)
    mx_pk = max(mx_pk, p_sum.at(i) - p_sum.at(i - K));
  cout << fixed << setprecision(10) << (mx_pk + K) / 2.0 << endl;
}
Problem p02780 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cassert>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define seg_size 524288

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  vector<int> a(n - k + 1);
  rep(i, n - k + 1) rep(j, k) a[i] += p[j + i];
  double max = 0;
  rep(i, a.size()) {

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

  max = (max + k) / 2;
  printf("%.10f\n", max);
  return 0;
}

Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cassert>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define seg_size 524288

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  vector<int> a(n - k + 1);
  rep(i, k) a[0] += p[i];
  for (int i = 1; i < n - k + 1; i++) {
    a[i] = a[i - 1] - p[i - 1] + p[i + k - 1];
  }
  double max = 0;
  rep(i, a.size()) {

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

  max = (max + k) / 2;
  printf("%.10f\n", max);
  return 0;
}
Problem p02780 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ALL(x) begin(x), end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

template <class T> inline bool chmax(T &a, const T &b) {
  return b > a ? a = b, true : false;
}
template <class T> inline bool chmin(T &a, const T &b) {
  return b < a ? a = b, true : false;
}
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) {
  sort(begin(v), end(v), f);
  v.resize(unique(begin(v), end(v)) - begin(v));
}

const int MAX_N = 200005;
double A[MAX_N];

double E(int x) { return (double)(x + 1) / 2; }

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

  int n, k;
  cin >> n >> k;
  REP(i, n) {
    int a;
    cin >> a;
    A[i] = E(a);
  }

  double ans = 0, temp = 0;

  REP(i, n) {
    temp += A[i];
    if (n >= k)
      temp -= A[i - k];
    chmax(ans, temp);
  }
  cout << setprecision(10) << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ALL(x) begin(x), end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

template <class T> inline bool chmax(T &a, const T &b) {
  return b > a ? a = b, true : false;
}
template <class T> inline bool chmin(T &a, const T &b) {
  return b < a ? a = b, true : false;
}
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) {
  sort(begin(v), end(v), f);
  v.resize(unique(begin(v), end(v)) - begin(v));
}

const int MAX_N = 200005;
double A[MAX_N];

double E(int x) { return (double)(x + 1) / 2; }

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

  int n, k;
  cin >> n >> k;
  REP(i, n) {
    int a;
    cin >> a;
    A[i] = E(a);
  }

  double ans = 0, temp = 0;

  REP(i, n) {
    temp += A[i];
    if (i >= k)
      temp -= A[i - k];
    chmax(ans, temp);
  }
  cout << setprecision(10) << ans << endl;
  return 0;
}
Problem p02780 (C++)

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<double> kit(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    kit.at(i) = (a.at(i) + 1.0) / 2;
  }
  double ans = 0;
  for (int i = 0; i <= n - k; i++) {
    double bf = 0;
    for (int j = 0; j < k; j++) {
      bf += kit.at(i + j);
    }
    ans = max(ans, bf);
  }
  cout << setprecision(9) << ans << endl;
  return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<double> kit(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    kit.at(i) = (a.at(i) + 1.0) / 2;
  }
  double ans = 0, bf = 0;
  for (int i = 0; i < k; i++)
    bf += kit.at(i);
  ans = bf;
  for (int i = k; i < n; i++) {
    bf += kit.at(i) - kit.at(i - k);
    ans = max(ans, bf);
  }
  cout << setprecision(9) << ans << endl;
  return 0;
}
Problem p02780 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll int64_t
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = 1; i <= n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007

using namespace std;

bool compare_by_b(pair<string, ll> a, pair<string, ll> b) {
  if (a.second != b.second)
    return a.second < b.second;
  else
    return a.first < b.first;
}

bool my_compare(pair<string, ll> a, pair<string, ll> b) {

  if (a.first != b.first)
    return a.first < b.first;
  if (a.second != b.second)
    return a.second > b.second;
  else
    return true;
}

ll factorial(ll n) {
  ll x = 1;
  rrep(i, n) x *= i;
  return x;
}

ll gcd(ll a, ll b) {
  if (a % b == 0)
    return (b);
  else
    return (gcd(b, a % b));
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  double n, k, maxi = -100, sum = 0;
  cin >> n >> k;
  vector<double> p(n), q(n), r(n, 0);
  rep(i, n) {
    cin >> p[i];
    q[i] = (1 + p[i]) / 2;
    sum += q[i];
    r[i + 1] = sum;
  }
  if (n == 1) {
    cout << q[0] << endl;
    return 0;
  }
  rep(i, n - k + 1) {
    if (maxi < (r[i + k] - r[i]))
      maxi = r[i + k] - r[i];
  }
  cout << fixed << setprecision(30) << maxi << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll int64_t
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = 1; i <= n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007

using namespace std;

bool compare_by_b(pair<string, ll> a, pair<string, ll> b) {
  if (a.second != b.second)
    return a.second < b.second;
  else
    return a.first < b.first;
}

bool my_compare(pair<string, ll> a, pair<string, ll> b) {

  if (a.first != b.first)
    return a.first < b.first;
  if (a.second != b.second)
    return a.second > b.second;
  else
    return true;
}

ll factorial(ll n) {
  ll x = 1;
  rrep(i, n) x *= i;
  return x;
}

ll gcd(ll a, ll b) {
  if (a % b == 0)
    return (b);
  else
    return (gcd(b, a % b));
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  double n, k, maxi = -100, sum = 0;
  cin >> n >> k;
  vector<double> p(n), q(n), r(n + 1, 0);
  rep(i, n) {
    cin >> p[i];
    q[i] = (1 + p[i]) / 2;
    sum += q[i];
    r[i + 1] = sum;
  }
  if (n == 1) {
    cout << q[0] << endl;
    return 0;
  }
  rep(i, n - k + 1) {
    if (maxi < (r[i + k] - r[i]))
      maxi = r[i + k] - r[i];
  }
  cout << fixed << setprecision(30) << maxi << endl;
  return 0;
}