Problem p03047 (python)

Fixed submission:
n,k=list(map(int,input().split()))
print(n-k+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input() for _ in range(n))
m,o,f,both=0,0,0,0

for i in range(n):
    m +=s[i].count("AB")
    if s[i][0]=="B":
        o +=1
for i in range(n):
    if s[i][-1]=="A":
        f +=1
for i in range(n):
    if s[i][0]=="B" and s[i][-1]=="A":
        both+=1
        o-=1
        f-=1

if both!=0:
    if i!=0 and f!=0:
        print(m+both+min(o,f))
    else:
        print(m+both+min(o,f)-1)

else:
    print(m+min(o,f))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input() for _ in range(n))
m,i,f,both=0,0,0,0

for i in range(n):
    m +=s[i].count("AB")

    if s[i][-1]=="A":
        f +=1
    if s[i][0]=="B" and s[i][1]=="A":
        both+=1
        i-=1
        f-=1

if both!=0:
    if i!=0 and f!=0:
        print(m+both+min(i,f)-1)
    else:
        print(m+both+min(i,f))

else:
    print(min(i,f))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input() for _ in range(n))
m,i,f,both=0,0,0,0

for i in range(n):
    m +=s[i].count("AB")
    if s[i][0]=="B":
        i +=1
    if s[i][-1]=="A":
        f +=1


if both!=0:
    if i!=0 and f!=0:
        print(m+both+min(i,f)-1)
    else:
        print(m+both+min(i,f))

else:
    print(min(i,f))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input() for _ in range(n))
m,i,f,both=0,0,0,0

for i in range(n):
    m +=s[i].count("AB")
    if s[i][0]=="B":
        i +=1
    if s[i][1]=="A":
        f +=1
    if s[i][0]=="B" and s[i][1]=="A":
        both+=1
        i-=1
        f-=1

if both!=0:
    if i!=0 and f!=0:
        print(m+both+min(i,f)-1)
    else:
        print(m+both+min(i,f))

else:
    print(min(i,f))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input() for _ in range(n))
m,i,f,both=0,0,0,0

for i in range(n):
    m +=s[i].count("AB")
    if s[i][0]=="B":
        i +=1
        
    if s[i][-1]=="A":
        f +=1
        
    if s[i][0]=="B" and s[i][1]=="A":
        both+=1
        i-=1
        f-=1

if both!=0:
    if i!=0 and f!=0:
        print(m+both+min(i,f)-1)
    else:
        print(m+both+min(i,f))

else:
    print(min(i,f))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input() for _ in range(n))
m,i,f,both=0,0,0,0

for i in range(n):
    m +=s[i].count("AB")
    if s[i][0]=="B":
        i +=1
    if s[i][-1]=="A":
        f +=1
  

if both!=0:
    if i!=0 and f!=0:
        print(m+both+min(i,f)-1)
    else:
        print(m+both+min(i,f))

else:
    print(min(i,f))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input() for _ in range(n))
m,i,f,both=0,0,0,0

for i in range(n):
    m +=s[i].count("AB")
   

if both!=0:
    if i!=0 and f!=0:
        print(m+both+min(i,f)-1)
    else:
        print(m+both+min(i,f))

else:
    print(min(i,f))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input() for _ in range(n))
m,i,f,both=0,0,0

for i in range(n):
    m +=s[i].count("AB")
    if s[i][0]=="B":
        i +=1
    if s[i][-1]=="A":
        f +=1
    if s[i][0]=="B" and s[i][1]=="A":
        both+=1
        i-=1
        f-=1

if both!=0:
    if i==0 and f==0:
        print(m+both+min(i,f)-1)
    else:
        print(m+both+min(i,f))

else:
    print(min(i,f))

Buggy submission (verdict: Runtime Error):
r,g,b,n=list(map(int,input().split()))
i,j,k=0,0,0
R,G,B=0,0,0
c=0
while R<n:
    R=r*i
    while G<=n-R:
        G=g*j
        B,k=0,0
        while B<=n-R-G:
            B=b*k
            if n-R-G-B==0:
                c+=1
            k+=1
        j+=1
    i+=1
    G,j=0,0
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input() for _ in range(n))
m,i,f=0,0,0

for i in range(n):
    m +=s[i].count("AB")
    if s[i][0]=="B":
        i +=1
    if s[i][-1]=="A":
        f +=1
print(m+min(i,f))

Buggy submission (verdict: Runtime Error):
r,g,b,n=list(map(int,input().split()))
i,j,k=0,0,0
R,G,B=0,0,0
c=0
while R<n:
    R=r*i
    print(R)
    while G<=n-R:
        G=g*j
        print(G)
        B,k=0,0
        while B<=n-R-G:
            B=b*k
            print(B)
            if n-R-G-B==0:
                c+=1
            k+=1
        j+=1
    i+=1
    G,j=0,0
print(c)