Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = []
for i in range(n):
    s = input()
    if not s in lst:
        lst.append(s)
print(len(lst))

Fixed submission:
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if not s in dic:
        dic[s] = 1
print(len(dic))
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())

def check(num):
    elems = str(num)
    flag = 0
    for elem1, elem2 in zip(elems[:-1], elems[1:]):
        if abs(ord(elem1) - ord(elem2)) <= 1:
            pass
        else:
            flag = 1
            break
    if flag == 0:
        return num
    else:
        return -1

i = 1
lst = []
while len(lst) < k:
    res = check(i)
    if res != -1:
        lst.append(res)
    i += 1
print(lst[-1])

Fixed submission:
def main():
     k = int(input())

     runrun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
     count = 0
     while(len(runrun) < k):
          target = runrun[count]
          num = target % 10
          if num != 0:
               runrun.append(target * 10 + num - 1)
          runrun.append(target * 10 + num)
          if num != 9:
               runrun.append(target * 10 + num + 1)

          count += 1

     print(runrun[k-1])

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
k, n = [int(elem) for elem in input().split()]
a_lst = [int(elem) for elem in input().split()]

diff = []
for i, a in enumerate(a_lst[:-1]):
    diff.append(a_lst[i+1] - a)
diff.append((a_lst[0] + k) - a_lst[-1])

res = []
for j in range(len(diff)):
    res.append(sum(diff) - diff[j])
print(min(res))

Fixed submission:
k, n = [int(elem) for elem in input().split()]
a_lst = [int(elem) for elem in input().split()]

diff = []
for i, a in enumerate(a_lst[:-1]):
    diff.append(a_lst[i+1] - a)
diff.append((a_lst[0] + k) - a_lst[-1])

res = sum(diff) - max(diff)
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
a_lst = [int(elem) for elem in input().split()]
c = collections.Counter(a_lst)
res1 = 0
for k in c.keys():
  if c[k] > 1:
    res1 += c[k] * (c[k] - 1) // 2

for i in range(n):
  res = res1
  lst = a_lst[:i]+a_lst[i+1:]
  res -= lst.count(a_lst[i])
  print(res)

Fixed submission:
import collections

n = int(input())
a_lst = [int(elem) for elem in input().split()]
c = collections.Counter(a_lst)
res1 = 0
for k in c.keys():
  res1 += c[k] * (c[k] - 1) // 2

for i in range(n):
  res = res1
  res -= c[a_lst[i]] - 1
  print(res)

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

n = int(input())
a_lst = [int(elem) for elem in input().split()]
c = collections.Counter(a_lst)
res1 = 0
for k in c.keys():
  if c[k] > 1:
    res1 += math.factorial(c[k]) // (math.factorial(c[k] - 2) * math.factorial(2))

for i in range(n):
  res = res1
  lst = a_lst[:i]+a_lst[i+1:]
  res -= lst.count(a_lst[i])
  print(res)

Fixed submission:
import collections

n = int(input())
a_lst = [int(elem) for elem in input().split()]
c = collections.Counter(a_lst)
res1 = 0
for k in c.keys():
  res1 += c[k] * (c[k] - 1) // 2

for i in range(n):
  res = res1
  res -= c[a_lst[i]] - 1
  print(res)

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

n = int(input())
a_lst = [int(elem) for elem in input().split()]

for i in range(n):
  res = 0
  lst = a_lst[:i]+a_lst[i+1:]
  c = collections.Counter(lst)
  for k in c.keys():
    if c[k] > 1:
      res += math.factorial(c[k]) // (math.factorial(c[k] - 2) * math.factorial(2))
  print(res)

Fixed submission:
import collections

n = int(input())
a_lst = [int(elem) for elem in input().split()]
c = collections.Counter(a_lst)
res1 = 0
for k in c.keys():
  res1 += c[k] * (c[k] - 1) // 2

for i in range(n):
  res = res1
  res -= c[a_lst[i]] - 1
  print(res)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

cnt = 0
llst = []
rlst = []
for i in range(q):
  line = input()
  if line == '1':
    cnt += 1
  else:
    elems = line.split()
    if cnt % 2 == 0:
      # 指示通り追加
      if elems[1] == '1':
        llst = [elems[2]] + llst
      else:
        rlst.append(elems[2])
    else:
      # 指示の向きと逆に追加
      if elems[1] == '1':
        rlst.append(elems[2])
      else:
        llst = [elems[2]] + llst
        
if cnt % 2 == 0:
  res = ''.join(llst) + s + ''.join(rlst)
  print(res)
else:
  res = ''.join(llst) + s + ''.join(rlst)
  print(res[::-1])

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

cnt = 0
llst = []
rlst = []
for i in range(q):
  line = input()
  if line == '1':
    cnt += 1
  else:
    elems = line.split()
    if cnt % 2 == 0:
      # 指示通り追加
      if elems[1] == '1':
        llst.append(elems[2])
      else:
        rlst.append(elems[2])
    else:
      # 指示の向きと逆に追加
      if elems[1] == '1':
        rlst.append(elems[2])
      else:
        llst.append(elems[2])
        
if cnt % 2 == 0:
  res = ''.join(llst[::-1]) + s + ''.join(rlst)
  print(res)
else:
  res = ''.join(llst[::-1]) + s + ''.join(rlst)
  print(res[::-1])

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

cnt = 0
llst = []
rlst = []
for i in range(q):
  line = input()
  if line == '1':
    cnt += 1
  else:
    elems = line.split()
    if cnt % 2 == 0:
      # 指示通り追加
      if elems[1] == '1':
        llst = [elems[2]] + llst
      else:
        rlst.append(elems[2])
    else:
      # 指示の向きと逆に追加
      if elems[1] == '1':
        rlst.append(elems[2])
      else:
        llst = [elems[2]] + llst
        
if cnt % 2 == 0:
  res = ''.join(llst) + s + ''.join(rlst)
  print(res)
else:
  res = ''.join(llst) + s + ''.join(rlst)
  print(''.join(list(reversed(res))))

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

cnt = 0
llst = []
rlst = []
for i in range(q):
  line = input()
  if line == '1':
    cnt += 1
  else:
    elems = line.split()
    if cnt % 2 == 0:
      # 指示通り追加
      if elems[1] == '1':
        llst.append(elems[2])
      else:
        rlst.append(elems[2])
    else:
      # 指示の向きと逆に追加
      if elems[1] == '1':
        rlst.append(elems[2])
      else:
        llst.append(elems[2])
        
if cnt % 2 == 0:
  res = ''.join(llst[::-1]) + s + ''.join(rlst)
  print(res)
else:
  res = ''.join(llst[::-1]) + s + ''.join(rlst)
  print(res[::-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
xs = [int(elem) for elem in input().split()]

min_ = min(xs)
max_ = max(xs)
result = []
for p in range(min_, max_):
  res = 0
  for x in xs:
    res += (x - p) ** 2
  result.append(res)
print(min(result))

Fixed submission:
n = int(input())
xs = [int(elem) for elem in input().split()]
 
min_ = min(xs)
max_ = max(xs)
result = []
for p in range(min_, max_+1):
  res = 0
  for x in xs:
    res += (x - p) ** 2
  result.append(res)
print(min(result))
Buggy python submission (verdict: Runtime Error):
a, b, c = [int(elem) for elem in input().split()]

if a == b and a != c:
  return "Yes"
if a == c and a != b:
  return "Yes"
if b == c and a != b:
  return "Yes"
else:
  return "No"

Fixed submission:
a, b, c = [int(elem) for elem in input().split()]

if a == b and a != c:
  print("Yes")
elif a == c and a != b:
  print("Yes")
elif b == c and a != b:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n, k = [int(elem) for elem in input().split()]
ps = [int(elem) for elem in input().split()]

exs = []
for p in ps:
  exs.append((1.0+p)/2)
res = [sum(exs[i:i+k]) for i in range(0, n-k)]
print(max(res))

Fixed submission:
n, k = [int(elem) for elem in input().split()]
ps = [int(elem) for elem in input().split()]

sum_max = 0
for i in range(k - 1, n):
    if i == k - 1:
        sum_now = sum(ps[:i + 1])
    else:
        sum_now = sum_now + ps[i] - ps[i - k]
    sum_max = max(sum_max, sum_now)
    
print(float(sum_max + k) / 2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ps  = [int(elem) for elem in input().split()]

res = []
for i, p in enumerate(ps):
  if ps[:i] == []:
    res.append(p)
  else:
    if res[-1] > p:
      res.append(p)
print(len(res))

Fixed submission:
n = int(input())
ps  = [int(elem) for elem in input().split()]

cnt = 0
for i, p in enumerate(ps):
  if i == 0:
    last = p
    cnt += 1
  else:
    if last > p:
      last = p
      cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ps  = [int(elem) for elem in input().split()]

cnt = 0
for i, p in enumerate(ps):
  if ps[:i] == []:
    cnt += 1
  else:
    if min(ps[:i]) > p:
      cnt += 1
print(cnt)

Fixed submission:
n = int(input())
ps  = [int(elem) for elem in input().split()]

cnt = 0
for i, p in enumerate(ps):
  if i == 0:
    last = p
    cnt += 1
  else:
    if last > p:
      last = p
      cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_lst = [int(elem) for elem in input().split()]

def calc(num, lst):
  if num in lst:
    return lst.index(num), lst[lst.index(num)+1:]
  else:
    return len(lst), []

if not 1 in a_lst:
  print(-1)
else:
  num = 1
  res = 0
  while a_lst != []:
    tmp, a_lst = calc(num, a_lst)
    res += tmp
    num += 1
  print(res)

Fixed submission:
input()
nums = list(map(int, input().split()))
 
cnt = 0
cur = 1
 
for i in nums:
    if i == cur:
        cur+=1
    else:
        cnt+=1
if cur == 1:
    print(-1)
else:
    print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())

def func(x):
  if x < 2:
    return 1
  else:
    return x * func(x - 2)
  
tmp = func(n)
res = 0
while tmp % 10 == 0:
  tmp = tmp // 10
  res += 1
print(res)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7

def resolve():
    n = int(input())
    if n % 2 != 0:
        print(0)
        exit()
    L = n // 2
    res = 0
    while L:
        res += L // 5
        L //= 5
    print(res)

if __name__ == '__main__':
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_lst = list(map(int, input().split()))

res = 0
for i in range(n):
  for j in range(i+1, n):
    res += (a_lst[i] ^ a_lst[j])
print(res % (10 ** 9 + 7))

Fixed submission:
import numpy as np
n=int(input())
arr = np.array([int(i) for i in input().split()])
mod = 10**9+7
sm=0

for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    sm += 2 ** i * c1 * (n-c1)
    arr >>= 1

print(sm%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

cand = []
for i in range(1, n):
  if n % i == 0:
    cand.append((i - 1) + (n // i - 1))
print(min(cand))
    

Fixed submission:
import math

n = int(input())

cand = []
for i in range(1, int(math.sqrt(n))+1):
  if n % i == 0:
    cand.append((i - 1) + (n // i - 1))
print(min(cand))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = [int(elem) for elem in input().split()]
ls = sorted(ls)

i = 0
j = len(ls) - 1
k = j - 1
res = []

while i < len(ls) - 1:
    while i < j:
        while i < k:
            if ls[j] - ls[i] < ls[k]:
                res.append((ls[i], ls[j], ls[k]))
                k -= 1
            else:
                break
        j -= 1
        k = j - 1
    i += 1
    j = len(ls) - 1
    k = j - 1
print(len(res))

Fixed submission:
import bisect

n = int(input())
ls = [int(elem) for elem in input().split()]
ls = sorted(ls)

cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        k = bisect.bisect_left(ls, ls[i] + ls[j])
        k -= 1
        cnt += k - j
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = [int(elem) for elem in input().split()]
ls = sorted(ls)

res = 0
for i, elem in enumerate(ls[:-2]):
    for j, elem1 in enumerate(ls[i+1:]):
        for k, elem2 in enumerate(ls[i+j+2:]):
            if elem2 < (elem + elem1):
                res += 1
            else:
                break
print(res)

Fixed submission:
import bisect

n = int(input())
ls = [int(elem) for elem in input().split()]
ls = sorted(ls)

cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        k = bisect.bisect_left(ls, ls[i] + ls[j])
        k -= 1
        cnt += k - j
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = [int(elem) for elem in input().split()]

import itertools

res = 0
cands = itertools.combinations(ls, 3)
for a, b, c in cands:
    if a < (b + c) and b < (c + a) and c < (a + b):
        res += 1
print(res)


Fixed submission:
import bisect

n = int(input())
ls = [int(elem) for elem in input().split()]
ls = sorted(ls)

cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        k = bisect.bisect_left(ls, ls[i] + ls[j])
        k -= 1
        cnt += k - j
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
import math

a, b = [int(elem) for elem in input().split()]

cf = []
for i in range(1, min(a, b)+1):
    if a % i == 0 and b % i == 0:
       cf.append(i)
       
# dest = int(math.sqrt(min(a, b)))
if len(cf) > 1:
    res = [cf[0], cf[1]]
    cf.pop(0)
    cf.pop(0)

    j = 0
    while True:
        if j >= len(cf):
            break
        flag = 0
        for elem in res[1:]:
            if cf == []:
                break
            if gcd(cf[j], elem) != 1:
                cf.pop(j)
                flag = 1
                break
        if flag == 0:
            res.append(cf[j])
            cf.pop(j)
else:
    res = [cf[0]]
print(len(res))

Fixed submission:
a, b = [int(elem) for elem in input().split()]

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

a_lst = factorize(a)
b_lst = factorize(b)
res = list(set(a_lst) & set(b_lst))
print(len(res) + 1)

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
import math

a, b = [int(elem) for elem in input().split()]

cf = []
for i in range(1, min(a, b)+1):
    if a % i == 0 and b % i == 0:
       cf.append(i)

res = [cf[0], cf[1]]
cf.pop(0)
cf.pop(0)

j = 0
while True:
    if j >= len(cf):
        break
    flag = 0
    for elem in res[1:]:
        if cf == []:
            break
        if gcd(cf[j], elem) != 1:
            cf.pop(j)
            flag = 1
            break
    if flag == 0:
        res.append(cf[j])
        cf.pop(j)
print(len(res))

Fixed submission:
a, b = [int(elem) for elem in input().split()]

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

a_lst = factorize(a)
b_lst = factorize(b)
res = list(set(a_lst) & set(b_lst))
print(len(res) + 1)

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

a, b = [int(elem) for elem in input().split()]

cf = []
for i in range(1, min(a, b)+1):
    if a % i == 0 and b % i == 0:
       cf.append(i)

dest = int(math.sqrt(min(a, b))) # cf[-1]
res = [cf[0]]
cf.pop(0)

while True:
    if cf == []:
        break
    num_min = min(cf)
    if num_min >= dest:
        res.extend(cf)
        break
    res.append(num_min)

    j = 0

    while True:
        if j >= len(cf):
            break
        elif cf[j] % num_min == 0:
            cf.pop(j)
        else:
            j += 1
print(len(res))

Fixed submission:
a, b = [int(elem) for elem in input().split()]

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

a_lst = factorize(a)
b_lst = factorize(b)
res = list(set(a_lst) & set(b_lst))
print(len(res) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = [int(elem) for elem in input().split()]

res = [k] * n
for i in range(q):
  a = int(input())
  res = [(elem - 1) for elem in res]
  res[a - 1] += 1

for elem in res:
  if elem > 0:
    print("Yes")
  else:
    print("No")

Fixed submission:
import collections

n, k, q = [int(elem) for elem in input().split()]

a_lst = []
for i in range(q):
  a = int(input())
  a_lst.append(a)

res = [k - q] * n
c = collections.Counter(a_lst)
for k in c.keys():
  res[k - 1] += c[k]

for elem in res:
  if elem > 0:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
if n == 1:
    print(0)
else:
    import numpy as np
    lst = np.array([(elem + 1) for elem in range(n)])
    print(np.sum(lst[:-1]))

Fixed submission:
n = int(input())
if n == 1:
    print(0)
else:
    print(n * (n - 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = [(elem + 1) for elem in range(n)]

if len(lst) == 1:
    print(0)
else:
    print(sum(lst[:-1]))

Fixed submission:
n = int(input())
if n == 1:
    print(0)
else:
    print(n * (n - 1) // 2)
Buggy python submission (verdict: Runtime Error):
n = int(input())

dic = {}
for i in range(n):
  s = ''.join(sorted(list(input())))
  if not s in dic:
    dic[s] = 1
  else:
    dic[s] += 1

res = 0
for v in dic.values():
	if v >= 2:
      res += v*(v-1)
print(res//2)

Fixed submission:
n = int(input())

dic = {}
for i in range(n):
  s = ''.join(sorted(list(input())))
  if not s in dic:
    dic[s] = 1
  else:
    dic[s] += 1

res = 0
for v in dic.values():
  if v >= 2:
    res += v*(v-1)
print(res//2)

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

lst = []
cnt = 0
n = int(input())
for i in range(n):
  s = input()
  c = collections.Counter(s)
  if c in lst:
    cnt += lst.count(c)
  lst.append(c)
print(cnt)

Fixed submission:
n = int(input())

dic = {}
for i in range(n):
  s = ''.join(sorted(list(input())))
  if not s in dic:
    dic[s] = 1
  else:
    dic[s] += 1

res = 0
for v in dic.values():
  if v >= 2:
    res += v*(v-1)
print(res//2)

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

lst = []
n = int(input())
for i in range(n):
  s = input()
  c = collections.Counter(s)
  lst.append(c)

cnt = 0
for i, elem1 in enumerate(lst):
  for elem2 in lst[i+1:]:
    if elem1 == elem2:
      cnt += 1
print(cnt)

Fixed submission:
n = int(input())

dic = {}
for i in range(n):
  s = ''.join(sorted(list(input())))
  if not s in dic:
    dic[s] = 1
  else:
    dic[s] += 1

res = 0
for v in dic.values():
  if v >= 2:
    res += v*(v-1)
print(res//2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
hs = [int(elem) for elem in input().split()]

if n == 1:
  print("Yes")
else:
  flag = 0
  for i, h in enumerate(hs):
    if i == 0:
      pass
    else:
      if hs[i-1] == h + 1:
        hs[i-1] -= 1
      elif hs[i-1] > h + 1:
        flag = 1
        break
      else:
        pass
  
if flag == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
n = int(input())
h = [int(elem) for elem in input().split()]

flg = 0
max = 0
if n > 1 :
  for i in range(n):
    if h[i] > max:
      max = h[i]
    elif h[i] < max-1 :
      flg = 1
      break
 
if flg == 1 :
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
import copy

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

sorted_a_lst = sorted(a_lst)
max_a = sorted_a_lst[-1]

for a in a_lst:
    if a == max_a:
        tmp = copy.copy(a_lst)
        tmp.remove(a)
        tmp = sorted(tmp)
        print(tmp[-1])
    else:
        print(max_a)

Fixed submission:
n = int(input())
a_lst = []
for i in range(n):
    a = int(input())
    a_lst.append(a)

sorted_a_lst = sorted(a_lst)
max_a = sorted_a_lst[-1]

for a in a_lst:
    if a == max_a:
        print(sorted_a_lst[-2])
    else:
        print(max_a)

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

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

sorted_a_lst = sorted(a_lst)
max_a = sorted_a_lst[-1]

for a in a_lst:
    if a == max_a:
        tmp = copy.copy(a_lst)
        tmp.remove(a)
        tmp = sorted(tmp)
        print(tmp[-1])
    else:
        print(max_a)

Fixed submission:
n = int(input())
a_lst = []
for i in range(n):
    a = int(input())
    a_lst.append(a)

sorted_a_lst = sorted(a_lst)
max_a = sorted_a_lst[-1]

for a in a_lst:
    if a == max_a:
        print(sorted_a_lst[-2])
    else:
        print(max_a)

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

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

max_a = max(a_lst)

for a in a_lst:
    if a == max_a:
        tmp = copy.copy(a_lst)
        tmp.remove(a)
        print(max(tmp))
    else:
        print(max_a)

Fixed submission:
n = int(input())
a_lst = []
for i in range(n):
    a = int(input())
    a_lst.append(a)

sorted_a_lst = sorted(a_lst)
max_a = sorted_a_lst[-1]

for a in a_lst:
    if a == max_a:
        print(sorted_a_lst[-2])
    else:
        print(max_a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_lst = []
for i in range(n):
    a = int(input())
    a_lst.append(a)

max_a = max(a_lst)
max_a_id_lst = [i for i, elem in enumerate(a_lst) if elem == max_a]

for i in range(n):
    if i in max_a_id_lst:
        if len(max_a_id_lst) == 1:
            a_lst.remove(max_a)
            print(max(a_lst))
        else:
            print(max_a)
    else:
        print(max_a)

Fixed submission:
n = int(input())
a_lst = []
for i in range(n):
    a = int(input())
    a_lst.append(a)

sorted_a_lst = sorted(a_lst)
max_a = sorted_a_lst[-1]

for a in a_lst:
    if a == max_a:
        print(sorted_a_lst[-2])
    else:
        print(max_a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_lst = []
for i in range(n):
    a = int(input())
    a_lst.append(a)

for i in range(n):
    if i == 0:
        tmp = a_lst[i+1:]
    elif i == n-1:
        tmp = a_lst[:i]
    else:
        tmp = a_lst[:i] + a_lst[i+1:]
    print(max(tmp))

Fixed submission:
n = int(input())
a_lst = []
for i in range(n):
    a = int(input())
    a_lst.append(a)

sorted_a_lst = sorted(a_lst)
max_a = sorted_a_lst[-1]

for a in a_lst:
    if a == max_a:
        print(sorted_a_lst[-2])
    else:
        print(max_a)
Buggy python submission (verdict: Runtime Error):
import math

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

a, b, c, d = [int(elem) for elem in input().split()]
print((b+1 - a) - ((b+1) // c) - ((b+1) // d) + (a // c) + (a // d) + ((b+1) // lcm(c, d)) - (a // lcm(c, d)))

Fixed submission:
import fractions

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

a, b, c, d = [int(elem) for elem in input().split()]

res = (b+1 - a) - ((b) // c) - ((b) // d) + ((a-1) // c) + ((a-1) // d) + ((b) // lcm(c, d)) - ((a-1) // lcm(c, d))
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_lst = []
b_lst = []
sum_lst = []

for i in range(0, n):
    a, b = [int(elem) for elem in input().split()]
    a_lst.append(a)
    b_lst.append(b)

tmp = zip(b_lst, a_lst)
tmp = sorted(tmp)
b_lst, a_lst = zip(*tmp)   

for i in range(0, len(a_lst)):
    sum_lst.append(sum(a_lst[:i+1]))

flag = 0
for a, b in zip(sum_lst, b_lst):
    if a > b:
        flag = 1

if flag == 0:
    print("Yes")
else:
    print("No")

Fixed submission:
n = int(input())
a_lst = []
b_lst = []

for i in range(0, n):
    a, b = [int(elem) for elem in input().split()]
    a_lst.append(a)
    b_lst.append(b)

tmp = zip(b_lst, a_lst)
tmp = sorted(tmp)
b_lst, a_lst = zip(*tmp)   

flag = 0
sums = 0
for i in range(0, len(a_lst)):
    sums += a_lst[i]
    if sums > b_lst[i]:
        flag = 1
        break

if flag == 0:
    print("Yes")
else:
    print("No")