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

Fixed submission:
def main():
    n, k, *h = map(int, open(0).read().split())
    dp = [float("inf")] * n
    dp[0] = 0
    for i in range(1, n):
        min_j = max(0, i-k)
        dp[i] = min([dp[j] + abs(h[i] - h[j]) for j in range(min_j, i)])
    print(dp[n-1])

main()

Buggy submission (verdict: Runtime Error):
 n, k, *hs = [int(x) for x in open(0).read().split()]            
 l = len(hs)                                                     
 delta = lambda a, b: abs(hs[a] - hs[b])                         
 dp = [0]                                                        
 for i in range(1, l):                                           
     cs = [dp[j] + delta(i, j) for j in range(max(0, i - k), i)] 
     v = min(cs)                                                 
     dp.append(v)                                                
 print(dp[-1])
Problem p02811 (python)

Fixed submission:
K, X = map(int, input().split())
print("Yes" if 500*K>=X else "No")

Buggy submission (verdict: Runtime Error):
K, X = map(int, input())
print("Yes" if 500*K>=X else "No")
Problem p03136 (python)

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
print("Yes" if max(L) < sum(L)-max(L) else "No")

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [int(input()) for i in range(N)]
print("Yes" if max(L) < sum(L)-max(L) else "No")
Problem p03337 (python)

Fixed submission:
A, B = map(int, input().split())
print(max(A+B, A-B, A*B))

Buggy submission (verdict: Runtime Error):
A, B = map(input().split())
print(max(A+B, A-B, A*B))
Problem p02898 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
  if(a[i]>=k):
    cnt+=1
    
print(cnt)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
  if(a[i]>=k):
    cnt+=1
    
print(cnt)
Problem p02614 (python)

Fixed submission:
h,w,k=map(int,input().split())
c=[input() for _ in range(h)]
count=0
for H in range(1<<h):
  for W in range(1<<w):
    b=0
    for i in range(h):
      for j in range(w):
        if (H >> i) & 1 == 0 and (W >> j) & 1 == 0 and c[i][j] == "#":
          b+=1
    if b==k:
      count+=1
print(count)

Buggy submission (verdict: Runtime Error):
h,w,k=map(int,input().split())
c=[input() for _ in range(h)]
count=0
for H in range(h<<1):
  for W in range(W<<1):
    b=0
    for i in range(h):
      for j in range(w):
        if (H >> i) & 1 == 0 and (W >> j) & 1 == 0 and c[i][j] == "#":
          b+=1
    if b==k:
      count+=1
print(count)

Buggy submission (verdict: Runtime Error):
h,w,k=map(int,input().split())
c=[input() for _ in range(h)]
count=0
for H in range(h<<1):
  for W in range(W<<1):
    b=0
    for i in range(h):
      for j in range(w):
        if (W >> i) & 1 == 0 and (H >> j) & 1 == 0 and c[i][j] == "#":
          b+=1
    if b==k:
      count+=1
print(count)
Problem p02657 (python)

Fixed submission:

a,b=map(int,input().split())
print(a*b)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split()))
print(a*b)
Problem p02658 (python)

Fixed submission:
import functools
import operator

n=int(input())
a=list(map(int,input().split()))
b=0
r=1
if min(a)==0:
  print(0)
  exit()
for i in a:
  r*=i
  if r>10**18:
    print(-1)
    exit()
print(r)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=eval(input().replace(" ","*"))
if a>10**18:
  print(-1)
else:
  print(a)
Problem p02678 (python)

Fixed submission:
from collections import deque
n,m=map(int,input().split())
adj=[[] for _ in range(n)]
for _ in range(m):
  a,b =map(int,input().split())
  a-=1
  b-=1
  adj[a].append(b)
  adj[b].append(a)
ans=[0]*n
que=deque([])
que.append(0)
while que:
  e=que.popleft()
  for i in adj[e]:
    if ans[i]!=0:
      continue
    ans[i]=e+1
    que.append(i)
print("Yes")
for i in range(1,n):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m=map(int,input().split())
adj=[[] for _ in range(n)]
for _ in range(m):
  a,b =map(int,input().split())
  a-=1
  b-=1
  adj[a].append(b)
  adj[b].append(a)
ans=[0]*n
que=deque([])
que.append(0)
while que:
  e=que.popleft
  for i in adj[e]:
    if ans[i]!=0:
      continue
    ans[i]=e+1
    que.append(i)
print("Yes")
for i in range(1,n):
  print(ans[i])
Problem p02684 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
adj=[1]*n
b=[1]
now=0
while adj[now]:
  adj[now]=0
  now=a[now]-1
  b.append(now+1)
loop_start=b.index(b[-1])
loop=b[loop_start:-1]
p=len(loop)
if k<loop_start:
  print(b[k])
else:
  k-=loop_start
  k%=p
  print(loop[k])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
adj=[1]*n
b=[1]
now=0
while adj[now]:
  adj[now]=0
  now=a[now]-1
  c.append(now+1)
loop_start=c.index(c[-1])
loop=c[loop_start:-1]
p=len(loop)
if k<loop_start:
  print(c[k])
else:
  k-=loop_start
  k%=p
  print(loop[k])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
ans=0
for i in range(k):
  ans=a[ans]-1
  if ans in b:
    d=len(b)-b.index(ans)
    e=b.index(ans)
    break
  else: b.append(ans)

f=(k-e)%d

print(b[e+f])
Problem p02690 (python)

Fixed submission:
x=int(input())
for i in range(-200,200):
  for j in range(-200,200):
    if i**5-j**5==x:
      print(i,j)
      exit()

Buggy submission (verdict: Runtime Error):
x=int(input())
for i in range(-200,200):
  for j in range(-200,200):
    if i**5-j**5==x:
      prtin(i,j)
      exit()

Buggy submission (verdict: Runtime Error):
x=int(input())
for i in range(-200,200):
  for j in range(-200,200):
    if i**5-j**5==x
    prtin(i,j)
    exit()

Buggy submission (verdict: Runtime Error):
x=int(input())
for i in range(-200,200):
  for j in range(-200,200):
    if i**5-j**5==x
    prtin(i,j)
    exit()
Problem p02830 (python)

Fixed submission:
n=int(input())
s,t=input().split()

print(*[i+j for i,j in zip(s,t)],sep="")

Buggy submission (verdict: Runtime Error):
n=int(input())
s,t=input()split()

print(*[s+t for i in zip(s,t)],sep="")
Problem p02861 (python)

Fixed submission:
import itertools
n=int(input())
a=[]
for i in range(n):
  x,y=map(int,input().split())
  a.append((x,y))
num=0
count=0
for i in itertools.permutations(range(n),n):
  s=list(i)
  num+=1
  for j in range(n-1):
    count+=((a[s[j+1]][0]-a[s[j]][0])**2+(a[s[j+1]][1]-a[s[j]][1])**2)**(0.5)
print(count/num)

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
xy=np.array([list(map(int,input().split())) for i in range(N)])
print(sum(np.linalg.norm(i-j) for i in xy for j in xy)/N)
Problem p02923 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
  if h[i-1]>=h[i]:
    dp[i]=dp[i-1]+1
print(max(dp))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=[map(int,input().split())]
dp=[0]*n
for i in range(1,n):
  if h[i-1]>=h[i]:
    dp[i]=dp[i-1]+1
print(max(dp))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=[map(int,input().split())]
dp=[0]*(n+1)
count=0
for i in range(1,n+1):
  if h[i-1]>=h[i]:
    dp[i]=dp[i-1]+1
print(max(dp))
Problem p02947 (python)

Fixed submission:
N=int(input())
dictionary={}
count=0
for i in range(N):
    s=tuple(sorted(input()))
    if s in dictionary:
        dictionary[s]+=1
        count+=dictionary[s]
    else:
        dictionary[s]=0
print(count)

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
ans=0
s=["".join(sorted(input())) for _ in range(n)]
c=collections.Counter(s)
for i in set(s):
  a=c[s]
  ans+=a*(a-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
inport collections
n=int(input())
ans=0
s=["".join(sorted(input())) for _ in range(n)]
c=collections.Counter(s)
for i in set(s):
  a=c[s]
  ans+=a*(a-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(intput())
di={}
count=0
for i in range(n):
  s=str(sorted(input()))
  if s in di:
    di[s]+=1
    count+=di[s]
  else:
    di[s]=0
print(count)

Buggy submission (verdict: Runtime Error):
n=int(intput())
di={}
count=0
for i in range():
  s=str(sorted(input()))
  if s in di:
    di[s]+=1
    count+=di[s]
  else:
    di[s]=0
print(count)
Problem p02953 (python)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
base=0
for h in H:
    if base>h:
        print("No")
        break
    base=max(base,h-1)
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
s=int(input())
ans=0
for i in range(len(s)-1):
  if not s[i]-1<=s[i+1]:
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s=str(input())
ans=0
for i in range(len(s)-1):
  if not s[i]-1<=s[i+1]:
    print("No")
    exit()
print("Yes")
Problem p03030 (python)

Fixed submission:
n=int(input())
sp=[]
for i in range(n):
  s,p=input().split()
  p=int(p)
  sp.append([s,p,i+1])

sp.sort(key=lambda sp:(sp[0],-sp[1]))
for i in sp:
  print(i[2])

Buggy submission (verdict: Runtime Error):
n=int(input())
sp=[]
for i in range(n):
  s,p=input().split()
  p=int(p)
  sp.append([s,p,i+1])

sp.sort(key=lambda sp:(sp[0],-sp[1])
for i in sp:
  print(i[2])

Buggy submission (verdict: Runtime Error):
n=int(input())
sp=[]
for i in range(n):
  s,p=input().split()
  p=int(p)
  sp.append([s,p,i+1])

sp.sort(key=lambda sp:(sp[0],-sp[1])
for n in sp:
  print(i[2])
Problem p03031 (python)

Fixed submission:
N,M=map(int,input().split())
s=[list(map(int,input().split()))[1:] for m in range(M)]
p=list(map(int,input().split()))
count=0
for i in range(1<<N):
    for m in range(M):
        switch=0
        for j in range(N):
            if (i>>j)&1 and j+1 in s[m]:
                switch+=1
        if switch%2!=p[m]:
            break
    else:
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
S=[]
for m in range(m):
  s=list(map(int,input().split()))
  S.sppend(s[1:])
p=list(map(int,input().split()))

ans=0
for i in range(1<<n):
  for k in range(m):
    sw=0
    for j in range(n):
      if (i>>j)&1==0 and j+1 in S[k]:
        sw+=1
    if se%2!=p[k]:
      break
  else:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
S=[]
for m in range(m):
  s=list(map(int,input().split()))
  S.sppend(s[1:])
p=list(map(int,input().split()))

ans=0
for i in range(1<<n):
  for k in range(m):
    sw=0
    for j in range(n):
      if (i>>j)&1==0 and j+1 in s[k]:
        sw+=1
    if se%2!=p[k]:
      break
  else:
    ans+=1
print(ans)

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

K=[list(map(int,input().split())) for _ in range(m)]
p=list(int,input().split())
ans=0
for i in range(1<<n):
  for k in range(m):
    on=0
    for j in range(n):
      if (i&(1<<j)) and j in K[k]:
        on+=1
    if on%2!=p[r]:
      break
  ans+=1
print(ans)
Problem p03068 (python)

Fixed submission:
n=int(input())
s=input()
k=int(input())
a=[]
for i in range(n):
  if s[i]!=s[k-1]:
    print("*",end="")
  else: print(s[i],end="")

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
k=int(input)
for i in range(n):
  if s[i]!=s[k-1]:
    s[i]="*"
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
k=int(input)
for i in range(n):
  if s[i]!=s[k-1]:
    s[i]=*
print(s)
Problem p03126 (python)

Fixed submission:
n,m=map(int,input().split())
a=[0]*m
b=[list(map(int,input().split())) for _ in range(n) ]
      
for i in range(n):
  c=b[i][0]
  for j in range(1,c+1):
    a[b[i][j]-1]+=1

print(a.count(n))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0]*m
b=[list(map(int,input().split())) for _ in range(n) ]
      
for i in range(n):
  c=b[i][0]
  for j in range(1,c):
    a[b[i][j]]+=1
ans=0
for i in range(m):
  if a[i]==n:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0]*m
b=[list(map(int,input().split())) for _ in range(n) ]
      
for i in range(n):
  c=b[i][0]
  for j in range(c):
    a[b[i][j]]+=1
ans=0
for i in range(m):
  if a[i]==n:
    ans+=1
print(ans)
Problem p03244 (python)

Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0]!=b[0][0]:
    print(n-(a[0][1]+b[0][1]))
else:
    print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1])))

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()

if a[0][0]!=b[0][0]:
    print(n-(a[0][1]+b[0][1]))
else:
    print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1])))
Problem p03281 (python)

Fixed submission:
N=int(input())
count=0
for i in range(105,N+1,2):
    divisor=0
    for j in range(1,i+1):
        if(i%j==0):divisor+=1
    if(divisor==8):count+=1
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
count=0
for i in range(105,N+1,2):
    divisor=0
    for j in range(1,i+1):
        if　i%j==0:
          divisor+=1
    if　divisor==8:
      count+=1
print(count)
Problem p03338 (python)

Fixed submission:
n=int(input())
s=input()
print(max(len(set(s[:i])&set(s[i:])) for i in range(n)))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
ams=0
for i in range(1,n):
  a=set(s[:i])
  b=set(s[i:])
  ans=max(ans,len(a&b))

print(ans)
Problem p03378 (python)

Fixed submission:
n,m,x=map(int,input().split())
s=sum(int(i)<x for i in input().split())
print(min(s,m-s))

Buggy submission (verdict: Runtime Error):
n,m,x=map(int,input().split())
a=sum(int(i)<x for i in input().split())
print(min(s,m-s))
Problem p03408 (python)

Fixed submission:
s=[input()for _ in range(int(input()))]
t=[input()for _ in range(int(input()))]
a=list(set(s))
print(max(0,max(s.count(a[i])-t.count(a[i]) for i in range(len(a)))))

Buggy submission (verdict: Runtime Error):
s=[input()for _ in range(int(input()))]
t=[input()for _ in range(int(input()))]
a=set(s)
print(max(0,max(s.count(a[i])-t.count(a[i]) for i in range(len(a)))))

Buggy submission (verdict: Runtime Error):
s=[int(input())for _ in range(int(input()))]
t=[int(input())for _ in range(int(input()))]
a=list(set(s))
print(max(0,max(s.count(a[i])-t.count(a[i]) for i in range(len(a)))))

Buggy submission (verdict: Runtime Error):
s=[int(input())for _ in range(int(input()))]
t=[int(input())for _ in range(int(input()))]
a=set(s)
print(max(0,max(s.count(a[i])-t.count(a[i]) for i in range(len(a)))))
Problem p03424 (python)

Fixed submission:
input()
print("Four" if "Y" in input() else "Three")

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[map(str,input().split())]
print("Four" if "Y" in s: else: "Three")
Problem p03486 (python)

Fixed submission:
s=sorted(input())
t=sorted(input(),reverse=True)
if s<t:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s=sorter(input())
t=sorted(input(),reverse=True)
if s<t:
  print("Yes")
else:
  print("No")
Problem p03494 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
count=0
while True:
  for i in range(n):
    if a[i]%2!=0:
      print(count)
      exit()
    else:
      a[i]//=2
  count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
n=list(map(int,input().split()))
count=0
while True:
  for i in range(n):
    if n[i]%2!=0:
      print(count)
      exit()
    n[i]//2
  count+=1
print(count)
Problem p03545 (python)

Fixed submission:
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            # 答えは1つ出力すれば良いので =7 になれば終了
            print(f + "=7")
            exit()

    else:
        # 式 f の末尾に符号と次の数字を追加し、その分 sum に加減する
        dfs(i + 1, f + "-" + s[i + 1], sum - int(s[i + 1]))
        dfs(i + 1, f + "+" + s[i + 1], sum + int(s[i + 1]))


s = input()

dfs(0, s[0], int(s[0]))

Buggy submission (verdict: Runtime Error):
s= input()
def dfs(i,f,sum):
    if i==3:
        if sum ==7:
            print(f+'=7')
            exit()
    else:
        dfs(i+1,f+"-"+s[i+1],sum-int(s[i+1]))
        dfs(i+1,f+"+"+s[i+1],sum+int(s[i+1]))
dfs(0,s[0],int(s[0])
Problem p03636 (python)

Fixed submission:
a,*b,c=input()
print(a+str(len(b))+c)

Buggy submission (verdict: Runtime Error):
a,*b,c=input()
print(a+Str(len(b))+c)

Buggy submission (verdict: Runtime Error):
a,*b,c=input()
print(a+len(b)+c)
Problem p03645 (python)

Fixed submission:
n,m=map(int,input().split())
sa=set()
sb=set()
for _ in range(m):
  a,b=map(int,input().split())
  if a==1:
    sa.add(b)
  if b==n:
    sb.add(a)
print("IMPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
sa={}
sb={}
for _ in range(m):
  a,b=map(int,input().split())
  if a==1:
    sa.add(b)
  if b==n:
    ab.add(a)
print("INPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE")
Problem p03672 (python)

Fixed submission:
s=input()
n=len(s)//2
n-=1
while n!=0:
  if s[:n]==s[n:2*n]:
    print(2*n)
    break
  n-=1

Buggy submission (verdict: Runtime Error):
s=int(input())
n=len(s)//2
while n!=0:
  
  if s[:n]==s[n:2*n]:
    print(n)
    break
  n=-1
Problem p03998 (python)

Fixed submission:
S={c:list(input()) for c in "abc"}
s="a"
while S[s]:s=S[s].pop(0)
print(s.upper())

Buggy submission (verdict: Runtime Error):
a=list(input())
b=list(input())
c=list(input())
S=[a,b,c]
s=a
while True:
  s=S[s].pop()
print(s.upper())
Problem p04001 (python)

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

for i in range(1<<(n-1)):
  f=s[0]
  for j in range(n-1):
    if i&(1<<j):
      f += "+"
    f+= s[j+1]
  ans += sum(map(int, f.split("+")))
  
print(ans)

Buggy submission (verdict: Runtime Error):
def dfs(i,f):
  if i == n-1:
    return sum(list(map(int,f.split("+"))))
  return dfs(i+1,f+s[i+1])+\dfs(i+1,f+"+"+s[i+1])
  
s= input()
n=len(s)
print(dfs(0,s[0]))
Problem p02534 (python)

Fixed submission:
k = int(input())

print (k*str("ACL"))

Buggy submission (verdict: Runtime Error):
k = int(raw_input())

print (k*str("ACL"))
Problem p02534 (python)

Fixed submission:
print("ACL"*int(input()))

Buggy submission (verdict: Runtime Error):
print("ACL"*int(inout()))
Problem p02607 (python)

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

ans = 0
for i in range(N):
  if i % 2 == 0 and A[i]%2 == 1:
    ans += 1
print(ans)

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

ans = 0
for i in range(N):
  if i % 2 == 0 AND A[i]%2 == 1:
    ans += 1
print(ans)
Problem p02678 (python)

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

AB = [tuple(map(int,input().split())) for i in range(M)]

es = [[] for _ in range(N)]
for a, b in AB:
    es[a-1].append(b-1)
    es[b-1].append(a-1)

ans = [-1] * N
ans[0] = 0

import queue
que = queue.Queue()
que.put(0)

while que.qsize():
    s = que.get()
    for v in es[s]:
        if ans[v] == -1:
            ans[v] = s+1
            que.put(v)

print("Yes")
print(*ans[1:], sep="\n")

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

AB = [tuple(map(int,input().split())) for i in range(M)]

es = [[] for _ in range(N)]
for a, b in AB:
    es[a-1].append(b-1)
    es[b-1].append(a-1)

ans = [-1] * N
ans[0] = 0

from collections import deque
que = deque
que.insert(0)

while que:
    s = que.popleft()
    for v in es[s]:
        if ans[v] == -1:
            ans[v] = s+1
            que.put(v)

print("Yes")
print(*ans[1:], sep="\n")
Problem p02985 (python)

Fixed submission:
import sys
sys.setrecursionlimit(500000)

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

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

ans = 1
def dfs(i, bb, b, p):
    global ans
    ans = (ans*(K-bb-b))%(10**9+7)
    cnt = 0
    for j in T[i]:
        if j == p:
            continue
        dfs(j, b + cnt, 1, i)
        cnt += 1

dfs(0, 0, 0, -1)
print(ans)

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

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

ans = 1
def dfs(i, bb, b, p):
    global ans
    ans = (ans*(K-bb-b))%(10**9+7)
    cnt = 0
    for j in T[i]:
        if j == p:
            continue
        bfs(j, b + cnt, 1, i)
        cnt += 1

dfs(0, 0, 0, -1)
print(ans)

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

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

ans = 1
def dfs(i, bb, b, p):
    global ans
    ans = (ans*(K-bb-b))%(10**9+7)
    cnt = 0
    for j in T[i]:
        if j == p:
            continue
        bfs(j, b + cnt, 1, i)
        cnt += 1

dfs(0, 0, 0, -1)
print(ans)

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

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

ans = 1
def bfs(i, bb, b, p):
    global ans
    ans = (ans*(K-bb-b))%(10**9+7)
    cnt = 0
    for j in T[i]:
        if j == p:
            continue
        bfs(j, b + cnt, 1, i)
        cnt += 1

bfs(0, 0, 0, -1)
print(ans)
Problem p03449 (python)

Fixed submission:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
A1 = LI()
A2 = LI()
ans = 0
for i in range(N):
    tmp = sum(A1[0:i+1]) + sum(A2[i:])
    ans = max(ans, tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
A1 = LI()
A2 = LI()
ans = 0
for i in range(N):
    tmp = sum(A1[0:i+1]) + sum(A2[i:])
    ans = max(ans, tmp)
print(ans)
Problem p03494 (python)

Fixed submission:
N = int(input())
li = list(map(int, input().split()))
ans = float('inf')
for i in li:
    cnt = 0
    if i%2==0:
        tudukeru = True
    else:
        tudukeru = False
        ans = 0
    while tudukeru:
        if i%2 == 0:
            i = i//2
            cnt += 1
        else:
            tudukeru = False
            if cnt < ans:
                ans = cnt
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
li = list(map(int, input().split()))
ans = math.inf
for i in li:
    cnt = 0
    if i%2==0:
        tudukeru = True
    else:
        tudukeru = False
        ans = 0
    while tudukeru:
        if i%2 == 0:
            i = i//2
            cnt += 1
        else:
            tudukeru = False
            if cnt < ans:
                ans = cnt
print(ans)
Problem p03760 (python)

Fixed submission:
o = input()
e = input()
ans_l = [0] * (len(o) + len(e))
for i in range(len(o)):
    ans_l[i*2] = o[i]
for j in range(len(e)):
    ans_l[j*2+1] = e[j]
print(''.join(ans_l))

Buggy submission (verdict: Runtime Error):
o = input()
e = input()
ans_l = [0] * (len(o) + len(e))
for i in range(len(o)):
    ans_l[i*2] = o[i]
for j in range(len(e)):
    ans_l[j*2+1] = e[i]
print(''.join(ans_l))