Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a==0:
    print(b)
elif b==1:
    print(b)
else:
    print(b)


Fixed submission:
a = input()
a = str(a)
b = 0
for i in range(len(a)):
    if a[i]=="2":
        b=b+1
    else:
        b=b
print(b)

Buggy python submission (verdict: Runtime Error):
a = str(input())
b = 0
for i in range(4):
if a[i]==2:
b=b+1
else:
b=b

print(b)


Fixed submission:
a = input()
a = str(a)
b = 0
for i in range(len(a)):
    if a[i]=="2":
        b=b+1
    else:
        b=b
print(b)

Buggy python submission (verdict: Runtime Error):
a = input()
b = 0
for i in range(len(a)):
if a[i]==2:
b=b+1
else:
b=b
print(b)


Fixed submission:
a = input()
a = str(a)
b = 0
for i in range(len(a)):
    if a[i]=="2":
        b=b+1
    else:
        b=b
print(b)

Buggy python submission (verdict: Runtime Error):
a = input()
b = 0
for i in range(len(a)):
if a[i]==2:
b=b+1
print(b)


Fixed submission:
a = input()
a = str(a)
b = 0
for i in range(len(a)):
    if a[i]=="2":
        b=b+1
    else:
        b=b
print(b)

Buggy python submission (verdict: Runtime Error):
a = input()
b = 0
for i in range(len(a)):



Fixed submission:
a = input()
a = str(a)
b = 0
for i in range(len(a)):
    if a[i]=="2":
        b=b+1
    else:
        b=b
print(b)
Buggy python submission (verdict: Runtime Error):
D = int(input())

if D ==25:
  print("Christmas")
elif D ==24:
  print("Christmas Eve")
elif D ==23:
  print("Christmas Eve Eve")
else D ==22:
  print("Christmas Eve Eve Eve")

Fixed submission:
D = int(input())

if D == 25:
  print("Christmas")
elif D == 24:
  print("Christmas Eve")
elif D == 23:
  print("Christmas Eve Eve")
else:
  print("Christmas Eve Eve Eve")

Buggy python submission (verdict: Runtime Error):
D = int(input())

if D==25:
  print("Christmas")
  elif D==24:
    print("Christmas Eve")
    elif D==23:
      print("Christmas Eve Eve")
      else D==22:
        print("Christmas Eve Eve Eve")

Fixed submission:
D = int(input())

if D == 25:
  print("Christmas")
elif D == 24:
  print("Christmas Eve")
elif D == 23:
  print("Christmas Eve Eve")
else:
  print("Christmas Eve Eve Eve")
Buggy python submission (verdict: Runtime Error):
a =int(input())
m =0
for i in range(N):
  p=int(input())
  m=max(m,p)
a=int(sum(p)-m/2)
print(a)

Fixed submission:
N = int(input())
sm,mx = 0,0
for i in range(N):
  P = int(input())
  sm += P
  mx = max(mx, P)

a = int(sm - mx / 2)
print(a)

Buggy python submission (verdict: Runtime Error):
N = int(input())
p = []
for i in range(N):
  p.append(int(input()))
  
print(int(sum(p)-max(p)/2)


Fixed submission:
N = int(input())
sm,mx = 0,0
for i in range(N):
  P = int(input())
  sm += P
  mx = max(mx, P)

a = int(sm - mx / 2)
print(a)

Buggy python submission (verdict: Runtime Error):
N = int(input())
for i in range(N):
  p =int(input())
  
print(int(sum(p)-max(p)/2)

Fixed submission:
N = int(input())
sm,mx = 0,0
for i in range(N):
  P = int(input())
  sm += P
  mx = max(mx, P)

a = int(sm - mx / 2)
print(a)

Buggy python submission (verdict: Runtime Error):
N = int(input()), sum = 0, mx = 0
for i in range(N):
  P = int(input())
  sum += P
  mx = max(mx, P)

print(sum - mx / 2)


Fixed submission:
N = int(input())
sm,mx = 0,0
for i in range(N):
  P = int(input())
  sm += P
  mx = max(mx, P)

a = int(sm - mx / 2)
print(a)

Buggy python submission (verdict: Runtime Error):
N = int(input()), sum = 0, mx = 0
for i in range(n):
  P = int(input())
  sum += P
  mx = max(mx, P)

print(sum - mx / 2)

Fixed submission:
N = int(input())
sm,mx = 0,0
for i in range(N):
  P = int(input())
  sm += P
  mx = max(mx, P)

a = int(sm - mx / 2)
print(a)
Buggy python submission (verdict: Runtime Error):
X = int(input())
Y = int(input())
a = int(X + Y/2)
print(a)

Fixed submission:
X,Y = map(int,input().split())
a = int(X + Y/2)
print(a)
Buggy python submission (verdict: Runtime Error):
n=int(inut())
t,a=map(int,input().split())
l=list(map(int,input().split()))
for i in range(n):
    l[i]=abs(a-(t-l[i]*0.006))
print(l.index(min(l))+1)

Fixed submission:
n=int(input())
t,a=map(int,input().split())
l=list(map(int,input().split()))
for i in range(n):
    l[i]=abs(a-(t-l[i]*0.006))
print(l.index(min(l))+1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A,B = map(int,input().split())
if N % 2 == 0:
  print(A+B)
else:
  print("Hello World")

Fixed submission:
a = int(input())
if a==1:
  print("Hello World")
else:
  A = int(input())
  B = int(input())
  print(A+B)
Buggy python submission (verdict: Runtime Error):
n,t=map(int,input().split())
l=[]
for i in range(n):
    c,time=map(int,input().split())
    if time>=t:
        l.append(c)
print(min(l))

Fixed submission:
n,t=map(int,input().split())
l=[]
for i in range(n):
    c,time=map(int,input().split())
    if time<=t:
        l.append(c)
print(min(l) if l!=[] else "TLE")
Buggy python submission (verdict: Runtime Error):
n = input()
if n[0]=1:
  n[0]=9
else:
  n[0]=1
if n[1]=1:
  n[1]=9
else:
  n[1]=1
if n[2]=1:
  n[2]=9
else:
  n[2]=1

print(n)

Fixed submission:
n = input()
a = ""
for i in range(len(n)):
  if n[i]=="1":
    a +="9"
  else:
    a +="1"
print(a)
Buggy python submission (verdict: Runtime Error):
import sys
n=input()
w=input()
l=[]
l.append(w)
for i in range(1,n):
    w=input()
    if w[0]!=l[-1][-1] or w in l:
        print("No")
        sys.exit()
    else:
        l.append(w)
print("Yes")

Fixed submission:
import sys
n=int(input())
w=input()
l=[]
l.append(w)
for i in range(1,n):
    w=input()
    if w[0]!=l[-1][-1] or w in l:
        print("No")
        sys.exit()
    else:
        l.append(w)
print("Yes")
Buggy python submission (verdict: Runtime Error):
k=int(input())
print(k//2*//2 if k%2==0 else k//2*(k+1)//2)

Fixed submission:
k=int(input())
print((k//2)**2 if k%2==0 else(k//2)*(k+1)//2)
Buggy python submission (verdict: Runtime Error):
n,i=map(int,input())
print(n+1-i)

Fixed submission:
n,i=map(int,input().split())
print(n+1-i)
Buggy python submission (verdict: Runtime Error):
s=input()
input()
if s.count("1")==len(s):
    print(1)
else:
    i=0
    while s[i]!="1":
        i+=1
    print(s[i])

Fixed submission:
s=input()
k=int(input())-1
if s.count("1")==len(s):
    t=k
    print(1)
else:
    i=0
    while s[i]=="1":
        i+=1
    if k<i:
        print(1)
    else:
        print(s[i])

Buggy python submission (verdict: Runtime Error):
s=input()
if s.count("1")==len(s):
    print(1)
else:
    i=0
    while s[i]!="1":
        i+=1
    print(s[i])

Fixed submission:
s=input()
k=int(input())-1
if s.count("1")==len(s):
    t=k
    print(1)
else:
    i=0
    while s[i]=="1":
        i+=1
    if k<i:
        print(1)
    else:
        print(s[i])

Buggy python submission (verdict: Runtime Error):
s=input()
input()
i=0
while s[i]=="1":
    i+=1
    if i==len(s)-1:
        break
print(s[i])

Fixed submission:
s=input()
k=int(input())-1
if s.count("1")==len(s):
    t=k
    print(1)
else:
    i=0
    while s[i]=="1":
        i+=1
    if k<i:
        print(1)
    else:
        print(s[i])

Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
i=0
while s[i]=="1":
    i+=1
print(s[i])

Fixed submission:
s=input()
k=int(input())-1
if s.count("1")==len(s):
    t=k
    print(1)
else:
    i=0
    while s[i]=="1":
        i+=1
    if k<i:
        print(1)
    else:
        print(s[i])
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input(),split())
if a<=8 and b<=8:
  print("Yay!")
else:
  print(":(")

Fixed submission:
a,b=map(int,input().split())
if a<=8 and b<=8:
  print("Yay!")
else:
  print(":(")

Buggy python submission (verdict: Runtime Error):
a,b =map(int,input(),split())
if a<=8 or b<=8:
  print("Yay!")
else:
  print(":(")



Fixed submission:
a,b=map(int,input().split())
if a<=8 and b<=8:
  print("Yay!")
else:
  print(":(")

Buggy python submission (verdict: Runtime Error):
a,b =int(input(),split())
if a<=8 or b<=8:
  print("Yay!")
else:
  print(":(")



Fixed submission:
a,b=map(int,input().split())
if a<=8 and b<=8:
  print("Yay!")
else:
  print(":(")
Buggy python submission (verdict: Runtime Error):
n=int(input())
p=n//2
l=list(map(int,input().split()))
for i in range(n):
    m=l
    m.pop(i)
    m.sort()
    print(m[p-1])

Fixed submission:
n=int(input())
x=list(map(int,input().split()))
l=sorted(x)
m1=l[n//2-1]
m2=l[n//2]
for i in range(n):
    if x[i]<=m1:
        print(m2)
    else:
        print(m1)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=n//2
l=list(map(int,input().split()))
for i in range(n):
    m=l[:i]+l[i+1:]
    m.sort()
    print(m[p-1])

Fixed submission:
n=int(input())
x=list(map(int,input().split()))
l=sorted(x)
m1=l[n//2-1]
m2=l[n//2]
for i in range(n):
    if x[i]<=m1:
        print(m2)
    else:
        print(m1)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(str,input().split())
d,e,f=map(str,input().split())
if (a==f and b==e and c==d):
    print("YES")
else:
    print("NO")

Fixed submission:
a = input()
b = input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
if a[0]=b[2] and a[1]=b[1] and a[2]=b[0]:
  print("YES")
else:
  print("NO")

Fixed submission:
a = input()
b = input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left,bisect_right
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
    for j in range(n):
        if a[i]>=b[j]:
            continue
        else:
            ans+=n-bisect_left(c,b[j]+1)
print(ans)


Fixed submission:
from bisect import bisect_left,bisect_right
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
    A=bisect_left(a,b[i])
    C=n-bisect_right(c,b[i])
    ans+=A*C
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left,bisect_right
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for A in a:
    indexB=bisect_left(b,A+1)
    for B in b[indexB:]:
        indexC=bisect_left(c,B+1)
        for C in c[indexC:]:
            ans+=1
print(ans)


Fixed submission:
from bisect import bisect_left,bisect_right
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
    A=bisect_left(a,b[i])
    C=n-bisect_right(c,b[i])
    ans+=A*C
print(ans)
Buggy python submission (verdict: Runtime Error):
n,t=map(int,input().split())
l=list(map(int,input().split()))
time=t
m=[0]
i=1
if len(l)==1:
    print(t)
else:
    while True:
        if l[i]-(time-m[-1])<0:
            time=time-(l[i]-(time-m[1]))+t
        else:
            m.append(time)
            time=t
        if i==n-1:
            break
        i+=1
    print(time if len(m)==1 else sum(m)+time)

Fixed submission:
n,t=map(int,input().split())
l=list(map(int,input().split()))
ans=0
for i in range(1,n):
    ans+=min(t,l[i]-l[i-1])
print(ans+t)
Buggy python submission (verdict: Runtime Error):
x=input()
ans=len(x)
r=len(x)
if "ST" in x:
    x.remove("ST")
    ans-=2
while r!=len(x):
    r=len(x)
    if "ST" in x:
        x.remove("ST")
        ans-=2
print(ans)

Fixed submission:
x=input()
l=[x[0]]
for i in range(1,len(x)):
    if l!=[]:
        if l[-1]=="S":
            h=1
        else:
            h=0
    l.append(x[i])
    if len(l)!=1:
        if l[-1]=="T":
            if h==1:
                l.pop(-1)
                l.pop(-1)
                if l!=[]:
                    h=(0 if l[-1]=="T" else 1)
                else:
                    h=0
            else:
                h=0
        else:
            h=0
print(len(l))
Buggy python submission (verdict: Runtime Error):
l=[]
for i in range(3):
    l.append(input())
turn=0
next_turn=0
while True:
    s=l[turn][0]
    l[turn]=l[turn][1:]
    if s=="a":
        turn=0
    elif s=="b":
        turn=1
    else:
        turn=2
    if l[0]=="":
        print("A")
        break
    elif l[1]=="":
        print("B")
    elif l[2]=="":
        print("C")

Fixed submission:
import sys
a=input()
b=input()
c=input()
turn=0
ap=0
bp=0
cp=0
while True:
    if turn==0:
        ap+=1
        if ap==len(a)+1:
            print("A")
            sys.exit()
        if a[ap-1]=="a":
            turn=0
        elif a[ap-1]=="b":
            turn=1
        else:
            turn=2
    if turn==1:
        bp+=1
        if bp==len(b)+1:
            print("B")
            sys.exit()
        if b[bp-1]=="a":
            turn=0
        elif b[bp-1]=="b":
            turn=1
        else:
            turn=2
    if turn==2:
        cp+=1
        if cp==len(c)+1:
            print("C")
            sys.exit()
        if c[cp-1]=="a":
            turn=0
        elif c[cp-1]=="b":
            turn=1
        else:
            turn=2
Buggy python submission (verdict: Runtime Error):
s=input()s=input()
if "N" in s and "S" in s and "W" in s and "E" in s:
    print("Yes")
elif "N" in s and "S" in s:
    print("Yes" if "W" in s or "E" in s else "No")
else:
    print("Yes" if "N" in s or "S" in s else "No")

Fixed submission:
s=input()
if "N" in s and "S" in s and "W" in s and "E" in s:
    print("Yes")
elif "N" in s and "S" in s:
    print("No" if "W" in s or "E" in s else "Yes")
elif "W" in s and "E" in s:
    print("No" if "N" in s or "S" in s else "Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
s=input()
ans=[]
for c in s:
    if c=="0" or c=="1":
        ans.append(c)
    else:
        ans.pop(-1)
print("".join(ans))s=input()
ans=[]
for c in s:
    if c=="0" or c=="1":
        ans.append(c)
    else:
        if len(ans)>0:
            ans.pop(-1)
print("".join(ans))

Fixed submission:
s=""
for c in input():
    s=s[:-1] if c=="B" else s+c
print(s)

Buggy python submission (verdict: Runtime Error):
s=input()
ans=[]
for c in s:
    if c=="0" or c=="1":
        ans.append(c)
    else:
        ans.pop(-1)
print("".join(ans))

Fixed submission:
s=""
for c in input():
    s=s[:-1] if c=="B" else s+c
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split())
ans=1
for i in range(a,b+1):
    ans*=i
if ans==0:
    print("Zero")
else:
    print("Positive" if ans>0 else "Negative")

Fixed submission:
a,b=map(int,input().split())
if a<=0 and b>=0:
    print("Zero")
elif a<0 and b<0:
    print("Negative" if (a-b-1)%2==1 else "Positive")
else:
    print("Positive")
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(0,n/2,2):
    ans+=l[i]
print(ans)n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range([0,]n[,2]):
    ans+=l[i]
print(ans)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
i=0
while i<n*2-1:
    ans+=l[i]
    i+=2
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(0,n/2,2):
    ans+=l[i]
print(ans)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
i=0
while i<n*2-1:
    ans+=l[i]
    i+=2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n=int(input())
X=[]
Y=[]
P=np.ndarray((0,2))
for i in range(n):
    x,y = map(int,input().split())
    X.append(x)
    Y.append(Y)
    P=np.vstack((P,[x+y,x-y]))
    
ans = max(max(P[:,0])-min(P[:,0]),max(P[:,1])-min(P[:,1]))

print(int(ans+0.5))

Fixed submission:
n=int(input())
X=[]
Y=[]
#P=np.ndarray((0,2))
for i in range(n):
    x,y = map(int,input().split())
    X.append(x+y)
    Y.append(x-y)

    
ans = max(max(X)-min(X),max(Y)-min(Y))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n=int(input())

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

ans=0

for i in range(n-1):
    for j in range(i+1,n):
        
        ans += (A[i] * A[j]) % (10**9+7)

print(ans % (10**9+7))


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

n=int(input())

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

B=[A[0]]

for i in range(len(A)-1):
    B.append((B[i]+A[i+1]) % (10**9+7))

ans=0

for i in range(n-1):
    
    ans += (A[i] * (B[-1]-B[i])  % (10**9+7))
    
#    for j in range(i+1,n):
        
#        ans += (A[i] * A[j]) % (10**9+7)
#
print(ans % (10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

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

ans=0

for i in range(n-1):
    for j in range(i+1,n):
        
        ans += (A[i] * A[j]) % (10**9+7)

print(ans % (10**9+7))

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

n=int(input())

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

B=[A[0]]

for i in range(len(A)-1):
    B.append((B[i]+A[i+1]) % (10**9+7))

ans=0

for i in range(n-1):
    
    ans += (A[i] * (B[-1]-B[i])  % (10**9+7))
    
#    for j in range(i+1,n):
        
#        ans += (A[i] * A[j]) % (10**9+7)
#
print(ans % (10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c=input()

for i in range(len(c)):
    
    c = c.lstrip("R")
    if c.count("R")==0:
        break
    
    firstW = c.find("W")
    lastR = c.rfind("R")
    
    c=list(c)
    c[firstW] = "R"
    c[lastR] = "W"
    c="".join(c)
    
#    print(c)


print(i)

Fixed submission:
n = int(input())
c=input()

rcount = c.count("R")
WcountuntilR = c[0:rcount].count("W")
print(WcountuntilR)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))

hyouten = []


for i in range(n-k+1):

    
    if i>0:
        score_old = a[i-1]
        score = a[i+k-1]
#        print(score_old,score)
        if score >score_old:
            print("Yes")
        else:
            print("No")
    hyouten.append(score)

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

#hyouten = []


for i in range(n-k+1):

    
    if i>0:
        score_old = a[i-1]
        score = a[i+k-1]
#        print(score_old,score)
        if score >score_old:
            print("Yes")
        else:
            print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))

#hyouten = []

score = 1
for i in range(k):
    score*=a[i]

for i in range(n-k+1):

    
    if i>0:
        score_old = score
        score = score // a[i-1] * a[i+k-1]
        
        if score >score_old:
            print("Yes")
        else:
            print("No")
#    hyouten.append(score)

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

#hyouten = []


for i in range(n-k+1):

    
    if i>0:
        score_old = a[i-1]
        score = a[i+k-1]
#        print(score_old,score)
        if score >score_old:
            print("Yes")
        else:
            print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input(n))
a = list(map(int,input().split()))

yen = 1000

kabu = 0

for i in range(n-1):
    if a[i] < a[i+1]:
        kabu_today = yen // a[i]
        kabu += kabu_today
        yen = yen % a[i]
        
    else:
        yen += kabu * a[i]
        kabu = 0
    
#    print(yen, kabu,a[i], a[i] < a[i+1])

yen += kabu * a[n-1]
kabu = 0

print(yen)

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

yen = 1000

kabu = 0

for i in range(n-1):
    if a[i] < a[i+1]:
        kabu_today = yen // a[i]
        kabu += kabu_today
        yen = yen % a[i]
        
    else:
        yen += kabu * a[i]
        kabu = 0
    
#    print(yen, kabu,a[i], a[i] < a[i+1])

yen += kabu * a[n-1]
kabu = 0

print(yen)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
AL,AR = {},{} 
BL,BR = {},{}
for i in range(N):
    if not A[i] in AL:
        AL[A[i]] = i
    AR[A[i]] = i

for i in range(N):
    if not B[i] in BL:
        BL[B[i]] = i
    BR[B[i]] = i
can = [1]*(N)

for i in BL.keys():
    if not i in AL:
        continue
    s = (N+AL[i]-BR[i])%N
    e = (N+AR[i]-BL[i])%N
    if e<s:
        e += N
    # print(i,s,e)
    for j in range(s,e+1):
        can[j%N] = 0

if 1 in can:
    print("Yes")
    ind = can.index(1)
    print(* (B+B)[N-ind:2*N-ind])
else:
    print(1/0)


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
AC = Counter(A)
BC = Counter(B)
for i in BC.keys():
    if i in AC and BC[i] + AC[i] > N:
        print("No")
        exit()
AL,AR = {},{} 
BL,BR = {},{}
for i in range(N):
    if not A[i] in AL:
        AL[A[i]] = i
    AR[A[i]] = i

for i in range(N):
    if not B[i] in BL:
        BL[B[i]] = i
    BR[B[i]] = i
can = [1]*(N)

for i in BL.keys():
    if not i in AL:
        continue
    s = (N+AL[i]-BR[i])%N
    e = (N+AR[i]-BL[i])%N
    if e<s:
        e += N
    # print(i,s,e)
    for j in range(s,e+1):
        can[j%N] = 0

if 1 in can:
    print("Yes")
    ind = can.index(1)
    print(* (B+B)[N-ind:2*N-ind])
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = -float("inf")
for i in range(N):
    hoge = []
    p = i
    s = 0
    for j in range(K):
        p = P[p]-1
        s += C[p]
        hoge.append(s)
        ans = max(ans,s)
        if p == i:
            S = s*((K-1)//len(hoge)) + max(hoge[:(K-1)%len(hoge)])
            if (K-1)//len(hoge) > 0:
                S = max(S,s*((K-1)//len(hoge))-1) + max(hoge)
            ans = max(ans,S)
            break
print(ans)
        

Fixed submission:
N, K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = -float("inf")
for i in range(N):
    hoge = []
    p = i
    s = 0
    for j in range(K):
        p = P[p]-1
        s += C[p]
        hoge.append(s)
        ans = max(ans,s)
        if p == i:
            s *= (K-1)//len(hoge)
            s += max(hoge[0:(K-1)%len(hoge)+1])
            ans = max(ans,s)
            break
print(ans)