Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02958 (python)

Fixed submission:
import sys
n = int(sys.stdin.readline())
p = [int(i) for i in sys.stdin.readline().split()]

if p == sorted(p):
    print('YES')
elif len(p) == 2:
    print('YES')
else:
    swap_index = []
    for i, v in enumerate(p[:-1]):
        if v > p[i + 1]:
            if len(swap_index) == 0:
                swap_index.append(i)
            else:
                swap_index.append(i + 1)
                break
    if len(swap_index) == 1:
        print('NO')
    else:
        p[swap_index[0]], p[swap_index[1]] = p[swap_index[1]], p[swap_index[0]]
        if p == sorted(p):
            print('YES')
        else:
            print('NO')

Buggy submission (verdict: Runtime Error):
import sys
n = int(sys.stdin.readline())
p = [int(i) for i in sys.stdin.readline().split()]

if p == sorted(p):
    print('YES')
elif len(p) == 2:
    print('YES')
else:
    swap_index = []
    for i, v in enumerate(p[:-1]):
        if v > p[i + 1]:
            if len(swap_index) == 0:
                swap_index.append(i)
            else:
                swap_index.append(i + 1)
                break
    if len(swap_index) == 1:
        print('NO')
    p[swap_index[0]], p[swap_index[1]] = p[swap_index[1]], p[swap_index[0]]

    if p == sorted(p):
        print('YES')
    else:
        print('NO')

Buggy submission (verdict: Runtime Error):
import sys
n = int(sys.stdin.readline())
p = [int(i) for i in sys.stdin.readline().split()]

if p == sorted(p):
    print('YES')
elif: len(p) == 2:
    print('YES')
else:
    swap_index = []
    for i, v in enumerate(p[:-1]):
        if v > p[i + 1]:
            if len(swap_index) == 0:
                swap_index.append(i)
            else:
                swap_index.append(i + 1)
                break
    if len(swap_index) == 1:
        print('NO')
    p[swap_index[0]], p[swap_index[1]] = p[swap_index[1]], p[swap_index[0]]

    if p == sorted(p):
        print('YES')
    else:
        print('NO')

Buggy submission (verdict: Runtime Error):
import sys
n = int(sys.stdin.readline())
p = [int(i) for i in sys.stdin.readline().split()]

if p == sorted(p):
    print('YES')
else:
    swap_index = []
    for i, v in enumerate(p[:-1]):
        if v > p[i + 1]:
            if len(swap_index) == 0:
                swap_index.append(i)
            else:
                swap_index.append(i + 1)
                break
    if len(swap_index) == 1:
        print('NO')
    p[swap_index[0]], p[swap_index[1]] = p[swap_index[1]], p[swap_index[0]]

    if p == sorted(p):
        print('YES')
    else:
        print('NO')

Buggy submission (verdict: Runtime Error):
import sys
n = int(sys.stdin.readline())
p = [int(i) for i in sys.stdin.readline().split()]

if p == sorted(p):
    print('YES')
else:
    swap_index = []
    for i, v in enumerate(p[:-1]):
        if v > p[i + 1]:
            if len(swap_index) == 0:
                swap_index.append(i)
            else:
                swap_index.append(i + 1)
                break
    p[swap_index[0]], p[swap_index[1]] = p[swap_index[1]], p[swap_index[0]]

    if p == sorted(p):
        print('YES')
    else:
        print('NO')
Problem p02981 (python)

Fixed submission:
_input = [i for i in open(0).read().split('\n') if i]
n, a, b = [int(i) for i in _input[0].split()]
print(min(n * a, b))

Buggy submission (verdict: Runtime Error):
_input = [i for i in open(0).read().split('\n') if i]
n, k = [int(i) for i in _input[0].split()]
edge = tuple([tuple([int(p) for p in i.split()]) for i in _input[1:n]])

factorial = [0] * (k + 1)
inverse = [0] * (k + 1)
MOD = 1000000007

# Ref: http://keita-matsushita.hatenablog.com/entry/2016/12/05/175024
def mod_pow1(n, k, mod):
    a = 1
    while k:
        if (k & 1) == 1:
            a = (a * n) % mod
        n = (n * n) % mod
        k >>= 1
    return a

# Ref: https://www.smartbowwow.com/2018/10/mod1097.html
def mod_pow2(n, k, mod):
    if k == 0:
        return 1
    if k % 2 == 0:
        a = mod_pow2(n, k // 2, mod)
        return (a * a) % mod
    else:
        return (n * mod_pow2(n, k - 1, mod)) % mod

mod_pow = pow

def mod_factorial_inverse(k, mod):
    factorial[0] = 1
    inverse[0] = 1

    # Ref: http://keita-matsushita.hatenablog.com/entry/2016/12/05/184011
    for i in range(1, k + 1):
        factorial[i] = ((i * factorial[i - 1]) % mod) # factrial[i]
        inverse[i] = mod_pow(factorial[i], mod - 2, mod) # inverse[i]

if not edge:
    print(k)
else:
    all_edge = tuple([[] for _ in range(n + 1)])
    for e in edge:
        all_edge[e[0]].append(e[1])
        all_edge[e[1]].append(e[0])

    if [v for v in all_edge if len(v) >= k]:
        print(0)
    else:
        mod_factorial_inverse(k, MOD)
Problem p03611 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
a = list(map(int, input().split()))

t = [0] * (max(a) + 1)
for v in a:
    t[v] += 1

if max(a) <= 1:
    print(sum(t))
    sys.exit(0)

ans = 0
for i in range(0, max(a) - 1):
    ans = max(ans, t[i] + t[i+1] + t[i+2])

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
a = list(map(int, input().split()))

t = [0] * (max(a) + 1)
for v in a:
    t[v] += 1

if max(a) <= 1:
    print(t[0] + t[1])
    sys.exit(0)

ans = 0
for i in range(0, max(a) - 1):
    ans = max(ans, t[i] + t[i+1] + t[i+2])

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
a = list(map(int, input().split()))

t = [0] * (max(a) + 1)
for v in a:
    t[v] += 1

if max(a) <= 1:
    pritn(t[0] + t[1])
    sys.exit(0)

ans = 0
for i in range(0, max(a) - 1):
    ans = max(ans, t[i] + t[i+1] + t[i+2])

print(ans)
Problem p03106 (python)

Fixed submission:
A, B, K = map(int, input().split())
l = []

for i in range(1, min(A, B) + 1):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])

Buggy submission (verdict: Runtime Error):
from math import gcd

A, B, K = map(int, input().split())
l = []

for i in range(1, min(A, B) + 1):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])

Buggy submission (verdict: Runtime Error):
from math import gcd

A, B, K = map(int, input().split())
l = []

for i in range(1, gcd(A, B) + 1):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])
Problem p03109 (python)

Fixed submission:
date = input()

import re
date_num = int(re.sub("\D", "", date))

if date_num <= 20190430:
    print("Heisei")
else:
    print("TBD")

Buggy submission (verdict: Runtime Error):
date = int(input().replace("/", ""))
if date <= 20190430:
    print("Heisei")
else:
    print("TBD")S = list(map(int, input().split("/")))
ans = True
if S[0] > 2019:
    ans = False
elif S[0] == 2019 and S[1] > 4:
    ans = False

if ans:
    print("Heisei")
else:
    print("TBD")
Problem p03434 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

alice = 0
bob = 0

a.sort(reverse = True)

i = 0

while True:
    if i >= n:
        break
    alice += a[i]
    i += 1
    if i >= n:
        break
    bob += a[i]
    i += 1

print(alice - bob)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

a.sort(reverce = True)

alice = sum(a[0::2])
bob = sum(a[1::2])

print(alice - bob)
Problem p03219 (python)

Fixed submission:
a,b = map(int,input().split())
c = int(a+b/2)
print(c)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
print(a+b/2)
Problem p02658 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))

if 0 in a:
    print(0)
    exit()

c = 1
for i in a:
    c *= i
    if c > 10 ** 18:
        print(-1)
        exit()

print(c)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = list(map(int,input().split()))

ans = np.prod(a)
if ans >= 10**18:
    ans = -1
print(ans)
Problem p02684 (python)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))

num = 1
li = [1]
flag = [True] * n
flag[0] = False

for i in range(k):
    num = a[num-1]
    if flag[num-1]:
        li.append(num)
        flag[num-1] = False
    else:
        break

d = li.index(num)
ans = (k-d)%(len(li)-d)+d

print(li[ans])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
a_m = max(a)
tt = [-1] * a_m
tt[0] = 0
ans_l = []

i = 0
while True:
    if tt[a[i]-1] != -1:
        loop = i - tt[a[i]-1]
        k -= tt[a[i]-1]
        break
    tt[a[i]-1] = i + 1
    ans_l.append(a[i])
    i += 1

ans_c = k % loop
print(ans_l[ans_c+tt[a[i]-1]])
Problem p02687 (python)

Fixed submission:
s = input()

if s == "ABC":
  ans = "ARC"
else:
  ans = "ABC"
  
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()

if s == "ABC":
  ans = "ARC"
else:
  ans = "ABC"
  
 print(ans)

Buggy submission (verdict: Runtime Error):
s = input()

if s == "ABC":
  ans = "ARC"
 else:
  ans = "ABC"
  
 print(ans)
Problem p02690 (python)

Fixed submission:
x = int(input())

for a in range(-1000,1000):
    for b in range(-1000,1000):
        if a ** 5 - b ** 5 == x:
            print(a,b)
            exit()

Buggy submission (verdict: Runtime Error):
x = int(input())

for a in range(1000):
    for b range(1000):
        if a ** 5 - b ** 5 == x:
            print(a,b)
            exit()
Problem p02732 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = [0 for i in range(n)]
c = 0
for i in a_2:
    if i > 1:
        al[c] += i * (i-1) / 2
    c += 1

sine = sum(al)
for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sine-(al[f-1]-t*(t-1)/2)))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = []
for i in a_2:
    pass
#    al.append(int(i * (i-1) / 2))

for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sum(al)-(al[f-1]-t*(t-1)/2)))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = []
#for i in a_2:
#    al.append(int(i * (i-1) / 2))

for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sum(al)-(al[f-1]-t*(t-1)/2)))
Problem p02761 (python)

Fixed submission:
n,m = map(int,input().split())
t = [[] for _ in range(n)]
for i in range(m):
    t_1,t_2 = map(int,input().split())
    t[t_1-1].append(t_2)

ans = ""
for i in range(n):
    if len(set(t[i])) == 1:
        ans += str(t[i][0])
    elif not t[i]:
        if i == 0:
            if n == 1:
                ans += "0"
            else:    
                ans += "1"
        else:
            ans += "0"
    else:
        print(-1)
        exit()
if ans[0] == "0":
    if n == 1:
        print(0)
    else:
        print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
t = [[] for _ in range(n)]
for i in range(m):
    t_1,t_2 = map(int,input().split())
    t[t_1-1].append(t_2)

ans = ""
for i in range(n):
    if len(set(t[i])) == 1:
        ans += str(t[i][0])
    if not t[i]:
        if i == 0:
            ans += "1"
        else:
            ans += "0"
if ans[0] == "0":
    if n == 1:
        print(0)
    else:
        print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
t = [[] for _ in range(n)]
for i in range(m):
    t_1,t_2 = map(int,input().split())
    t[t_1-1].append(t_2)

ans = ""
for i in t:
    if len(set(i)) == 1:
        ans += str(i[0])
    if not i:
        ans += "0"
if ans[0] == "0":
    if n == 1:
        print(0)
    else:
        print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
t = [[] for _ in range(n)]
for i in range(m):
    t_1,t_2 = map(int,input().split())
    t[t_1-1].append(t_2)

ans = ""
for i in t:
    if len(set(i)) == 1:
        ans += str(i[0])
    if not i:
        ans += "0"
if ans[0] == "0":
    print(-1)
else:
    print(ans)
Problem p02818 (python)

Fixed submission:
A,B,K = map(int,input().split())
if K == 0:
    print(A,B)
    exit()
if (A+B) < K:
    print(0,0)
    exit()
elif A > K:
    A -= K
else:
    A -= K
    if A != 0:
        B += A
        A -= A
print(A,B)

Buggy submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
for i in range(K):
    if A == 0:
        K_2 = K - i
        break
    A -= 1
for i in range(K_2):
    B -= 1
print(A,B)
Problem p02838 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
ans = 0
for k in range(60):
    A_0 = 0
    A_1 = 0
    for i in range(N):
        if A[i]>>k&1:
            A_1 += 1
        else:
            A_0 += 1
    num = A_1 * A_0
    ans += (num * 2 ** k)
ans %=  mod
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
b = 0
num = 1000000007
N_1 = N.pop(-1)
N_2 = N.pop(0)
for i in N_1:
    for j in N_2:
        b += N_1 ^ N_2
print(b%num)
Problem p02923 (python)

Fixed submission:
n = int(input())
h = list(map(int,input().split()))

ans = []
c = 0
for i in range(n-1):
    if h[i+1] <= h[i]:
        c += 1
        if i == n-2:
            ans.append(c)
    elif h[i+1] > h[i]:
        ans.append(c)
        c = 0

if not ans:
    print(0)
    exit()
print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))

ans = []
c = 0
for i in range(n-1):
    if h[i+1] <= h[i]:
        c += 1
        if i == n-2:
            ans.append(c)
    elif h[i+1] > h[i]:
        ans.append(c)
        c = 0

print(max(ans))
Problem p03103 (python)

Fixed submission:
n,m = map(int,input().split())
a_b = {}
for i in range(n):
    x,y = map(int,input().split())
    if x in a_b.keys():
        a_b[x] += y
        continue
    a_b[x] = y
a_b = sorted(a_b.items(), key=lambda x:x[0])

#print(a_b)
c = 0
ans = 0
t = 0
for i in range(int(len(a_b))):
    c += a_b[i][1]
    if c > m:
        ans += a_b[i][0] * (m - t)
        break
    else:
        ans += a_b[i][0] * a_b[i][1]
        t += a_b[i][1]

print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a_b = {}
for i in range(n):
    x,y = map(int,input().split())
    if x in a_b.keys():
        a_b[x] += y
        continue
    a_b[x] = y
a_b = sorted(a_b.items(), key=lambda x:x[0])

#print(a_b)
c = 0
ans = 0
t = 0
for i in range(n):
    c += a_b[i][1]
    if c > m:
        ans += a_b[i][0] * (m - t)
        break
    else:
        ans += a_b[i][0] * a_b[i][1]
        t += a_b[i][1]

print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    x,y = map(int,input().split())
    a.append(x)
    b.append(y)
if int(len(set(a))) == 1:
    print(a[0] * m)
    exit()
a_b = dict(zip(a,b))
a_b = sorted(a_b.items(), key=lambda x:x[0])

c = 0
ans = 0
t = 0
for i in range(n):
    c += a_b[i][1]
    if c > m:
        ans += a_b[i][0] * (m - t)
        break
    else:
        ans += a_b[i][0] * a_b[i][1]
        t += a_b[i][1]

print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    z,y = map(int,input().split())
    a.append(z)
    b.append(y)
a_b = dict(zip(a,b))
a_b = sorted(a_b.items(), key=lambda x:x[0])

c = 0
ans = 0
t = 0
for i in range(n):
    c += a_b[i][1]
    if c > m:
        ans += a_b[i][0] * (m - t)
        break
    else:
        ans += a_b[i][0] * a_b[i][1]
        t += a_b[i][1]

print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    x,y = map(int,input().split())
    a.append(x)
    b.append(y)
a_b = dict(zip(a,b))
a_b = sorted(a_b.items(), key=lambda x:x[0])

c = 0
ans = 0
t = 0
for i in range(n):
    c += a_b[i][1]
    if c > m:
        ans += a_b[i][0] * (m - t)
        break
    else:
        ans += a_b[i][0] * a_b[i][1]
        t += a_b[i][1]

print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    x,y = map(int,input().split())
    a.append(x)
    b.append(y)
a_b = dict(zip(a,b))
a_b = sorted(a_b.items(), key=lambda x:x[0])

c = 0
ans = 0
t = 0
for i in range(n):
    c += a_b[i][1]
    if c > m:
        ans += a_b[i][0] * (m - t)
        break
    else:
        ans += a_b[i][0] * a_b[i][1]
        t += a_b[i][1]

print(ans)
Problem p03730 (python)

Fixed submission:
a,b,c = map(int,input().split())
for i in range(b):
    if i * a % b == c:
        print("YES")
        exit()
print("NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

k = 1
p = False
for i in range(n):
    if a[k-1] == 2:
        print(i+1)
        p = True
        break
    k = a[k-1]
if not p:
    print(-1)
Problem p02536 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)


def dfs(idx):
    for x in arr[idx]:
        if not vis[x]:
            vis[x] = True
            dfs(x)


n, m = map(int, input().split())

arr = [[] * (n + 1) for _ in range(n + 1)]
vis = [False] * (n + 1)

for _ in range(m):
    a, b = map(int, sys.stdin.readline().split())
    arr[a].append(b)
    arr[b].append(a)

ans = 0

if m == 0:
    print(n-1)
    sys.exit()

dfs(1)
for i in range(2, n + 1):
    if not vis[i]:
        vis[i] = True
        dfs(i)
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys


def dfs(idx):
    for x in arr[idx]:
        if not vis[x]:
            vis[x] = True
            dfs(x)


n, m = map(int, input().split())

arr = [[] * (n + 1) for _ in range(n + 1)]
vis = [False] * (n + 1)

for _ in range(m):
    a, b = map(int, sys.stdin.readline().split())
    arr[a].append(b)
    arr[b].append(a)

ans = 0

dfs(1)
for i in range(2, n + 1):
    if not vis[i]:
        vis[i] = True
        dfs(i)
        ans += 1
for i in range(1, n + 1):
    if not vis[i]:
        ans += 1
print(ans)
Problem p02548 (python)

Fixed submission:
n = int(input())
ans = 0
for a in range(1, n):
  ans += (n - 1) // a
print(ans)

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

ans = 0

print((n-1)+len(range(n**(1/2))))
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(lambda x: int(x) - 1, input().split()))

done = [-1]*N
done[0] = 0

tmp = 0
done[0] = 0
for k in range(1, K + 1):
    tmp = A[tmp]
    if done[tmp] >= 0:
        for _ in range((K - done[tmp]) % (k - done[tmp])):
            tmp = A[tmp]
        print(tmp + 1)
        exit()
    else:
        done[tmp] = k
print(tmp + 1)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split())) 

ll = [a[0]]

for i in range(1, n):
    cnt = ll[i-1]
    if cnt = a[cnt-1]:
        print(cnt)
        exit()
    if a[cnt-1] == a[0]:
        break
    else:
        ll.append(a[cnt-1])

print(ll[k%3-1])

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split())) 

ll = [a[0]]

for i in range(1, n):
    cnt = ll[i-1]
    if a[cnt-1] == a[0]:
        break
    else:
        ll.append(a[cnt-1])

print(ll[k%3-1])
Problem p02714 (python)

Fixed submission:
N = int(input())
S = list(input())

cntOne = S.count('R') * S.count('G') * S.count('B')
cntTwo = 0


for i in range(N-1):
    for j in range(i+1, N):
        k = (j - i) + j
        if k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cntTwo += 1
print(cntOne - cntTwo)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())

a = S[0]
res= 0

for i in range(1, N-2):
    if a == S[i]:
        b = S[i]
        for j in range(j, N-1):
            if i == j:
                continue
            c = S[j]
            if a!=b and b!= c and a!=c:
                res +=1

print(res)
Problem p02743 (python)

Fixed submission:
a,b,c = map(int,input().split())

if (c-a-b)>0 and 4*a*b<(c-a-b)**2:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
 
if a**2 + 2*math.sqrt(a*b)+b**2 -c**2 < 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
 
if a**2 + 2*math.sqrt(a*b)+b**2 < c**2:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())

if a**2 + 2*math.sqrt(a*b)+b**2 < c**2:
  print('yes')
else:
  print('no')
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
P = [list(map(int,input().split())) for i in range(M)]

ans = -1

for x in range(1000):
    if len(str(x)) != N: 
        continue
    else:
        count = 0
        s = str(x)
        for p in P:
            if int(s[int(p[0]) - 1]) == p[1]:
                count += 1
        if count == M:
            ans = x
            break

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int,input().split())) for i in range(M)]

sc = list(map(list, set(map(tuple, A))))
for i in range(len(sc)):
    tmp0 = sc[i][0]
    tmp1 = sc[i][1]
    for j in range(1, len(sc)-i+1):
        if tmp0 == sc[-j][0] and tmp1 != sc[-j][1]:
            print(-1)
            exit()

if N == 3:
    #for i in range(100,1000):
        #i_str = str(i)
    for j in range(len(sc)):
        if sc[j][0] == 1 and sc[j][0] == 0:
            print(-1)
            exit()
        if sc[j][0] == 1:
            num = sc[j][1]
print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int,input().split())) for i in range(M)]

sc = list(map(list, set(map(tuple, A))))
for i in range(len(sc)):
    tmp0 = sc[i][0]
    tmp1 = sc[i][1]
    for j in range(1, len(sc)-i+1):
        if tmp0 == sc[-j][0] and tmp1 != sc[-j][1]:
            print(-1)
            exit()

if N == 3:
    #for i in range(100,1000):
        #i_str = str(i)
    for j in range(len(sc)):
        if sc[j][0] == 1 and sc[j][0] == 0:
            print(-1)
            exit()
        if sc[j][0] == 1:
            num = sc[j][1]
Problem p02802 (python)

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

ac = [0] *N
pena = [0] *N

for _ in range(M):
    P, S = map(str, input().split())
    P = int(P) - 1
    if ac[P]: continue
    if S == 'AC':
        ac[P] = 1
    else:
        pena[P] += 1

AC = 0
PENA = 0

for i in range(N):
    AC += ac[i]
    if ac[i]:
        PENA += pena[i]

print('{} {}'.format(AC, PENA))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
x = []
y = []
for i in range(M):
    x1,y1=[i for i in input().split()]
    x.append(int(x1))
    y.append(y1)

if not any(x):
  print('{} {}'.format(0, 0))
  exit()


countWC = 0
countAC = 0
index = 0

for i in range(N):
  while y[index] == 'WA':
    countWC += 1
    index += 1   
  if index > 0:
    if x[index] == x[index - 1]:
      if y[index] == 'AC' and y[index - 1] == 'AC':
        continue
      if y[index] == 'WA' and y[index - 1] == 'AC':
        continue
  countAC += 1 
  index += 1

	
print('{} {}'.format(countAC, countWC))
Problem p02923 (python)

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

ans = 0
cnt = 0

for i in range(N-1):
    if H[i] < H[i+1]:
        cnt = 0
    else:
        cnt += 1
    ans = max(cnt, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split())) 
H.reverse()

ans = 0
arr = []

for i in range(N-1):
    if H[i+1] >= H[i]:
        ans += 1
    else:
        arr.append(ans)
        ans = 0

print(max(arr))
Problem p03378 (python)

Fixed submission:
import numpy as np

n, m, x = map(int, input().split())
a = np.array(list(map(int, input().split())))


print(min(len(a[a<x]),len(a[a>x])))

Buggy submission (verdict: Runtime Error):
import numpy as np

n, m, x = map(int, input().split())
a = np.array(list(map(int, input().split())))


print(min(len(a[a<x]),len(a[a>x])))