Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]

sum = 0
ans = []

for b in range(-int(N / 2), int(N / 2)):
    for i in range(N):
        sum += abs(A[i] - (b + i))
    else:
        ans.append(sum)
        sum = 0

print(min(ans))


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

B = [A[i] - (i + 1) for i in range(N)]

B.sort()

b = B[len(B) // 2]

ans = 0

for j in range(N):
    ans += abs(A[j] - (b + j + 1))

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]

sum = 0
ans = []

for b in range(int(-N / 2), int(N / 2)):
    for i in range(N):
        sum += abs(A[i] - (b + i))
    else:
        ans.append(sum)
        sum = 0

print(min(ans))



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

B = [A[i] - (i + 1) for i in range(N)]

B.sort()

b = B[len(B) // 2]

ans = 0

for j in range(N):
    ans += abs(A[j] - (b + j + 1))

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0

while N > 0:
    sum += N % 10
    N = N // 10

if sum % N == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())
sum = 0
a = N
while a > 0:
    sum += a % 10
    a = a // 10

if N % sum == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [str(i) for i in input().split()]
 
print("Three" if len(list(set(s))) == 3 else "Four" if len(list(set(s))) == 4)

Fixed submission:
def abc089_b():
    n = int(input())
    s = [str(i) for i in input().split()]

    return "Three" if len(set(s)) == 3 else "Four"


if __name__ == '__main__':
    print(abc089_b())

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [str(i) for i in input().split()]

print("Three" if len(set(s)) ==3 else "Four" if len(set(s)) == 4)

Fixed submission:
def abc089_b():
    n = int(input())
    s = [str(i) for i in input().split()]

    return "Three" if len(set(s)) == 3 else "Four"


if __name__ == '__main__':
    print(abc089_b())
Buggy python submission (verdict: Runtime Error):
def card_game():
    n = int(input())
    a_li = [int(i) for i in input().split()]
    ans = 0
    turn_switch = True

    li = a_li.sorted()

    for i in li:
        if turn_switch:
            ans += i
            turn_switch = False
        else:
            ans -= i
            turn_switch = True

    return ans


if __name__ == '__main__':
    print(card_game())

Fixed submission:
def card_game():
    n = int(input())
    a_li = [int(i) for i in input().split()]
    ans = 0
    turn_switch = True

    li = sorted(a_li, reverse=True)

    for i in li:
        if turn_switch:
            ans += i
            turn_switch = False
        else:
            ans -= i
            turn_switch = True

    return ans


if __name__ == '__main__':
    print(card_game())
Buggy python submission (verdict: Runtime Error):
def abc086_b():
    a, b = map(str, input().split())

    inpt = a + b

    for i in range(100101):
        if int(inpt) / i == i:
            return "Yes"

    return "No"


if __name__ == '__main__':
    print(abc086_b())

Fixed submission:
def abc086_b():
    a, b = map(str, input().split())

    inpt = a + b

    for i in range(1, 100101):
        if int(inpt) / i == i:
            return "Yes"

    return "No"


if __name__ == '__main__':
    print(abc086_b())

Buggy python submission (verdict: Runtime Error):
def abc086_b():
    a, b = map(str, input().split())
    
    inpt = a + b
    
    for i in range(100101):
        if inpt / i == i:
            return "Yes"

    return "No"


if __name__ == '__main__':
    print(abc086_b())

Fixed submission:
def abc086_b():
    a, b = map(str, input().split())

    inpt = a + b

    for i in range(1, 100101):
        if int(inpt) / i == i:
            return "Yes"

    return "No"


if __name__ == '__main__':
    print(abc086_b())

Buggy python submission (verdict: Runtime Error):
def abc086_b():
    inpt = sum(map(str, input().split()))

    for i in range(100101):
        if inpt / i == i:
            return "Yes"

    return "No"


if __name__ == '__main__':
    print(abc086_b())

Fixed submission:
def abc086_b():
    a, b = map(str, input().split())

    inpt = a + b

    for i in range(1, 100101):
        if int(inpt) / i == i:
            return "Yes"

    return "No"


if __name__ == '__main__':
    print(abc086_b())
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

a = "%d+%d+%d+%d=7" % (A, B, C, D)
b = "%d+%d+%d-%d=7" % (A, B, C, D)
c = "%d+%d-%d+%d=7" % (A, B, C, D)
d = "%d-%d+%d+%d=7" % (A, B, C, D)
e = "%d+%d+%d+%d=7" % (A, B, C, D)
f = "%d-%d+%d-%d=7" % (A, B, C, D)
g = "%d-%d-%d+%d=7" % (A, B, C, D)
h = "%d-%d-%d-%d=7" % (A, B, C, D)

if A + B + C + D == 7:
    print(a)
elif A + B + C - D == 7:
    print(b)
elif A + B - C + D == 7:
    print(c)
elif A - B + C + D == 7:
    print(d)
elif A + B - C - D == 7:
    print(e)
elif A - B + C - D == 7:
    print(f)
elif A - B - C + D == 7:
    print(g)
elif A - B - C - D == 7:
    print(h)



Fixed submission:
inp = str(input())

A = int(inp[0])
B = int(inp[1])
C = int(inp[2])
D = int(inp[3])

a = "%d+%d+%d+%d=7" % (A, B, C, D)
b = "%d+%d+%d-%d=7" % (A, B, C, D)
c = "%d+%d-%d+%d=7" % (A, B, C, D)
d = "%d-%d+%d+%d=7" % (A, B, C, D)
e = "%d+%d-%d-%d=7" % (A, B, C, D)
f = "%d-%d+%d-%d=7" % (A, B, C, D)
g = "%d-%d-%d+%d=7" % (A, B, C, D)
h = "%d-%d-%d-%d=7" % (A, B, C, D)

if A + B + C + D == 7:
    print(a)
elif A + B + C - D == 7:
    print(b)
elif A + B - C + D == 7:
    print(c)
elif A - B + C + D == 7:
    print(d)
elif A + B - C - D == 7:
    print(e)
elif A - B + C - D == 7:
    print(f)
elif A - B - C + D == 7:
    print(g)
elif A - B - C - D == 7:
    print(h)
Buggy python submission (verdict: Runtime Error):
def abc070_b():
    a, b, c, d = map(int, input().split())
    
    if c > b:
        return 0
    
    if c < a < b < d:
        return b - a
    
    if a < c < b < d:
        return b - c
    
    if a < c < d < b:
        return d - c
    
    
if __name__ == '__main__':
    print(abc048_b())

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

    if c <= a < b <= d:
        return b - a

    if a <= c < d <= b:
        return d - c

    if a <= c < b <= d:
        return b - c

    if c <= a < d <= b:
        return d - a

    if b <= c or d <= a:
        return 0


if __name__ == '__main__':
    print(abc070_b())
Buggy python submission (verdict: Runtime Error):
def abc053_b():
    s = str(input())

    start = int(s.index('a'))
    
    for i in range(len(s), 0, -1):
        if s[i] == "z":
            return i - start


if __name__ == '__main__':
    print(abc053_b())

Fixed submission:
def abc053_b():
    s = str(input())

    start = s.index('A')
    end = 0
    for i in range(len(s) - 1, 0, -1):
        if s[i] == "Z":
            return i - start + 1


if __name__ == '__main__':
    print(abc053_b())
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
ans = 0

for x in range(a+1):
  for y in range(a+1):
    for z in range(a+1):
      if x + y + z == b:
        ans += 1

print(ans)

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

for x in range(a+1):
  for y in range(a+1):
    z = b - x - y
    
    if z >= 0 and a >= z:
      ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def abc048_b():
    a_min, b_max, x_cin = map(int, input().split())
    ans = 0
    for i in range(a_min, b_max+1):
        if i % x_cin == 0:
            ans += 1

    return ans


if __name__ == '__main__':
    print(abc048_b())

Fixed submission:
def f(n, x):
    if n == -1: 
      return 0
    else: 
      return n // x + 1
 
a, b, x = map(int, input().split())
print(f(b,x) - f(a-1, x))
Buggy python submission (verdict: Runtime Error):

def abc046_b():
	n, k = map(int, input().split())
    return k * ((k - 1) ** (n - 1))


if __name__ == '__main__':
    print(abc046_b())

Fixed submission:
# -*- coding: utf-8 -*-


def abc046_b():
    n, k = map(int, input().split())
    return k * ((k - 1) ** (n - 1))


if __name__ == '__main__':
    print(abc046_b())
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]

li_ans = []
ans = 0

for j in range(min(a), max(a)):
    for k in a:
        ans += abs(k - j) ** 2
    else:
        li_ans.appned(ans)
        ans = 0

if len(li_ans) == 0:
    print(0)
else:
    print(min(li_ans))


Fixed submission:
N = int(input())

a = [int(i) for i in input().split()]

ans = []
sum = 0

for j in range(min(a), max(a)):
    for num in a:
        sum += (num - j) ** 2
    else:
        ans.append(sum)
        sum = 0

if len(ans) == 0:
    print(0)
else:
    print(min(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]

li_ans = []
ans = 0

for num in (min(a), max(a)):
    for j in range(len(a)):
        ans += abs(a[j] - num) ** 2
    else:
        li_ans.appned(ans)
        ans = 0

if len(li_ans) == 0:
    print(0)
else:
    print(min(li_ans))


Fixed submission:
N = int(input())

a = [int(i) for i in input().split()]

ans = []
sum = 0

for j in range(min(a), max(a)):
    for num in a:
        sum += (num - j) ** 2
    else:
        ans.append(sum)
        sum = 0

if len(ans) == 0:
    print(0)
else:
    print(min(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]

li_ans = []
ans = 0

for num in (min(a), max(a)):
    for j in range(len(a)):
        ans += abs(a[j] - num) ** 2
    else:
        li_ans.appned(ans)
        ans = 0

print(min(li_ans))


Fixed submission:
N = int(input())

a = [int(i) for i in input().split()]

ans = []
sum = 0

for j in range(min(a), max(a)):
    for num in a:
        sum += (num - j) ** 2
    else:
        ans.append(sum)
        sum = 0

if len(ans) == 0:
    print(0)
else:
    print(min(ans))

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

a = [int(i) for i in input().split()]

ans = []
sum = 0

for j in range(min(a), max(a)):
    for num in a:
        sum += (num - j) ** 2
    else:
        ans.append(sum)
        sum = 0

if ans == None:
    ans.appned(0)

print(min(ans))




Fixed submission:
N = int(input())

a = [int(i) for i in input().split()]

ans = []
sum = 0

for j in range(min(a), max(a)):
    for num in a:
        sum += (num - j) ** 2
    else:
        ans.append(sum)
        sum = 0

if len(ans) == 0:
    print(0)
else:
    print(min(ans))

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

a = [int(i) for i in input().split()]

ans = []
sum = 0

for j in range(min(a), max(a)):
    for num in a:
        sum += (num - j) ** 2
    else:
        ans.append(sum)
        sum = 0

print(min(ans))


Fixed submission:
N = int(input())

a = [int(i) for i in input().split()]

ans = []
sum = 0

for j in range(min(a), max(a)):
    for num in a:
        sum += (num - j) ** 2
    else:
        ans.append(sum)
        sum = 0

if len(ans) == 0:
    print(0)
else:
    print(min(ans))
Buggy python submission (verdict: Runtime Error):
price, len_hate_set = map(int, input().split())
hate_set = set([int(i) for i in input().split()])

ans = 0

while True:
    if all(map(lambda x: int(x) in set(range(0, 10)) - hate_set, [int(str(ans)[i]) for i in range(len(str(ans)))])) and ans >= price:
        return ans
    ans += 1


Fixed submission:
def abc042_c():
    price, len_hate_set = map(int, input().split())
    hate_set = set([int(i) for i in input().split()])

    usable_list = list(set(range(0, 10)) - hate_set)

    ans = 0

    while True:
        if all(map(lambda x: int(x) in usable_list, [int(str(ans)[i]) for i in range(len(str(ans)))])) and ans >= price:
            return ans

        ans += 1


if __name__ == '__main__':
    print(abc042_c())

Buggy python submission (verdict: Runtime Error):
price, len_hate_set = map(int, input().split())
hate_set = set([int(i) for i in input().split()])

ans = 0

while True:
    if all(map(lambda x: int(x) in set(range(0, 10)) - hate_set, 
               [int(str(ans)[i]) for i in range(len(str(ans)))])) and ans >= price:
        print ans

    ans += 1

Fixed submission:
def abc042_c():
    price, len_hate_set = map(int, input().split())
    hate_set = set([int(i) for i in input().split()])

    usable_list = list(set(range(0, 10)) - hate_set)

    ans = 0

    while True:
        if all(map(lambda x: int(x) in usable_list, [int(str(ans)[i]) for i in range(len(str(ans)))])) and ans >= price:
            return ans

        ans += 1


if __name__ == '__main__':
    print(abc042_c())
Buggy python submission (verdict: Runtime Error):
import math
n, m = [int(i) for i in input().split()]
p = [0 for i in range(n + 1)]
for _ in range(m):
    p[int(input())] = 1
    
a = []
a.append(1)
if p[1] == 1:
    a.append(0)
else:
    a.append(1)
for i in range(2, n + 1):
    if p[i] == 1:
        a.append(0)
    else:
        a.append((a[i - 2] + a[i - 1]) % 1000000007)
    
print(a[n])

Fixed submission:
p = (int(i) for i in input().split())
p = sorted(p)
print(p[0] + p[1])

Buggy python submission (verdict: Runtime Error):
import math
n, m = [int(i) for i in input().split()]
p = [int(input()) for i in range(m)]

a = []
a.append(1)
if 1 in p:
    a.append(0)
else:
    a.append(1)
for i in range(2, n + 1):
    if i in p:
        a.append(0)
    else:
        a.append((a[i - 2] + a[i - 1]) % 1000000007)
    
print(a[n])

Fixed submission:
p = (int(i) for i in input().split())
p = sorted(p)
print(p[0] + p[1])
Buggy python submission (verdict: Time Limit Exceeded):
import math
n, m = [int(i) for i in input().split()]
p = [int(input()) for i in range(m)]
 
a = []
a.append(1)
if 1 in p:
    a.append(0)
else:
    a.append(1)
for i in range(2, n + 1):
    if i in p:
        a.append(0)
    else:
        a.append((a[i - 2] + a[i - 1]) % 1000000007)
    
print(a[n])

Fixed submission:
import math
n, m = [int(i) for i in input().split()]
p = [0 for i in range(n + 1)]
for _ in range(m):
    p[int(input())] = 1
    
a = []
a.append(1)
if p[1] == 1:
    a.append(0)
else:
    a.append(1)
for i in range(2, n + 1):
    if p[i] == 1:
        a.append(0)
    else:
        a.append((a[i - 2] + a[i - 1]) % 1000000007)
    
print(a[n])

Buggy python submission (verdict: Time Limit Exceeded):
import math
n, m = [int(i) for i in input().split()]
p = [int(input()) for i in range(m)]

a = []
a.append(1)
if 1 in p:
    a.append(0)
else:
    a.append(1)
for i in range(2, n + 1):
    if i in p:
        a.append(0)
    else:
        a.append(a[i - 2] + a[i - 1])
    
print(a[n] % 1000000007)

Fixed submission:
import math
n, m = [int(i) for i in input().split()]
p = [0 for i in range(n + 1)]
for _ in range(m):
    p[int(input())] = 1
    
a = []
a.append(1)
if p[1] == 1:
    a.append(0)
else:
    a.append(1)
for i in range(2, n + 1):
    if p[i] == 1:
        a.append(0)
    else:
        a.append((a[i - 2] + a[i - 1]) % 1000000007)
    
print(a[n])
Buggy python submission (verdict: Runtime Error):
s = input()
left = int(s[:2])
right = int(s[2:])
 
if 1 <= left and left <=12 and 1 <= right and right <= 12:
	print("AMBIGUOUS")
elif 1 <= left and left <= 12:
	print("MMYY")
elif 1 <= rihgt and right <= 12:
	print("YYMM")
else:
	print("NA")

Fixed submission:
s = input()
left = int(s[:2])
right = int(s[2:])
 
if 1 <= left and left <=12 and 1 <= right and right <= 12:
  print("AMBIGUOUS")
elif 1 <= left and left <= 12:
  print("MMYY")
elif 1 <= right and right <= 12:
  print("YYMM")
else:
  print("NA")

Buggy python submission (verdict: Runtime Error):
s = input()
left = int(s[:2])
right = int(s[2:])

if 1 <= left and left <=12 and 1 <= right and right <= 12:
    print("AMBIGUOUS")
elif 1 <= left and left <= 12:
  	print("MMYY")
elif 1 <= rihgt and right <= 12:
  	print("YYMM")
else:
  	print("NA")

Fixed submission:
s = input()
left = int(s[:2])
right = int(s[2:])
 
if 1 <= left and left <=12 and 1 <= right and right <= 12:
  print("AMBIGUOUS")
elif 1 <= left and left <= 12:
  print("MMYY")
elif 1 <= right and right <= 12:
  print("YYMM")
else:
  print("NA")
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, k = map(int, input())
ans = 0

for i in range(1, n):
  if i >= k:
    ans += 1.0 / n
    
  ans += np.power(1 / 2, np.ceil(np.log2(k / i))) / n
  
print(ans)

Fixed submission:
import numpy as np
 
n, k = map(int, input().split())
ans = 0
 
for i in range(1, n + 1):
  if i>= k:
    ans += 1 / n
  else:
    ans += np.power(1 / 2, np.ceil(np.log2(k / i))) / n
    
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, _ = map(int, input().split())
print(a * b / 2)

Fixed submission:
s = int(input())
a = [s]

counter = 2
while True:
    if a[-1] % 2 == 0:
        temp = int(a[-1] / 2)
    else:
        temp = int(3 * a[-1] + 1)
    
    if temp in a:
        break
        
    counter += 1
    a.append(temp)
    
print(counter)
Buggy python submission (verdict: Runtime Error):
number = int(input())
rate = [int(i) for i in input().split()]


# In[7]:

counter = {}
for r in rate:
    if 1 <= r < 400:
        counter["grey"] = counter.get("grey", 0) + 1
    if 400 <= r < 800:
        counter["brown"] = counter.get("brown", 0) + 1
    if 800 <= r < 1200:
        counter["green"] = counter.get("green", 0) + 1
    if 1200 <= r < 1600:
        counter["sky"] = counter.get("sky", 0) + 1
    if 1600 <= r < 2000:
        counter["blue"] = counter.get("blue", 0) + 1
    if 2000 <= r < 2400:
        counter["yellow"] = counter.get("yellow", 0) + 1
    if 2400 <= r < 2800:
        counter["orange"] = counter.get("orange", 0) + 1
    if 2800 <= r < 3200:
        counter["red"] = counter.get("red", 0) + 1
    if 3200 <= r:
        counter["color"] = counter.get("color", 0) + 1

answer = 0
for k, v in counter.items():
    if not v == 0:
        answer += 1
        
if counter.get("color", 0) == 0:
    print(str(answer) + " " + str(answer))
else:
    if answer == 1:
        print("1 " + str(counter["color"]))
    else:
        print(str(answer-1) + " " + str(answer-1+counter["color"]))


Fixed submission:
numbers = [i for i in input().split()]
number = numbers[0] + numbers[1] + numbers[2]
number = int(number)

if number % 4:
    print("NO")
else:
    print("YES")

Buggy python submission (verdict: Runtime Error):
number = int(input())
rate = [int(i) for i in input().split()]


# In[7]:

counter = {}
for r in rate:
    if 1 <= r < 400:
        counter["grey"] = counter.get("grey", 0) + 1
    if 400 <= r < 800:
        counter["brown"] = counter.get("brown", 0) + 1
    if 800 <= r < 1200:
        counter["green"] = counter.get("green", 0) + 1
    if 1200 <= r < 1600:
        counter["sky"] = counter.get("sky", 0) + 1
    if 1600 <= r < 2000:
        counter["blue"] = counter.get("blue", 0) + 1
    if 2000 <= r < 2400:
        counter["yellow"] = counter.get("yellow", 0) + 1
    if 2400 <= r < 2800:
        counter["orange"] = counter.get("orange", 0) + 1
    if 2800 <= r < 3200:
        counter["red"] = counter.get("red", 0) + 1
    if 3200 <= r:
        counter["color"] = counter.get("color", 0) + 1

answer = 0
for k, v in counter.items():
    if not v == 0:
        answer += 1
        
if counter.get("color", 0) == 0:
    if answer == 1:
        print("1 " + str(counter["colors"]))
    else:
        print(str(answer) + " " + str(answer))
else:
    print(str(answer-1) + " " + str(answer-1+counter["color"]))


Fixed submission:
numbers = [i for i in input().split()]
number = numbers[0] + numbers[1] + numbers[2]
number = int(number)

if number % 4:
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int, input().split())

ans = "IMPOSSIBLE"

if a < b:
  for i in range(a, b):
    if abs(a-i) == abs(b-i):
      ans = str(i)
      break
else:
  for i in range(b, a):
    if abs(a-i) == abs(b-i):
      ans = str(i)
      break
  
print(ans)

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

kari = (a + b) /2

if (a + b ) % 2 != 0:
  print('IMPOSSIBLE')
else:
  print(int((a+b)/2))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for _ in range(n):
  a.append(int(input()))

b = sorted(a)
maxnum = b[-1]
nextmaxnum = b[-2]

if maxnum == nextmaxnum:
  for i in range(n):
    print(maxnum)
else:
  for i in range(n):
    if a.pop(i) == maxnum:
      print(nextmaxnum)
    else:
      print(maxnum)

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

b = sorted(a)
maxnum = b[-1]
nextmaxnum = b[-2]

if maxnum == nextmaxnum:
  for i in range(n):
    print(maxnum)
else:
  for i in range(n):
    if a[i] == maxnum:
      print(nextmaxnum)
    else:
      print(maxnum)

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

maxnum = max(a)

for i in range(n):
  tmp = a.pop(i)
  if tmp == maxnum:
    print(max(a))
  else:
    print(maxnum)
  a.insert(i, tmp)


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

b = sorted(a)
maxnum = b[-1]
nextmaxnum = b[-2]

if maxnum == nextmaxnum:
  for i in range(n):
    print(maxnum)
else:
  for i in range(n):
    if a[i] == maxnum:
      print(nextmaxnum)
    else:
      print(maxnum)

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

maxnum = max(a)

for i in range(n):
  tmp = a.pop(i)
  if tmp == maxnum:
    print(max(a))
  else:
    print(maxnum)
  a.insert(i, tmp)


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

b = sorted(a)
maxnum = b[-1]
nextmaxnum = b[-2]

if maxnum == nextmaxnum:
  for i in range(n):
    print(maxnum)
else:
  for i in range(n):
    if a[i] == maxnum:
      print(nextmaxnum)
    else:
      print(maxnum)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for _ in range(n):
  a.append(int(input()))
  
for i in range(n):
  tmp = a.pop(i)
  print(max(a))
  a.insert(i, tmp)


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

b = sorted(a)
maxnum = b[-1]
nextmaxnum = b[-2]

if maxnum == nextmaxnum:
  for i in range(n):
    print(maxnum)
else:
  for i in range(n):
    if a[i] == maxnum:
      print(nextmaxnum)
    else:
      print(maxnum)
Buggy python submission (verdict: Runtime Error):
s = input()
listS = list(s)
sortS = listS.sort()

if listS[0] == listS[1] and listS[2] == listS[3]:
  if listS[0] != listS[2]
  	print('Yes')
else:
  print('No')


Fixed submission:
s = input()
listS = list(s)
sortS = listS.sort()
if listS[0] == listS[1] and listS[2] == listS[3]:
  if listS[0] != listS[3]:
    print('Yes')
  else:
    print('No')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int, input().split())
cnt = 0

for i in range(a,b+1):
  if i % c == 0 or i % d == 0:
    continue
  cnt +=1

print(cnt)

Fixed submission:
import fractions
a,b,c,d = map(int, input().split())
bcBaisu = b // c
bdBaisu = b // d
acBaisu = (a -1) // c
adBaisu = (a-1) // d
cdlcm =  c * d // fractions.gcd(c, d)
bcdLcm = b // cdlcm
acdLcm = (a-1) // cdlcm

karib = b - (bcBaisu + bdBaisu -bcdLcm)
karia = a - 1 - (acBaisu + adBaisu - acdLcm)

print(int(karib - karia))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [0] * n
b = [0] * n
task = []

for i in range(n):
  a[i],b[i] = map(int, input().split())
  temp = [a[i],b[i]]
  task.append(temp)
  
task.sort(key=lambda x: x[1])
suma = 0
output = 'Yes'

for i in range(n):
  suma += task[i][0]
  if suma > task[i][i]:
    output = 'No'
    break

print(output)


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

for i in range(n):
  a[i],b[i] = map(int, input().split())
  temp = [a[i],b[i]]
  task.append(temp)
  
task.sort(key=lambda x: x[1])
suma = 0
output = 'Yes'

for i in range(n):
  suma += task[i][0]
  if suma > task[i][1]:
    output = 'No'
    break

print(output)
Buggy python submission (verdict: Runtime Error):
n = int(input())
fukuro = list(map(str,input().split()))
types = 'Three'
for i in range(len(fukuro)):
  if fukuro[i] == 'Y':
    types = 'Four'
    break
print(types)

Fixed submission:
n = int(input())
print(int(n/3))