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

Fixed submission:
# coding:utf-8                                                                  

alls = raw_input()
tarx, tary = map(int, raw_input().split())

ss = alls.split("T")

xs = []
ys = []
posx = set()
posy = set()
posy.add(0)
for i, s in enumerate(ss):
    if i == 0:
        posx.add(len(s))
    elif i % 2 == 0:
        xs.append(len(s))
    else:
        ys.append(len(s))

for x in xs:
    tmpx = set()
    for px in posx:
        tmpx.add(px+x)
        tmpx.add(px-x)
    posx = tmpx

for y in ys:
    tmpy = set()
    for py in posy:
        tmpy.add(py+y)
        tmpy.add(py-y)
    posy = tmpy

if tarx in posx and tary in posy:
    print "Yes"
else:
    print "No"

Buggy submission (verdict: Runtime Error):
# coding:utf-8                                                                  

alls = raw_input()
tarx, tary = map(int, raw_input().split())

ss = alls.split("T")

xs = []
ys = []
posx = set()
posy = set()
posy.add(0)
for i, s in enumerate(ss):
    if i == 0:
        posx.add(len(s))
    elif i % 2 == 0:
        xs.add(len(s))
    else:
        ys.add(len(s))

for x in xs:
    tmpx = set()
    for px in posx:
        tmpx.add(px+x)
        tmpx.add(px-x)
    posx = tmpx

for y in ys:
    tmpy = set()
    for py in posy:
        tmpy.add(py+y)
        tmpy.add(py-y)
    posy = tmpy

if tarx in posx and tary in posy:
    print "Yes"
else:
    print "No"
Problem p03565 (python)

Fixed submission:
S = input()
T = input()
def solve(i):
  flag = True
  for j in range(len(T)):
    if i+j < len(S) and (S[i+j] == "?" or S[i+j] == T[j]):
      continue
    else:
      flag = False
      break
  return flag
anslist = []
for i in range(len(S)):
  if solve(i):
    anstmp = S[:i] + T + S[i+len(T):]
    anstmp = anstmp.replace("?", "a")
    anslist.append(anstmp)
if len(anslist) > 0:
  anslist.sort()
  ans = anslist[0]
else:
  ans = "UNRESTORABLE"
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
def solve(i):
  flag = True
  for j in range(len(T)):
    if i+j < len(S) and (S[i+j] == "?" or S[i+j] == T[j]):
      continue
    else:
      flag = False
      break
  return flag

for i in range(len(S)):
  if solve(i):
    ansind = i
if ansind:
  ans = S[:ansind] + T + S[ansind+len(T):]
  ans = ans.replace("?", "a")
else:
  ans = "UNRESTORABLE"
print(ans)
Problem p03830 (python)

Fixed submission:
n = int(input())
mod = 10**9+7
# https://note.nkmk.me/python-prime-factorization/
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

table = [0] * (n+1)
for i in range(2, n+1):
  p = prime_factorize(i)
  for pi in p:
    table[pi] += 1
ans = 1
for t in table:
  ans = ans * (t+1) % mod
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
# https://note.nkmk.me/python-prime-factorization/
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

table = [0] * n
for i in range(2, n+1):
  p = prime_factorize(i)
  for pi in p:
    table[pi] += 1
ans = 1
for t in table:
  ans *= t+1
print(ans)
Problem p03836 (python)

Fixed submission:
sx, sy, tx, ty = map(int, input().split())

ans = ""

ans += "U" * (ty - sy) + "R" * (tx - sx)
ans += "D" * (ty - sy) + "L" * (tx - sx)
ans += "L" + "U" * (ty - sy + 1) + "R" * (tx - sx + 1) + "D"
ans += "R" + "D" * (ty - sy + 1) + "L" * (tx - sx + 1) + "U"
print(ans)

Buggy submission (verdict: Runtime Error):
sx, sy, tx, ty = map(int, input().split())

ans = ""

ans += "U" * (ty - sy) + "R" * (tx - sx)
ans += "D" * (ty - sy) + "L" * (tx - sx)
ans += "L" + "U" * (ty - sy + 1) + "R" * (tx - sx + 1) + "D"
ans += "R" + "D" * (ty - sy + 1) + "L" * (tx - sx + 1) + "U"
print(ans)sx, sy, tx, ty = map(int, input().split())

ans = ""

ans += "U" * (ty - sy) + "R" * (tx - sx)
ans += "D" * (ty - sy) + "L" * (tx - sx)
ans += "L" + "U" * (ty - sy + 1) + "R" * (tx - sx + 1) + "D"
ans += "R" + "D" * (ty - sy + 1) + "L" * (tx - sx + 1) + "U"
print(ans)
Problem p02665 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=1
flag=0
sum_=0
for i in range(N+1):
  sum_+=A[i]
node=2
if A[0]>0:
  flag=1
  if A==[1] and N==0:
    flag=2
if N!=0:
  sum_-=A[1]
for i in range(1,N+1):
  if i!=N and node-A[i]<=0:
    flag=1
  elif i!=N:
    sum_-=A[i+1]
    ans+=node
    if 2*(node-A[i])-A[i+1]<=sum_:
      node=2*(node-A[i])
    else:
      node=sum_+A[i+1]   
  else:
    if node-A[i]<0:
      flag=1
    else:
      ans+=A[i]
if N==0 and A==[0]:
  flag=1

if flag==1:
  print("-1")
elif flag==2:
  print("1")
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=1
flag=0
sum_=0
for i in range(N+1):
  sum_+=A[i]
node=2
if A[0]>0:
  flag=1
  
sum_-=A[1]
for i in range(1,N+1):
  if i!=N and node-A[i]<=0:
    flag=1
  elif i!=N:
    sum_-=A[i+1]
    ans+=node
    if 2*(node-A[i])-A[i+1]<=sum_:
      node=2*(node-A[i])
    else:
      node=sum_+A[i+1]   
  else:
    ans+=A[i]

if flag==1:
  print("-1")
elif flag==2:
  print("1")
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=1
flag=0
sum_=0
for i in range(N+1):
  sum_+=A[i]
node=2
if A[0]>0:
  flag=1
  if A==[1] and N==0:
    flag==2
sum_-=A[1]
for i in range(1,N+1):
  if i!=N and node-A[i]<=0:
    flag=1
  elif i!=N:
    sum_-=A[i+1]
    ans+=node
    if 2*(node-A[i])-A[i+1]<=sum_:
      node=2*(node-A[i])
    else:
      node=sum_+A[i+1]   
  else:
    ans+=A[i]

if flag==1:
  print("-1")
elif flag==2:
  print("1")
else:
  print(ans)
Problem p02683 (python)

Fixed submission:
N,M,X=map(int,input().split())
l=[]
for i in range (N):
  l.append(list(map(int,input().split())))
ans=10000000
for i in range(2**N):
  score=[0]*M
  coin=0
  for j in range(N):
    if i>=2**(N-1-j):
      for p in range(M):
        score[p]+=l[j][p+1]
      coin+=l[j][0]
      i-=2**(N-1-j)
  flag=0
  for q in range(M):
    if score[q]<X:
      flag=1
  if flag==0:
    if ans>coin:
      ans=coin
if ans==10000000:
  print("-1")
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
N,M,X=map(int,input().split())
l=[]
for i in range (N):
  l.append(list(map(int,input().split())))
ans=10000000
for i in range(2**N):
  score=[0]*M
  coin=0
  for j in range(N):
    if i>=2**(N-1-j):
      for p in range(M):
        score[p]+=l[j][p+1]
      coin+=l[j][0]
      i-=2**(N-1-j)
  flag=0
  for q in range(M):
    if score[q]<X:
      flag=1
  if flag==0:
    if ans>coin:
      ans=coin
if ans=10000000:
  print("-1")
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
N,M,X=map(int,input().split())
l=[]
for i in range (N):
  l.append(list(map(int,input().split())))
ans=0
for i in range(2**N):
  score=[0]*M
  coin=0
  for j in range(N):
    if i>=2**(N-1-j):
      for p in range(M):
        score[p]+=l[j][p+1]
        coin+=l[j][0]
      i-=2**(N-1-j)
  flag=0
  for q in range(M):
    if score(q)<X:
      flag=1
  if flag==0:
    if ans<coin:
      ans=coin
print(coin)
Problem p02684 (python)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
flag=0
now=0
i=0
count=0
c=[0]*N
r=[0]
c[0]=1
while flag==0:
  now=A[now]-1
  count+=1
  if count==K:
    flag=1
  elif c[now]==1:
    flag=2
  c[now]=1
  r.append(now)
if flag==1:
  print(now+1)
else:
  o=[i for i, x in enumerate(r) if x == now]
  print(r[(K-o[0])%(o[1]-o[0])+o[0]]+1)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
flag=0
now=0
i=0
count=0
c=[0]*N
r=[0]
c[0]=1
while flag==0:
  now=A[now]-1
  count+=1
  if count==K:
    flag=1
  elif c[now]==1:
    flag=2
  c[now]=1
  r.append(now)
if flag==1:
  print(now+1)
else:
  o=[i for i, x in enumerate(r) if x == now]
  print(A[r[K%(o[1]-o[0])]+o[0]-1])

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
flag=0
now=0
i=0
count=0
c=[0]*N
r=[0]
c[0]=1
while flag==0:
  now=A[now]-1
  count+=1
  if count==K:
    flag=1
  elif c[now]==1:
    flag=2
  c[now]=1
  r.append(now)
print(r)
if flag==1:
  print(now+1)
else:
  o=[i for i, x in enumerate(r) if x == now]
  print(A[r[K%(o[1]-o[0])]+o[0]-1])

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
flag=0
now=0
i=0
count=0
c=[0]*N
r=[0]
while flag==0:
  now=A[now]-1
  count+=1
  if count==K:
    flag=1
  elif c[now]==1:
    flag=2
  c[now]=1
  r.append(now)
print(r)
if flag==1:
  print(now+1)
else:
  o=[i for i, x in enumerate(r) if x == now]
  print(A[r[K%(o[1]-o[0])]+o[0]-1])
Problem p02727 (python)

Fixed submission:
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
x=0
y=0
R=0
z=0
s=0
while (x<X or y<Y) and z<X+Y:
  if (max(p[0],q[0],r[0])==p[0] or (y==Y and r[0]<p[0])) and x<X:
    s+=p[0]
    x+=1
    if x<A:
      p[0]=p[x]
    else:
      p[0]=0
    z+=1
  elif (max(p[0],q[0],r[0])==q[0] or (x==X and r[0]<q[0])) and y<Y:
    s+=q[0]
    y+=1
    if y<B:
      q[0]=q[y]
    else:
      q[0]=0
    z+=1
  else:
    s+=r[0]
    R+=1
    if R<C:
      r[0]=r[R]
    else:
      r[0]=0
    z+=1
print(s)

Buggy submission (verdict: Runtime Error):
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
x=0
y=0
R=0
z=0
s=0
while (x<X or y<Y) and z<X+Y:
  if (max(p[0],q[0],r[0])==p[0] or (y==Y and r[0]<p[0])) and x<X:
    s+=p[0]
    x+=1
    p[0]=p[x]
    z+=1
  elif (max(p[0],q[0],r[0])==q[0] or (x==X and r[0]<q[0])) and y<Y:
    s+=q[0]
    y+=1
    q[0]=q[y]
    z+=1
  else:
    s+=r[0]
    R+=1
    r[0]=r[R]
    z+=1
print(s)
Problem p03262 (python)

Fixed submission:
from fractions import gcd
N,X=map(int,input().split())
x=list(map(int,input().split()))
g=x[0]-X
for i in range (N-1):
  g=gcd(g,x[i+1]-x[i])
print(abs(g))

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
x=list(map(int,input().split()))
from fractions import gcd
g=x[1]-x[0]
for i in range (N-1):
  g=gcd(g,x[i+1]-x[i])
print(g)
Problem p03497 (python)

Fixed submission:
N,K=map(int,input().split())
a=input().split()

list.sort(a)#小さい順に並び替える
    
count=1#各数字が何回出てくるか
size=0#何種類の数字が出てくるか
b=[]#各数字が何回出てきたかを入れる箱
for p in range (N-1):
  if a[p]==a[p+1]:
    count+=1
  else:
    b.append(count)
    count=1
    size+=1

b.append(count)
size+=1
  
list.sort(b,reverse=True)#大きい順に並び替える

s=0
if K<size:
  for u in range (K):
    s+=b[u]#大きい方からK個分の個数の合計
else:
  s=N#出てくる数の個数が少なければ変える必要はない
print(N-s)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
a=input().split()

for i in range (N):
  for j in range (N-1):
    if a[j]>a[j+1]:
      g=a[j]
      a[j]=a[j+1]
      a[j+1]=g
    
count=1
size=0
b=[]
for p in range (N-1):
  if a[p]==a[p+1]:
    count+=1
  else:
    b.append(count)
    count=1
    size+=1

for q in range (size):
  for r in range (size-1):
    if b[r]<b[r+1]:
      g=b[r]
      b[r]=b[r+1]
      b[r+1]=g

s=0
for u in range (K):
  s+=b[u]

print(N-s)
Problem p03639 (python)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
odd=0
four=0
for i in range(N):
  if a[i]%4==0:
    four+=1
  elif a[i]%2!=0:
    odd+=1
if four>=odd:
  print("Yes")
else:
  if odd==four+1 and odd+four==N:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
odd=0
four=0
for i in range(N):
  if a[i]%4==0:
    four+=1
  elif a[i]%2!=0:
    odd+=1
if four>=odd or four+odd=N:
  print("Yes")
else:
  print("No")
Problem p02574 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = list(map(int,input().split()))
    pr = [0]*(max(a)+1)
    flag = True
    for num in a:
        pr[num] += 1
    for i in range(2, max(a)+1):
        count = sum(pr[i::i])
        if count == N:
            print("not coprime")
            exit()
        elif count > 1:
            flag = False
    if flag:
        print("pairwise coprime")
    else:
        print("setwise coprime")

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = list(map(int,input().split()))
    
    pr = [0]*(max(a)+1)
    for num in a:
        pr[num] += 1
    for i in range(2, max(a)+1):
        count = sum(pr[i::i])
        if count == N:
            print("not coprime")
        elif count > 1:
            flag = False
    if flag:
        print("pairwise coprime")
    else:
        print("setwise coprime")

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

Fixed submission:
import sys
input = sys.stdin.buffer.readline

def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))
    A.sort()
    l, r = 0, N-1
    MOD = 10**9+7
    if K == N:
        ans = 1
        for num in A:
            ans *= num
            ans = (ans+MOD)%MOD
        print((ans+MOD)%MOD)
        exit()
    elif A[-1] < 0 and K%2 == 1:
        ans = 1
        for i in range(K):
            ans *= A[-i-1]
            ans = (ans+MOD)%MOD
        print(ans)
        exit()
    ans = 1
    if K%2 == 1:
        ans *= A[-1]
        r -= 1
    for _ in range(K//2):
        nl = A[l]*A[l+1]
        nr = A[r]*A[r-1]
        if nl > nr:
            ans *= nl
            l += 2
        else:
            ans *= nr
            r -= 2
        ans = (ans+MOD)%MOD
    print(ans)
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline

def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))
    MOD = 10**9+7
    nega, posi = [], []
    for num in A:
        if num > 0:
            posi.append(num)
        elif num < 0:
            nega.append(num)
    
    if K > len(posi)+len(nega):
        print(0)
    elif K == len(nega)+len(posi):
        ans = 1
        for num in A:
            ans *= num
            ans = (ans+MOD)%MOD
        print(ans)
    elif len(posi) == 0:
        if K%2 != 0:
            if 0 in A:
                print(0)
            else:
                nega.sort(reverse = True)
                ans = 1
                for i in range(K):
                    ans *= nega[i]
                print((ans+MOD)%MOD)
        else:
            nega.sort()
            ans = 1
            for i in range(K):
                ans *= nega[i]
            print((ans+MOD)%MOD)
    else:
        nega.sort()
        posi.sort(reverse = True)
        if K <= len(posi):
            ans = 1
            for i in range(K):
                ans *= posi[i]
            print((ans+MOD)%MOD)
            exit()
        cn = [1]
        cp = [1]
        for num in nega:
            cn.append(cn[-1]*num)
        for num in posi:
            cp.append(cp[-1]*num)
        ans = 0
        l = len(cp)
        for i in range(l):
            if K-i > len(cn):
                continue
            ret = cp[i]*cn[K-i]
            ans = max(ans, ret)
        print((ans+MOD)%MOD)
    
if __name__ == "__main__":
    main()
Problem p02664 (python)

Fixed submission:
S = input()
print(S.replace("?","D"))

Buggy submission (verdict: Runtime Error):
a,b,c,d,e = map(int,input().split())

print(c*60+d-(a*60+b)-e)
Problem p02698 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline
import bisect
import copy
from collections import deque
sys.setrecursionlimit(10**7)

def main():
    N = int(input())
    a = list(map(int,input().split()))
    INF = 10**12
    
    edge = [[] for _ in range(N)]
    for _ in range(N-1):
        u,v = map(int,input().split())
        edge[u-1].append(v-1)
        edge[v-1].append(u-1)
        
    def LIS(dp,num):
        ind = bisect.bisect_left(dp,num)
        ret = dp[ind]
        dp[ind] = num
        return ind,ret
    
    dp = [INF]*(N+2)
    dp[0] = -INF

    ans = [0]*N
    q = deque([])
    
    def DFS(prev,now,dp):
        while q:
            s,t,ind,num = q.pop()
            if t == prev:
                q.append((s,t,ind,num))
                break
            else:
                dp[ind] = num
        ind,num = LIS(dp,a[now])
        ans[now] = max(ind,ans[prev])
        q.append((prev,now,ind,num))
        for fol in edge[now]:
            if fol != prev:
                DFS(now,fol,dp)

    DFS(-1,0,dp)
    print(*ans,sep="\n")
 
if __name__ == "__main__":
    main()

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

def main():
    N = int(input())
    a = list(map(int,input().split()))
    INF = 10**12
    
    edge = [[] for _ in range(N)]
    for _ in range(N-1):
        u,v = map(int,input().split())
        edge[u-1].append(v-1)
        edge[v-1].append(u-1)
        
    def LIS(dp,num):
        ind = bisect.bisect_left(dp,num)
        ret = dp[ind]
        dp[ind] = num
        return ind,ret
    
    dp = [INF]*(N+2)
    dp[0] = -INF
    dp[1] = a[0]

    ans = [0]*N
    q = deque([])
    
    def DFS(prev,now,dp):
        while q:
            s,t,ind,num = q.pop()
            if t == prev:
                q.append((s,t,ind,num))
                break
            else:
                dp[ind] = num
        ind,num = LIS(dp,a[now])
        ans[now] = ind
        q.append((prev,now,ind,num))
        for fol in edge[now]:
            if fol != prev:
                DFS(now,fol,dp)

    DFS(-1,0,dp)
    print(*ans,sep="\n")
 
if __name__ == "__main__":
    main()
Problem p02719 (python)

Fixed submission:
N,K = map(int,input().split())
a = N%K
b = abs(a-K)
print(min(a,b))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
s = sum(a)
vor = -(-s//(4*M))
if a[M-1] >= vor:
    print("Yes")
else:
    print("No")
Problem p02742 (python)

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    H,W = map(int,input().split())
    if H == 1 or W == 1:
        print(1)
    else:
        print((H*W)//2+(H*W)%2)
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
    print((H*W)//2+(H*W)%2)
Problem p02821 (python)

Fixed submission:
import numpy as np
 
N,M = map(int,input().split())
A = np.array(input().split(),np.int64)
 
A = np.sort(A)
S = np.zeros(N+1,np.int64)
S[1:]= np.cumsum(A)
 
hi = 200001
lo = -1
 
while hi-lo > 1:
    mid = (hi+lo)//2
    above_mid = (N-np.searchsorted(A,mid-A,side='left')).sum()
    if above_mid >= M:
        lo = mid
    else:
        hi = mid
 
X = np.searchsorted(A,hi-A,side='left')
 
above_hi = (N-X).sum()
happiness = (S[-1]-S[X]).sum()
happiness += (A*(N-X)).sum()
happiness += (M-above_hi)*lo
 
print(happiness)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N,M = map(int,input().split())
    a = sorted(list(map(int,input().split())))
    b = [0]+a
    a = np.array(a)
    cum = np.cumsum(b)
    
    def power(x,y):
        pos = np.searchsorted(a,x-y)
        count = np.sum(N-pos)
        if count >= M:
            return True
        else:
            return False
    
    l,r = 0,10**5+1
    while r-l > 1:
        mid = (l+r)//2
        if power(mid,a):
            l = mid
        else:
            r = mid

    def solve(x,y,minuse):
        ans = 0
        pos_rev = np.searchsorted(a,x-y)
        pos = N-pos_rev
        count = np.sum(pos)
        ans = np.sum(a*[pos]+cum[-1]-cum[-pos-1])
        return ans-minuse*(count-M)
        
    print(solve(l,a,l))

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

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    H = list(map(int,input().split()))

    if N == 1:
        print(0)
    else:
        ans_list = []
        count = 0
        for i in range(N-1):
            if H[i+1] <= H[i]:
                count += 1
            else:
                ans_list.append(count)
                count = 0
        ans_list.append(count)
        print(max(ans_list))

if __name__ == "__main__":
    main()

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

def main():
    N = int(input())
    H = list(map(int,input().split()))
    count = 0
    for i in range(N-1):
        if H[i+1] <= H[i]:
            count += 1
            ans = count
        else:
            count = 0
            ans = 0
        ans = max(ans,count)

    print(ans)

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

Fixed submission:
N,A,B = (int(x) for x in input().split())
if N * A < B:
  print( N * A )
else:
  print( B )

Buggy submission (verdict: Runtime Error):
N,D = map(int,input().split())

X = [list(map(int,input().split())) for _ in range(N)]

ans = 0
for i in range(N):
  for j in range(i):
    tmp = 0
    for k in range(D):
      tmp += (X[i][k] - X[j][k]) ** 2
    tmp = tmp ** 0.5
    if tmp % 1 == 0:
      ans += 1
      
print(ans)

Buggy submission (verdict: Runtime Error):
N,D = map(int,input().split())

X = [list(map(int,input().split())) for _ in range(N)]

ans = 0
for i in range(N):
  for j in range(i):
    tmp = 0
    for k in range(D):
      tmp += (X[i][k] - X[j][k]) ** 2
    tmp = tmp ** 0.5
    if tmp % 1 == 0:
      ans += 1
      
print(ans)
Problem p02985 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline
import copy
from collections import deque

def main():
    N,K = map(int,input().split())
    edge = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = map(int,input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
        
    go = [False for _ in range(N)]
    go[0] = True
    for num in edge[0]:
        go[num] = True
    MOD = 10**9+7
    fac = [0 for _ in range(K+1)]
    fac[0],fac[1] = 1,1
    inv = copy.deepcopy(fac)
    invfac = copy.deepcopy(fac)
    
    for i in range(2,K+1):
        fac[i] = (fac[i-1]*i)%MOD
        inv[i] = MOD-(MOD//i)*inv[MOD%i]%MOD
        invfac[i] = (invfac[i-1]*inv[i])%MOD
        
    def per(x,y):
        num = ((fac[x]*invfac[x-y])%MOD)
        return num

    if K-1 < len(edge[0]):
        print(0)
        exit()
    ans = K*(per(K-1,len(edge[0])))

    q = deque(edge[0])
    while q:
        now = q.popleft()
        use = 0
        for fol in edge[now]:
            if not go[fol]:
                use += 1
                go[fol] = True
                q.append(fol)
        if use > K-2:
            print(0)
            exit()
        num = per(K-2,use)
        ans *= num
        ans %= MOD
        
    print(ans%MOD)

if __name__ == "__main__":
    main()

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

def main():
    N,K = map(int,input().split())
    tree = [[] for _ in range(N)]
    INF = 10**9+7
    for _ in range(N-1):
        a,b = map(int,input().split())
        tree[a-1].append(b-1)
        tree[b-1].append(a-1)
        
    q = deque()
    go = [True for _ in range(N)]
    go[0] = False
    for i in tree[0]:
        go[i] = False
    ans = K*perm(K-1,len(tree[0]),exact = True)
    for i in tree[0]:
        q.append(i)
        while q:
            now = q.popleft()
            count = 0
            for fol in tree[now]:
                if go[fol]:
                    count += 1
                    q.append(fol)
                    go[fol] = False
            u = perm(K-2,count,exact = True)
            ans *= u
            ans %= INF
    
    print(ans)
    
if __name__ == "__main__":
    main()