Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))
now, route = 1, []

while not now in route:
    route.append(now)
    now = a[now-1]
route.append(now)
route.pop(0)
num = k%len(route)

count = route.index(route[-1])
if k-1 <= count:
    print(route[k-1])
    sys.exit()
else:
    if count != len(route)-1:
        route = route[count:]
if num == 0:
    num = len(route)
print(route[num-1])


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

route = []
town = set()
now = 1

while True:
    now = a[now-1]
    if now in town:
        break
    town.add(now)
    route.append(now)

count = route.index(now)
if count >= k:
    print(route[k-1])
else:
    route = route[count:]
    num = (k-count)%len(route)
    print(route[num-1])

Buggy python submission (verdict: Runtime Error):
N, K = (int(x) for x in input().split())
trip = input().split()

now = 1
way = [now]

for k in range(K):
  now = int(trip[now-1])
  way.append(now)
  if way.count(now) == 2:
    index = way.index(now)
    if index != 0:
      del way[:index]
      a = (K-index) % (len(way)-1)
      break
print(way[a])

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

route = []
town = set()
now = 1

while True:
    now = a[now-1]
    if now in town:
        break
    town.add(now)
    route.append(now)

count = route.index(now)
if count >= k:
    print(route[k-1])
else:
    route = route[count:]
    num = (k-count)%len(route)
    print(route[num-1])

Buggy python submission (verdict: Runtime Error):
N, K = (int(x) for x in input().split())
trip = input().split()
 
now = 1
way = []
 
for k in range(K): 
  now = int(trip[now-1])
  way.append(now)
  if way.count(now) == 2:
    a = K % len(way)
    break

print(way[a])

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

route = []
town = set()
now = 1

while True:
    now = a[now-1]
    if now in town:
        break
    town.add(now)
    route.append(now)

count = route.index(now)
if count >= k:
    print(route[k-1])
else:
    route = route[count:]
    num = (k-count)%len(route)
    print(route[num-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = (int(x) for x in input().split())
trip = input().split()

now = 1

for k in range(K):
  now = int(trip[now-1])
   
print(now)



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

route = []
town = set()
now = 1

while True:
    now = a[now-1]
    if now in town:
        break
    town.add(now)
    route.append(now)

count = route.index(now)
if count >= k:
    print(route[k-1])
else:
    route = route[count:]
    num = (k-count)%len(route)
    print(route[num-1])
Buggy python submission (verdict: Runtime Error):
import math
import sys

X = int(input())
 
for i in range(-118, 119):
  for j in range(-119, 118):
    if math.pow(i, 5) - math.pow(j, 5) == X:
      print("%d %d" % (i, j))
      sys.exit()


Fixed submission:
S = input()
 
if S == 'ABC':
  print('ARC')
else:
  print('ABC')

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

X = int(input())
 
for i in range(1000):
  for j in range(-100, 1000):
    if math.pow(i, 5) - math.pow(j, 5) == X:
      print("%d %d" % (i, j))
      sys.exit()


Fixed submission:
S = input()
 
if S == 'ABC':
  print('ARC')
else:
  print('ABC')

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

X = int(input())

for i in range(-100, 1000):
  for j in range(-100, 1000):
    if	math.pow(i, 5) - math.pow(j, 5)	== X:
      print("%d %d" % (i, j))
      sys.exit()


Fixed submission:
S = input()
 
if S == 'ABC':
  print('ARC')
else:
  print('ABC')

Buggy python submission (verdict: Runtime Error):
S = input()
 
if S == 'ABC':
  print(ARC)
else:
  print(ABC)

Fixed submission:
S = input()
 
if S == 'ABC':
  print('ARC')
else:
  print('ABC')
Buggy python submission (verdict: Runtime Error):
import math

X = int(input())

i = 0
j = 0
while True:
   i += 1
   a = math.pow((X + math.pow(i, 5)), float(1/5))
   if a.is_integer():
      print("%d %d" % (a, i))
      exit()
   j -= 1
   a = math.pow((X + math.pow(j, 5)), float(1/5))
   if a.is_integer():
      print("%d %d" % (a, j))
      exit()

Fixed submission:
import sys
x = int(input())

for i in range(-1000, 1001):
    for j in range(-1000, 1001):
        if i**5-j**5 == x:
            print(i, j)
            sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
import math

X = int(input())

i = 0
while True:
   i += 1
   a = math.pow((X + math.pow(i, 5)), float(1/5))
   if a.is_integer():
      print("%d %d" % (a, i))
      exit()


Fixed submission:
import sys
x = int(input())

for i in range(-1000, 1001):
    for j in range(-1000, 1001):
        if i**5-j**5 == x:
            print(i, j)
            sys.exit()

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

X = int(input())

i = 0
while True:
   i += 1
   b = - math.pow((X - math.pow(i, 5)), float(1/5))
   if b.is_integer():
      print("%d %d" % (i, b))
      exit()

Fixed submission:
import sys
x = int(input())

for i in range(-1000, 1001):
    for j in range(-1000, 1001):
        if i**5-j**5 == x:
            print(i, j)
            sys.exit()
Buggy python submission (verdict: Time Limit Exceeded):
import math

A, B, N = [int(x) for x in input().split()]
val = 0

for i in range(min(B, N+1)):
    a = math.floor(float(A*i)/B) - A * math.floor(float(i)/B)
    if a > val:
        val = a

print(val)





Fixed submission:
import math

A, B, N = [int(x) for x in input().split()]
count = min(B-1, N)
a = math.floor(float(A*count)/B) - A * math.floor(float(count)/B)
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

a = [int(x) for x in input().split()]
num = len(a)
for i in range(N):
    a = [int(x) for x in a if i+1 != x]
    print(num-len(a))
    num -= (num-len(a))
    


Fixed submission:
import collections

N = int(input())

c = collections.Counter([int(x) for x in input().split()])
for i in range(N):
    print(c[i+1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

num = len(s)
ans = 0
for i in range(num):
    a = set(s[i])
    for j in range(i+1, num):
        if s[j] in a:
            continue
        a.add(s[j])
        for k in range(j+1, num):
            if s[k] in a or j-i == k-j:
                continue
            ans += 1
        a.remove()

print(ans)


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

num = len(s)
ans = s.count('R')*s.count('G')*s.count('B')

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

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

num = len(s)
ans = 0
for i in range(num):
    a = [s[i]]
    for j in range(i+1, num):
        if s[j] in set(a):
            continue
        a.append(s[j])
        for k in range(j+1, num):
            if s[k] in set(a) or j-i == k-j:
                continue
            ans += 1
        a.pop()

print(ans)


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

num = len(s)
ans = s.count('R')*s.count('G')*s.count('B')

for i in range(num):
    for j in range(i+1, num):
        if 0 <= 2*j-i < num:
            if s[i] != s[j] and s[j] != s[2*j-i] and s[2*j-i] != s[i]:
                ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

N, M = map(int, input().split())
print(comb(N, 2) + comb(M, 2))



Fixed submission:
N, M = map(int, input().split())
print(int(N*(N-1)/2+M*(M-1)/2))

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

N, M = map(int, input().split())
print(comb(N, 2, exact=True) + comb(M, 2, exact=True))



Fixed submission:
N, M = map(int, input().split())
print(int(N*(N-1)/2+M*(M-1)/2))
Buggy python submission (verdict: Runtime Error):
from math import factorial

N = int(input())
index = list(map(int, input().split()))
val = [0]*max(index)
for i in index:
    val[i-1] += 1
total = 0
for i in val:
    if i >= 2:
        total += comb(i, 2, exact=True)
for i in index:
    if val[i-1] >= 2:
        print(total-(comb(val[i-1], 2, exact=True)-comb(val[i-1]-1, 2, exact=True)))
    else:
        print(total)


Fixed submission:
from scipy.special import comb

N = int(input())
index = list(map(int, input().split()))
val = [0]*max(index)
for i in index:
    val[i-1] += 1
total = 0
for i in val:
    if i >= 2:
        total += comb(i, 2, exact=True)
for i in index:
    if val[i-1] >= 2:
        print(total-(comb(val[i-1], 2, exact=True)-comb(val[i-1]-1, 2, exact=True)))
    else:
        print(total)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())
now: bool = True

for i in range(n):
    q = list(input().split())
    if q[0] == '1':
        now = not now
    else:
        if (q[1] == '1' and now == True) or (q[1] == '2' and now == False):
            s = q[2]+s
        elif (q[1] == '1' and now == False) or (q[1] == '2' and now == True):
            s = s+q[2]
if now == True:
    print(s)
else:
    print(s[::-1])


Fixed submission:
from collections import deque
s = deque(input())
n = int(input())
now: bool = True

for i in range(n):
    q = list(input().split())
    if q[0] == '1':
        now = not now
    else:
        if (q[1] == '1' and now == True) or (q[1] == '2' and now == False):
            s.appendleft(q[2])
        elif (q[1] == '1' and now == False) or (q[1] == '2' and now == True):
            s.append(q[2])
if now == True:
    print(''.join(s))
else:
    print(''.join(reversed(s)))

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

for i in range(n):
    q = list(input().split())
    if q[0] == '1':
        s = s[::-1]
    else:
        if q[1] == '1':
            s = q[2]+s
        else:
            s = s+q[2]
print(s)


Fixed submission:
from collections import deque
s = deque(input())
n = int(input())
now: bool = True

for i in range(n):
    q = list(input().split())
    if q[0] == '1':
        now = not now
    else:
        if (q[1] == '1' and now == True) or (q[1] == '2' and now == False):
            s.appendleft(q[2])
        elif (q[1] == '1' and now == False) or (q[1] == '2' and now == True):
            s.append(q[2])
if now == True:
    print(''.join(s))
else:
    print(''.join(reversed(s)))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
for i in range(0, N-K+1):
    ans = max((sum(p[i:i+K])+K)/2, ans)
print(ans)


Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
ans = (sum(p[0:K])+K)/2
pre = ans
for i in range(1, N-K+1):
    pre -= (p[i-1]-p[i+K-1])/2
    ans = max(pre, ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p = list(map(int, input().split()))

max0, max1, count = [], 0, 0
for i in p:
    max0.append(i)
    max1 = i
    if max1 == 1:
        count += 1
        break
    elif min(max0) >= max1:
        count += 1
print(count)


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

max0, max1, count = p[0], 0, 0
for i in p:
    max0 = min(max0, i)
    max1 = i
    if max1 == 1:
        count += 1
        break
    elif max0 >= max1:
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for _ in range(n):
    c0, c1 = map(int, input().split())
    a.append([c0-c1, c0+c1])
a.sort(key=lambda x: x[1])
ans = 1
b = [a[0]]

for i in a[1:]:
    for j, k in enumerate(b):
        if not (k[1] <= i[0]):
            break
        if j == len(b)-1:
            ans += 1
            b.append(i)
print(ans)


Fixed submission:
n = int(input())
a = []
for _ in range(n):
    c0, c1 = map(int, input().split())
    a.append([c0-c1, c0+c1])
a.sort(key=lambda x: x[1])
ans, b = 1, a[0][1]
for i in a[1:]:
    if b <= i[0]:
        b = i[1]
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
ans = 0

for i in range(0, 1000):
    count = 0
    val = list(str(i).zfill(3))
    for j in s:
        if j == val[count]:
            count += 1
            if count == 3:
                ans += 1
                break
print(ans)



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

for i in range(0, 1000):
    count = 0
    val = list(str(i).zfill(3))
    k = val[count]
    for j in s:
        if j == k:
            count += 1
            if count <= 2:
                k = val[count]
            elif count == 3:
                ans += 1
                break
print(ans)

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

for i in range(0, 1000):
    count = 0
    val = str(i).zfill(3)
    for j in s:
        if j == val[count]:
            count += 1
            if count == 3:
                ans += 1
                break
print(ans)



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

for i in range(0, 1000):
    count = 0
    val = list(str(i).zfill(3))
    k = val[count]
    for j in s:
        if j == k:
            count += 1
            if count <= 2:
                k = val[count]
            elif count == 3:
                ans += 1
                break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n = int(input())
s = input()
ans = set()
for i in combinations(s, 3):
    a = ''.join(i)
    if not a in ans:
        ans.add(a) 
print(len(ans))


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

for i in range(0, 1000):
    count = 0
    val = list(str(i).zfill(3))
    k = val[count]
    for j in s:
        if j == k:
            count += 1
            if count <= 2:
                k = val[count]
            elif count == 3:
                ans += 1
                break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n = int(input())
s = input()
ans = []
for i in combinations(s, 3):
    ans += [''.join(i)]
print(len(set(ans)))


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

for i in range(0, 1000):
    count = 0
    val = list(str(i).zfill(3))
    k = val[count]
    for j in s:
        if j == k:
            count += 1
            if count <= 2:
                k = val[count]
            elif count == 3:
                ans += 1
                break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))

ans = 10**10
for i in range(1, N):
    ans = min(ans, abs(sum(a[:i])-sum(a[i:])))

print(ans)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
num0 = 0
num1 = sum(a)

ans = 10**10
for i in range(0, N):
    num0 += a[i]
    num1 -= a[i]
    if ans > abs(num1-num0):
        ans = abs(num1-num0)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())

if N > 81:
    print('No')
else:
    val = []
    i = 3
    while N != 1:
        if N % 2 == 0:
            val.append(2)
            N //= 2
        else:
            if i >= 10:
                print('No')
                sys.exit()
            elif N % i == 0:
                val.append(i)
                N //= i
            else:
                i += 2
if val.count(5) >= 2 and len(val) >= 3:
    print('No')
elif val.count(7) >= 2 and len(val) >= 3:
    print('No')
else:
    print('Yes')
        


Fixed submission:
import sys
N = int(input())

if N > 81 or N == 50 or N == 60 or N == 70 or N == 80:
    print('No')
    sys.exit()
else:
    val = []
    i = 3
    while N != 1:
        if N % 2 == 0:
            val.append(2)
            N //= 2
        else:
            if i >= 10:
                print('No')
                sys.exit()
            elif N % i == 0:
                val.append(i)
                N //= i
            else:
                i += 2

print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
N = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0
now = l[:2]
for i in range(2, N):
    for j in combinations(now, 2):
        if j[0]+j[1] > l[i]:
            count += 1
    now.append(l[i])
print(count)


Fixed submission:
import bisect

N = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0

for i in range(N):
    for j in range(i+1, N):
        count += bisect.bisect_left(l, l[i]+l[j])-j-1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())

def cal(a, b):
    c = [1]
    if a%2 == 0 and b%2 == 0:
        c.append(2)
    for i in range(3, min(a, b)+1, 2):
        if a%i == 0 and b%i == 0:
            if len(c) == 1:
                c.append(i)
            else:
                for j, k in enumerate(c[1:]):
                    if i%k == 0:
                        break
                    elif j == len(c)-2:
                        c.append(i)
    return c

ans = cal(a, b)
print(len(ans))


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

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def cal(c):
    d = []
    while c%2 == 0:
        d.append(2)
        c //= 2
    f = 3
    while f**2 <= c:
        if c%f == 0:
            d.append(f)
            c //= f
        else:
            f += 2
    if c != 1:
        d.append(c)
    return d
    
c = gcd(a, b)
d = cal(c)
print(len(set(d))+1)

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

def cal(a, b):
    c = [1]
    for i in range(2, min(a, b)+1):
        if a%i == 0 and b%i == 0:
            if len(c) == 1:
                c.append(i)
            else:
                for j, k in enumerate(c[1:]):
                    if i%k == 0:
                        break
                    elif j == len(c)-2:
                        c.append(i)
    return c

ans = cal(a, b)
print(len(ans))


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

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def cal(c):
    d = []
    while c%2 == 0:
        d.append(2)
        c //= 2
    f = 3
    while f**2 <= c:
        if c%f == 0:
            d.append(f)
            c //= f
        else:
            f += 2
    if c != 1:
        d.append(c)
    return d
    
c = gcd(a, b)
d = cal(c)
print(len(set(d))+1)
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
val = [K]*N
a = []
for i in range(Q):
    num = [int(i) for i in range(N)]
    num.remove(int(input())-1)
    for j in num:
        val[j] -= 1

for i in val:
    if i <= 0:
        print('No')
    else:
        print('Yes')


Fixed submission:
N, K, Q = map(int, input().split())
val = [K]*N
for i in range(Q):
    val[int(input())-1] += 1

for i in val:
    if i - Q <= 0:
        print('No')
    else:
        print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
ans = sum(a[min(n, m):])
a = a[:min(n, m)]

if len(a) == 1 and n == 1:
    print(a[0]//2**m)
elif len(a) == 1:
    print(a[0]//2**m+ans)
else:
    for i in range(m):
        a[0] //= 2
        a = sorted(a, reverse=True)
    print(ans+sum(a))


Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [x*(-1) for x in a]
heapq.heapify(a)

for i in range(m):
    c = (heapq.heappop(a)*(-1)//2)*(-1)
    heapq.heappush(a, c)
print(-sum(a))
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
ans = [0 for _ in range(n)]
trees = [[] for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    trees[a-1].append(b-1)
    trees[b-1].append(a-1)

for _ in range(q):
    p, x = map(int, input().split())
    ans[p-1] += x

visited = [False]*n
def dfs(n):
    visited[n] = True
    for i in trees[n]:
        if visited[i]:
            continue
        ans[i] += ans[n]
        dfs(i)
dfs(0)
for i in ans:
    print(i)



Fixed submission:
import sys
sys.setrecursionlimit(10**7)

n, q = map(int, input().split())
ans = [0 for _ in range(n)]
trees = [[] for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    trees[a-1].append(b-1)
    trees[b-1].append(a-1)

for _ in range(q):
    p, x = map(int, input().split())
    ans[p-1] += x

visited = [False]*n
def dfs(n):
    visited[n] = True
    for i in trees[n]:
        if visited[i]:
            continue
        ans[i] += ans[n]
        dfs(i)
dfs(0)
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
N = int(input())
s = sorted([sorted(input()) for _ in range(N)])
total = 0
count = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        count += 1
    else:
        total += comb(count, 2)
        count = 1
total += comb(count, 2)
print(int(total))


Fixed submission:
N = int(input())
s = sorted([sorted(input()) for _ in range(N)])
total = 0
count = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        count += 1
    else:
        total += count * (count - 1) / 2
        count = 1
total += count * (count - 1) / 2
print(int(total))

Buggy python submission (verdict: Runtime Error):
from collections import Counter
from scipy.special import comb
N = int(input())
a, b = [], []
for i in range(N):
    b = sorted([x for x in input()])
    a += [int(''.join([str(ord(x)) for x in b]))]
count = Counter(a)
total = 0
for i in count.items():
    if i[1] >= 2:
        total += comb(i[1], 2)
print(int(total))


Fixed submission:
N = int(input())
s = sorted([sorted(input()) for _ in range(N)])
total = 0
count = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        count += 1
    else:
        total += count * (count - 1) / 2
        count = 1
total += count * (count - 1) / 2
print(int(total))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
now = [1 for _ in range(len(s))]
pre = [0 for _ in range(len(s))]
pre2 = [0 for _ in range(len(s))]
count = 0

while now != pre2:
    count += 1
    pre2 = [i for i in pre]
    pre = [i for i in now]
    nex = [0 for _ in range(len(s))]
    for i in range(len(s)):
        if s[i] == 'R':
            nex[i+1] += pre[i]
        else:
            nex[i-1] += pre[i]
    now = [i for i in nex]
    
if count%2 == 0:
    print(*now)
else:
    print(*pre)
            


Fixed submission:
s = input()
a = [0]*len(s)
r, l = 0, 0

for i in range(len(s)):
    r += 1
    if s[i] == 'L':
        a[i-1] += r//2
        a[i] += (r+1)//2
        r = 0
        
for j in range(len(s)-1, -1, -1):
    l += 1
    if s[j] == 'R':
        a[j+1] += l//2
        a[j] += (l+1)//2
        l = 0
    a[j] -= 1

print(*a)
Buggy python submission (verdict: Runtime Error):
rint(3*int(input())**2)

Fixed submission:
print(3*int(input())**2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))

for i in range(N):
    val = a[i]
    del a[i]
    print(max(a))
    a.insert(i, val)


Fixed submission:
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
b = sorted(a)

if a.count(b[-1]) > 1:
    for i in range(N):
        print(b[-1])
else:
    ind = a.index(b[-1])
    for i in range(N):
        if i == ind:
            print(b[-2])
        else:
            print(b[-1])
Buggy python submission (verdict: Runtime Error):
import math
A, B, C, D = list(map(int, input().split()))

def num(x, y):
    return (x * y) // math.gcd(x, y)

print(B-A+1-((B//C+B//D-B//(num(C, D)))-((A-1)//C+(A-1)//D-(A-1)//(num(C, D)))))


Fixed submission:
from fractions import gcd
A, B, C, D = list(map(int, input().split()))

def num(x, y):
    return (x * y) // gcd(x, y)

print(B-A+1-((B//C+B//D-B//(num(C, D)))-((A-1)//C+(A-1)//D-(A-1)//(num(C, D)))))