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

Fixed submission:

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

S=[0]
s = 0
for i in range(N):
    s+=a[i]
    S.append(s)
ans=10**28
for i in range(1,N):
    ans=min(abs(S[N]-2*S[i]),ans)
print(ans)

Buggy submission (verdict: Runtime Error):

N=int(input())
e_list = [[] for i in range(N)]
for i in range(N-1):
    a,b=list(map(int,input().split()))
    a,b=a-1,b-1
    e_list[a].append(b)
    e_list[b].append(a)

vi = 0 #時と場合によってここを変える
from collections import deque
Q = deque([vi])
checked_list = [False for i in range(N)]
checked_list[vi]=True
prev_list = [-1 for i in range(N)]
min_path_list = [10**27 for i in range(N)] #問題によりここを変える
min_path_list[vi] = 0
while len(Q)>0:
    v = Q.pop()
    for v1 in e_list[v]:
        if not checked_list[v1]:
            checked_list[v1]=True
            Q.appendleft(v1)
            prev_list[v1]=v
            min_path_list[v1]=min(min_path_list[v1],min_path_list[v]+1) #問題によりここを変える

path = [N-1]
v=N-1
while prev_list[v]!=-1:
    path.append(prev_list[v])
    v=prev_list[v]

a=path[(min_path_list[N-1]-1)//2]
b=path[(min_path_list[N-1]-1)//2+1]
for i in range(len(e_list[a])):
    if e_list[a][i]==b:
        break
del e_list[a][i]

for i in range(len(e_list[b])):
    if e_list[b][i]==a:
        break
del e_list[b][i]

vi = 0 #時と場合によってここを変える

Q = deque([vi])
checked_list = [False for i in range(N)]
checked_list[vi]=True
count = 1
while len(Q)>0:
    v = Q.pop()
    for v1 in e_list[v]:
        if not checked_list[v1]:
            checked_list[v1]=True
            Q.appendleft(v1)
            count+=1

if count>N-count:
    print("Fennec")
else:
    print("Snuke")
Problem p03837 (python)

Fixed submission:
N,M=list(map(int,input().split()))
e_list = [[] for i in range(N)]
e_list2 = []
for i in range(M):
    a,b,d = list(map(int,input().split()))
    a=a-1
    b=b-1
    e_list[a].append([b,d])
    e_list[b].append([a,d])
    e_list2.append([a,b,d])

dist_list = []
import heapq
for i in range(N):
    vi = i
    min_d_list = [10**27 for i in range(N)]
    min_d_list[vi] = 0
    prev_list = [-1 for i in range(N)]
    q = []
    for i in range(N):
        heapq.heappush(q,[min_d_list[i],i])

    while len(q)>0:
        d,v = heapq.heappop(q)
        for e in e_list[v]:
            v1,d1=e
            if min_d_list[v1]>d+d1:
                min_d_list[v1]=d+d1
                prev_list[v1]=v
                heapq.heappush(q,[d+d1,v1])
    dist_list.append(min_d_list)
count=len(e_list2)
for e in e_list2:
    for i in range(N):
        if dist_list[i][e[0]]+e[2]==dist_list[i][e[1]]:
            count-=1
            break

print(count)

Buggy submission (verdict: Runtime Error):

INF = 10**6 + 1

N,M = map(int,raw_input().split())

a_l=[]
b_l=[]
c_l=[]

for i in range(M):
    a,b,c=map(int,raw_input().split())
    a_l.append(a-1)
    b_l.append(b-1)
    c_l.append(c-1)
    

d = [[INF for j in range(N)] for i in range(N)]

for i in range(N):
    d[i][i]=0

    

for i in range(M):
    d[a_l[i]][b_l[i]] = min(c_l[i],d[a_l[i]][b_l[i]])
    d[b_l[i]][a_l[i]] = min(c_l[i],d[b_l[i]][a_l[i]])


for i in range(N):
    for j in range(N):
        for k in range(N):
            d[i][j] = min(d[i][j],d[i][k]+d[k][j])
        
ans = M

for i in range(M):
    flag=False
    for j in range(N):
        for k in range(N):
            if d[j][k]==d[j][a[i]]+d[b[i]][k]:
                flag=True
    if flag:
        ans-=1
print ans

Buggy submission (verdict: Runtime Error):
INF = 10**6 + 1

N,M = map(int,raw_input().split())

a_l=[]
b_l=[]
c_l=[]

for i in range(M):
    a,b,c=map(int,raw_input().split())
    a_l.append(a-1)
    b_l.append(b-1)
    c_l.append(c-1)
    

d = [[] for i in range(N)]

for i in range(N):
    for j in range(N):
        if i==j:
            d[i][j].append(0)
        else:
            d[i][j].append(INF)
    

for i in range(M):
    d[a_l[i]][b_l[i]] = min(c_l[i],d[a_l[i]][b_l[i]])
    d[b_l[i]][a_l[i]] = min(c_l[i],d[b_l[i]][a_l[i]])


for i in range(N):
    for j in range(N):
        for k in range(N):
            d[i][j] = min(d[i][j],d[i][k]+d[k][j])
        
ans = M

for i in range(M):
    flag=False
    for j in range(N):
        for k in range(N):
            if d[j][k]==d[j][a[i]]+d[b[i]][k]:
                flag=True
    if flag:
        ans-=1
print ans
Problem p03848 (python)

Fixed submission:

N = int(raw_input())
A = map(int,raw_input().split())

flag=True
if N%2==0:
    l = [0 for i in range(N/2)]
    for i in range(N):
        if A[i]%2!=1 or A[i]>=N or A[i]<=0:
            print 0
            flag=False
            break
        l[(A[i]-1)/2]+=1
        if l[(A[i]-1)/2]>=3:
            print 0
            flag=False
            break
    if flag:
        print (2**(N/2))%(10**9+7)
else:
    l = [0 for i in range((N+1)/2)]
    for i in range(N):
        if A[i]%2!=0 or A[i]>=N or A[i]<0:
            print 0
            flag=False
            break
        if A[i]==0:
            l[0]+=1
            if l[0]>=2:
                print 0
                flag=False
                break
        else:
            l[A[i]/2]+=1
            if l[A[i]/2]>=3:
                print 0
                flag=False
                break        
    if flag:
        print (2**((N-1)/2))%(10**9+7)

Buggy submission (verdict: Runtime Error):

def power(N):
    ans=1
    for i in range(N):
        ans=(ans*2)%(10**9+7)
    return ans

N=int(input())

A = map(int,input().split())
flag=True
if N%2==0:
    n = [0 for i in range(N/2)]
    for a in A:
        if a%2==0:
            print(0)
            flag=False
            break
        if (a-1)/2 in range(N/2):
            n[(a-1)/2]+=1
            if n[(a-1)/2]==3:
                print(0)
                flag=False
                break
        else:
            print(0)
            flag=False
            break
    if flag:
        print(power(N/2))
    
else:
    n = [0 for i in range((N+1)/2)]
    for a in A:
        if a%2==1:
            print(0)
            flag=False
            break
        if a/2 in range((N+1)/2):
            n[a/2]+=1
            if a==0:
                if n[a]==2:
                    print(0)
                    flag=False
                    break
            elif n[a/2]==3:
                print(0)
                flag=False
                break
        else:
            print(0)
            flag=False
            break
    if flag:
        print(power((N-1)/2))
Problem p03909 (python)

Fixed submission:

def itoa(i):
    if i==0:
        return "a"
    elif i==1:
        return "b"
    elif i==2:
        return "c"
    elif i==3:
        return "d"
    elif i==4:
        return "e"
    elif i==5:
        return "f"
    elif i==6:
        return "g"
    elif i==7:
        return "h"
    elif i==8:
        return "i"
    elif i==9:
        return "j"
    elif i==10:
        return "k"
    elif i==11:
        return "l"
    elif i==12:
        return "m"
    elif i==13:
        return "n"
    elif i==14:
        return "o"
    elif i==15:
        return "p"
    elif i==16:
        return "q"
    elif i==17:
        return "r"
    elif i==18:
        return "s"
    elif i==19:
        return "t"
    elif i==20:
        return "u"
    elif i==21:
        return "v"
    elif i==22:
        return "w"
    elif i==23:
        return "x"
    elif i==24:
        return "y"
    elif i==25:
        return "z"


H,W = list(map(int,input().split()))
S = []
for i in range(H):
    S.append(input().split())

for i in range(H):
    for j in range(W):
        if S[i][j]=="snuke":
            print(itoa(j).upper()+str(i+1))

Buggy submission (verdict: Runtime Error):

def itoa(i):
    if i==0:
        return "a"
    elif i==1:
        return "b"
    elif i==2:
        return "c"
    elif i==3:
        return "d"
    elif i==4:
        return "e"
    elif i==5:
        return "f"
    elif i==6:
        return "g"
    elif i==7:
        return "h"
    elif i==8:
        return "i"
    elif i==9:
        return "j"
    elif i==10:
        return "k"
    elif i==11:
        return "l"
    elif i==12:
        return "m"
    elif i==13:
        return "n"
    elif i==14:
        return "o"
    elif i==15:
        return "p"
    elif i==16:
        return "q"
    elif i==17:
        return "r"
    elif i==18:
        return "s"
    elif i==19:
        return "t"
    elif i==20:
        return "u"
    elif i==21:
        return "v"
    elif i==22:
        return "w"
    elif i==23:
        return "x"
    elif i==24:
        return "y"
    elif i==25:
        return "z"



H,W = list(map(int,input().split()))
S = []
for i in range(H):
    S.append(list(map(int,input().split())))

for i in range(H):
    for j in range(W):
        if S[i][j]=="snuke":
            print(itoa(j).upper()+str(i))
        break
Problem p03938 (python)

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

q = [0 for i in range(N)]

for i in range(N):
    q[p[i]-1]=i+1

a = [str((i+1)*N)  for i in range(N)]
b = [str((N-i-1)*N + q[i]) for i in range(N)]
print(" ".join(a))
print(" ".join(b))

Buggy submission (verdict: Runtime Error):

N = int(input())
p = list(map(int,input().split()))

q = [0 for i in range(N)]

for i in range(N):
    q[p[i]-1]=i+1

a = [(i+1)*N  for i in range(N)]
b = [(N-i-1)*N + q[i] for i in range(N)]
print(" ".join(a))
print(" ".join(b))
Problem p03998 (python)

Fixed submission:


Sa = input()
Sb = input()
Sc = input()
flg=True
nxt = "a"
while flg:
    if nxt=="a":
        if len(Sa)==0:
            winner = "A"
            break
        nxt = Sa[0]
        Sa=Sa[1:]
    elif nxt=="b":
        if len(Sb)==0:
            winner = "B"
            break
        nxt = Sb[0]
        Sb=Sb[1:]
    elif nxt=="c":
        if len(Sc)==0:
            winner = "C"
            break
        nxt = Sc[0]
        Sc=Sc[1:]

print(winner)

Buggy submission (verdict: Runtime Error):

Sa = input()
Sb = input()
Sc = input()
flg=True
nxt = "a"
while flg:
    if nxt=="a":
        if len(Sa)==0:
            break
            winner = "A"
        nxt = Sa[0]
        Sa=Sa[1:]
    elif nxt=="b":
        if len(Sb)==0:
            break
            winner = "B"
        nxt = Sb[0]
        Sb=Sb[1:]
    elif nxt=="c":
        if len(Sc)==0:
            break
            winner = "C"
        nxt = Sc[0]
        Sc=Sc[1:]

print(winner)

Buggy submission (verdict: Runtime Error):

Sa = input()
Sb = input()
Sc = input()
flg=True
nxt = "a"
while flg:
    if nxt=="a":
        if len(Sa)==0:
            flg=False
            winner = "A"
        nxt = Sa[0]
        Sa=Sa[1:]
    elif nxt=="b":
        if len(Sb)==0:
            flg=False
            winner = "B"
        nxt = Sb[0]
        Sb=Sb[1:]
    elif nxt=="c":
        if len(Sc)==0:
            flg=False
            winner = "C"
        nxt = Sc[0]
        Sc=Sc[1:]

print(winner)
Problem p04007 (python)

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

a = [input() for i in range(H)]

b = [[] for i in range(H)]
r = [[] for i in range(H)]
for i in range(H):
    for j in range(W):
        if i==0:
            b[i].append("#")
            r[i].append(".")
        elif i==H-1:
            b[i].append(".")
            r[i].append("#")
        elif a[i][j]=="#":
            b[i].append("#")
            r[i].append("#")
        elif j%2==0:
            b[i].append(".")
            r[i].append("#")
        elif j%2==1:
            b[i].append("#")
            r[i].append(".")

for i in range(H):
    ans = ""
    for j in range(W):
        ans = ans+b[i][j]

    print(ans)
print("")

for i in range(H):
    ans = ""
    for j in range(W):
        ans = ans+r[i][j]

    print(ans)

Buggy submission (verdict: Runtime Error):

H,W = list(map(int,input().split()))

a = [input() for i in range(H)]

b = [[] for i in range(H)]
r = [[] for i in range(H)]
for i in range(H):
    for j in range(W):
        if i==0:
            b[i].append("#")
            r[i].append(".")
        elif i==H-1:
            b[i].append(".")
            r[i].append("#")
        elif S[i][j]=="#":
            b[i].append(".")
            r[i].append("#")
        elif j%2==0:
            b[i].append(".")
            r[i].append("#")
        elif j%2==1:
            b[i].append("#")
            r[i].append(".")

for i in range(H):
    ans = ""
    for j in range(W):
        ans = ans+b[i][j]

    print(ans)
print("")

for i in range(H):
    ans = ""
    for j in range(W):
        ans = ans+r[i][j]

    print(ans)
Problem p04025 (python)

Fixed submission:
import numpy as np
N=int(input())
a=list(map(int,input().split()))

a=np.array(a)
min_s = 10**29
for i in range(201):
    s=np.sum((a-np.ones(N)*(i-100))**2)
    min_s = min(int(s),min_s)
print(min_s)

Buggy submission (verdict: Runtime Error):

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

a=np.array(a)
min_s = 10**29
for i in range(201):
    s=np.sum((a-np.ones(N)*(i-100))**2)
    min_s = min(int(s),min_s)
print(min_s)
Problem p04034 (python)

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

ball_list = [1 for i in range(N)]
flag_list = [False for i in range(N)]
flag_list[0] = True

for i in range(M):
    x,y = list(map(int,input().split()))
    if flag_list[x-1]:
        flag_list[y-1]=True
        if ball_list[x-1]==1:
            flag_list[x-1]=False
    ball_list[x-1]-=1
    ball_list[y-1]+=1
count=0    
for i in range(N):
    if flag_list[i]:
        count+=1

print(count)

Buggy submission (verdict: Runtime Error):

N,M = list(map(int,input().split()))

ball_list = [1 for i in range(N)]
flag_list = [False for i in range(N)]
flag_list[0] = True

for i in range(M):
    x,y = list(map(int,input().split()))
    if flag_list[x-1]:
        flag_list[y-1]=True
        if ball_list[x-1]==1:
            flag_list[x-1]=False
    ball_list[x-1]-=1
    ball_list[y-1]+=1
count=0    
for i in range(M):
    if flag_list[i]:
        count+=1

print(count)
Problem p04039 (python)

Fixed submission:

N,K =list(map(int,input().split()))

D = list(map(str,input().split()))

for i in range(N,100000):
    if len(set(list(str(i)))&set(D))==0:
        print(i)
        break

Buggy submission (verdict: Runtime Error):

N,K =list(map(int,input().split()))

D = list(map(str,input().split()))

for i in range(N,100000):
    if len(set(list(str(i)))&set(D))==0:
        print(i)
        break
Problem p02658 (python)

Fixed submission:
n = int(input())
a = 1
s = list(map(int, input().split()))
if 0 in s:
    print(0)
    exit()
for i in s:
    a*=i
    if a>10**18:
        print(-1)
        exit()
else:
    print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = 1
s = list(map(int, input().split()))
if 0 in s:
    print(0)
    exit()
for i in s:
    a*=s[i]
    if a>10**18:
        print(-1)
        exit()
else:
    print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = 1
for i in range(0,n):
    a*=int(input())
    if(a>10**18):
        a=-1
if(a<0):
    a=-1
print(a)
Problem p02660 (python)

Fixed submission:
# Import
from collections import deque

# I/O
def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return list(map(type, input().split()))
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]

# Implementation
N = read_int()

MAX_P = 1000006
isP = [True] * MAX_P
for i in range(2,MAX_P):
    if isP[i]:
        for j in range(2*i,MAX_P,i):
            isP[j] = False

P = [i for i in range(2,MAX_P) if isP[i]]
ans = 0
for p in P:
    cnt = 0
    while N % p == 0:
        N /= p
        cnt += 1
    dec = 1
    while cnt >= dec:
        cnt -= dec
        dec += 1
        ans += 1
if N > 1:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
# Import
from collections import deque

# I/O
def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return list(map(type, input().split()))
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]

# Implementation
class PrimeNumber:
    def __init__(self, N):
        self.N = N
        self.compute()

    def compute(self):
        self.isP, self.P = [True] * N+1, []
        for i in range(2,N+1):
            if self.isP[i]:
                self.P.append(i)
                for j in range(2*i,N+1,i):
                    self.isP[j] = False

N = read_int()

pn = PrimeNumber(1000006)
ans = 0
for p in pn.P:
    cnt = 0
    while N % p == 0:
        N /= p
        cnt += 1
    dec = 1
    while cnt >= dec:
        cnt -= dec
        dec += 1
        ans += 1
if N > 1:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
# Import
from collections import deque

# I/O
def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return list(map(type, input().split()))
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]

# Implementation
class PrimeNumber:
    def __init__(self, N):
        self.N = N
        self.compute()

    def compute(self):
        isP, P = [True] * N+1, []
        for i in range(2,N+1):
            if isP[i]:
                P.append(i)
                for j in range(2*i,N+1,i):
                    isP[j] = False
        self.isP, self.P = isP, P

N = read_int()

pn = PrimeNumber(1000006)
ans = 0
for p in pn.P:
    cnt = 0
    while N % p == 0:
        N /= p
        cnt += 1
    dec = 1
    while cnt >= dec:
        cnt -= dec
        dec += 1
        ans += 1
if N > 1:
    ans += 1
print(ans)
Problem p02609 (python)

Fixed submission:
n=int(input())
X=input()
x=X.count('1')
x_plus=int(X,2)%(x+1)
keta=n-1
if x==1:
    for i in range(n):
        tmp=0
        ans=1
        if X[i]=='0':
            tmp+=x_plus
            tmp+=pow(2,keta,(x+1))
            tmp%=(x+1)
            while tmp:
                tmp=tmp%(bin(tmp).count('1'))
                ans+=1
            print(ans)
        else:
            print(0)
        keta-=1
else:
    x_minus=int(X,2)%(x-1)
    for i in range(n):
        tmp=0
        ans=1
        if X[i]=='0':
            tmp+=x_plus
            tmp+=pow(2,keta,(x+1))
            tmp%=(x+1)
            while tmp:
                tmp=tmp%(bin(tmp).count('1'))
                ans+=1
            print(ans)
        else:
            tmp+=x_minus
            tmp-=pow(2,keta,(x-1))
            tmp%=(x-1)
            while tmp:
                tmp=tmp%(bin(tmp).count('1'))
                ans+=1
            print(ans)
        keta-=1

Buggy submission (verdict: Runtime Error):
n=int(input())
x=str(input())
for i in range(n):
    if x[i]=='0':
        tmp=x[:i]+'1'+x[(i+1):]
    elif x[i]=='1':
        tmp=x[:i]+'0'+x[(i+1):]
    cnt=0
    while True:
        r=int(tmp,2)%tmp.count('1')
        tmp='{:b}'.format(r)
        cnt+=1
        if tmp=='0':
            print(cnt)
            break
Problem p02761 (python)

Fixed submission:
n,m=map(int,input().split())
placelist=[]
numlist=[]
ans=-1
for _ in range(m):
    place,num=map(int,input().split())
    placelist.append(place)
    numlist.append(num)
if n>1:
    for i in range(10**(n-1),10**n):
        cnt=0
        tmp=str(i)
        for j in range(m):
            if tmp[placelist[j]-1]==str(numlist[j]):
                cnt+=1
        if cnt==m:
            ans=tmp
            break
if n==1:
    for i in range(0,10):
        cnt=0
        tmp=str(i)
        for j in range(m):
            if tmp[placelist[j]-1]==str(numlist[j]):
                cnt+=1
        if cnt==m:
            ans=tmp
            break
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=[10 for _ in range(n)]
for i in range(m):
    place,num=map(int,input().split())
    if ans[place-1]==10:
        ans[place-1]=num
    elif ans[place-1]!=num:
        ans=-1
        print(ans)
        break
if ans[0]==0:
    ans=-1
    print(ans)
if ans!=-1:
    for j in range(n):
        if j==0 and ans[j]==10:
            ans[j]=1
        if j>0 and ans[j]==10:
            ans[j]=0
    ans=map(str,ans)
    print("".join(ans))
Problem p02765 (python)

Fixed submission:
n,r=map(int,input().split())
print(r+100*(10-n) if n<10 else r)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
cnt=0
while n>0:
    n=n//k
    cnt+=1
print(cnt)
Problem p02947 (python)

Fixed submission:
n=int(input())
L=[[] for _ in range(n)]
ans=0
for i in range(n):
    L[i]=sorted(list(input()))
L=sorted(L)
tmp=1
ans=0
for i in range(n-1):
    if L[i]==L[i+1]:
        tmp+=1
    else:
        ans+=tmp*(tmp-1)//2
        tmp=1
ans+=tmp*(tmp-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
input = sys.stdin.readline

n=int(input())
s=deque([])
cnt=0
for _ in range(n):
    s.append(input().sort())
for i in range(n):
    for j in range(n):
        if i<j:
            if s[i]==s[j]:
                cnt+=1
print(cnt)
Problem p02975 (python)

Fixed submission:
n=int(input())
L=list(map(int,input().split()))
LL=list(set(L))
ans="No"
if LL==[0]:
    ans="Yes"
elif len(LL)==2:
    if L.count(LL[0])==2*L.count(LL[1]) or L.count(LL[1])==2*L.count(LL[0]):
        ans="Yes"
elif len(LL)==3:
    if L.count(LL[0])==L.count(LL[1]) and L.count(LL[1])==L.count(LL[2]):
        if LL[0]^LL[1]^LL[2]==0:
            ans="Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
A=list(set(a))
ans="Yes"
if len(A)!=3 or A==[0]:
    ans="No"
    if a.count(A[0])==2*a.count(A[1]) or 2*a.count(A[0])==a.count(A[1]):
        ans="Yes"
print(ans)
Problem p03076 (python)

Fixed submission:
t=[int(input()) for _ in range(5)]
s=[]
for i in range(5):
    s.append(t[i]%10)
    t[i]=-(-t[i]//10)*10
S=sorted(s)[-5+s.count(0)]
if S==0:
    print(sum(t))
else:print(sum(t)-10+S)

Buggy submission (verdict: Runtime Error):
t=[int(input()) for _ in range(5)]
s=[]
for i in range(5):
    s.append(t[i]%10)
    t[i]=-(-t[i]//10)*10
S=sorted(s)[-5+s.count(0)]
if S==0:
    print(sum(t))
else:print(sum(t-10+S))
Problem p03087 (python)

Fixed submission:
n,q=map(int,input().split())
s=input()
ans_l=[0]*n
for i in range(n-1):
    tmp=s[i]+s[i+1]
    if tmp=='AC':
        ans_l[i+1]=ans_l[i]+1
    else:
        ans_l[i+1]=ans_l[i]
for i in range(q):
    l,r=map(int,input().split())
    print(ans_l[r-1]-ans_l[l-1])

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
ans_l=[0]*8
for i in range(n-1):
    tmp=s[i]+s[i+1]
    if tmp=='AC':
        ans_l[i+1]=ans_l[i]+1
    else:
        ans_l[i+1]=ans_l[i]
for i in range(q):
    l,r=map(int,input().split())
    print(ans_l[r-1]-ans_l[l-1])