Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0]*n
for i in range(m):
	a[int(input())]=1

num=[1,1,2]

mod=1000000007

count=0
jud=1
ans=1
for i in range(n+1):
	
	if i>2:
		num.append(1)
		num[i]=(num[i-1]+num[i-2])%mod

	if(jud==0 and a[i]==1):
		print("0")
		break
	elif(i==n):
		count+=1
		ans=(ans%mod)*(num[count-1]%mod)
		
		print(ans%mod)
	elif a[i]==1:
		
		ans=(ans%mod)*(num[count-1]%mod)
		count=0
		jud=0
	else:
		jud=1
		count+=1

Fixed submission:
n,m=map(int,input().split())
a=[0]*(n+1)
for i in range(m):
	a[int(input())]=1


num=[1,1,2]


mod=1000000007

count=0
jud=1
ans=1
for i in range(n+1):
	
	if i>2:
		num.append(1)
		num[i]=(num[i-1]+num[i-2])%mod

	if(jud==0 and a[i]==1):
		print("0")
		break
	elif a[i]==1:
		ans=(ans%mod)*(num[count-1]%mod)
		count=0
		jud=0
	elif(i==n):
		count+=1
		ans=(ans%mod)*(num[count-1]%mod)
		print(ans%mod)
	else:
		jud=1
		count+=1

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=[]
for i in range(m):
	a.append(int(input()))

num=[1,1,2]


mod=1000000007

count=0
jud=1
ans=1
for i in range(n+1):
	
	if i>2:
		num.append(1)
		num[i]=(num[i-1]+num[i-2])%mod

	if(jud==0 and i in a):
		print("0")
		break
	elif i in a:
		
		ans=(ans%mod)*(num[count-1]%mod)
		count=0
		jud=0
	elif(i==n):
		count+=1
		ans=(ans%mod)*(num[count-1]%mod)
		
		print(ans%mod)
	else:
		jud=1
		count+=1




Fixed submission:
n,m=map(int,input().split())
a=[0]*(n+1)
for i in range(m):
	a[int(input())]=1


num=[1,1,2]


mod=1000000007

count=0
jud=1
ans=1
for i in range(n+1):
	
	if i>2:
		num.append(1)
		num[i]=(num[i-1]+num[i-2])%mod

	if(jud==0 and a[i]==1):
		print("0")
		break
	elif a[i]==1:
		ans=(ans%mod)*(num[count-1]%mod)
		count=0
		jud=0
	elif(i==n):
		count+=1
		ans=(ans%mod)*(num[count-1]%mod)
		print(ans%mod)
	else:
		jud=1
		count+=1
Buggy python submission (verdict: Time Limit Exceeded):
h, w, d = map(int, input().split())
A = []
for i in range(h):
    A.append(list(map(int, input().split())))
q = int(input())

I = [0] * (w * h + 1)
for i in range(h):
    for j in range(w):
        I[A[i][j]] = (i, j)

s = []
g = []
for i in range(q):
    s, g = map(int, input().split())
    ans = 0
    while(g != s):
        ans += abs(I[s][0] - I[s + d][0]) + abs(I[s][1] - I[s + d][1])
        s += d
    print(ans)


Fixed submission:
h, w, d = map(int, input().split())
A = []
for i in range(h):
    A.append(list(map(int, input().split())))
q = int(input())

I = [0] * (w * h + 1)
for i in range(h):
    for j in range(w):
        I[A[i][j]] = (i, j)
D = [0] * (h * w + 1)
for i in range(d + 1, h * w + 1):
    D[i] = D[i - d] + abs(I[i][0] - I[i - d][0]) + abs(I[i][1] - I[i - d][1])
s = []
g = []
for i in range(q):
    s, g = map(int, input().split())
    print(D[g] - D[s])

Buggy python submission (verdict: Time Limit Exceeded):
h, w, d = map(int, input().split())
A = []
for i in range(h):
    A.append(list(map(int, input().split())))
q = int(input())
s = []
g = []
search = []
for i in range(q):
    s, g = map(int, input().split())
    search.append([])
    while(s != g):
        search[i].append([s, s + d])
        s += d

for i in range(h):
    for j in range(w):
        for l in range(q):
            for k in range(len(search[l])):
                if(search[l][k][0] == A[i][j]):
                    search[l][k][0] = (i, j)
                elif(search[l][k][1] == A[i][j]):
                    search[l][k][1] = (i, j)

for i in range(q):
    ans = 0
    for x in search[i]:
        ans += abs(x[0][0] - x[1][0]) + abs(x[0][1] - x[1][1])
    print(ans)


Fixed submission:
h, w, d = map(int, input().split())
A = []
for i in range(h):
    A.append(list(map(int, input().split())))
q = int(input())

I = [0] * (w * h + 1)
for i in range(h):
    for j in range(w):
        I[A[i][j]] = (i, j)
D = [0] * (h * w + 1)
for i in range(d + 1, h * w + 1):
    D[i] = D[i - d] + abs(I[i][0] - I[i - d][0]) + abs(I[i][1] - I[i - d][1])
s = []
g = []
for i in range(q):
    s, g = map(int, input().split())
    print(D[g] - D[s])
Buggy python submission (verdict: Time Limit Exceeded):
list_ = [0]
n, min_count = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
kind = 1
tmp = a[0]
for i in range(n):
    if(tmp != a[i]):
        kind += 1
        tmp = a[i]
        list_.append(0)
    list_[kind - 1] += 1
ans = 0
for i in range(kind - min_count):
    min_idx = list_.index(min(list_))
    ans += list_[min_idx]
    list_[min_idx] = 200001
print(ans)

Fixed submission:
list_ = [0]
n, min_count = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
kind = 1
tmp = a[0]
for i in range(n):
    if(tmp != a[i]):
        kind += 1
        tmp = a[i]
        list_.append(0)
    list_[kind - 1] += 1
ans = 0
list_.sort()
idx = 0
for i in range(kind - min_count):
    ans += list_[idx]
    idx += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
def L(n):
    a = 2
    b = 1
    for i in range(n - 1):
        res = 0
        res += a + b
        a = b
        b = res
    return res
print(L(int(input())))

Fixed submission:
def L(n):
    a = 2
    b = 1
    res = 1
    for i in range(n - 1):
        res = 0
        res += a + b
        a = b
        b = res
    return res
print(L(int(input())))
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(n**2 - int(input())

Fixed submission:
n = int(input())
print(n**2 - int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_n = list(map(int, input().split()))
a_n.sort()
a_n.reverse()
def check(idx):
    global a_n
    base = a_n[idx]
    count = 0
    dif = 0
    now = a_n[idx]
    while dif <= 2:
        idx += 1
        count += 1
        if(idx == len(a_n)):
            return count
        dif = base - a_n[idx]
        
    return count

ans = -1
for i in  range(n):
    if(ans < check(i)):
        ans = check(i)
print(ans)


Fixed submission:
n = int(input())
a_n = list(map(int, input().split()))
a_n.sort()
a_n.reverse()
def check(idx):
    global a_n
    base = a_n[idx]
    count = 0
    dif = 0
    while dif <= 2:
        idx += 1
        count += 1
        if(idx == n):
            return count
        dif = base - a_n[idx]
    return count

ans = 1
i = 0
c = check(i)
tmp = a_n[0]
while(i != n):
    if(tmp != a_n[i]):
        tmp = a_n[i]
        c = check(i)
    if(ans < c):
        ans = c
    i += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)
n = int(input())
prev = 0
for i in range(n):
    if(i == 0):
        prev = int(input())
    else:
        t = int(input())
        prev = int(prev * t / gcd(prev, t))
print(prev)


Fixed submission:
def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)
n = int(input())
prev = 1
for i in range(n):
        t = int(input())
        prev = prev * t // gcd(prev, t)
print(prev)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
prev = 0
for i in range(n):
    if(i == 0):
        prev = int(input())
    else:
        t = int(input())
        prev = int(prev * t / math.gcd(prev, t))
print(prev)


Fixed submission:
def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)
n = int(input())
prev = 1
for i in range(n):
        t = int(input())
        prev = prev * t // gcd(prev, t)
print(prev)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
prev = 0
for i in range(n):
    if(i == 0):
        prev = int(input())
    else:
        t = int(input())
        prev = prev * t // math.gcd(prev, t)
print(prev)


Fixed submission:
def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)
n = int(input())
prev = 1
for i in range(n):
        t = int(input())
        prev = prev * t // gcd(prev, t)
print(prev)
Buggy python submission (verdict: Runtime Error):
a, b = list(map(int, input().split()))
if(a % 3 == 0 or b % 3 ==0 or (a + b)4 5 % 3 == 0):
    print("Possible")
else:
    print("Impossible")


Fixed submission:
a, b = list(map(int, input().split()))
if(a % 3 == 0 or b % 3 ==0 or (a + b) % 3 == 0):
    print("Possible")
else:
    print("Impossible")
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
if(a > b):
    print("GREATER")
elif(a < b):
    print("LESS")
elif(a == b):
    print("EQUAL")


Fixed submission:
inp = input()
split = inp.split()
out = ""
for s in split:
    out += s[0].upper()
print(out)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = 1
for i in range(n):
    p *= (i + 1)
print(p % (10**9 + 7))


Fixed submission:
n = int(input())
p = 1
for i in range(n):
    p = p * (i + 1) % (10**9 + 7)
print(p)
Buggy python submission (verdict: Runtime Error):
import collections
from math import factorial

max = int(input())
i = 0
strings = []
while True:
  if i == max:
    break
  strings.append(input())
  i+=1

#print(strings) # ['acornistnt', 'peanutbomb', 'constraint']

strings2 = [list(str) for str in strings]
[str.sort() for str in strings2] # 配列の中身を副作用でソートする
# print(strings2)
strs3 = [''.join(str) for str in strings2] # ソートした文字のリストを文字列に戻す

#print(strs3)

c = collections.Counter(strs3)
# print(c)
counts = list(c.values()) # 組み合わせの数のリスト
counts2 = [ c for c in counts if c > 1] # 2個以上の重複がないものは除外
#print(counts2)

# nC2 の組み合わせを計算して、合計する
print(sum([int(factorial(n) / factorial(2) / factorial(n - 2)) for n in counts2]))

Fixed submission:
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

max = int(input())
i = 0
strings = []
while True:
  if i == max:
    break
  strings.append(input())
  i+=1

#print(strings) # ['acornistnt', 'peanutbomb', 'constraint']

strings2 = [list(str) for str in strings]
[str.sort() for str in strings2] # 配列の中身を副作用でソートする
# print(strings2)
strs3 = [''.join(str) for str in strings2] # ソートした文字のリストを文字列に戻す

#print(strs3)

c = collections.Counter(strs3)
# print(c)
counts = list(c.values()) # 組み合わせの数のリスト
counts2 = [ c for c in counts if c > 1] # 2個以上の重複がないものは除外
#print(counts2)

# nC2 の組み合わせを計算して、合計する
print(sum([int(cmb(n, 2)) for n in counts2]))
Buggy python submission (verdict: Runtime Error):
n = list(map(int, input().split()))
a = n[0]
b = n[1]
 
if a == b:
  print(a + b)
elif a > b:
  print(a*2 - 1)
else:
  print(b*2 - 1)
n = list(map(int, input().split()))
a = n[0]
b = n[1]

if a == b:
  print(a + b)
elif a > b:
  print(a*2 - 1)
else:
  print(b*2 - 1)


Fixed submission:
n = list(map(int, input().split()))
a = n[0]
b = n[1]

if a == b:
  print(a + b)
elif a > b:
  print(a*2 - 1)
else:
  print(b*2 - 1)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = (int(x) for x in input().split())
mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

K2 = K-2
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(N):
    for j in range(i):
        ans += (a[i]-a[j])*(cmb(i-j-1,K2,mod))
        ans = ans % mod
print(ans)

Fixed submission:
N,K = (int(x) for x in input().split())
mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

K1 = K-1
NK = N-K+1
a = list(map(int, input().split()))
a.sort()
ans = 0
maxs = 0
mins = 0
for i in range(N):
    if i < K1:continue
    maxs += a[i] * cmb(i,K1,mod)
    maxs = maxs%mod
for i in range(NK):
    mins += a[i] * cmb(N-i-1,K1,mod)
    mins = mins%mod
print((maxs - mins)%mod)
Buggy python submission (verdict: Runtime Error):
5 1000000000

Fixed submission:
import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n,m = (int(x) for x in input().split())
a = list(map(int, input().split()))

lc = int(lcm_list(a) // 2)

tmp = 0
bol = 0
num = a[0]
while num % 2 == 0:
        num = num // 2
        tmp += 1
cnt = 0
for num in a:
    cnt = 0
    while num % 2 == 0:
        num = num // 2
        cnt += 1
    if cnt != tmp:
        bol = 1

if lc > m: print(0)
elif bol == 1: print(0)
else: print(int(((m / lc) + 1) // 2))

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n,m = (int(x) for x in input().split())
a = list(map(int, input().split()))

lc = lcm_list(a) / 2
if lc > m: print(0)
else: print(int((m / lc) // 2 + 1))

Fixed submission:
import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n,m = (int(x) for x in input().split())
a = list(map(int, input().split()))

lc = int(lcm_list(a) // 2)

tmp = 0
bol = 0
num = a[0]
while num % 2 == 0:
        num = num // 2
        tmp += 1
cnt = 0
for num in a:
    cnt = 0
    while num % 2 == 0:
        num = num // 2
        cnt += 1
    if cnt != tmp:
        bol = 1

if lc > m: print(0)
elif bol == 1: print(0)
else: print(int(((m / lc) + 1) // 2))
Buggy python submission (verdict: Runtime Error):
C = input()

if x == "a":
    print("b")
elif x == "b":
    print("c")
elif x == "c":
    print("d")
elif x == "d":
    print("e")
elif x == "e":
    print("f")
elif x == "f":
    print("g")
elif x == "g":
    print("h")
elif x == "h":
    print("i")
elif x == "i":
    print("j")
elif x == "j":
    print("k")
elif x == "k":
    print("l")
elif x == "l":
    print("m")
elif x == "m":
    print("n")
elif x == "n":
    print("o")
elif x == "o":
    print("p")
elif x == "p":
    print("q")
elif x == "q":
    print("r")
elif x == "r":
    print("s")
elif x == "s":
    print("t")
elif x == "t":
    print("u")
elif x == "u":
    print("v")
elif x == "v":
    print("w")
elif x == "w":
    print("x")
elif x == "x":
    print("y")
elif x == "y":
    print("z")
else:
    print("era-")

Fixed submission:
C = input()
 
if C == "a":
    print("b")
elif C == "b":
    print("c")
elif C == "c":
    print("d")
elif C == "d":
    print("e")
elif C == "e":
    print("f")
elif C == "f":
    print("g")
elif C == "g":
    print("h")
elif C == "h":
    print("i")
elif C == "i":
    print("j")
elif C == "j":
    print("k")
elif C == "k":
    print("l")
elif C == "l":
    print("m")
elif C == "m":
    print("n")
elif C == "n":
    print("o")
elif C == "o":
    print("p")
elif C == "p":
    print("q")
elif C == "q":
    print("r")
elif C == "r":
    print("s")
elif C == "s":
    print("t")
elif C == "t":
    print("u")
elif C == "u":
    print("v")
elif C == "v":
    print("w")
elif C == "w":
    print("x")
elif C == "x":
    print("y")
elif C == "y":
    print("z")
else:
    print("era-")

Buggy python submission (verdict: Runtime Error):
C = input()
alphabetlist = [chr(i) for i in range(97, 97+26)]
next_index = alphabetlist.index(C)+1
print(alphabetlist(next_index))

Fixed submission:
C = input()
alphabetlist = [chr(i) for i in range(97, 97+26)]
next_index = alphabetlist.index(C)+1
print(alphabetlist[next_index])
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
D = list(map(int, input().split()))
shiharai=N
l = [int(x) for x in list(str(N))]
c=len(l)
for i in range(len(l)):
    while l[i] in D:
        shiharai+=1
        l = [int(x) for x in list(str(shiharai))]
if len(l)!=c:
    for i in range(len(l)):
        while l[i] in D:
            shiharai+=1
            l = [int(x) for x in list(str(shiharai))]
print(shiharai)

Fixed submission:
A, B, C= map(int, input().split())
if (A!=5 and A!=7) or (B!=5 and B!=7) or (C!=5 and C!=7):
    print("NO")
elif A==5:
    if (B==5 and C==7) or (B==7 and C==5):
        print ("YES")
    else:
        print("NO")
elif (B==5 and C==5):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
import sys

for alpha in sys.stdin:
	sys.stdout.write(chr(ord(alpha)+1))

Fixed submission:
alpha = input()
print(chr(ord(alpha)+1))

Buggy python submission (verdict: Runtime Error):
import sys

alphas = [chr(i) for i in range(ord('a'), ord('z') +1)]
for alpha in sys.stdin:
	print(alphas[alphas.index(alpha)+1])

Fixed submission:
alpha = input()
print(chr(ord(alpha)+1))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np
iNum, iK = map(int, input().split())
iK -= 1
naA = np.array(list(map(int, input().split())), dtype = "int64")
naA = np.sort(naA)
naA = list(naA)
#print(naA)
iMod = 1000000007
iRet*=0
iNmrt = 1
iDnmt = 1
for iK0 in range(iK):
  iNmrt *= iNum - iK0
  iDnmt *= iK0 + 1
iU0= iNmrt // iDnmt
#print(iNum, iK, iU0)
iL0=0
iU = iNum
for iL, iA in enumerate(naA):
  iU -= 1
  if iL > iK:
    iL0 *= iL
    iL0//= iL - iK
  elif iL == iK:
    iL0 = 1
  else:
    iL0 = 0
  if iU >= iK:
    iU0 *=  iU+1-iK
    iU0 //= iU+1
  else:
    iU0 = 0
  #print("iU, iK, iU0, iA :",iU,iK,iU0, iA)
  #print("iL, iK, iL0, iA :",iL,iK,iL0, iA)
  iL0mU0=  iL0 - iU0
  iRet0 = (iL0mU0 * iA) % iMod
  iRet += iRet0
  #print(iRet0)
  iAp = iA
print(iRet%iMod)


Fixed submission:
# -*- coding: utf-8 -*-
import numpy as np

iMod = 1000000007
lModPow = [iP for iP, s in enumerate(bin(iMod-2)[:1:-1]) if s == "1"]

def fnModInv(iDivN):
  lNp  = [iDivN % iMod]
  for _ in range(max(lModPow)):
    lNp.append(lNp[-1]**2 % iMod)
  iRet = 1
  for iP in lModPow:
    iRet *= lNp[iP]
    iRet %= iMod
  return iRet

def fnSolv():
  iNum, iK = map(int, input().split())
  naU = [0]*iNum
  naA = np.array(list(map(int, input().split())), dtype = np.int64)
  naA = np.sort(naA)
  iRet =0
  if iK >= 2:
    naU[-iK] = 1
    for iK0 in range(iNum - iK):
      naU[-iK -iK0 - 1]= ( (naU[- iK - iK0] * (iK + iK0))%iMod * fnModInv(iK0 + 1) )%iMod
  for iL, iA in enumerate(naA):
    iRet += ((naU[-iL-1] - naU[iL])%iMod * iA)%iMod
    iRet %=iMod
  print(iRet)

if __name__ == '__main__':
  fnSolv()
Buggy python submission (verdict: Runtime Error):
c=input()
print(char(ord(c)+1)

Fixed submission:
c=input()
print(chr(ord(c)+1))
Buggy python submission (verdict: Runtime Error):
X=input()
c=list(input())
result=0
i=0
while i<len(c):
    if c[i]=='A':
        if c[i+1]=='B' and c[i+2]=='C':
            result+=1
            i+=1
        else:
            i+=1
    else:
        i+=1
print(result)

Fixed submission:
X=input()
c=list(input())
result=0
i=0
while i<len(c)-2:
    if c[i]=='A':
        if c[i+1]=='B' and c[i+2]=='C':
            result+=1
            i+=3
        else:
            i+=1
    else:
        i+=1
print(result)

Buggy python submission (verdict: Runtime Error):
X=input()
c=list(input())
result=0
i=0
while i<len(c):
    if c[i]=='A':
        if c[i+1]=='B' and c[i+2]=='C':
            result+=1
            i+=3
        else:
            i+=1
    else:
        i+=1
print(result)

Fixed submission:
X=input()
c=list(input())
result=0
i=0
while i<len(c)-2:
    if c[i]=='A':
        if c[i+1]=='B' and c[i+2]=='C':
            result+=1
            i+=3
        else:
            i+=1
    else:
        i+=1
print(result)
Buggy python submission (verdict: Runtime Error):
#Nが問題数Mが提出数
N, M = map(int, input().split())

submit = []
for _ in range(M):
  temp = [x for x in input().split()]
  submit.append(temp)

ac = [0]*(N + 1)
wa = [0]*(N + 1)
  
for i in range(M):
  result = submit[i][1]
  question = int(submit[i][0])
  
  if result == 'AC' and ac[question] == 0:
    ac[question] = 1
  elif result == 'WA' and ac[question] == 0:
    wa[question] += 1

for i in range(n + 1):
  if ac[i] != 1:
    wa[i] = 0

print(sum(ac), sum(wa))
  

Fixed submission:
#Nが問題数Mが提出数
N, M = map(int, input().split())
 
submit = []
for _ in range(M):
  temp = [x for x in input().split()]
  submit.append(temp)
 
ac = [0]*(N + 1)
wa = [0]*(N + 1)
  
for i in range(M):
  result = submit[i][1]
  question = int(submit[i][0])
  
  if result == 'AC' and ac[question] == 0:
    ac[question] = 1
  elif result == 'WA' and ac[question] == 0:
    wa[question] += 1
 
for i in range(N + 1):
  if ac[i] != 1:
    wa[i] = 0
 
print(sum(ac), sum(wa))
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int(), input().split())

if A >= K:
  a = A - K
  b = B
elif A+B >= K:
  a = 0
  b = A + B - K
else:
  a = 0
  b = 0

print(str(a) + " " + str(b))

Fixed submission:
A, B, K = map(int, input().split())
     
if A >= K:
  a = A - K
  b = B
elif A+B >= K:
  a = 0
  b = A + B - K
else:
  a = 0
  b = 0
     
print(str(a) + " " + str(b))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = map(int, input().split())

num = 0
for i in range(N):
  if a[i] == (num + 1):
    num += 1

if num == 0:
  print(-1)
else:
  print(N-num)

Fixed submission:
N = int(input())
a = [i for i in map(int, input().split())]
     
num = 0
for i in range(N):
  if a[i] == (num + 1):
    num += 1
    
if num == 0:
  print(-1)
else:
  print(N-num)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
print(t + s)

Fixed submission:
s, t = input().split()
print(t + s)
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
print(int(a * b / math.gcd(a, b)))


Fixed submission:
import fractions
a, b = map(int, input().split())
print(int(a * b / fractions.gcd(a, b)))
Buggy python submission (verdict: Time Limit Exceeded):
def t(a):
    b = 0
    n = 0
    while n < len(a):
        if a[n] == n + 1:
            n += 1
        else:
            a.pop(n)
            b += 1
    return b if len(a) != 0 else -1


if __name__ == '__main__':
    n = input()
    a = list(map(int, input().split()))
    print(t(a))


Fixed submission:
def t(a):
    b = [False] * len(a)
    c = 1
    for i, j in enumerate(a):
        if j == c:
            b[i] = True
            c += 1

    return b.count(False) if any(b) else -1


if __name__ == '__main__':
    n = input()
    a = list(map(int, input().split()))
    print(t(a))
Buggy python submission (verdict: Time Limit Exceeded):
def t(n, a):
    return ' '.join([str(a.index(i) + 1) for i in range(1, n + 1)])


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    print(t(n, a))


Fixed submission:
def t(a):
    return " ".join([str(j + 1) for i, j in sorted([(j, i) for i, j in enumerate(a)])])


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    print(t(a))