Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K, N = il()
    A = il()
    A.sort()
    ret = max(A) - min(A)

    for n in range(N - 1):
        mi = min(A)
        tmp = abs(A[n] - mi) + (K - A[n + 1])
        ret = min(ret, tmp)

    print(ret)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K, N = il()
    A = il()
    A.sort()
    ret = max(A) - min(A)

    for n in range(N - 1):
        ret = min(ret, A[n] + (K - A[n + 1]))

    print(ret)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import os
import math


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.buffer.readline().rstrip())
    A = list(map(int, sys.stdin.buffer.readline().split()))
    P = set(A)

    for n in range(N):
        ary = A[n + 1:] + A[:-len(A) + n]
        tmp = 0
        for p in P:
            t = ary.count(p)
            tmp += (t * (t - 1)) // 2

        print(tmp)



if __name__ == '__main__':
    main()


Fixed submission:
import sys
import os

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.buffer.readline().split()))
    even = (N * (N - 1)) // 2
    odd = 0 if M == 1 else (M * (M - 1)) // 2
    print(even + odd)


if __name__ == '__main__':
    main()

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    L = int(sys.stdin.buffer.readline().rstrip())
    print(L ** 3 / 27)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import os

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.buffer.readline().split()))
    even = (N * (N - 1)) // 2
    odd = 0 if M == 1 else (M * (M - 1)) // 2
    print(even + odd)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, A, B = map(int, sys.stdin.readline().split())

    isBlue = True
    ret = []
    for n in range(N):
        for a in range(A):
            if len(ret) == N:
                break
            ret.append('b')

        for b in range(B):
            if len(ret) == N:
                break
            ret.append('r')

        if len(ret) == N:
            break

    print(ret.count('b'))


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, A, B = map(int, sys.stdin.readline().split())

    ret = 0
    cnt = N // (A + B)

    if N % (A + B) == 0:
        print(int(A * cnt))
    elif N < A + B:
        print(min(N, A))
    else:
        ret += A*cnt
        if N - (A+B)*cnt <= A:
            ret += N - (A+B)*cnt
        else:
            ret += A

        print(ret)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, A, B = map(int, sys.stdin.readline().split())

    ret = 0
    tmp = 0
    while True:
        for a in range(A):
            if(tmp == N):
                break
            ret += 1
            tmp += 1

        for b in range(B):
            if(tmp == N):
                break
            tmp += 1

        if (tmp == N):
            break


    print(ret)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, A, B = map(int, sys.stdin.readline().split())

    ret = 0
    cnt = N // (A + B)

    if N % (A + B) == 0:
        print(int(A * cnt))
    elif N < A + B:
        print(min(N, A))
    else:
        ret += A*cnt
        if N - (A+B)*cnt <= A:
            ret += N - (A+B)*cnt
        else:
            ret += A

        print(ret)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import os
import math
import string
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def f(N):
    return sum(map(int, str(N)))


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    SC = [il() for _ in range(M)]
    ret = [0] * N
    for s, c in SC:
        if ret[s - 1] == 0 or ret[s - 1] == c:
            ret[s - 1] = c
        else:
            print(-1)
            exit()
    else:
        q = ''.join(map(str, ret))
        print(q if q[0] != str(0) and len(q) == N else -1)


if __name__ == '__main__':
    main()


Fixed submission:
a = input()
n, mod = divmod(int(a), 2)
print(n if mod == 0 else n + 1)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

        a = int(sys.stdin.readline().rstrip())

    print(int(a // 2 if a % 2 == 0 else a // 2 + 1))


if __name__ == '__main__':
    main()


Fixed submission:
a = input()
n, mod = divmod(int(a), 2)
print(n if mod == 0 else n + 1)

Buggy python submission (verdict: Runtime Error):
a = input()
n, mod = divmod(a, 2)
print(n if mod == 0 else n + 1)

Fixed submission:
a = input()
n, mod = divmod(int(a), 2)
print(n if mod == 0 else n + 1)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

        a = int(sys.stdin.readline().strip())
        n, mod = divmod(a, 2)
    print(n if mod == 0 else n + 1)


if __name__ == '__main__':
    main()


Fixed submission:
a = input()
n, mod = divmod(int(a), 2)
print(n if mod == 0 else n + 1)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

        a = int(sys.stdin.readline().rstrip())
        n, mod = divmod(a, 2)
    print(n if mod == 0 else n + 1)


if __name__ == '__main__':
    main()


Fixed submission:
a = input()
n, mod = divmod(int(a), 2)
print(n if mod == 0 else n + 1)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

        a = int(sys.stdin.readline().rstrip())

    print(a // 2 if a % 2 == 0 else a // 2 + 1)


if __name__ == '__main__':
    main()


Fixed submission:
a = input()
n, mod = divmod(int(a), 2)
print(n if mod == 0 else n + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os
import time

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    key = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
    time.sleep(1.99)
    print(7 - key.index(S))


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    key = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
    print(7 - key.index(S))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())

    ret = float('inf')
    for i in range(1, 10000000):
        q, mod = divmod(N, i)
        if mod == 0:
            j = N // i
            ret = min(ret, ((j-1)+(i-1)))

    print(ret)


if __name__ == '__main__':
    main()

Fixed submission:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    a, b = list(map(int, sys.stdin.readline().split()))
    if a < 10 and b < 10:
        print(a*b)
    else:
        print(-1)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())

    ret = float('inf')
    for i in range(1, 100000000):
        q, mod = divmod(N, i)
        if mod == 0:
            j = N // i
            ret = min(ret, ((j-1)+(i-1)))

    print(ret)


if __name__ == '__main__':
    main()

Fixed submission:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())

    ret = float('inf')
    for i in range(1, 10000000):
        q, mod = divmod(N, i)
        if mod == 0:
            j = N // i
            ret = min(ret, ((j-1)+(i-1)))

    print(ret)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
function Main(input) {
  const step = input.trim().split('');
  const even = ['L', 'U', 'D'];
  const odd = ['R', 'U', 'D'];
  var easy = true;

  for (var i in step) {
    var cnt = i + 1
    if (cnt % 2 == 0) {
      if ( even.indexOf(step[i]) !== -1 ) easy = false;
    } else {
      if ( odd.indexOf(step[i]) !== -1 ) easy = false;
    }
  }

  console.log(easy ? 'Yes':'No')
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Fixed submission:
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    odd = 'RUD'
    even = 'LUD'
    ret = 'Yes'
    for n in range(len(S)):
        if (n + 1) % 2 == 0 and S[n] not in even or (n + 1) % 2 != 0 and S[n] not in odd:
            ret = 'No'
    else:
        print(ret)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
"use strict"

function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0].trim());
  const B = input[1].trim().split(' ').map(Number);

  let cnt = N-2;
  let ret = B[0];
  for(let i=0; i<cnt; i++){
    ret += Math.min(B[i], B[i+1])
  }
  ret += B[cnt];
  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Fixed submission:
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    B = il()
    ret = B[len(B) - 1] + B[0]
    for n in range(N - 2):
        ret += min(B[n+1], B[n])
    print(ret)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
"use strict"

function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0].trim());
  const B = input[1].trim().split(' ').map(Number);
  
  let cnt = N-1;
  let ret = 0;
  let tmp = 0;
  for(let i=0; i<cnt; i++){
    if(i===0){
      ret += B[i];
      tmp = B[i]
      continue;
    } 

    if(tmp < B[i]){
      ret += B[i];
      ret += tmp - B[i];
    } else {
      ret += B[i];
    }
    tmp = B[i];
  }
  ret += tmp;
  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Fixed submission:
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    B = il()
    ret = B[len(B) - 1] + B[0]
    for n in range(N - 2):
        ret += min(B[n+1], B[n])
    print(ret)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os
import math
import bisect
import collections
import itertools

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = [collections.Counter(iss()) for _ in range(N)]

    ret = 0
    for s in S:
        ret += S.count(s) - 1

    print(ret//2)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    lines = ["".join(sorted(line.rstrip())) for line in sys.stdin.readlines()]

    ret = 0
    sortedlines = {}
    for n in range(N):
        item = lines[n]
        if item in sortedlines:
            sortedlines[item] += 1
            ret += sortedlines[item] - 1
        else:
            sortedlines[item] = 1

    print(ret)


if __name__ == '__main__':
    main()

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

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = [''.join(sorted(iss())) for _ in range(N)]
    ret = 0
    for s in S:
        ret += S.count(s) - 1
    print(ret // 2)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    lines = ["".join(sorted(line.rstrip())) for line in sys.stdin.readlines()]

    ret = 0
    sortedlines = {}
    for n in range(N):
        item = lines[n]
        if item in sortedlines:
            sortedlines[item] += 1
            ret += sortedlines[item] - 1
        else:
            sortedlines[item] = 1

    print(ret)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    P = il()
    cnt = 0
    for n in range(N):
        if P[n] != n + 1:
            cnt += 1
        if P[P[n]] != n+1:
            print('NO')
            exit()
    print('NO' if cnt > 3 else 'YES')


if __name__ == '__main__':
    main()


Fixed submission:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    P = il()
    Q = [n+1 for n in range(N)]

    cnt = 0
    for p, q in zip(P, Q):
        if p != q and P[p-1] != q:
            print('NO')
            exit()
        elif p != q:
            cnt += 1
    else:
        if cnt/2 < 2: print('YES')
        else: print('NO')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    A = [int(sys.stdin.readline().rstrip()) for _ in range(N)]

    for n in range(N):
        l = len(A)
        a = A[0:n] if len(A[0:n]) > 0 else [0]
        b = A[n + 1:l] if len(A[n + 1: l]) else [0]
        print(max(max(a), max(b)))


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import os
import copy

def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    A = [int(sys.stdin.readline().rstrip()) for _ in range(N)]
    B = copy.copy(A)
    A.sort(reverse=True)
    f = A[0]
    s = A[1]

    for n in range(N):
        t = B[n]
        if f == t:
            print(s)
        else:
            print(f)


if __name__ == '__main__':
    main()

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    A = [int(sys.stdin.readline().rstrip()) for _ in range(N)]

    for n in range(N):
        ary = copy.copy(A)
        ary.pop(n)
        print(max(ary))


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import os
import copy

def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    A = [int(sys.stdin.readline().rstrip()) for _ in range(N)]
    B = copy.copy(A)
    A.sort(reverse=True)
    f = A[0]
    s = A[1]

    for n in range(N):
        t = B[n]
        if f == t:
            print(s)
        else:
            print(f)


if __name__ == '__main__':
    main()