Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
x = list(map(int,input().split()))
N = x[0]
X = x[1]
Y = x[2]

import numpy as np
ans = np.zeros(N)

for i in range(1,N+1):
    for j in range(i,N+1):
        k = min(abs(i-j),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
        ans[k] += 1

[print(int(x)) for x in ans[1:]]

Fixed submission:
x = list(map(int,input().split()))
N = x[0]
X = x[1]
Y = x[2]

ans = [0] * N

for i in range(1,N+1):
    for j in range(i,N+1):
        k = min(abs(i-j),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
        ans[k] += 1

[print(int(x)) for x in ans[1:]]

Buggy python submission (verdict: Time Limit Exceeded):
x = list(map(int,input().split()))
N = x[0]
X = x[1]
Y = x[2]

import numpy as np
ans = np.zeros(N)
for i in range(1,N+1):
    for j in range(i,N+1):
        k = min(abs(i-j),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
        ans[k] += 1

for i in range(1,N):
    print(int(ans[i]))

Fixed submission:
x = list(map(int,input().split()))
N = x[0]
X = x[1]
Y = x[2]

ans = [0] * N

for i in range(1,N+1):
    for j in range(i,N+1):
        k = min(abs(i-j),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
        ans[k] += 1

[print(int(x)) for x in ans[1:]]
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))

count = [0] * (N+1)
for i in range(1,N+1):
    for j in range(N):
        if a[j] == i:
            count[i] += 1
            
for i in range(N):
    count_cp = count.copy()
    count_cp[a[i]] -= 1
    su = 0
    for j in range(1,N+1):
        if count_cp[j] > 1:
            su += count_cp[j]*(count_cp[j]-1)/2
    print(int(su))

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

count = [0] * (N+1)
for aa in a:
    count[aa] += 1

su = 0
for ct in count:
    su += ct*(ct-1)/2
    
for aa in a:
    print(int(su-count[aa]+1))
Buggy python submission (verdict: Runtime Error):
import numpy as np

x = list(map(int,input().split()))
if x[0] > x[1]:
    ans = np.repeat(x[1],x[0])
    for i in ans:
        print(i, end="")
    
elif x[0] < x[1]:
    for i in ans:
        print(i, end="")
    
else:
    ans = np.repeat(x[0],x[1])
    for i in ans:
        print(i, end="")

Fixed submission:
import numpy as np

x = list(map(int,input().split()))
if x[0] > x[1]:
    ans = np.repeat(x[1],x[0])
    for i in ans:
        print(i, end="")
    
elif x[0] < x[1]:
    ans = np.repeat(x[0],x[1])
    for i in ans:
        print(i, end="")
    
else:
    ans = np.repeat(x[0],x[1])
    for i in ans:
        print(i, end="")

Buggy python submission (verdict: Runtime Error):
import numpy as np

x = list(map(int,input().split()))
if x[0] > x[1]:
    ans = np.repeat(x[1],x[0])
    for i in ans:
        print(i, end="")
    
elif x[0] < x[1]:
    for i in ans:
        print(i, end="")
    
else:
    for i in ans:
        print(i, end="")

Fixed submission:
import numpy as np

x = list(map(int,input().split()))
if x[0] > x[1]:
    ans = np.repeat(x[1],x[0])
    for i in ans:
        print(i, end="")
    
elif x[0] < x[1]:
    ans = np.repeat(x[0],x[1])
    for i in ans:
        print(i, end="")
    
else:
    ans = np.repeat(x[0],x[1])
    for i in ans:
        print(i, end="")
Buggy python submission (verdict: Runtime Error):
import math
x = input().split()
a,b,c,d = int(x[0]),int(x[1]),int(x[2]),int(x[3])

cn=0
if a%c==0:
    cn+=1
cn+=int(b/c)-int(a/c)
dn=0
if a%d==0:
    dn+=1
dn+=int(b/d)-int(a/d)

cdn=0
cd = c*d/math.gcd(c,d)
if a%cd==0:
    cdn+=1
cdn+=int(b/cd)-int(a/cd)

print((b-a+1)-(cn+dn-cdn))

Fixed submission:
import fractions
x = input().split()
a,b,c,d = int(x[0]),int(x[1]),int(x[2]),int(x[3])

cd = int(c*d/fractions.gcd(c,d))

cn = b // c - (a-1) // c
dn = b // d - (a-1) // d
cdn = b // cd - (a-1) // cd

print((b-a+1)-(cn+dn-cdn))
Buggy python submission (verdict: Runtime Error):
a = input()

if (isupper(a)):
  print("A")
else:
  print("a")

Fixed submission:
a = input()

if (a.isupper()):
  print("A")
else:
  print("a")
Buggy python submission (verdict: Runtime Error):
n = [i for i in raw_input()]
print "Yes" if "7" in n else "No"


Fixed submission:
n = [i for i in input()]
print("Yes" if "7" in n else "No")
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, raw_input().split())

if k >= a + b:
    a, b = 0, 0
else:
    for i in range(k):
        if a > 0:
            a -= 1
            continue   
        if a == 0 and b > 0:
            b -= 1
            continue
        break
print a, b

Fixed submission:
a, b, k = map(int, raw_input().split())

if k <= a:
    a, b = a - k, b
elif k <= a + b:
    a, b = 0, b - (k - a)
else:
    a, b = 0, 0
        
print a, b
Buggy python submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())
print max(
  a + b,
  a - b,
  a * c
)

Fixed submission:
a, b = map(int, raw_input().split())
print max(
    a + b,
    a - b,
    a * b
)
Buggy python submission (verdict: Runtime Error):
x = int(input())
if x >= 30:
  print("YES")
 else:
  print("NO")

Fixed submission:
x = int(input())
if x >= 30:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
	n = len(numbers)
	#print(numbers)
    #lcm_tmp = (numbers[0] * numbers[1]) // fractions.gcd(numbers[0], numbers[1])
	lcm_tmp = lcm_base(numbers[0],numbers[1])
	for i in range(2,n):
		lcm_tmp = lcm_base(numbers[i],lcm_tmp)
	return lcm_tmp

n,m = map(int,input().split())
t = list(map(int,input().split()))
#print(t)
#lcm = (a * b) // fractions.gcd(a, b)
lcm = lcm_list(t)
x = m // (lcm /2 )
y = m // (lcm)
print(int(x-y))

Fixed submission:
# 100 points
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
k, x = map(int, input().split())
if k*500 >= x:
    # 出力
    print('Yes')
else:
    # 出力
    print('No')# 100 points

Buggy python submission (verdict: Runtime Error):
hoge = input()
c,s = hoge.sprit()

if x * 500 >= s:
  res = "Yes"
else:
  res = "No"
  
print(res)

Fixed submission:
# 100 points
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
k, x = map(int, input().split())
if k*500 >= x:
    # 出力
    print('Yes')
else:
    # 出力
    print('No')# 100 points
Buggy python submission (verdict: Runtime Error):
import itertools
import math

n = input()
p = input()
q = input()
i==0
for x in itertools.permutations(range(1,n+1), n):
	i += 1
	if p == x:
      a = i
    elif q == x:
      b = i
print(math.abs(a-b))

Fixed submission:
import itertools
#import math

n = int(input())
#n = 2
#p = tuple(map(int,input().split(" ")))
#q = tuple(map(int,input().split(" ")))

p = input()
q = input()
#print(n)
#print(p)
i = 0
#a = 0 
#b = 0

for x in itertools.permutations(range(1,n+1), n):
	#print(x)
	x = " ".join(map(str,x))
	#print(x)
	i += 1
	if x == p:
		a = i
		#print(i)
	if x == q:
		b = i
		#print(i)

print(abs(a-b))

Buggy python submission (verdict: Runtime Error):
import itertools
import math

n = input()
p = input()
q = input()

counter = 1
base = list(range(1,n+1))

i = 0
for x in itertools.permutations(range(n), n):
	i += 1
    if p == x:
    	a = i
    elif q == x:
    	b = i
print(math.abs(a-b))


Fixed submission:
import itertools
#import math

n = int(input())
#n = 2
#p = tuple(map(int,input().split(" ")))
#q = tuple(map(int,input().split(" ")))

p = input()
q = input()
#print(n)
#print(p)
i = 0
#a = 0 
#b = 0

for x in itertools.permutations(range(1,n+1), n):
	#print(x)
	x = " ".join(map(str,x))
	#print(x)
	i += 1
	if x == p:
		a = i
		#print(i)
	if x == q:
		b = i
		#print(i)

print(abs(a-b))
Buggy python submission (verdict: Runtime Error):
def Test(n,k):
    if n > 2 * k:
        res = "YES"
    else:
        count = 0
        res = "NO"
        for i in range(1,n + 1,2):
            count += 1
            if count == k:
                res = "YES"
    print(res)
    
if __name__ == '__main__':
    _N = input()
    _K = input()
    try:
        N = int(_N)
        K = int(_K)
        Test(N,K)
    except:
        print("Error")

Fixed submission:
def Test(n,k):
    if n > 2 * k:
        res = "YES"
    else:
        count = 0
        res = "NO"
        for i in range(1,n + 1,2):
            count += 1
            if count == k:
                res = "YES"
    print(res)
    
if __name__ == '__main__':
    N,K = map(int,input().split())
    try:
        Test(N,K)
    except:
        print("Error")

Buggy python submission (verdict: Runtime Error):
def Test(n,k):
    if n > 2 * k:
        res = "YES"
    else:
        count = 0
        res = "NO"
        for i in range(1,n + 1,2):
            count += 1
            if count == k:
                res = "YES"
    print(res)
    
if __name__ == '__main__':
    _N = input()
    _K = input()
    try:
        N = int(_N)
        K = int(_K)
        Test(N,K)
    except:
        print("Error")

Fixed submission:
def Test(n,k):
    if n > 2 * k:
        res = "YES"
    else:
        count = 0
        res = "NO"
        for i in range(1,n + 1,2):
            count += 1
            if count == k:
                res = "YES"
    print(res)
    
if __name__ == '__main__':
    N,K = map(int,input().split())
    try:
        Test(N,K)
    except:
        print("Error")

Buggy python submission (verdict: Runtime Error):
def Test(n,k):
    if n > 2 * k:
        res = "YES"
    else:
        count = 0
        res = "NO"
        for i in range(1,n + 1,2):
            count += 1
            if count == k:
                res = "YES"
    print(res)
    
if __name__ == '__main__':
    _N = input()
    _K = input()
    try:
        N = int(_N)
        K = int(_K)
        Test(N,K)
    except:
        print("Error")

Fixed submission:
def Test(n,k):
    if n > 2 * k:
        res = "YES"
    else:
        count = 0
        res = "NO"
        for i in range(1,n + 1,2):
            count += 1
            if count == k:
                res = "YES"
    print(res)
    
if __name__ == '__main__':
    N,K = map(int,input().split())
    try:
        Test(N,K)
    except:
        print("Error")
Buggy python submission (verdict: Runtime Error):
x,k,d=map(int,input().split())
if d>=x:
  print(x)
  exit()
else:
  if x//d>=k:
    print(x-k*d)
    exit()
  else:
    if (x//d)%2==k%2:
      print(x%d)
      exit()
    else:
      print(d-x%d)
      exit()

Fixed submission:
s=input()
c=0
for i in range(3):
  if s[i]=='R':
    c+=1
if s=='RSR' :
  print(1)
else:
  print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
from collections import deque
toku=[0]*(n+1)
for i in range(1,n+1):
  ans=[0]
  d=deque()
  visit=[0]*(n+1)
  d.append(i)
  while d:
    now=d.pop()
    if visit[now]==0:
      visit[now]=1
      ans.append(ans[-1]+c[p[now-1]-1])
      d.append(p[now-1])
  syuki=sum(visit)
  if ans[-1]>=0:
    if k%syuki==0:
      toku[i]=max((k//syuki)*ans[-1],(k//syuki-1)*ans[-1]+max(ans))
      
    else:
      toku[i]=(k//syuki)*ans[-1]+max(ans[1:k%syuki+1])
  else:
    if k//syuki==0:
      toku[i]=max(ans[1:k%syuki+1])
    else:
      toku[i]=max(ans[1:])
print(max(toku[1:]))      
    

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
from collections import deque
toku=[0]*(n+1)
for i in range(1,n+1):
  ans=[0]
  d=deque()
  visit=[0]*(n+1)
  d.append(i)
  while d:
    now=d.pop()
    if visit[now]==0:
      visit[now]=1
      ans.append(ans[-1]+c[p[now-1]-1])
      d.append(p[now-1])
  syuki=sum(visit)
  if ans[-1]>=0:
    if k%syuki==0:
      toku[i]=max((k//syuki)*ans[-1],(k//syuki-1)*ans[-1]+max(ans))
      
    else:
      toku[i]=(k//syuki)*ans[-1]+max(ans[1:k%syuki+1])
  else:
    if k//syuki==0:
      toku[i]=max(ans[1:k%syuki+1])
    else:
      toku[i]=max(ans[1:])
print(max(toku[1:]))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=[1]
for i in range(n):
  s.append(s[-1]*a[i])
for i in range(k+1,n+1):
  if s[i]/s[i-k]>s[i-1]/s[i-1-k]:
    print('Yes')
  else:
    print('No')

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k,n):
  if a[i]/a[i-k]>1:
    print('Yes')
  else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
score=1
for i in range(k):
  score=score*a[i]
for i in range(k,n):
  rscore=score
  score=score*a[i]/a[i-k]
  if score>rscore:
    print('Yes')
  else:
    print('No')

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k,n):
  if a[i]/a[i-k]>1:
    print('Yes')
  else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
score=1
for i in range(k):
  score=score*a[i]
for i in range(k,n):
  rscore=score
  score=score*a[i]/a[i-k]
  if score>rscore:
    print('Yes')
  else:
    print('No')

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k,n):
  if a[i]/a[i-k]>1:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
for n_ in range(1,n+1):
  c=0
  for x in range(1,41):
    if n_-x**2>=0:
      y_=(n_-x**2)**(1/2)
      y_=int(y_)
    else:
      break
    for y in range(x,y_+1):
      if n_-x**2-y**2>=0:
         z_=(n_-x**2-y**2)**(1/2)
         z_=int(z_)
      else:
        break
      for z in range(y,z_+1):
        if (x+y)**2+(y+z)**2+(z+x)**2==2*n_:
          if x==y and y==z:
            c+=1	
          elif len({x,y,z})==2:
            c+=3
          else:
            c+=6
  print(c)          

Fixed submission:
n=int(input())
ans=[0]*(n+1)
for x in range(1,105):
  for y in range(1,105):
    for z in range(1,105):
      t=x*x+y*y+z*z+x*y+y*z+z*x
      if t<=n:
        ans[t]+=1
for i in range(1,n+1):
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a=0
b=0
t=0
while t<=k:
  if a<=n-1 and b<=m-1:
    if A[a]<B[b]:
      t+=A[a]
      a+=1
    elif A[a]>B[b]:
      t+=B[b]
      b+=1
    else:
      d=1
      d_=1
      while d!=n-a or d_!=m-b:
        if A[a+d]==B[b+d_]:
          d+=1
          d_+=1
        elif A[a+d]<B[b+d_]:
          a_=a
          while t<=k and a<=a_+d:
            t+=A[a]
            a+=1
        elif A[a+d]>B[b+d_]:
          b_=b
          while t<=k and b<=b_+d:
            t+=B[b]
            b+=1
        if d==n-a:
          b_=b
          while t<=k and b_+d:
            t+=B[b]
            b+=1
        elif d_==m-b:
          a_=a
          while t<=k and a<=a_+d_:
            t+=A[a]
            a+=1
  elif a>=n and b<=m-1:
    t+=B[b]
    b+=1
  elif b>=m and a<=n-1:
    t+=A[a]
    a+=1
  else:
    print(n+m)
    exit()
print(a+b-1)        

Fixed submission:
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_=[0]
for i in range(len(a)):
  a_.append(a_[-1]+a[i])
b_=[0]
for i in range(len(b)):
  b_.append(b_[-1]+b[i])
ans=[0]
a_now=0
b_now=m
for i in range(n+1):
  k_=k-a_[i]
  while b_[b_now]>k_:
    b_now+=-1
    if b_now==-1:
      b_now=0
      break
  if a_[i]+b_[b_now]<=k:
    ans.append(i+b_now)
print(max(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
c=0
for i in range(n):
  if i==n-1:
    if max(a)>a[n-1]:
      c+=1
      break
  for j in range(n-i-1):
    d=0
    if i==n-1-j:
      continue
    elif a[i]%a[n-1-j]==0:
      d+=1
      break
  if d==0:
     c+=1
print(c)    

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

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
c=0
for i in range(len(a)):
  for j in range(len(a)):
    d=0
    if i==n-1-j:
      continue
    elif a[i]%a[n-1-j]==0:
      d+=1
      break
  if d==0:
     c+=1
print(c)  

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

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort()
c=0
for i in range(len(a)):
  for j in range(len(a)):
    d=0
    if i==n-1-j:
      continue
    elif a[i]%a[n-1-j]==0:
      d+=1
      break
  if d==0:
     c+=1
print(c)    
      

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

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort()
c=0
for i in range(len(a)):
  for j in range(len(a)):
    d=0
    if i==n-1-j:
      continue
    elif a[i]%a[n-1-j]==0:
      d+=1
      break
  if d==0:
     c+=1
print(c)    
      

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
dp=[0]*(10**6+1)
for i in A:
  dp[i]+=1
for i in range(1,10**6+1):
  if dp[i]>0:
    for j in range(2*i,10**6+1,i):
      dp[j]=0
print(dp.count(1))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=list(map(int,input().split()))
b=1
for i in range(N):
  b=b*a[i]
if b>10**18:
  print(-1)
else:
  print(b)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
a.sort()
b=1
if a[0]==0:
  print(0)
  exit()
for i in range(N):
  b=b*a[i]
  if b>10**18:
    print(-1)
    exit()
print(b)
Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
def hantei(u):
  if u==1:
    return 1
  for i in range(1,u+1):
    if (1/2)*i**2+(1/2)*i>u:
      return int(i-1)
    else:
      continue
   
a=[0]*int(N)
for i in range(2,N+1):
  while N%i==0:
    N=N//i
    a[i-1]=a[i-1]+1
c=0
for t in range(len(a)):
  if a[t]!=0:
    c+=hantei(a[t])
print(c)    

    

Fixed submission:
import math
N=int(input())
def hantei(u):
  if u==1:
    return 1
  for i in range(1,u+1):
    if (1/2)*i**2+(1/2)*i>u:
      return int(i-1)
    else:
      continue
   
a=[0]*int(math.sqrt(N))
for i in range(2,int(math.sqrt(N))+1):
  while N%i==0:
    N=N//i
    a[i-1]=a[i-1]+1
c=0
if N!=1:
  c+=1
for t in range(len(a)):
  if a[t]!=0:
    c+=hantei(a[t])
print(c)

Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
def hantei(u):
  if u==1:
    return 1
  for i in range(1,u+1):
    if (1/2)*i**2+(1/2)*i>u:
      return int(i-1)
    else:
      continue
   
a=[0]*int(N)
for i in range(2,N+1):
  while N%i==0:
    N=N//i
    a[i-1]=a[i-1]+1
c=0
for t in range(len(a)):
  if a[t]!=0:
    c+=hantei(a[t])
print(c)    

Fixed submission:
import math
N=int(input())
def hantei(u):
  if u==1:
    return 1
  for i in range(1,u+1):
    if (1/2)*i**2+(1/2)*i>u:
      return int(i-1)
    else:
      continue
   
a=[0]*int(math.sqrt(N))
for i in range(2,int(math.sqrt(N))+1):
  while N%i==0:
    N=N//i
    a[i-1]=a[i-1]+1
c=0
if N!=1:
  c+=1
for t in range(len(a)):
  if a[t]!=0:
    c+=hantei(a[t])
print(c)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n,m=map(int,input().split())
A=[set() for _ in range(m)]
for i in range(m):
  a,b=map(int,input().split())
  A[a-1].add(b)
  A[b-1].add(a)
visit=[0]*n
visit[0]=n+1
stack=deque()
stack.append(1)
while stack:
  now=stack.popleft()
  for j in A[now-1]:
    if visit[j-1]==0:
      visit[j-1]=now
      stack.append(j)
if min(visit)>0:
  print('Yes')
  for j in range(1,n):
    print(visit[j])
else:
  print('No')
    

Fixed submission:
from collections import deque
n,m=map(int,input().split())
A=[set() for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  A[a-1].add(b)
  A[b-1].add(a)
visit=[0]*n
visit[0]=n+1
stack=deque()
stack.append(1)
while stack:
  now=stack.popleft()
  for j in A[now-1]:
    if visit[j-1]==0:
      visit[j-1]=now
      stack.append(j)
if min(visit)>0:
  print('Yes')
  for j in range(1,n):
    print(visit[j])
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
ans=0
for i in range(n):
  b.append(i+1-a[i])
  c.append(a[i]+i+1)
c_=[0]*(max(c)+1)
b_=[0]*(max(c)+1)
for i in range(n):
  c_[c[i]]+=1
for i in range(n):
  if 0<=b[i]<=max(c)+1:
    b_[b[i]]+=1
for i in range(max(c)+1):
  ans+=b_[i]*c_[i]
print(ans)    

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
ans=0
for i in range(n):
  b.append(i+1-a[i])
  c.append(a[i]+i+1)
x=max(b)
if x<=0:
  print(0)
  exit()
else:
  ans=0
  b_=[0]*(x+1)
  for i in range(n):
    if 0<=b[i]<=x:
      b_[b[i]]+=1
  for i in range(n):
    if 0<=c[i]<=x:
      ans+=b_[c[i]]
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
ans=0
for i in range(n):
  b.append(i+1-a[i])
  c.append(a[i]+i+1)
for i in range(n-1):
  for j in range(i+1,n):
    if b[j]==c[i]:
      ans+=1
print(ans)    

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
ans=0
for i in range(n):
  b.append(i+1-a[i])
  c.append(a[i]+i+1)
x=max(b)
if x<=0:
  print(0)
  exit()
else:
  ans=0
  b_=[0]*(x+1)
  for i in range(n):
    if 0<=b[i]<=x:
      b_[b[i]]+=1
  for i in range(n):
    if 0<=c[i]<=x:
      ans+=b_[c[i]]
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
c=0
for i in range(N):
  for j in range(i):
    
      if abs(j-i)==A[i]+A[j]:
        c+=1
print(c)        

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
ans=0
for i in range(n):
  b.append(i+1-a[i])
  c.append(a[i]+i+1)
x=max(b)
if x<=0:
  print(0)
  exit()
else:
  ans=0
  b_=[0]*(x+1)
  for i in range(n):
    if 0<=b[i]<=x:
      b_[b[i]]+=1
  for i in range(n):
    if 0<=c[i]<=x:
      ans+=b_[c[i]]
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
c=0
for i in range(N):
  for j in range(N):
    if i<j:
      if abs(j-i)==A[i]+A[j]:
        c+=1
print(c)        

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
ans=0
for i in range(n):
  b.append(i+1-a[i])
  c.append(a[i]+i+1)
x=max(b)
if x<=0:
  print(0)
  exit()
else:
  ans=0
  b_=[0]*(x+1)
  for i in range(n):
    if 0<=b[i]<=x:
      b_[b[i]]+=1
  for i in range(n):
    if 0<=c[i]<=x:
      ans+=b_[c[i]]
  print(ans)
Buggy python submission (verdict: Runtime Error):
N,M,Q=map(int,input().split())
a=[0]*Q
b=[0]*Q
c=[0]*Q
d=[0]*Q
for i in range(Q):
  a[i],b[i],c[i],d[i]=map(int,input().split())
import itertools
for A in itertools.combinations_with_replacement(range(1,M+1),N):
    ans=0
    if i in range(Q):
        s=0
        if A[b[i]]-A[a[i]]==c[i]:
           s+=d[i]
            ans=max(ans,s)
print(ans)        
        

Fixed submission:
N,M,Q=map(int,input().split())
a=[0]*Q
b=[0]*Q
c=[0]*Q
d=[0]*Q
for i in range(Q):
  a[i],b[i],c[i],d[i]=map(int,input().split())
import itertools
ans=0
for A in itertools.combinations_with_replacement(range(1,M+1),N):
    A=list(A)
    s=0
    
    for i in range(Q):
        if A[b[i]-1]-A[a[i]-1]==c[i]:
           s+=d[i]

           ans=max(ans,s)
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M,Q=map(int,input().split())
a=[0]*Q
b=[0]*Q
c=[0]*Q
d=[0]*Q
for i in range(Q):
  a[i],b[i],c[i],d[i]=map(int,input().split())
import itertools
for A in itertools.combinations_with_replacement(range(1,M+1),N):
    ans=0
    if i in range(Q):
        s=0
        A[b[i]]-A[a[i]]=c[i]
        s+=d[i]
        ans=max(ans,s)
print(ans)   

Fixed submission:
N,M,Q=map(int,input().split())
a=[0]*Q
b=[0]*Q
c=[0]*Q
d=[0]*Q
for i in range(Q):
  a[i],b[i],c[i],d[i]=map(int,input().split())
import itertools
ans=0
for A in itertools.combinations_with_replacement(range(1,M+1),N):
    A=list(A)
    s=0
    
    for i in range(Q):
        if A[b[i]-1]-A[a[i]-1]==c[i]:
           s+=d[i]

           ans=max(ans,s)
print(ans)