Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
F = [[] for TF in range(0,N)]
for TF in range(0,N):
    F[TF] = [int(T) for T in input().split()]
P = [[] for TP in range(0,N)]
for TP in range(0,N):
    P[TP] = [int(T) for T in input().split()]
    
MAXB = -10**9
for TB in range(1,2**10):
    BaseConv,BaseSInd = ForBaseConvert(TB,10,2)
    Benefit = 0
    for TN in range(0,N):        
        Count = sum(1 if F[TN][TT]==1 else 0 for TT in BaseSInd[1])
        Benefit += P[TN][Count]
    if MAXB<Benefit:
        MAXB = Benefit
print(MAXB)

Fixed submission:
def ForBaseConvert(Roop,MaxD,Base):
    if all(type(TT) is int for TT in [Roop,MaxD,Base]):
        if Base>=2 and MaxD>=1:
            ConvertN = []
            while Roop>0:
                ConvertN.append(Roop%Base)
                Roop = Roop//Base

            BaseConv = [0]*(MaxD-len(ConvertN))+ConvertN[::-1]
            BaseSInd = [[] for TB in range(0,Base)]
            for TB in range(0,Base):
                BaseSInd[TB] = [SInd for SInd,SNum in enumerate(BaseConv) if SNum==TB]
            return BaseConv,BaseSInd
        else:
            return []
    else:
        return []
      
N = int(input())
F = [[] for TF in range(0,N)]
for TF in range(0,N):
    F[TF] = [int(T) for T in input().split()]
P = [[] for TP in range(0,N)]
for TP in range(0,N):
    P[TP] = [int(T) for T in input().split()]
    
MAXB = -10**9
for TB in range(1,2**10):
    BaseConv,BaseSInd = ForBaseConvert(TB,10,2)
    Benefit = 0
    for TN in range(0,N):        
        Count = sum(1 if F[TN][TT]==1 else 0 for TT in BaseSInd[1])
        Benefit += P[TN][Count]
    if MAXB<Benefit:
        MAXB = Benefit
print(MAXB)
Buggy python submission (verdict: Runtime Error):
# (A,B,C)<=3500
# 4/N = (1/A)+(1/B)+(1/C)
# (4/N)-(1/A) = (1/B)+(1/C)
# (4A-N)/AN   = (B+C)/BC

# XX-(4A-N)X+AN=0
# X = (-b±sqrt(bb-4c))/2 (a=1)
#   = ((4A-N)±sqrt((4A-N)(4A-N)-4AN))/2
#   = ((4A-N)±sqrt(16AA-12AN+NN))/2


def BiSearch(Func,N):
    Left  = 0
    FLeft = Func(Left)
    Right  = N
    FRight = Func(Right)
    Flag = False
    while Left<=Right:
        Med  = (Left+Right)//2
        FMed = Func(Med)
        if FMed==N:
            Flag = True
            return Med
        elif FMed>N:
            Right  = Med-1
            FRight = Func(Right)
        else:
            Left  = Med+1
            FLeft = Func(Left)
    if not Flag:
        return False
def SquareRootSearch(K):
    return BiSearch(lambda N:N*N,K)

N = int(input())
for TA in range(1,3501):
    SqrtX = SquareRootSearch(16*(TA**2)-(12*TA*N)+(N**2))
    if SqrtX:
        NumerB = (4*TA-N)+SqrtX
        NumerC = (4*TA-N)-SqrtX
        if NumerB%2==0 and NumerC%2==0 and NumerB>0 and NumerC>0:
            A = TA
            B = NumerB//2
            C = NumerC//2
print('{} {} {}'.format(A,B,C))

Fixed submission:
N = int(input())
A,B,C = 0,0,0
for TA in range(1,3501):
    for TB in range(1,3501):
        Numer = TA*TB*N
        Denom = 4*TA*TB-(TA+TB)*N
        if Denom>0 and Numer>0 and Numer%Denom==0:
            A = TA
            B = TB
            C = Numer//Denom
print('{} {} {}'.format(A,B,C))
Buggy python submission (verdict: Runtime Error):
from math import gcd
A,B,C,D,E,F = (int(T) for T in input().split())
SugerMax = 0
for TC in range(0,D//gcd(C,D)):
    RestC = F-C*TC
    for TD in range(0,(RestC//D)+1):
        RestD = RestC-D*TD
        Suger = C*TC+D*TD
        if RestD>=0:
            NeedMin = (100*Suger)/E
            for TA in range(0,B//gcd(A,B)):
                for TB in range(0,(F//100)+1):
                    Water = A*TA*100+B*TB*100
                    if Water<=RestD:
                        if NeedMin<=Water and SugerMax<Suger:
                            SugerMax = Suger
                            WaterMax = Water
                    else:
                        break
        else:
            break
print('{} {}'.format(WaterMax+SugerMax,SugerMax))

Fixed submission:
A,B,C,D,E,F = (int(T) for T in input().split())
SugM = 0
WatM = 100*A
for TA in range(0,(F//100)+1):
    for TB in range(0,(F//100)+1):
        if TA==TB==0:
            continue
        else:
            Water = TA*100*A+TB*100*B
            RestW = F-Water
            if RestW>=0:
                for TC in range(0,RestW+1):
                    for TD in range(0,RestW+1):
                        Suger = TC*C+TD*D
                        RestS = RestW-Suger
                        if RestS>=0 and Water>=(100*Suger)/E:
                            if Suger/(Suger+Water)>SugM/(SugM+WatM):
                                SugM = Suger
                                WatM = Water
                        else:
                            break
            else:
                break
print('{} {}'.format(WatM+SugM,SugM))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = [int(T) for T in input().split()]
Num = [0]*(max(A)-min(A)+3)
for T in range(0,N):
    Num[A[T]-min(A)+1] += 1
MAX = 0
for T in range(0,max(A)-min(A)+1):
    if MAX<sum(Num[T:T+3]):
        MAX = sum(Num[T:T+3])
print(MAX)

Fixed submission:
import collections
N = int(input())
Num,Count = zip(*sorted(collections.Counter(int(T) for T in input().split()).most_common()))
DisN = ((min(Num)-1),)+Num+((max(Num)+1),)
DisC = (0,)+Count+(0,)
MAX = 0
for T in range(1,len(Num)+1):
    Dis = DisC[T]
    if DisN[T-1]==DisN[T]-1:
        Dis += DisC[T-1]
    if DisN[T+1]==DisN[T]+1:
        Dis += DisC[T+1]
    if MAX<Dis:
        MAX = Dis
print(MAX)
Buggy python submission (verdict: Runtime Error):
Flag = False
LS = 0
SS = 0
for T in range(0,len(A)):
    if LS==0 and A[T][1]>=4:
        Sq = A[T][0]**2
        Flag = True
        break
    if A[T][1]>=2:
        if LS==0:
            LS = A[T][0]
        else:
            SS = A[T][0]
            Sq = LS*SS
            Flag = True
            break
if Flag:
    print(Sq)
else:
    print(0)

Fixed submission:
import collections
N = int(input())
A = sorted(collections.Counter(int(T) for T in input().split()).most_common(),reverse=True)
Flag = False
LS = 0
SS = 0
for T in range(0,len(A)):
    if LS==0 and A[T][1]>=4:
        Sq = A[T][0]**2
        Flag = True
        break
    if A[T][1]>=2:
        if LS==0:
            LS = A[T][0]
        else:
            SS = A[T][0]
            Sq = LS*SS
            Flag = True
            break
if Flag:
    print(Sq)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
a,b,c = (int(T) for T in input().split())
print(['No','Yes'][(a+ab)==c or (b+c)==a or (c+a)==b])

Fixed submission:
a,b,c = (int(T) for T in input().split())
print(['No','Yes'][(a+b)==c or (b+c)==a or (c+a)==b])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
T,A = (int(T) for T in input().split())
for TN in range(1,N):
    TNext,ANext = (int(T) for T in input().split())
    Cnt = 1
    while TNext*Cnt<T or ANext*Cnt<A:
        Cnt += 1
    T = TNext*Cnt
    A = ANext*Cnt
print(A+T)

Fixed submission:
N = int(input())
TNow,ANow = (int(T) for T in input().split())
for TN in range(1,N):
    TNext,ANext = (int(T) for T in input().split())
    Magn = max(TNow//TNext+(TNow%TNext!=0),ANow//ANext+(ANow%ANext!=0))
    TNow,ANow = TNext*Magn,ANext*Magn
print(TNow+ANow)
Buggy python submission (verdict: Runtime Error):
from itertools import product
S = input()
if len(S)==1:
    print(int(S))
else:
    Sum = 0
    for TR in product([0,1],repeat=(len(S)-1)):
        Op = ['+' if TO==1 else '' for TO in TR]+['']
        Sum += eval(''.join([TS+TO for TS,TO in zip(S,Op)]))
print(Sum)

Fixed submission:
from itertools import product
S = input()
if len(S)==1:
    print(int(S))
else:
    Sum = 0
    for TR in product([0,1],repeat=(len(S)-1)):
        Op = ['+' if TO==1 else '' for TO in TR]+['']
        Sum += eval(''.join([TS+TO for TS,TO in zip(S,Op)]))
    print(Sum)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
N,A = (int(T) for T in input().split())
X = [int(T) for T in input().split()]
Count = 0
for TB in product([0,1],repeat=N):
    Card = list(TB)
    UseN = sum(Card)
    if A*UseN==sum(TX*TC for TX,TC in zip(X,Card)) and UseN>=1:
        Count += 1
print(Count)

Fixed submission:
N,A = (int(T) for T in input().split())
X = [int(T) for T in input().split()]
DP = [[[0]*(N+1) for TS in range(0,50*N+1)] for TI in range(0,N+1)]
DP[0][0][0] = 1
for TI in range(0,N):
    for TS in range(0,50*N+1):
        for TK in range(0,N+1):
            if DP[TI][TS][TK]!=0:
                DP[TI+1][TS][TK] += DP[TI][TS][TK]
                DP[TI+1][TS+X[TI]][TK+1] += DP[TI][TS][TK]
print(sum(DP[N][A*TA][TA] for TA in range(1,N+1)))
Buggy python submission (verdict: Runtime Error):
import collections
n,m=map(int,input().split())
par=[i for i in range(n+1)]
def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
for _ in range(m):
    a,b=map(int,input().split())
    A=find(a)
    B=find(b)
    par[max(A,B)]=par[min(A,B)]
l=[]
for i in range(1,n+1):
    l.append(find(i))
l=collections.Counter(l)
print(max(l.values()))

Fixed submission:
import collections
n,m=map(int,input().split())
par=[i for i in range(n+1)]
def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
for _ in range(m):
    a,b=map(int,input().split())
    A=find(a)
    B=find(b)
    par[max(A,B)]=par[min(A,B)]
l=[]
for i in range(1,n+1):
    l.append(find(i))
l=collections.Counter(l)
print(max(l.values()))

Buggy python submission (verdict: Runtime Error):
import collections
n,m=map(int,input().split())
par=[i for i in range(n+1)]
def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
for _ in range(m):
    a,b=map(int,input().split())
    A=find(a)
    B=find(b)
    par[max(A,B)]=par[min(A,B)]
l=[]
for i in range(1,n+1):
    l.append(find(i))
l=collections.Counter(l)
print(max(l.values()))

Fixed submission:
import collections
n,m=map(int,input().split())
par=[i for i in range(n+1)]
def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
for _ in range(m):
    a,b=map(int,input().split())
    A=find(a)
    B=find(b)
    par[max(A,B)]=par[min(A,B)]
l=[]
for i in range(1,n+1):
    l.append(find(i))
l=collections.Counter(l)
print(max(l.values()))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c=map(int,input().split())
k=int(input())
if a<b:
    if b<c:
        print('Yes')
    else:
        count=0
        while b>=c:
            b*=2
            count+=1
        if count<=k:
            print('Yes')
        else:
            print('No')
else:
    count=0
    while a>=b:
        b*=2
        count+=1
    while b>=c:
        c*=2
        count+=1
    if count<=k:
        print('Yes')
    else:
        print('No')

Fixed submission:
a,b,c=map(int,input().split())
k=int(input())
if a<b:
    if b<c:
        print('Yes')
    else:
        count=0
        while b>=c:
            c*=2
            count+=1
        if count<=k:
            print('Yes')
        else:
            print('No')
else:
    count=0
    while a>=b:
        b*=2
        count+=1
    while b>=c:
        c*=2
        count+=1
    if count<=k:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().slit())
k=int(input())
if a<b:
    if b<c:
        print('Yes')
    else:
        count=0
        while b>=c:
            b*=2
            count+=1
        if count<=k:
            print('Yes')
        else:
            print('No')
else:
    count=0
    while a>=b:
        b*=2
        count+=1
    while b>=c:
        c*=2
        count+=1
    if count<=k:
        print('Yes')
    else:
        print('No')

Fixed submission:
a,b,c=map(int,input().split())
k=int(input())
if a<b:
    if b<c:
        print('Yes')
    else:
        count=0
        while b>=c:
            c*=2
            count+=1
        if count<=k:
            print('Yes')
        else:
            print('No')
else:
    count=0
    while a>=b:
        b*=2
        count+=1
    while b>=c:
        c*=2
        count+=1
    if count<=k:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
count=n
l=sorted(l)
newl=[]
for i  in l:
    flag=True
    for j in newl:
        if i%j==0:
            flag=False
            count-=1
            break
    if flag==True:
        newl.append(i)
if l[0]==l[1]:
        count-=1
print(count)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
counter=[0]*(10**6+1)
l=sorted(l)
for i in l:
    counter[i]+=1
    if counter[i]<2:
        for j in range(2*i,10**6+1,i):
            counter[j]+=2
print(counter.count(1))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
count=0
for i in range(n):
    flag=True
    for j in range(n):
        if i!=j and l[i]%l[j]==0:
            flag=False
            break
    if flag==True:
        count+=1
print(count)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
counter=[0]*(10**6+1)
l=sorted(l)
for i in l:
    counter[i]+=1
    if counter[i]<2:
        for j in range(2*i,10**6+1,i):
            counter[j]+=2
print(counter.count(1))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,k=map(int,input().split())
l=list(map(int,input().split()))
if k>42:
    l=[n]*n
    print(*l)
else:
    for _ in range(k):
        countl=[0]*(n+1)
        for i in range(n):
            countl[max(1,i+1-l[i])]+=1
            if i+2+l[i]<=n:
                countl[i+2+l[i]]-=1
            
        l=list(itertools.accumulate(countl))
        l.remove(l[0])
    print(*l)

Fixed submission:
import itertools
n,k=map(int,input().split())
l=list(map(int,input().split()))
if k>42:
    l=[n]*n
    print(*l)
else:
    for _ in range(k):
        countl=[0]*(n+1)
        for i in range(n):
            countl[max(1,i+1-l[i])]+=1
            if i+2+l[i]<=n:
                countl[i+2+l[i]]-=1
            
        l=list(itertools.accumulate(countl))
        l.remove(l[0])
    print(*l)
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
if l.count(0)!=0:
  print(0)
else:
  num=1
  for i in l:
    if num>10**18:
      break
    else:
      num*=i
if num>=10**18:
  print(-1)
else:
  print(num)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
num=1
if l.count(0)!=0:
    print(0)
else:
    flag=True
    for i in l:
        if num>10**18:
            print(-1)
            flag=False
            break
        else:
            num*=i
    if flag==True:
        if num>10**18:
            print(-1)
        else:
            print(num)
Buggy python submission (verdict: Runtime Error):
import decimal
a,b=map(str,input().split())
c=decimal.Decimal(a)*decimal.Decimal(b)
print(decimal.Decimal(str(c)).quantize(decimal.Decimal('0'),rounding=ROUND_FLOOR))

Fixed submission:
from decimal import Decimal,ROUND_FLOOR
a,b=map(str,input().split())
c=Decimal(a)*Decimal(b)
print(Decimal(str(c)).quantize(Decimal('0'),rounding=ROUND_FLOOR))
Buggy python submission (verdict: Runtime Error):
import queue
n,m=map(int,input().split())
A=[]
B=[]
c=[0]*(n+1)
for _ in range(m):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
q=queue.Queue()
q.put(1)
count=n-1
while not q.empty() and count>0:
    aa=q.get()
    for i in range(m):
        print(aa)
        print(c)
        if A[i]==aa:
            if c[B[i]]==0:
                c[B[i]]=aa
                count-=1
                q.put(B[i])
                B[i]=-1
        elif B[i]==aa:
            if c[A[i]]==0:
                c[A[i]]=aa
                count-=1
                q.put(A[i])
                A[i]=-1
print('Yes')
for i in range(2,n+1):
    print(c[i])
    

Fixed submission:
n,m=map(int,input().split())
route=[[] for _ in range(n+1)]
for _ in range(m):
    a,b=map(int,input().split())
    route[a].append(b)
    route[b].append(a)
from collections import deque
q=deque()
q.append(1)
sigh=[0]*(n+1)
depth=[0]*(n+1)
depth[1]=0
while q:
    a=q.popleft()
    for i in route[a]:
        if depth[i]==0 or depth[i]>depth[a]+1:
            if i!=1:
                depth[i]=depth[a]+1
                q.append(i)
                sigh[i]=a
print('Yes')
for i in range(2,n+1):
    print(sigh[i])

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
c=[0]*(n+1)
l=[1]
count=n
while count>0:
    for _ in range(m):
        a,b=map(int,input().split())
        if l.count(a)!=0 and l.count(b)==0:
            l.append(b)
            c[b]==a
            count-=1
        elif l.count(b)!=0 and l.count(a)==0:
            l.append(a)
            c[a]==b
            count-=1
print('Yes')
for i in range(1,n+1):
    print(c[i])
    

Fixed submission:
n,m=map(int,input().split())
route=[[] for _ in range(n+1)]
for _ in range(m):
    a,b=map(int,input().split())
    route[a].append(b)
    route[b].append(a)
from collections import deque
q=deque()
q.append(1)
sigh=[0]*(n+1)
depth=[0]*(n+1)
depth[1]=0
while q:
    a=q.popleft()
    for i in route[a]:
        if depth[i]==0 or depth[i]>depth[a]+1:
            if i!=1:
                depth[i]=depth[a]+1
                q.append(i)
                sigh[i]=a
print('Yes')
for i in range(2,n+1):
    print(sigh[i])
Buggy python submission (verdict: Runtime Error):
count=0
n=int(input())
l=list(map(str,input()))
i=0
while i<=n-3:
    j=i+1
    while i+1<=j and j<=n-2:
        if l[i]==l[j]:
            j+=1
        else:
            k=j+1
            while j+1<=k and k<=n-1 and k-j!=j-i:
                if l[i]!=l[j] and l[j]!=l[k]:
                    count+=1
                    k+=1
                else:
                    k+=1
            j+=1
    i+=1
print(count)

Fixed submission:
n=int(input())
if n%10==7:
    print('Yes')
elif 70<=n%100 and n%100<=79:
    print('Yes')
elif 700<=n and n<=799:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd,numbers)
count=0
a=1
b=1
c=1
for i in range(n):
    for j in range(n):
        for m in range(n):
            count+=gcd(a,b,c)
            c+=1
        c=1
        b+=1
    b=1
    a+=1
print(count)

Fixed submission:
n=int(input())
import math
count=0
a=1
b=1
c=1
for i in range(n):
    for j in range(n):
        for m in range(n):
            k=math.gcd(a,b)
            l=math.gcd(k,c)
            count+=l
            c+=1
        c=1
        b+=1
    b=1
    a+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
import math
count=0
a=1
b=1
c=1
for i in range(n):
    for j in range(n):
        for m in range(n):
            k=math.gcd(a,b)
            l=math.gcd(k,c)
            count+=l
            c+=1
        c=1
        b+=1
    b=1
    a+=1
print(count)

Fixed submission:
n=int(input())
import math
count=0
a=1
b=1
c=1
for i in range(n):
    for j in range(n):
        for m in range(n):
            k=math.gcd(a,b)
            l=math.gcd(k,c)
            count+=l
            c+=1
        c=1
        b+=1
    b=1
    a+=1
print(count)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if 4*a*b<(c-a-b)**2 and c-a-b>=0:
    print('Yes')
else:
    print('No')

Fixed submission:
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(l[k-1])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[0]*(n+1)
miss=[0]*(n+1)
for _ in range(m):
    p,s=input().split()
    p=int(p)
    if l[p]==0:
        if s=='AC':
            l[p]+=1
        else:
            miss[p]+=1
for i in range(m):
    if l[i]==0 and miss[i]!=0:
        miss[i]=0
a=l.count(1)
b=sum(miss)
print(a,b)

Fixed submission:
n,m=map(int,input().split())
l=[0]*(n+1)
miss=[0]*(n+1)
for _ in range(m):
    p,s=input().split()
    p=int(p)
    if l[p]==0:
        if s=='AC':
            l[p]+=1
        else:
            miss[p]+=1
for i in range(1,n+1):
    if l[i]==0 and miss[i]!=0:
        miss[i]=0
a=l.count(1)
b=sum(miss)
print(a,b)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
q=collections.deque()
h,w=map(int,input().split())
S=[]
for _ in range(h):
    s=input()
    S.append(s)
went=[[0]*w for _ in range(h)]
l=[]
def walk(x,y):
    if x<=h-2:
        if S[x+1][y]=='.' and (x+1,y)!=(ih,iw) and went[x+1][y]==0 or went[x+1][y]>went[x][y]+1:
            went[x+1][y]=went[x][y]+1
            q.append((x+1,y))
    if y<=w-2:
        if S[x][y+1]=='.' and (x,y+1)!=(ih,iw) and went[x][y+1]==0 or went[x][y+1]>went[x][y]+1:
            went[x][y+1]=went[x][y]+1
            q.append((x,y+1))
    if y>=1:
        if S[x][y-1]=='.' and (x,y-1)!=(ih,iw) and went[x][y-1]==0 or went[x][y-1]>went[x][y]+1:
            went[x][y-1]=went[x][y]+1
            q.append((x,y-1))
    if x>=1:
        if S[x-1][y]=='.' and (x-1,y)!=(ih,iw) and went[x-1][y]==0 or went[x-1][y]>went[x][y]+1:
            went[x-1][y]=went[x][y]+1
            q.append((x-1,y))
        
for ih in range(h):
    for iw in range(w):
        if S[ih][iw]=='.':
            went=[[0]*w for _ in range(h)]
            q.append((ih,iw))
            while q:
                (a,b)=q.pop()
                walk(a,b)
            
            ll=[]
            for i in range(h):
                ll.append(max(went[i]))
            l.append(max(ll))
            
print(max(l))

Fixed submission:
import collections
q=collections.deque()
h,w=map(int,input().split())
S=[]
for _ in range(h):
    s=input()
    S.append(s)
went=[[0]*w for _ in range(h)]
l=[]
def walk(x,y):
    if x<=h-2:
        if S[x+1][y]=='.' and (x+1,y)!=(ih,iw) and went[x+1][y]==0 or went[x+1][y]>went[x][y]+1:
            went[x+1][y]=went[x][y]+1
            q.append((x+1,y))
    if y<=w-2:
        if S[x][y+1]=='.' and (x,y+1)!=(ih,iw) and went[x][y+1]==0 or went[x][y+1]>went[x][y]+1:
            went[x][y+1]=went[x][y]+1
            q.append((x,y+1))
    if y>=1:
        if S[x][y-1]=='.' and (x,y-1)!=(ih,iw) and went[x][y-1]==0 or went[x][y-1]>went[x][y]+1:
            went[x][y-1]=went[x][y]+1
            q.append((x,y-1))
    if x>=1:
        if S[x-1][y]=='.' and (x-1,y)!=(ih,iw) and went[x-1][y]==0 or went[x-1][y]>went[x][y]+1:
            went[x-1][y]=went[x][y]+1
            q.append((x-1,y))
        
for ih in range(h):
    for iw in range(w):
        if S[ih][iw]=='.':
            went=[[0]*w for _ in range(h)]
            q.append((ih,iw))
            while q:
                (a,b)=q.pop()
                walk(a,b)
            
            ll=[]
            for i in range(h):
                ll.append(max(went[i]))
            l.append(max(ll))
            
print(max(l))
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
count=0
suml=sum(l)
i=0
while count<suml/2:
    count+=l[i]
    i+=1
k=suml/2
a=l[i]
if count==k:
    print(0)
else:
    print(int(2*(min(count-k,a-count+k))))
    

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
count=0
suml=sum(l)
i=0
while count<suml/2:
    count+=l[i]
    i+=1
k=suml/2
a=l[i-1]
if count==k:
    print(0)
else:
    print(int(2*(min(count-k,a-count+k))))
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))
length=0
i=0
while length<=x:
    length+=l[i]
    i+=1
print(i)


Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))
length=0
i=0
while length<=x and i<=n-1:
    length+=l[i]
    i+=1
if length<=x:
    print(n+1)
else:
    print(i)
Buggy python submission (verdict: Runtime Error):
n=int(input())
count=0
for i in range(1,n+1):
    if i%2==1:
        yakusuu=0
        for j in range(1,int((i**0.5)//1)+1):
            if i%j==0:
                if j**2==i:
                    yakusuu+=1
                else:
                    yakusuu+=2
        if yakusuu==8:
            count+=1
print(count)

Fixed submission:
s=list(map(str,input()))
l=[[]]
count=0
for i in s:
    if i=='A' or i=='C' or i=='G' or i=='T':
        l[count].append(i)
    else:
        count+=1
        l.append([])
maxl=0
for j in l:
    if len(j)>maxl:
        maxl=len(j)
print(maxl)