Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate

n, k = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

visited = [0] * n

A = []
for i in range(1, n + 1):
    if visited[i - 1] == 1:
        continue
    s = i
    X = []
    while True:
        s = P[s - 1]
        X.append(C[s - 1])
        visited[s - 1] = 1
        if s == i:
            break
    A.append(X)

ANS=[]

for a in A:
    b=[0]+a+a
    d=list(accumulate(b))
    if k%len(a)==0:
        x=len(a)
    else:
        x=k%len(a)
    y=k//len(a)
    cnt=-(10**18)

    for i in range(1,x+1):
        for j in range(len(a)+1):
            cnt=max(d[i+j]-d[j],cnt)

    if sum(a)<0:
        ANS.append(cnt)
    else:
        ANS.append(cnt+sum(a)*y)

print(max(ANS))


Fixed submission:
s=input()
ans=0


if 'RR' in s:
    ans=2
else:
    ans=1

if not 'R' in s:
    ans=0

if s=='RRR':
    ans=3
print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect
x,n=map(int,input().split())
P=list(map(int,input().split()))
Q=[]
for i in range(1,101):
    if i not in P:
        Q.append(i)

i=bisect.bisect_left(Q,x)

if abs(Q[i-1]-x)>abs(Q[i]-x):
    print(Q[i])
else:
    print(Q[i-1])

Fixed submission:
x,n=map(int,input().split())
P=list(map(int,input().split()))
Q=[-1,0]
for i in range(1,102):
    if i not in P:
        Q.append(i)

ans=10**9
A=[]
for i,q in enumerate(Q):
    A.append([i,abs(q-x)])
A.sort(key=lambda x:(x[1],x[0]))
print(Q[A[0][0]])
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))

m=max(A)

X=[True]*(m+1)

A.sort()

for i in range(n):
    for j in range(A[i]*2,m+1,A[i]):
        X[j]=False

if A[0]==A[1]:
    ans=0
else:
    ans=1

for i in range(1,n):
    if A[i-1]==A[i]:
        continue
    if X[A[i]]==True:
        ans+=1
print(ans)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))

m=max(A)

X=[0]*(m+1)

A.sort()

for i in range(n):
    for j in range(A[i],m+1,A[i]):
        X[j]+=1

ans=0

for i in range(n):
    if X[A[i]]==1:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(float,input())

print(math.floor(int(a)*b))

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b[0]+b[2:])
print(a*b//100)
Buggy python submission (verdict: Runtime Error):
from _collections import deque
n,m=map(int,input().split())
X=[[] for _ in range(n)]
visited=[0]*(n+1)
ANS=[0]*n
ANS[0]=1
for i in range(m):
    a,b=map(int,input().split())
    X[a-1].append(b-1)
    X[b-1].append(a-1)

q=deque([0])
visited[0]=1
while len(q)>0:
    s=q.popleft()
    for x in X[s]:
        if visited[x]:
            continue
        q.append(x)
        ANS[x]=s
        visited[x]=1
    print(ANS)
print('Yes')
for ans in ANS[1:]:
    print(ans+1)

Fixed submission:
from _collections import deque
n,m=map(int,input().split())
X=[[] for _ in range(n)]
visited=[0]*(n+1)
ANS=[0]*n
ANS[0]=1
for i in range(m):
    a,b=map(int,input().split())
    X[a-1].append(b-1)
    X[b-1].append(a-1)

q=deque([0])
visited[0]=1
while len(q)>0:
    s=q.popleft()
    for x in X[s]:
        if visited[x]:
            continue
        q.append(x)
        ANS[x]=s
        visited[x]=1
print('Yes')
for ans in ANS[1:]:
    print(ans+1)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
A=list(map(int,input().split()))
cnt=0
s=1
M=[0]
while cnt<n:
    s=A[s-1]
    if s-1 in M:
        imp=s-1
        break
    M.append(s-1)
    cnt+=1
x=M.index(imp)
y=len(M)-x

if k<=x:
    print(M[k]+1)
else:
    N=M[x:]
    print(N[(k-x)%y]+1)

Fixed submission:
n,k=map(int,input().split())
A=list(map(int,input().split()))
cnt=0
s=1
M=[0]
B=[0]*(n+1)
while cnt<n:
    s=A[s-1]
    if B[s-1]==0:
        B[s-1]+=1
    else:
        imp=s-1
        break
    M.append(s-1)
    cnt+=1
x=M.index(imp)
y=len(M)-x

if k<=x:
    print(M[k]+1)
else:
    N=M[x:]
    print(N[(k-x)%y]+1)
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
mod= 998244353

def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

n,m,k=map(int,input().split())

ans=0
for i in range(n-k-1,n):
    X=factorial(n-1)*pow(factorial(i),mod-2,mod)*pow(factorial(n-1-i),mod-2,mod)
    X%=mod
    ans+=X*m*pow(m-1,i,mod)
    ans%=mod
print(ans)


Fixed submission:
mod= 998244353

n,m,k=map(int,input().split())

ans=0
cmb=1
for i in range(k+1):
    ans+=cmb*m*pow(m-1,n-1-i,mod)
    ans%=mod
    cmb*=(n-1-i)*pow(i+1,mod-2,mod)
    cmb%=mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n=int(input())
A=list(map(int,input().split()))

X=[A[i]-(i+1) for i in range(n)]
Y=[-A[i]-(i+1) for i in range(n)]
ans=0
X.sort()

for y in Y:
    i=bisect.bisect_left(X,y)
    for j in range(i,n):
        if X[j]==y:
            ans+=1
        else:
            break
print(ans)

Fixed submission:
from _collections import defaultdict
n=int(input())
A=list(map(int,input().split()))

X=[A[i]-(i+1) for i in range(n)]
Y=[-A[i]-(i+1) for i in range(n)]
ans=0

P=defaultdict(int)
Q=defaultdict(int)

for x in X:
    P[x]+=1
for y in Y:
    Q[y]+=1

p=set(P.keys())
q=set(Q.keys())

r=p&q

for key in r:
    ans+=P[key]*Q[key]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
L=len(s)
ans=0
N=[0]*n
r=0
g=0
b=0
for i in reversed(range(L)):
    if s[i]=='R':
        r+=1
        N[i]=r
    elif s[i]=='G':
        g+=1
        N[i]=g
    else:
        b+=1
        N[i]=b

for i in range(L-2):
    x=s[i]
    for j in range(i+1,L-1):
        if s[j]!=x:
            y=s[j]
            for k in range(j+1,L):
                if s[k]!=x and s[k]!=y:
                    ans+=N[k]
                    if k<=j+j-i and j+j-i<=L-1:
                        if s[j+j-i]==s[k]:
                            ans-=1
                    break
print(ans)

Fixed submission:
n=int(input())
s=input()
L=len(s)
ans=0

r=s.count('R')
b=s.count('B')
g=s.count('G')

for i in range(L-2):
    for j in range(i+1,L-1):
        if s[j]!=s[i]:
            if j+j-i<=L-1:
                if s[j+j-i]!=s[i] and s[j+j-i]!=s[j]:
                    ans+=1
print(r*b*g-ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
L=len(s)
ans=0
R=[]
G=[]
B=[]
for i in range(L):
    if s[i]=='R':
        R.append(i)
    elif s[i]=='G':
        G.append(i)
    else:
        B.append(i)
for r in R:
    for g in G:
        for b in B:
            X=[r,b,g]
            X.sort()
            if X[1]-X[0]==X[2]-X[1]:
                continue
            ans+=1
print(ans)

Fixed submission:
n=int(input())
s=input()
L=len(s)
ans=0

r=s.count('R')
b=s.count('B')
g=s.count('G')

for i in range(L-2):
    for j in range(i+1,L-1):
        if s[j]!=s[i]:
            if j+j-i<=L-1:
                if s[j+j-i]!=s[i] and s[j+j-i]!=s[j]:
                    ans+=1
print(r*b*g-ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,x,y=map(int,input().split())
x-=1
y-=1
D=[[0]*n for _ in range(n)]
for i in range(n-1):
    for j in range(i+1,n):
        D[i][j]=min(abs(j-i),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))

K=[0]*(n-1)

for i in range(n-1):
    for j in range(i+1,n):
        K[D[i][j]-1]+=1

for k in K:
    print(k)

Fixed submission:
n,x,y=map(int,input().split())
x-=1
y-=1
D=[[0]*n for _ in range(n)]
for i in range(n-1):
    for j in range(i+1,n):
        D[i][j]=min(abs(j-i),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))

K=[0]*(n-1)

for i in range(n-1):
    for j in range(i+1,n):
        K[D[i][j]-1]+=1

for k in K:
    print(k)

Buggy python submission (verdict: Time Limit Exceeded):
n,x,y=map(int,input().split())
x-=1
y-=1
D=[[0]*n for _ in range(n)]
for i in range(n):
    for j in range(n):
        D[i][j]=min(abs(j-i),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))

K=[0]*(n-1)

for i in range(n-1):
    for j in range(i+1,n):
        K[D[i][j]-1]+=1

for k in K:
    print(k)

Fixed submission:
n,x,y=map(int,input().split())
x-=1
y-=1
D=[[0]*n for _ in range(n)]
for i in range(n-1):
    for j in range(i+1,n):
        D[i][j]=min(abs(j-i),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))

K=[0]*(n-1)

for i in range(n-1):
    for j in range(i+1,n):
        K[D[i][j]-1]+=1

for k in K:
    print(k)
Buggy python submission (verdict: Runtime Error):
def find(x):
    if par[x]<0:
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def unite(x,y):
  x,y=find(x),find(y)
  if x!=y:
    if x>y:
        x,y=y,x
    par[x]+=par[y]
    par[y]=x
    
def same(x,y):
  return find(x)==find(y)

def size(x):
  return-par[find(x)]
  
n,m,k=map(int,input().split())

par=[-1]*n

F=[]
B=[]

f=[set() for _ in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    F.append([a,b])
    
for i in range(k):
    c,d=map(int,input().split())
    B.append([c,d])

for a,b in F:
    a-=1
    b-=1
    unite(a,b)
    f[a].add(b)
    f[b].add[a]

a=[size(i)-len(f[i])-1 for i in range(n)]

for c,d in B:
    c-=1
    d-=1
    if same(c,d):
        a[c]-=1
        a[d]-=1
print(*a)

Fixed submission:
def find(x):
    if par[x]<0:
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def unite(x,y):
  x,y=find(x),find(y)
  if x!=y:
    if x>y:
        x,y=y,x
    par[x]+=par[y]
    par[y]=x
    
def same(x,y):
  return find(x)==find(y)

def size(x):
  return-par[find(x)]
  
n,m,k=map(int,input().split())

par=[-1]*n

F=[]
B=[]

f=[set() for _ in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    F.append([a,b])
    
for i in range(k):
    c,d=map(int,input().split())
    B.append([c,d])

for a,b in F:
    a-=1
    b-=1
    unite(a,b)
    f[a].add(b)
    f[b].add(a)

a=[size(i)-len(f[i])-1 for i in range(n)]

for c,d in B:
    c-=1
    d-=1
    if same(c,d):
        a[c]-=1
        a[d]-=1
print(*a)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,k,m=map(int,input().split())

F=[[] for _ in range(n)]
B=[[] for _ in range(n)]

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

for i in range(m):
    c,d=map(int,input().split())
    B[c-1].append(d-1)
    B[d-1].append(c-1)


def find(i):
    dis=0
    Q=deque([[i,dis]])
    ans=0
    visited={i}
    while Q:
        f,dis=Q.pop()
        if dis>1 and not f in B[i]:
            ans+=1

        for j in F[f]:
            if j in visited:
                continue
            Q.appendleft([j,dis+1])
            visited.add(j)
    return ans

ANS=[]
for i in range(n):
    ANS.append(find(i))
print(*ANS)

Fixed submission:
def find(x):
    if par[x]<0:
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def unite(x,y):
  x,y=find(x),find(y)
  if x!=y:
    if x>y:
        x,y=y,x
    par[x]+=par[y]
    par[y]=x
    
def same(x,y):
  return find(x)==find(y)

def size(x):
  return-par[find(x)]
  
n,m,k=map(int,input().split())

par=[-1]*n

F=[]
B=[]

f=[set() for _ in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    F.append([a,b])
    
for i in range(k):
    c,d=map(int,input().split())
    B.append([c,d])

for a,b in F:
    a-=1
    b-=1
    unite(a,b)
    f[a].add(b)
    f[b].add(a)

a=[size(i)-len(f[i])-1 for i in range(n)]

for c,d in B:
    c-=1
    d-=1
    if same(c,d):
        a[c]-=1
        a[d]-=1
print(*a)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

n,a,b=map(int,input().split())

s=(2**n-1)%(10**9+7)
x=comb(n,a,exact=True)%(10**9+7)
y=comb(n,b,exact=True)%(10**9+7)

print(s-x-y)

Fixed submission:
n,a,b=map(int,input().split())

s=pow(2,n,10**9+7)-1
x=1
for i in range(a):
    x*=(n-i)
    x%=(10**9+7)
    x*=pow(i+1,10**9+5,10**9+7)
y=1
for i in range(b):
    y*=(n-i)
    y%=(10**9+7)
    y*=pow(i+1,10**9+5,10**9+7)

print((s-x-y)%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
P=list(map(int,input().split()))
for i in range(n):
    P[i]=sum(range(P[i]+1))/P[i]

s=[]
for i in range(n-k+1):
    s.append(sum(P[i:i+k]))

print(max(s))

Fixed submission:
n,k=map(int,input().split())
P=list(map(int,input().split()))
for i in range(n):
    P[i]=0.5*(P[i]+1)
x=sum(P[:k])
s=[x]

for i in range(1,n-k+1):
    x=x-P[i-1]+P[i+k-1]
    s.append(x)

print(max(s))
Buggy python submission (verdict: Runtime Error):
h,n=map(int,input().split())
dp=[10**10]*(h+1)
dp[0][0]=1
X=[]
for i in range(n):
    a,b=map(int,input().split())
    X.append([a,b])


for i in range(h):
    for j in range(n):
        k=min(i+X[j][0],h)
        dp[k]=min(dp[k],dp[i]+X[j][1])
print(dp[h])

Fixed submission:
h,n=map(int,input().split())
H=[]
A=[]
for i in range(n):
    a,b=map(int,input().split())
    H.append([a,b])
    A.append(a)
a_max=max(A)
dp=[10**10]*(h+a_max+1)
dp[0]=0
for i in range(1,h+a_max+1):
    for j in range(n):
        if i-H[j][0]<0:
            dp[i]=min(dp[i],H[j][1])
        else:
            dp[i]=min(dp[i],dp[i-H[j][0]]+H[j][1])
print(min(dp[h:h+a_max+1]))
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

def lcm(a,b):
    return a*(b//gcd(a,b))

mod=10**9+7

n=int(input())
A=list(map(int,input().split()))

L=A[0]
for i in range(1,n):
    L=lcm(L,A[i])
ans=0
for i in range(n):
    ans+=(L//A[i])%mod
print(ans%mod)

Fixed submission:
from fractions import gcd

def lcm(a,b):
    return a*(b//gcd(a,b))

mod=10**9+7

n=int(input())
A=list(map(int,input().split()))

L=A[0]
for i in range(1,n):
    L=lcm(L,A[i])
L%=mod

coef=sum(pow(x,mod-2,mod) for x in A)
print(L*coef%mod)

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

def lcm(a,b):
    return a*(b//gcd(a,b))

mod=10**9+7

n=int(input())
A=list(map(int,input().split()))

L=A[0]
for i in range(1,n):
    L=lcm(L,A[i])
L%=mod

ans=0
for i in range(n):
    ans+=(L//A[i])%mod
print(ans)

Fixed submission:
from fractions import gcd

def lcm(a,b):
    return a*(b//gcd(a,b))

mod=10**9+7

n=int(input())
A=list(map(int,input().split()))

L=A[0]
for i in range(1,n):
    L=lcm(L,A[i])
L%=mod

coef=sum(pow(x,mod-2,mod) for x in A)
print(L*coef%mod)

Buggy python submission (verdict: Runtime Error):
mod=10**9+7
from math import sqrt
n=int(input())

A=list(map(int,input().split()))
N=[0]*(10**3+1)
def soi(n):
    cnt_2=0
    while n%2==0:
        n//=2
        cnt_2+=1
    N[2]=max(N[2],cnt_2)
    for j in range(3,int(sqrt(n))+1,2):
        cnt_j=0
        while n%j==0:
            n//=j
            cnt_j+=1
        N[j]=max(N[j],cnt_j)
    if n!=1:
        N[n]=max(N[n],1)

for i in range(n):
    soi(A[i])
L=1
for i in range(1,10**3+1):
    L*=((i)**(N[i]))%mod
ans=0
for i in range(n):
    ans+=(L*pow(A[i],mod-2,mod))%mod
print(ans)

Fixed submission:
from fractions import gcd

def lcm(a,b):
    return a*(b//gcd(a,b))

mod=10**9+7

n=int(input())
A=list(map(int,input().split()))

L=A[0]
for i in range(1,n):
    L=lcm(L,A[i])
L%=mod

coef=sum(pow(x,mod-2,mod) for x in A)
print(L*coef%mod)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())

N=[]

for i in range(n):
    N.append([0,0])

co=0
pe=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=='WA':
        N[p-1][0]+=1
    elif N[p-1][1]!=1:
        pe+=N[p][0]
        co+=1
        N[p-1][1]=1

print(str(co)+' '+str(pe))

Fixed submission:
n,m=map(int,input().split())

N=[]

for i in range(n):
    N.append([0,0])

co=0
pe=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=='WA':
        N[p-1][0]+=1
    elif N[p-1][1]!=1:
        pe+=N[p-1][0]
        co+=1
        N[p-1][1]=1

print(str(co)+' '+str(pe))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())

N=[[0,0]*n]
co=0
pe=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=='WA':
        N[p-1][0]+=1
    elif N[p-1][1]!=1:
        pe+=N[p-1][0]
        co+=1
        N[p-1][1]=1

print(str(co)+' '+str(pe))

Fixed submission:
n,m=map(int,input().split())

N=[]

for i in range(n):
    N.append([0,0])

co=0
pe=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=='WA':
        N[p-1][0]+=1
    elif N[p-1][1]!=1:
        pe+=N[p-1][0]
        co+=1
        N[p-1][1]=1

print(str(co)+' '+str(pe))
Buggy python submission (verdict: Runtime Error):
n=int(input())
cnt_10=0
if n%2==1:
    print(0)
else:
    for i in range(100):
        if 2*5**i<=n and n<2*5**(i+1):
            MAX_10=i
            break
    for j in range(1,MAX_10+1):
        cnt_10+=n//(2*5**j)  
    print(cnt_10)

Fixed submission:
n=int(input())
cnt_10=0
MAX_10=0
if n%2==1:
    print(0)
else:
    for i in range(100):
        if 2*5**i<=n and n<2*5**(i+1):
            MAX_10=i
            break
    for j in range(1,MAX_10+1):
        cnt_10+=n//(2*5**j)  
    print(cnt_10)

Buggy python submission (verdict: Runtime Error):
n=int(input())
cnt_2=0
cnt_10=0
if n%2==1:
    print(0)
else:

    for i in range(1000):
        if 2*5**i<=n and n<2*5**(i+1):
            MAX_10=i
            break
    for j in range(1,MAX_10+1):
        cnt_10+=n//(2*5**j)  
    print(cnt_10)

Fixed submission:
n=int(input())
cnt_10=0
MAX_10=0
if n%2==1:
    print(0)
else:
    for i in range(100):
        if 2*5**i<=n and n<2*5**(i+1):
            MAX_10=i
            break
    for j in range(1,MAX_10+1):
        cnt_10+=n//(2*5**j)  
    print(cnt_10)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
S=input()
ans=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            flag1=False
            flag2=False
            flag3=False
            for s in S:
                if s==str(i) and not(flag1):
                    flag1=True
                    continue
                if s==str(j) and flag1 and not(flag2):
                    flag2=True
                    continue
                if s==str(k) and flag1 and flag2 and not(flag3):
                    flag3=True
                    continue
            if flag1 and flag2 and flag3:
                ans+=1
print(ans)



Fixed submission:
n=int(input())
S=input()
ans=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            x=str(i)+str(j)+str(k)
            p=S.find(x[0])
            q=S.find(x[1],p+1)
            r=S.find(x[2],q+1)
            if p!=-1 and q!=-1 and r!=-1:
                ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
S=input()
ans=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            flag1=False
            flag2=False
            flag3=False
            for s in S:
                if s==str(i) and not(flag1):
                    flag1=True
                    continue
                if s==str(j) and flag1 and not(flag2):
                    flag2=True
                    continue
                if s==str(k) and flag1 and flag2 and not(flag3):
                    flag3=True
                    continue
            if flag1 and flag2 and flag3:
                ans+=1
print(ans)



Fixed submission:
n=int(input())
S=input()
ans=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            x=str(i)+str(j)+str(k)
            p=S.find(x[0])
            q=S.find(x[1],p+1)
            r=S.find(x[2],q+1)
            if p!=-1 and q!=-1 and r!=-1:
                ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
N=[0]*(10**6)
ans=10**9+7
if len([a for a in A if a==0])==1:
    ans=3
else:
    ans=6

for a in A:
    N[a]+=1
    if a!=0:
        ans*=N[a-1]%mod
        N[a-1]-=1
print(ans)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
N=[3]+[0]*n
mod=10**9+7
ans=1

for a in A:
    ans*=N[a]
    ans%=mod
    N[a]-=1
    N[a+1]+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
from _collections import deque
h,w,k=map(int,input().split())
S=[input() for _ in range(h)]
A=deque([])
cnt=1

def func(X):
    global cnt
    ANS=[]
    c=X.count('#')
    a=0
    for x in X:
        ANS.append(cnt)
        if x=='#':
            cnt+=1
            a+=1
            if a==c:
                for _ in range(w-len(ANS)):
                    ANS.append(cnt-1)
                break
    A.append(ANS)



for i in range(h):
    if S[i].count('#')==0 and i!=0:
        A.append(A[-1])
    elif S[i].count('#')!=0:
        func(S[i])

if S[0].count('#')==0:
    A.appendleft(A[0])

for ans in A:
    print(*ans)

Fixed submission:
from _collections import deque
h,w,k=map(int,input().split())
S=[input() for _ in range(h)]
A=deque([])
cnt=1

def func(X):
    global cnt
    ANS=[]
    c=X.count('#')
    a=0
    for x in X:
        ANS.append(cnt)
        if x=='#':
            cnt+=1
            a+=1
            if a==c:
                for _ in range(w-len(ANS)):
                    ANS.append(cnt-1)
                break
    A.append(ANS)



for i in range(h):
    if S[i].count('#')==0 and i!=0 and len(A)!=0:
        A.append(A[-1])
    elif S[i].count('#')!=0:
        func(S[i])

if len(A)!=h:
    for _ in range(h-len(A)):
        A.appendleft(A[0])

for ans in A:
    print(*ans)

Buggy python submission (verdict: Runtime Error):
from _collections import deque
h,w,k=map(int,input().split())
S=[input() for _ in range(h)]
A=deque([])
cnt=1

def func(X):
    global cnt
    ANS=''
    c=X.count('#')
    a=0
    for x in X:
        ANS+=str(cnt)
        if x=='#':
            cnt+=1
            a+=1
            if a==c:
                ANS+=str(cnt-1)*(w-len(ANS))
                break
    A.append(ANS)



for i in range(h):
    if S[i].count('#')==0 and i!=0:
        A.append(A[-1])
    elif S[i].count('#')!=0:
        func(S[i])

if S[0].count('#')==0:
    A.appendleft(A[0])

for ans in A:
    print(*[int(n) for n in ans])

Fixed submission:
from _collections import deque
h,w,k=map(int,input().split())
S=[input() for _ in range(h)]
A=deque([])
cnt=1

def func(X):
    global cnt
    ANS=[]
    c=X.count('#')
    a=0
    for x in X:
        ANS.append(cnt)
        if x=='#':
            cnt+=1
            a+=1
            if a==c:
                for _ in range(w-len(ANS)):
                    ANS.append(cnt-1)
                break
    A.append(ANS)



for i in range(h):
    if S[i].count('#')==0 and i!=0 and len(A)!=0:
        A.append(A[-1])
    elif S[i].count('#')!=0:
        func(S[i])

if len(A)!=h:
    for _ in range(h-len(A)):
        A.appendleft(A[0])

for ans in A:
    print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())

A=list(map(int,input().split()))

for i in range(m):
    A[A.index(max(A))]//=2
print(sum(A))

Fixed submission:
import heapq

n,m=map(int,input().split())

A=list(map(int,input().split()))

A=[i*-1 for i in A]

heapq.heapify(A)

for i in range(m):
    x=heapq.heappop(A)
    if x%2==0:
        heapq.heappush(A,x//2)
    else:
        heapq.heappush(A,x//2+1)
print(-1*sum(A))
Buggy python submission (verdict: Runtime Error):
n=int(input())
H=list(map(int,input().split()))
c=0
C=[]
for i in range(n-1):
    if H[i]>=H[i+1]:
        c+=1
    else:
        C.append(c)
        c=0
    if i==n-2:
        C.append(c)
print(max(C))
    

Fixed submission:
n=int(input())
H=list(map(int,input().split()))
c=0
C=[]

    

for i in range(n-1):
    if H[i]>=H[i+1]:
        c+=1
    else:
        C.append(c)
        c=0
    if i==n-2:
        C.append(c)
if len(H)!=1:        
    ans=max(C)
else:
    ans=0

print(ans)