Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = set()
s.add(1)
former = []
latter = []
temp = [1]
cur = a[0]
buf = 0

while True:
    if cur not in s:
        s.add(cur)
        temp.append(cur)
        cur = a[cur-1]
    else:
        buf = temp.index(cur)
        former = temp[:buf]
        latter = temp[buf:]
        break

# print('buf:', buf)
# print('former:', former)
# print('latter:', latter)

if len(latter) == 0:
    mod = k % len(temp)
    print(temp[mod])
    exit()

if k <= len(former):
    print(former[k])
else:
    mod = k % len(latter)
    # print('mod:', mod)
    idx = mod - len(former)
    print(latter[idx])


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = set()
s.add(1)
former = []
latter = []
temp = [1]
cur = a[0]
buf = 0

while True:
    if cur not in s:
        s.add(cur)
        temp.append(cur)
        cur = a[cur-1]
    else:
        buf = temp.index(cur)
        former = temp[:buf]
        latter = temp[buf:]
        break

# print('buf:', buf)
# print('former:', former)
# print('latter:', latter)

if len(latter) == 0:
    mod = k % len(temp)
    print(temp[mod])
    exit()

if k <= len(former):
    # print(former[k])
    print(temp[k])
else:
    # mod = k % len(latter)
    mod = (k-len(former)) % len(latter)
    # print('mod:', mod)
    # idx = mod - len(former)
    idx = mod
    
    print(latter[idx])

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = set()
s.add(1)
former = []
latter = []
temp = [1]
idx = 0
cur = a[idx]
buf = 0

while True:
    if cur not in s:
        s.add(cur)
        temp.append(cur)
        cur = a[cur-1]
    else:
        buf = temp.index(cur)
        former = temp[:buf]
        latter = temp[buf:]
        break

# print('buf:', buf)
# print('former:', former)
# print('latter:', latter)

if k <= len(former):
    print(former[k])
else:
    mod = k % len(latter)
    # print('mod:', mod)
    idx = mod - len(former)
    print(latter[idx])


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = set()
s.add(1)
former = []
latter = []
temp = [1]
cur = a[0]
buf = 0

while True:
    if cur not in s:
        s.add(cur)
        temp.append(cur)
        cur = a[cur-1]
    else:
        buf = temp.index(cur)
        former = temp[:buf]
        latter = temp[buf:]
        break

# print('buf:', buf)
# print('former:', former)
# print('latter:', latter)

if len(latter) == 0:
    mod = k % len(temp)
    print(temp[mod])
    exit()

if k <= len(former):
    # print(former[k])
    print(temp[k])
else:
    # mod = k % len(latter)
    mod = (k-len(former)) % len(latter)
    # print('mod:', mod)
    # idx = mod - len(former)
    idx = mod
    
    print(latter[idx])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = s[::-1]
isS = True
n = int(input())
query = []

for i in range(n):
    query.append(list(input().split()))

# print(query)

for i in range(n):
    # Reverse
    if query[i][0] == '1':
        # s = s[::-1]
        isS = not isS
    # Add
    else:
        # To Head
        if query[i][1] == '1':
            if isS:
                s = query[i][2] + s
                t += query[i][2]
            else:
                s += query[i][2]
                t = query[i][2] + t
        # To Tail
        else:
            if isS:
                s += query[i][2]
                t = query[i][2] + t
            else:
                s = query[i][2] + s
                t += query[i][2]

if isS:
    print(s)
else:
    print(t)

Fixed submission:
from collections import deque

s = input()
t = s[::-1]
ss = deque(s)
tt = deque(t)
isS = True
n = int(input())
query = []

# print(q1, q2)

for i in range(n):
    query.append(list(input().split()))

# print(query)

for i in range(n):
    # Reverse
    if query[i][0] == '1':
        # s = s[::-1]
        isS = not isS
    # Add
    else:
        # To Head
        if query[i][1] == '1':
            if isS:
                ss.appendleft(query[i][2])
                tt.append(query[i][2])
            else:
                ss.append(query[i][2])
                tt.appendleft(query[i][2])
        # To Tail
        else:
            if isS:
                ss.append(query[i][2])
                tt.appendleft(query[i][2])
            else:
                ss.appendleft(query[i][2])
                tt.append(query[i][2])

if isS:
    temp = list(ss)
    ans = ''.join(temp)
    print(ans)
else:
    temp = list(tt)
    ans = ''.join(temp)
    print(ans)

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

for i in range(n):
    query.append(list(input().split()))

# print(query)

for i in range(n):
    # Reverse
    if query[i][0] == '1':
        s = s[::-1]
    # Add
    else:
        # To Head
        if query[i][1] == '1':
            s = query[i][2] + s

        # To Tail
        else:
            s += query[i][2]

print(s)


Fixed submission:
from collections import deque

s = input()
t = s[::-1]
ss = deque(s)
tt = deque(t)
isS = True
n = int(input())
query = []

# print(q1, q2)

for i in range(n):
    query.append(list(input().split()))

# print(query)

for i in range(n):
    # Reverse
    if query[i][0] == '1':
        # s = s[::-1]
        isS = not isS
    # Add
    else:
        # To Head
        if query[i][1] == '1':
            if isS:
                ss.appendleft(query[i][2])
                tt.append(query[i][2])
            else:
                ss.append(query[i][2])
                tt.appendleft(query[i][2])
        # To Tail
        else:
            if isS:
                ss.append(query[i][2])
                tt.appendleft(query[i][2])
            else:
                ss.appendleft(query[i][2])
                tt.append(query[i][2])

if isS:
    temp = list(ss)
    ans = ''.join(temp)
    print(ans)
else:
    temp = list(tt)
    ans = ''.join(temp)
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())

if n == 1:
    print(1)
    exit()

# if n % 2 != 0:
#     n -= 1

h = math.log2(n)
h = math.floor(h)
print(2**(h+1)-1)

Fixed submission:
import math
n = int(input())

if n == 1:
    print(1)
    exit()

# if n % 2 != 0:
#     n -= 1

h = math.log2(n)
h = math.floor(h)
print(2**(h+1)-1)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())

if n == 1:
    print(1)
    exit()

if n % 2 != 0:
    n -= 1

h = math.log2(n)
h = math.floor(h)
print(2**(h+1)-1)

Fixed submission:
import math
n = int(input())

if n == 1:
    print(1)
    exit()

# if n % 2 != 0:
#     n -= 1

h = math.log2(n)
h = math.floor(h)
print(2**(h+1)-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
xy = []

for i in range(n):
    a = int(input())
    temp = {}
    for j in range(a):
        x, y = map(int, input().split())
        temp[x] = y
    xy.append(temp)

ans = 0

for i in range(0, 2**n):
    # print('\n', i, bin(i))
    isValid = True
    temp = 0

    for k in range(len(xy)):
        hMap = xy[k]
        kBit = (i >> k) & 1
        # print('k:', k, 'kBit:', kBit)
        if kBit == 1:
            # print('hMap is correct:', hMap)
            for key, value in hMap.items():
                # print(key, value, (i >> (key-1)) & 1, 'must be same')
                if not (i >> (key-1)) & 1 == value:
                    # print('paradox!')
                    isValid = False
                    break
        else:
            # print('hMap is NOT correct:', hMap)
            for key, value in hMap.items():
                # print(key, value, (i >> (key-1)) & 1, 'must be different')
                if not (i >> (key-1)) & 1 != value:
                    # print('paradox!')
                    isValid = False
                    break
    if isValid:
        for j in range(n):
            # print('Check digit:', j)
            jBit = (i >> j) & 1
            # print('bit:', jBit)
            if jBit == 1:
                temp += 1
    	ans = max(ans, temp)

print(ans)

Fixed submission:
n = int(input())
xy = []

for i in range(n):
    a = int(input())
    temp = {}
    for j in range(a):
        x, y = map(int, input().split())
        temp[x] = y
    xy.append(temp)

ans = 0

for i in range(0, 2**n):
    # print('\n', i, bin(i))
    isValid = True
    temp = 0

    for k in range(len(xy)):
        hMap = xy[k]
        kBit = (i >> k) & 1
        # print('k:', k, 'kBit:', kBit)
        if kBit == 1:
            # print('hMap is correct:', hMap)
            for key, value in hMap.items():
                # print(key, value, (i >> (key-1)) & 1, 'must be same')
                if not (i >> (key-1)) & 1 == value:
                    # print('paradox!')
                    isValid = False
                    break
        # else:
        #     # print('hMap is NOT correct:', hMap)
        #     for key, value in hMap.items():
        #         # print(key, value, (i >> (key-1)) & 1, 'must be different')
        #         if not (i >> (key-1)) & 1 != value:
        #             # print('paradox!')
        #             isValid = False
        #             break
    if isValid:
        for j in range(n):
            # print('Check digit:', j)
            jBit = (i >> j) & 1
            # print('bit:', jBit)
            if jBit == 1:
                temp += 1
        ans = max(ans, temp)

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0

for i in range(60):
    zeroCnt = 0
    oneCnt = 1
    
    for j in range(n):
        if (a[j] >> i) & 1 == 1:
            oneCnt += 1
        else:
            zeroCnt += 0
    ans += zeroCnt * oneCnt * pow(2, i, mod)
    ans %= mod

pirnt(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0

for i in range(60):
    zeroCnt = 0
    oneCnt = 0

    for j in range(n):
        if (a[j] >> i) & 1 == 1:
            oneCnt += 1
        else:
            zeroCnt += 1
    ans += zeroCnt * oneCnt * pow(2, i, mod)
    ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7

for i in range(n-1):
    for j in range(i+1, n):
        #print(a[i] ^ a[j])
        ans += (a[i] ^ a[j]) % mod

print(ans % mod)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0

for i in range(60):
    zeroCnt = 0
    oneCnt = 0

    for j in range(n):
        if (a[j] >> i) & 1 == 1:
            oneCnt += 1
        else:
            zeroCnt += 1
    ans += zeroCnt * oneCnt * pow(2, i, mod)
    ans %= mod

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
s = input()
nums = set()

for num in itertools.combinations(s, 3):
    nums.add(num)

print(len(nums))

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

def isAvailable(pw):
    for i in range(len(s)):
        if s[i] == pw[0]:
            pw = pw[1:]
            if pw == '':
                break

    if len(pw) == 0:
        return True
    else:
        return False

for i in range(10):
    for j in range(10):
        for k in range(10):
            pw = str(i) + str(j) + str(k)
            if isAvailable(pw):
                ans += 1

print(ans)

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

n = int(input())
s = input()
nums = set()

conb = list(itertools.combinations(s, 3))
#print(conb)

for i in range(len(conb)):
    nums.add(str(conb[i]))

#print(nums)
print(len(nums))

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

def isAvailable(pw):
    for i in range(len(s)):
        if s[i] == pw[0]:
            pw = pw[1:]
            if pw == '':
                break

    if len(pw) == 0:
        return True
    else:
        return False

for i in range(10):
    for j in range(10):
        for k in range(10):
            pw = str(i) + str(j) + str(k)
            if isAvailable(pw):
                ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

class Node:
    def __init__(self, val):
        self.val = val
        self.adj = []
        self.pec = 0

n = int(input())
ab = []
nodes = [None] * n
cntMap = {}

def addCount(v1):
    if v1 not in cntMap:
        cntMap[v1] = 1
    else:
        cntMap[v1] += 1

for i in range(n-1):
    v1, v2 = map(int, input().split())
    addCount(v1)
    addCount(v2)
    ab.append([v1, v2])
    nodeAidx = v1-1
    nodeBidx = v2-1
    nodeA = None
    nodeB = None
    if nodes[nodeAidx] is None:
        nodeA = Node(v1)
        nodes[nodeAidx] = nodeA
    else:
        nodeA = nodes[nodeAidx]
    if nodes[nodeBidx] is None:
        nodeB = Node(v2)
        nodes[nodeBidx] = nodeB
    else:
        nodeB = nodes[nodeBidx]
    nodeA.adj.append(nodeB)

#print(ab)
#print(nodes)
root = nodes[0]
nodes[1].pec = 1
q = deque()
q.append(root)

temp = list(cntMap.values())
temp.sort()
maxV = temp[-1]
used = set()
edgeMap = {}

print(maxV)

while q:
    used.clear()
    node = q.popleft()
    pec = node.pec
    used.add(pec)

    for i in range(len(node.adj)):
        a = node.adj[i]
        for j in range(1, maxV+1):
            if j not in used:
                a.pec = j
                used.add(j)
                break

        edgeMap[(node.val, a.val)] = a.pec
        q.append(a)

for i in range(n-1):
    key = (ab[i][0], ab[i][1])
    print(edgeMap[key])


Fixed submission:
from collections import deque

class Node:
    def __init__(self, val):
        self.val = val
        self.adj = []
        self.pec = 0

n = int(input())
ab = []
nodes = [None] * n
cntMap = {}

def addCount(v1):
    if v1 not in cntMap:
        cntMap[v1] = 1
    else:
        cntMap[v1] += 1

for i in range(n-1):
    v1, v2 = map(int, input().split())
    addCount(v1)
    addCount(v2)
    ab.append([v1, v2])
    nodeAidx = v1-1
    nodeBidx = v2-1
    nodeA = None
    nodeB = None
    if nodes[nodeAidx] is None:
        nodeA = Node(v1)
        nodes[nodeAidx] = nodeA
    else:
        nodeA = nodes[nodeAidx]
    if nodes[nodeBidx] is None:
        nodeB = Node(v2)
        nodes[nodeBidx] = nodeB
    else:
        nodeB = nodes[nodeBidx]
    nodeA.adj.append(nodeB)

#print(ab)
#print(nodes)
root = nodes[0]
nodes[1].pec = 1
q = deque()
q.append(root)

temp = list(cntMap.values())
temp.sort()
maxV = temp[-1]
used = set()
edgeMap = {}

print(maxV)

while q:
    used.clear()
    node = q.popleft()
    pec = node.pec
    used.add(pec)
    prev = 0

    for i in range(len(node.adj)):
        a = node.adj[i]
        for j in range(prev+1, maxV+1):
            if j not in used:
                a.pec = j
                used.add(j)
                prev = j
                break

        edgeMap[(node.val, a.val)] = a.pec
        q.append(a)

for i in range(n-1):
    key = (ab[i][0], ab[i][1])
    print(edgeMap[key])
Buggy python submission (verdict: Runtime Error):
import sys
x, y = map(int, input().split())
#dp = [[0] * (y+1) for _ in range(x+1)]
#dp = [[0] * (x*2+1) for _ in range(x+1)]
dp = [[0] * (y+1) for _ in range(x+1)]
div = 10**9+7

if (x + y) % 3 != 0:
    print(0)
    sys.exit()

if y > 2 * x or y < x / 2:
    print(0)
    sys.exit()

dp[0][0] = 1
dp[2][1] = 1
dp[1][2] = 1

#print(dp)

for i in range(2, x+1):
    #for j in range(i // 2, 2 * i + 1):
    for j in range(i // 2, y+1):
        #print(i, j)
        # if j > y:
        #     break
        if (i + j) % 3 != 0:
            continue
        if y == x / 2:
            dp[i][j] = dp[i-2][j-1] % div
        elif y == 2 * x:
            dp[i][j] = dp[i-1][j-2] % div
        else:
            #print('merge!', dp[i-1][j-2], dp[i-2][j-1])
            dp[i][j] = (dp[i-1][j-2] + dp[i-2][j-1]) % div

#print(dp)
print(dp[x][y])

Fixed submission:
import math
import sys
sys.setrecursionlimit(10**5)
x, y = map(int, input().split())
mod = 10**9+7

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if (x + y) % 3 != 0:
    print(0)
    sys.exit()

if y > 2 * x or y < x / 2:
    print(0)
    sys.exit()

cnt = (x + y) // 3
# p = cnt // 2
p = (2 * x - y) // 3
#print(cnt, p)

# Calclate cntCp
comb = Combination(1000000)
ans = comb(cnt, p)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
p = [k]*n
a = []
ans = ['No'] * n

for i in range(q):
    a.append(int(input()))

for i in range(len(a)):
    idx = a[i] - 1
    for j in range(len(p)):
        if j != idx:
            p[j] = p[j] - 1


for i in range(len(p)):
    if p[i] > 0:
        ans[i] = 'Yes'

# print(p)
# print(a)
# print(ans)

for i in range(len(ans)):
    print(ans[i])

Fixed submission:
n, k, q = map(int, input().split())
p = [k]*n
a = []
ans = ['No'] * n
counts = {}

for i in range(q):
    a.append(int(input()))

for i in range(len(a)):
    key = a[i]
    if key in counts:
        counts[key] += 1
    else:
        counts[key] = 1

for key, value in counts.items():
    idx = key - 1
    p[idx] += value

#print('p: ' + str(p))
for i in range(len(p)):
    p[i] -= q

for i in range(len(p)):
    if p[i] > 0:
        ans[i] = 'Yes'

# print('counts: ' + str(counts))
# print('p: ' + str(p))
# print(a)
# print(ans)

for i in range(len(ans)):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = []

ans = 0
for i in range(n):
    ans += i

print(ans)

Fixed submission:
import sys

n = int(input())

if n == 2:
    print(1)
    sys.exit()

# temp1 = (n-1) // 2
# temp2 = 2 + n - 2
#ans = ((n-1) / 2) * (2 + (n - 2))
ans = (n-1) * (2 + (n - 2))
ans = ans // 2
#ans = temp1 * temp2

#print(ans)
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = []
#p.append(n)

for i in range(2, n+1):
    p.append(i)
p.append(1)

#print(p)
ans = 0

for i in range(1, n+1):
    # print("\n #i: " + str(i))
    # print("#p[i-1]: " + str(p[i-1]))
#    print(i % p[i-1])
    ans += i % p[i-1]

print(ans)


Fixed submission:
import sys

n = int(input())

if n == 2:
    print(1)
    sys.exit()

# temp1 = (n-1) // 2
# temp2 = 2 + n - 2
#ans = ((n-1) / 2) * (2 + (n - 2))
ans = (n-1) * (2 + (n - 2))
ans = ans // 2
#ans = temp1 * temp2

#print(ans)
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
s = []
textSet = set()
ans = 0

for i in range(n):
    s.append(''.join(sorted(input())))

s.sort()

# print(s)
cnt = 0

for i in range(1, n):
    if s[i] == s[i-1]:
        cnt += 1
    elif cnt > 0:
        # ans += cntC2
        ans += len(list(itertools.combinations(range(cnt+1), 2)))
        cnt = 0

if cnt > 0:
    ans += len(list(itertools.combinations(range(cnt + 1), 2)))

print(ans)

Fixed submission:
import itertools

n = int(input())
s = []
textSet = set()
ans = 0

for i in range(n):
    s.append(''.join(sorted(input())))

s.sort()

# print(s)
cnt = 0

for i in range(1, n):
    if s[i] == s[i-1]:
        cnt += 1
    elif cnt > 0:
        # ans += cntC2
        # ans += len(list(itertools.combinations(range(cnt+1), 2)))
        ans += (cnt + 1) * cnt // 2
        cnt = 0

if cnt > 0:
    # ans += len(list(itertools.combinations(range(cnt + 1), 2)))
    ans += (cnt + 1) * cnt // 2

print(ans)

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

for i in range(n):
    s.append(input())

for i in range(n):
    temp = []
    for j in range(len(s[i])):
        temp.append(s[i][j])

    ans.append(''.join(sorted(temp)))

#ans.sort()
temp = ans[0]

# if ans.count(temp) == 1:
#     count = 0
# else:
#     count = ans.count(temp)
count = 0
setV = set()

for i in range(n):
    if ans.count(ans[i]) > 1:
        if ans[i] in setV:
            continue
        else:
            num = ans.count(ans[i])
            count += (num * (num-1))/2
            setV.add(ans[i])

print(int(count))


Fixed submission:
import itertools

n = int(input())
s = []
textSet = set()
ans = 0

for i in range(n):
    s.append(''.join(sorted(input())))

s.sort()

# print(s)
cnt = 0

for i in range(1, n):
    if s[i] == s[i-1]:
        cnt += 1
    elif cnt > 0:
        # ans += cntC2
        # ans += len(list(itertools.combinations(range(cnt+1), 2)))
        ans += (cnt + 1) * cnt // 2
        cnt = 0

if cnt > 0:
    # ans += len(list(itertools.combinations(range(cnt + 1), 2)))
    ans += (cnt + 1) * cnt // 2

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

print(max(0, c - (a - b)))



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

print(max(0, c - (a - b)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0] * n
#dp = []

for i in range(n):
    a[i] = int(input())

maxV = max(a)

for i in range(n):
    if a[i] == maxV:
        new = list(a)
        del new[i]
        print(max(new))
    else:
        print(maxV)


Fixed submission:
n = int(input())
a = [0] * n

for i in range(n):
    a[i] = int(input())

#maxV = max(a)
sortedA = sorted(a)
maxV = sortedA[n-1]
maxV2 = sortedA[n-2]

for i in range(n):
    if a[i] == maxV:
        # new = list(a)
        # del new[i]
        # print(max(new))
        print(maxV2)
    else:
        print(maxV)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0] * n

for i in range(n):
    a[i] = int(input())

for i in range(n):
    new = list(a)
    del new[i]
    print(max(new))


Fixed submission:
n = int(input())
a = [0] * n

for i in range(n):
    a[i] = int(input())

#maxV = max(a)
sortedA = sorted(a)
maxV = sortedA[n-1]
maxV2 = sortedA[n-2]

for i in range(n):
    if a[i] == maxV:
        # new = list(a)
        # del new[i]
        # print(max(new))
        print(maxV2)
    else:
        print(maxV)
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())
dp = []

for i in range(l, r):
    for j in range(i+1, r+1):
        dp.append(i * j % 2019)

dp.sort()
print(dp[0])



Fixed submission:
import sys

l, r = map(int, input().split())
#dp = []
min = 1000000000000000000

if l <= 2019 < r:
    print(0)
    sys.exit()

for i in range(l, r):
    for j in range(i+1, r+1):
        ans = i * j % 2019
        if ans < min:
            min = ans

        if min == 0:
            print(0)
            sys.exit()

#        dp.append(i * j % 2019)
#        dp.append(i * j % 18)

#dp.sort()
#print(dp[0])
print(min)