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

Fixed submission:
i=input()

a=int(i[0])
b=int(i[1])
c=int(i[2])
d=int(i[3])

if a+b+c+d==7:
    x="+"
    y="+"
    z="+"
elif a+b+c-d==7:
    x="+"
    y="+"
    z="-"
elif a+b-c+d==7:
    x="+"
    y="-"
    z="+"    
elif a-b+c+d==7:
    x="-"
    y="+"
    z="+"
elif a-b-c+d==7:
    x="-"
    y="-"
    z="+"
elif a-b+c-d==7:
    x="-"
    y="+"
    z="-"
elif a+b-c-d==7:
    x="+"
    y="-"
    z="-"
elif a-b-c-d==7:
    x="-"
    y="-"
    z="-"
    
    
print(a,end="")
print(x,end="")
print(b,end="")
print(y,end="")
print(c,end="")
print(z,end="")
print(d,end="")
print("=7")

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

a=int(i[0])
b=int(i[1])
c=int(i[2])
d=int(i[3])

if a+b+c+d==7:
    x="+"
    y="+"
    z="+"
elif a+b+c-d==7:
    x="+"
    y="+"
    z="-"
elif a+b-c+d==7:
    x="+"
    y="-"
    z="+"    
elif a-b+c+d==7:
    x="-"
    y="+"
    z="+"
elif a-b-c+d==7:
    x="-"
    y="-"
    z="+"
elif a-b+c-d==7:
    x="-"
    y="+"
    z="-"
elif a-b-c+d==7:
    x="-"
    y="-"
    z="+"
elif a-b-c-d==7:
    x="-"
    y="-"
    z="-"
    
    
print(a,end="")
print(x,end="")
print(b,end="")
print(y,end="")
print(c,end="")
print(z,end="")
print(d,end="")
print("=7")

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

a=int(i[0])
b=int(i[1])
c=int(i[2])
d=int(i[3])

if a+b+c+d==7:
    x="+"
    y="+"
    z="+"

if a+b+c-d==7:
    x="+"
    y="+"
    z="-"
    
    
if a+b-c+d==7:
    x="+"
    y="-"
    z="+"    

if a-b+c+d==7:
    x="-"
    y="+"
    z="+"
    
if a-b-c+d==7:
    x="-"
    y="-"
    z="+"

if a-b+c-d==7:
    x="-"
    y="+"
    z="-"

if a-b-c+d==7:
    x="-"
    y="-"
    z="+"
    
if a-b-c-d==7:
    x="-"
    y="-"
    z="-"
    
    
print(a,end="")
print(x,end="")
print(b,end="")
print(y,end="")
print(c,end="")
print(z,end="")
print(d,end="")
print("=7")
Problem p03565 (python)

Fixed submission:
s=input()
t=input()

ls=len(s)
lt=len(t)

def f(a,b):
    r=""
    for i in range(lt):
        if a[i]==b[i] or a[i]=="?":
            r+=b[i]
        else:
            return False
    return True
        
ans=[]

for i in range(ls-lt+1):
    c=""
    if f(s[i:i+lt],t):
        c+=s[0:i]
        c+=t
        c+=s[i+lt:ls]
        c=c.replace("?","a")
        ans.append(c)

if ans==[]:
    print("UNRESTORABLE")
else:
    print(min(ans))

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
ans=""
k=0
l=0
for i in range(len(s)):
    x=i+k
    y=0
    if x>=len(s):
        break
    if s[i+k]==t[0]:
        for j in range(len(t)):
            if (s[x+j]==t[j] or s[x+j]=="?")and x+j<len(s):
                y+=1
            else:
                break
        if y==len(t):
            ans+=t
            k+=len(t)-1
            l=1
        
    else:
        ans+=s[i+k]

ans=ans.replace("?","a")  
if l==1:
    print(ans)    
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
ans=""
k=0
l=0
for i in range(len(s)):
    x=i+k
    y=0
    if x>=len(s):
        break
    if s[i+k]==t[0]:
        for j in range(len(t)):
            if (s[x+j]==t[j] or s[x+j]=="?")and x+j<len(s):
                y+=1
            else:
                break
        if y==len(t):
            ans+=t
            k+=len(t)
            l=1
        
    else:
        ans+=s[i]

ans=ans.replace("?","a")  
if l==1:
    print(ans)    
else:
    print("UNRESTORABLE")
Problem p03612 (python)

Fixed submission:
n=int(input())
p=[int(i) for i in input().split()]

ans=0

if p[0]==1:
    ans+=1
    p[1]=1

for i in range(1,n):
    if p[i]==i+1:
        if p[i-1]==i:
            ans+=1
            p[i]=i
        else:
            if i+1!=n:
                if p[i+1]!=i+2:
                    ans+=1
                    p[i]=p[i-1]
            else:
                ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
p=[int(i) for i in input().split()]

ans=0

if p[0]==1:
    ans+=1
    p[1]=1

for i in range(1,n):
    if p[i]==i+1:
        if p[i-1]==i:
            ans+=1
            p[i]=i
        else:
            if p[i+1]!=i+2:
                ans+=1
                p[i]=p[i-1]

print(ans)
Problem p03722 (python)

Fixed submission:
n,m=map(int,input().split())
abc=[]
for i in range(m):
    abc.append([int(j) for j in input().split()])
b=[float("INF")]*(n+1)
b[1]=0
for i in range(1,n+1):
    for s,t,u in abc:
        if b[t]>b[s]-u:
            b[t]=b[s]-u
            if i==n and t==n:
                print("inf")
                exit()
print(-b[-1])

Buggy submission (verdict: Runtime Error):
#ベルマンフォード法
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford

n,m=map(int,input().split())
edge=np.array([input().split() for _ in range(m)],dtype=np.int64).T
graph=csr_matrix(((-edge[2],edge[:2]-1)),(n,n))

while True:
    try:
        #False->無向グラフ True->有効グラフ
        ans=bellman_ford(graph,directed=True,indices=[0])[0].astype(int)
        print(-ans[-1])
        break
    except:
        #負経路の場合
        print("inf")
        break
Problem p03952 (python)

Fixed submission:
n,x=map(int,input().split())
m=2*n-1
if x==1 or x==m:
    print("No")
    exit()
if n==2:
    print("Yes")
    for i in [1,2,3]:
        print(i)
    exit()
ll=list(range(1,2*n))
if x!=2:
    l=[x-1,x,x+1,x-2]
    ll.remove(x-1)
    ll.remove(x)
    ll.remove(x+1)
    ll.remove(x-2)
else:
    l=[x+1,x,x-1,x+2]
    ll.remove(x-1)
    ll.remove(x)
    ll.remove(x+1)
    ll.remove(x+2)

ans=[]
for i in range(len(ll)):
    if i==n-2:
        ans+=l
    ans.append(ll[i])
if len(ll)==n-2:
    ans+=l
print("Yes")
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
m=2*n-1
if x==1 or x==m:
    print("No")
    exit()
ll=list(range(1,2*n))
if x!=2:
    l=[x-1,x,x+1,x-2]
    ll.remove(x-1)
    ll.remove(x)
    ll.remove(x+1)
    ll.remove(x-2)
else:
    l=[x+1,x,x-1,x+2]
    ll.remove(x-1)
    ll.remove(x)
    ll.remove(x+1)
    ll.remove(x+2)

ans=[]
for i in range(len(ll)):
    if i==n-2:
        ans+=l
    ans.append(ll[i])

print("Yes")
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
m=2*n-1
if x==1 or x==m:
    print("No")
    exit()
ll=list(range(1,2*n))
if x!=2:
    l=[x-1,x,x+1,x-2]
    ll.remove(x-1)
    ll.remove(x)
    ll.remove(x+1)
    ll.remove(x-2)
else:
    l=[x+1,x,x-1,x+2]
    ll.remove(x-1)
    ll.remove(x)
    ll.remove(x+1)
    ll.remove(x+2)

ans=[]
k=0
for i in range(len(ll)+1):
    if i==n-2:
        ans+=l
        k=-1
    else:
        ans.append(ll[i+k])

print("Yes")
for i in ans:
    print(i)
Problem p04013 (python)

Fixed submission:
n,a=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]
y=[i-a for i in x]
m=sum(x)+1
dp=[[0 for j in range(m*2+1)] for i in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
    for j in range(-m,1+m):
        if j-y[i-1]>=-m and j-y[i-1]<=1+m:
            dp[i][j]=dp[i-1][j]+dp[i-1][j-y[i-1]]
        else:
            dp[i][j]=dp[i-1][j]

print(dp[n][0]-1)

Buggy submission (verdict: Runtime Error):
n,a=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]
y=[i-a for i in x]
m=sum(x)+1
dp=[[0 for j in range(m*2+1)] for i in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
    for j in range(-m,1+m):
        if j-y[i-1]>=-m:
            dp[i][j]=dp[i-1][j]+dp[i-1][j-y[i-1]]
        else:
            dp[i][j]=dp[i-1][j]

print(dp[n][0]-1)
Problem p02574 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
maxA=max(A)
pn=list(range(maxA+1))
n=2
while n*n <= maxA:
  if n == pn[n]:
    for m in range(n, len(pn), n):
      if pn[m] == m:
        pn[m] = n
  n+=1

s=set()
for a in A:
  st = set()
  while a > 1:
    st.add(pn[a])
    a//=pn[a]
  if not s.isdisjoint(st):
    break
  s |= st
else:
  print("pairwise coprime")
  exit()

from math import gcd

n = gcd(A[0], A[1])
for a in A[2:]:
  n=gcd(n,a)
if n == 1:
  print("setwise coprime")
else:
  print("not coprime")

Buggy submission (verdict: Runtime Error):
from math import gcd
N = int(input())
A = [int(i) for i in input().split()]
st=set()
s=0
pn = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]

for a in A:
  if a == 1:
    continue
  ary=[]
  d={}
  while a % 2 == 0:
    if 2 in d:
      d[2] += 1
    else:
      d[2] = 1
    a//=2
  i=1
  n = 3
  while n * n <= a:
    if a % n == 0:
      a //= n
      if n in d:
        d[n] += 1
      else:
        d[n] = 1
    else:
      i += 1
      n=pn[i]
  if a > 1:
    ary.append(a)
    if a in d:
      d[a]=1

  for k in d.keys():
    if k in st:
      break
    else:
      st.add(k)
  else:
    continue

  n=gcd(A[0],A[1])
  for a in A[2:]:
    n=gcd(n,a)
  if n == 1:
    print("setwise coprime")
  else:
    print("not coprime")
  exit()
 
print("pairwise coprime")
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = [int(i)-1 for i in input().split()]
l = []
d = {}
p = 0
while p not in d:
    d[p] = len(l)
    l.append(p)
    p = A[p]
if K < len(l):
    print(l[K % len(l)] + 1)
    exit()
elif K == len(l):
    print(p + 1)
    exit()
K -= d[p]
K %= len(l) - d[p]
print(l[K + d[p]] + 1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = [int(i)-1 for i in input().split()]
l = []
d = {}
p = 0
while p not in d:
    d[p] = len(l)
    l.append(p)
    p = A[p]
if K <= len(l):
    print(l[K] + 1)
    exit()
K -= d[p]
K %= len(l) - d[p]
print(l[K + d[p]] + 1)
Problem p02727 (python)

Fixed submission:
X, Y, A, B, C = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]
p.sort()
q.sort()
r.sort(reverse=True)
p = p[A - X:]
q = q[B - Y:]
pi = 0
qi = 0
for v in r:
    if p[pi] < v or q[qi] < v:
        if p[pi] < q[qi]:
            p[pi] = v
            pi = min(pi + 1, X - 1)
        else:
            q[qi] = v
            qi = min(qi + 1, Y - 1)
    else:
        break
print(sum(p) + sum(q))

Buggy submission (verdict: Runtime Error):
X, Y, A, B, C = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]
p.sort()
q.sort()
r.sort(reverse=True)
p = p[A - X:]
q = q[B - Y:]
pi = 0
qi = 0
for v in r:
    if p[pi] < v or q[qi] < v:
        if p[pi] < q[qi]:
            p[pi] = v
            pi = min(pi + 1, A - 1)
        else:
            q[qi] = v
            qi = min(qi + 1, B - 1)
    else:
        break
print(sum(p) + sum(q))
Problem p02768 (python)

Fixed submission:
mod = 10**9+7
N, A, B = [int(i) for i in input().split()]


def ncr(n, r):
    r = min(r, n-r)
    res = 1
    m = n
    for _ in range(r):
        res *= m
        res %= mod
        m -= 1
    m = r
    for _ in range(r):
        res *= pow(m, mod-2, mod)
        res %= mod
        m -= 1
    return res


print((pow(2, N, mod)-1-ncr(N, A)-ncr(N, B)) % mod)

Buggy submission (verdict: Runtime Error):
	mod = 10**9+7
N, A, B = [int(i) for i in input().split()]


def ncr(n, r):
    r = min(r, n-r)
    res = 1
    m = n
    for _ in range(r):
        res *= m
        res %= mod
        m -= 1
    m = r
    for _ in range(r):
        res *= pow(m, mod-2, mod)
        res %= mod
        m -= 1
    return res


print((pow(2, N, mod)-1-ncr(N, A)-ncr(N, B)) % mod)
Problem p02917 (python)

Fixed submission:
def main():
    N = int(input())
    B = [int(i) for i in input().split()]

    A = [B[0]]
    for i in range(1, len(B)):
        A.append(min([B[i], B[i-1]]))

    A.append(B[-1])
    print(sum(A))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    B = [int(i) for i in input().split()]
    b = B.copy()
    for i in (range(N-3, -1, -1)):
        if B[i] > B[i+1]:
            B[i] = B[i+1]

    for i in range(N-2):
        if b[i] < b[i+1]:
            b[i+1] = b[i]
    ans1 = sum(B)+B[0]
    ans2 = sum(b)+b[len(b)-1]
    print(ans1 if ans1 >= ans2 else ans2)


if __name__ == '__main__':
    main()
Problem p02983 (python)

Fixed submission:
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    l, r = map(int, input().split())
    if r-l >= 2018:
        print(0)
    else:
        ans = 2222
        n = [i for i in range(l, r+1)]
        for i in range(len(n)):
            for j in range(i+1, len(n)):
                s = n[i]*n[j] % 2019
                if ans > s:
                    ans = s
        print(ans)

        # n = [[i % 2019, i] for i in range(l, r+1)]
        # n.sort(key=lambda x: x[0])
        # print((n[0][1]*n[1][1]) % 2019)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
L, R = [int(i) for i in input().split()]
a = []
for i in range(L, R+1):
    a.append(i % 2019)
    if not i % 2019:
        break
a.sort()
print((a[0]*a[1]) % 2019)
Problem p02993 (python)

Fixed submission:
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    n = input()
    if n[1] == n[2] or n[2] == n[3] or n[1] == n[0]:
        print("Bad")

    else:
        print("Good")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    n = input()
    if n[1] == n[2] or n[2] == n[3] or n[3] == n[4]:
        print("Bad")

    else:
        print("Good")


if __name__ == "__main__":
    main()
Problem p03006 (python)

Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
xy = [tuple([int(i) for i in input().split()]) for _ in range(N)]
ary = []
if N == 1:
    print(1)
    exit()
for i, t in enumerate(xy[:-1]):
    x = t[0]
    y = t[1]
    for x2, y2 in xy[i+1:]:
        ary.append((x2-x, y2-y))
        ary.append((x-x2, y-y2))
c = dict(Counter(ary))
print(N-max(c.values()))

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
xy = [tuple([int(i) for i in input().split()]) for _ in range(N)]
ary = []
for i, t in enumerate(xy[:-1]):
    x = t[0]
    y = t[1]
    for x2, y2 in xy[i+1:]:
        p = x2-x
        q = y2-y
        ary.append((p, q))
c = dict(Counter(ary))
print(N-max(c.values()))
Problem p03031 (python)

Fixed submission:
import sys

def input():
    return sys.stdin.readline()[:-1]

def main():
    n,m = map(int,input().split())
    k = []
    s = []
    ans = 0
    
    for _ in range(m):
        tmp = [int(i) for i in input().split()]
        k.append(tmp.pop(0))
        s.append(tmp)

    p = [int(i) for i in input().split()]

    for i in range(2**n):
        tentou=[0]*m
        b = bin(i)[2:].zfill(n)
        for i2 in range(len(s)):
            for i3 in s[i2]:
                if b[i3-1] == "1":
                    tentou[i2]+=1
        tentou = [z % 2 for z in tentou]
        if tentou == p:
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

def input():
    return sys.stdin.readline()[:-1]

def main():
    n,m = map(int,input().split())
    k = []
    s = []
    ans = 0
    
    for _ in range(m):
        tmp = [int(i) for i in input().split()]
        k.append(tmp.pop(0))
        s.append(tmp)

    p = [int(i) for i in input().split()]

    for i in range(2**n):
        tentou=[0]*m
        b = bin(i)[2:].zfill(5)
        for i2 in range(len(s)):
            for i3 in s[i2]:
                if b[i3-1] == "1":
                    tentou[i2]+=1
        tentou = [z % 2 for z in tentou]
        if tentou == p:
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()
Problem p03240 (python)

Fixed submission:
N = int(input())
P = [[int(i) for i in input().split()] for _ in range(N)]

P.sort(key=lambda x: x[2])
array = []
p = P.pop()

for x in range(0, 101):
    for y in range(0, 101):
        H = p[2]+abs(p[0]-x)+abs(p[1]-y)
        if H > 0:
            array.append((x, y, H))

for x, y, h in P:
    ary = []
    for cx, cy, H in array:
        if h == 0:
            if h >= (H-abs(x-cx)-abs(y-cy)):
                ary.append((cx, cy, H))
        else:
            if h == (H-abs(x-cx)-abs(y-cy)):
                ary.append((cx, cy, H))
    array = ary

print(*array[0])

Buggy submission (verdict: Runtime Error):
N = int(input())
P = [[int(i) for i in input().split()] for _ in range(N)]

P.sort(key=lambda x: x[2])
array = []
p = P.pop()

for x in range(0, 101):
    for y in range(0, 101):
        H = p[2]+abs(p[0]-x)+abs(p[1]-y)
        if H > 0:
            array.append((x, y, H))

for x, y, h in P:
    ary = []
    for cx, cy, H in array:
        if h == (H-abs(x-cx)-abs(y-cy)):
            ary.append((cx, cy, H))
    array = ary

print(*array[0])
Problem p03436 (python)

Fixed submission:
from queue import Queue
H, W = map(int, input().split())
s = [input() for _ in range(H)]
d = [[float('inf')]*W for _ in range(H)]
d[0][0] = 1
cs = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            cs += 1
            d[i][j] = 0


def check(t):
    if 0 <= t[0] < H and 0 <= t[1] < W and d[t[0]][t[1]] == float('inf'):
        return True
    return False


q = Queue()
q.put((0, 0))
while not q.empty():
    h, w = q.get()
    for v in [(h-1, w), (h+1, w), (h, w-1), (h, w+1)]:
        if check(v):
            d[v[0]][v[1]] = d[h][w]+1
            q.put(v)

print(H*W-cs-d[-1][-1] if not (d[-1][-1] == float('inf')) else -1)

Buggy submission (verdict: Runtime Error):
import math
from queue import Queue
H, W = map(int, input().split())
s = [input() for _ in range(H)]
d = [[math.inf]*W for _ in range(H)]
d[0][0] = 1
cs = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            cs += 1
            d[i][j] = 0


def check(t):
    if 0 <= t[0] < H and 0 <= t[1] < W and math.isinf(d[t[0]][t[1]]):
        return True
    return False


q = Queue()
q.put((0, 0))
while not q.empty():
    h, w = q.get()
    for v in [(h-1, w), (h+1, w), (h, w-1), (h, w+1)]:
        if check(v):
            d[v[0]][v[1]] = d[h][w]+1
            q.put(v)

print(H*W-cs-d[-1][-1] if not math.isinf(d[-1][-1]) else -1)
Problem p03569 (python)

Fixed submission:
s = input()
l = 0
r = len(s)-1
ans = 0
while l < r:
    while (s[l] == 'x'or s[r] == 'x') and l < r:
        if s[l] != s[r]:
            ans += 1
        if s[l] == 'x':
            l += 1
        if s[r] == 'x':
            r -= 1
    if s[l] != s[r]:
        break
    l += 1
    r -= 1
else:
    print(ans)
    exit()
print(-1)

Buggy submission (verdict: Runtime Error):
s = input()
l = 0
r = len(s)-1
ans = 0
while l < r:
    while s[l] == 'x'or s[r] == 'x':
        if s[l] != s[r]:
            ans += 1
        if s[l] == 'x':
            l += 1
        if s[r] == 'x':
            r -= 1
    if s[l] != s[r]:
        break
    l += 1
    r -= 1
else:
    print(ans)
    exit()
print(-1)
Problem p02802 (python)

Fixed submission:
nm=list(map(int,input().split()))
ps=[]
for i in range(nm[1]):
    ps.append(list(input().split()))
    ps[-1][0]=int(ps[-1][0])
ac=[0]*nm[0]
wa=[0]*nm[0]
for i in range(nm[1]):
    if ps[i][1]=="AC":
        if ac[ps[i][0]-1]==0:
            ac[ps[i][0]-1]=1
        else:
            pass
    else:
        if ac[ps[i][0]-1]==0:
            wa[ps[i][0]-1]+=1
        else:
            pass
ans=0
for i in range(nm[0]):
    if ac[i]==1:
        ans+=wa[i]
print(sum(ac),ans)

Buggy submission (verdict: Runtime Error):
nm=list(map(int,input().split()))
ps=[]
for i in range(nm[1]):
    ps.append(list(input().split()))
    ps[-1][0]=int(ps[-1][0])
ac=[0]*nm[0]
wa=0
for i in range(nm[1]):
    if ps[i][1]=="AC":
        if ac[ps[i][0]]==0:
            ac[ps[i][0]]=1
        else:
            pass
    else:
        if ac[ps[i][0]]==0:
            wa+=1
        else:
            pass
print(sum(ac),wa)
Problem p02918 (python)

Fixed submission:
nk=list(map(int,input().split()))
s=input()
L=[]
R=[]
lr="a"
for i in range(nk[0]):
    if lr=="L":
        if s[i]=="R":
            lr="R"
            R.append(1)
        else:
            L[-1]+=1
    elif lr=="R":
        if s[i]=="L":
            lr="L"
            L.append(1)
        else:
            R[-1]+=1
    else:
        lr=s[0]
        if lr=="L":
            L.append(1)
        else:
            R.append(1)
L.sort(reverse=True)
R.sort(reverse=True)
lsum=sum(L[:nk[1]])
rsum=sum(R[:nk[1]])
if len(L)<=nk[1] or len(R)<=nk[1]:
    print(nk[0]-1)
else:
    if lsum+sum(R)>rsum+sum(L):
        rmerge=sum(R[:nk[1]+1])+lsum
        R=R[nk[1]:]
        if R!=[]:
            R[0]=rmerge
        else:
            R=[rmerge]
        L=L[nk[1]:]
        ans=sum(R)-len(R)+sum(L)-len(L)
    else:
        lmerge=sum(L[:nk[1]+1])+rsum
        L=L[nk[1]:]
        if L!=[]:
            L[0]=lmerge
        else:
            L=[lmerge]
        R=R[nk[1]:]
        ans=sum(L)-len(L)+sum(R)-len(R)
    print(ans)

Buggy submission (verdict: Runtime Error):
nk=list(map(int,input().split()))
s=input()
L=[]
R=[]
lr="a"
for i in range(nk[0]):
    if lr=="L":
        if s[i]=="R":
            lr="R"
            R.append(1)
        else:
            L[-1]+=1
    elif lr=="R":
        if s[i]=="L":
            lr="L"
            L.append(1)
        else:
            R[-1]+=1
    else:
        lr=s[0]
        if lr=="L":
            L.append(1)
        else:
            R.append(1)
L.sort(reverse=True)
R.sort(reverse=True)
lsum=sum(L[:nk[1]])
rsum=sum(R[:nk[1]])
if len(L)<nk[1] or len(R)<nk[1]:
    print(n)
else:
    if lsum+sum(R)>rsum+sum(L):
        rmerge=sum(R[:nk[1]+1])+lsum
        R=R[nk[1]:]
        if R!=[]:
            R[0]=rmerge
        else:
            R=[rmerge]
        ans=sum(R)-len(R)
    else:
        lmerge=sum(L[:nk[1]+1])+rsum
        L=L[nk[1]:]
        if L!=[]:
            L[0]=lmerge
        else:
            L=[lmerge]
        ans=sum(L)-len(L)
    print(ans)