Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+5;
int mod = 1e9+7;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n;
       cin>>n;
       unordered_map<int,int> mp;
       int arr[n];
       rep(i,0,n)
       cin>>arr[i];
       rep(i,0,n)
       {
           int ct = 0;
           int x = arr[i];
           for(int i=2;i*i<=x;++i)
           {

               if(x%i==0)
               {
                  ct = 0;
                 while(x%i==0)
                 {
                     ct++;
                     x/=i;
                 }
                 mp[i]= max(mp[i],ct);mp[i]= max(mp[i],ct);
               }

           }
           if(x!=1)
            mp[x] = max(mp[x],1LL);
       }
       int lcm = 1;
       for(auto x:mp)
        lcm = (lcm*powmod(x.ff,x.ss))%mod;
        int ans = 0;
        rep(i,0,n)
       {
           ans = (ans + (lcm*powmod(arr[i],mod-2))%mod)%mod;
       }
        cout<<ans<<el;
    }


        return 0;
    }


Fixed submission:
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)
def lcm(arr):
  ans = 1
  for i in arr:
    ans = (ans*i)//gcd(ans,i)
  return ans
n = int(input())
arr = list(map(int,input().split())) #list(map(int, input().split()))
l = lcm(arr)
ans = 0;
for i in arr:
  ans+= l//i
print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
a =input()
b =input()
c =input()
d =input()

if c <= a <= d or c >= b <= d:
  print("Yes")
else:
  print("No")



  

Fixed submission:
n = int(input())
s = "ACL"
print(s*n)

Buggy python submission (verdict: Runtime Error):
a =input()
b =input()
c =input()
d =input()

if a >= c and a <= d or b >= c and b <= d:
  print("Yes")
else:
  print("No")




Fixed submission:
n = int(input())
s = "ACL"
print(s*n)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if a >= c and a <= d or b >= c and b <= d:
  print("Yes")
else:
  print("No")




Fixed submission:
n = int(input())
s = "ACL"
print(s*n)
Buggy python submission (verdict: Runtime Error):
n=input()
print(n[3]+n[4]+n[5])


Fixed submission:
n=input()
print('ABC'+n)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().sploit())

print('YES' if b-a==c-b else 'NO')


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

print('YES' if b-a==c-b else 'NO')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,inpput().split())

if a+b>24:
    print((a+b)-24)
else:
    print(a+b)


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

if a+b>=24:
    print((a+b)-24)
else:
    print(a+b)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import collections
import math
import sys
sys.setrecursionlimit(2000000)
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
data = [i for i in range(n)]

for i, j in itertools.combinations(data, 2):
    ans += (a[i] % mod)*(a[j] % mod) % mod

ans %= mod
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
total = sum(a)
for i in range(n):
    total -= a[i]
    ans += a[i]*total
    ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += (a[i] % mod)*(a[j] % mod) % mod

ans %= mod
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
total = sum(a)
for i in range(n):
    total -= a[i]
    ans += a[i]*total
    ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += a[i]*a[j] % mod

ans %= mod
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
total = sum(a)
for i in range(n):
    total -= a[i]
    ans += a[i]*total
    ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
data = [list(map(int, input().split())) for i in range(n)]
def dist(x, y):
    return math.sqrt(x**2 + y**2)
count = 0
for i in range(n):
    dis = dist(data[i][0], data[i][1])
    if dis <= d:
        count += 1

print(count)


Fixed submission:
import math
n, d = list(map(int, input().split()))
data = [list(map(int, input().split())) for i in range(n)]
def dist(x, y):
    return math.sqrt(x**2 + y**2)


count = 0
for i in range(n):
    dis = dist(data[i][0], data[i][1])
    if dis <= d:
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
a = str(input())
oomoji = ["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
komoji = ["abcdefghijklmnopqrstuvwxyz"]

if a.isupper():
    print("A")
else:
    print("a"a)


Fixed submission:
a = str(input())
oomoji = ["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
komoji = ["abcdefghijklmnopqrstuvwxyz"]

if a.isupper():
    print("A")
else:
    print("a")
Buggy python submission (verdict: Runtime Error):
n = int(input())
# w = list(map(int, input().split()))
#n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
q = int(input())
#p = list(map(int, input().split()))
#a = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
bc = [list(map(int, input().split())) for i in range(q)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
a_count = collections.Counter(a)
a_list = dict(list(a_count.items()))
#print(a_list)
total = sum(a)
for b, c in bc:
    if b in a_list:
        total += (c-b)*a_list[b]
        num = a_list[b]
        a_list[b] = 0
        if c in a_list:
            a_list[c] += num
        else:
            a_list[c] = num
            
    print(total)


Fixed submission:
import collections
n = int(input())
# w = list(map(int, input().split()))
#n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
q = int(input())
#p = list(map(int, input().split()))
#a = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
bc = [list(map(int, input().split())) for i in range(q)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
a_count = collections.Counter(a)
a_list = dict(list(a_count.items()))
#print(a_list)
total = sum(a)
for b, c in bc:
    if b in a_list:
        total += (c-b)*a_list[b]
        num = a_list[b]
        a_list[b] = 0
        if c in a_list:
            a_list[c] += num
        else:
            a_list[c] = num
            
    print(total)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
# h1, m1, h2, m2, k = list(map(int, input().split()))
#a, b = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
#p = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# py = [list(map(int, input().split())) for i in range(m)]
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
    # print(ans)
    if ans > 1000000000000000000 and not(0 in a):
        print(-1)
        exit()
print(ans)


Fixed submission:
n = int(input())
# h1, m1, h2, m2, k = list(map(int, input().split()))
#a, b = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
#p = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# py = [list(map(int, input().split())) for i in range(m)]
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        # print(ans)
        if ans > 1000000000000000000:
            print(-1)
            exit()
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
# h1, m1, h2, m2, k = list(map(int, input().split()))
#a, b = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
#p = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# py = [list(map(int, input().split())) for i in range(m)]
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
    # print(ans)
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)


Fixed submission:
n = int(input())
# h1, m1, h2, m2, k = list(map(int, input().split()))
#a, b = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
#p = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# py = [list(map(int, input().split())) for i in range(m)]
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        # print(ans)
        if ans > 1000000000000000000:
            print(-1)
            exit()
    print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
# a = list(map(int, input().split()))
# ab = [list(map(int, input().split())) for i in range(n)]
# n = int(input())
# n, m = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
room = [[] for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    room[a-1].append(b-1)
    room[b-1].append(a-1)


def search(i):
    q = deque()
    q.append(i)
    while q:
        x = q.popleft()
        if 0 in room[x]:
            return x
        else:
            for i in range(len(room[x])):
                q.append(room[x][i])


print("Yes")
for i in range(1, n):
    if 0 in room[i]:
        print(1)
    else:
        a = search(i)
        print(a+1)


Fixed submission:
from collections import deque
# from math import factorial
import itertools
import collections
import math
import sys
sys.setrecursionlimit(2000000)
n, m = list(map(int, input().split()))
room = [[] for i in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    room[a-1].append(b-1)
    room[b-1].append(a-1)

ans = [-1]*n


def bfs(i):
    q = deque()
    q.append(i)
    while q:
        x = q.popleft()
        for i in range(len(room[x])):
            if ans[room[x][i]] == -1:
                q.append(room[x][i])
                ans[room[x][i]] = x
    return


bfs(0)
print("Yes")
for i in range(1, n):
    print(ans[i]+1)
Buggy python submission (verdict: Runtime Error):
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a = [aa-1 for aa in a]
check = [0 for i in range(n)]

count = 0
point = 0
check[0] = 1
path = [0]
for i in range(min(n, k)):
    if i == 0 or check[point] == 0:
        check[point] = 1
        point = a[point]
        path.append(point)
    else:
        break

for i in range(len(path)):
    if path[i] == point:
        break
    else:
        count += 1

k -= count
p = k % (len(path)-count-1)

for i in range(p):
    point = a[point]
  
print(point+1)


Fixed submission:
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a = [aa-1 for aa in a]
check = [0 for i in range(n)]

count = 0
point = 0
check[0] = 1
path = [0]
for i in range(min(n, k)):
    if i == 0 or check[point] == 0:
        check[point] = i+1
        point = a[point]
        path.append(point)
    else:
        break


cycle_len = len(path)-check[point]
pre = check[point]
if pre > k:
    print(path[k])
else:
    k -= pre
    k %= cycle_len
    print(path[pre+k]+1)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
#n, k = list(map(int, input().split()))
# a, b, c = list(map(int, input().split()))
#a = 0
#b = 0
for a in range(0, x+1):
    for b in range(0, x+1):
        if pow(a, 5)-pow(b, 5) == x:
            print(a, end=" ")
            print(b)
            exit()
        elif pow(a, 5)-pow(b*-1, 5) == x:
            print(a, end=" ")
            print(b*-1)
            exit()


Fixed submission:
x = int(input())
#n, k = list(map(int, input().split()))
# a, b, c = list(map(int, input().split()))
#a = 0
#b = 0
for a in range(0, 1000):
    for b in range(0, 1000):
        if pow(a, 5)-pow(b, 5) == x:
            print(a, end=" ")
            print(b)
            exit()
        elif pow(a, 5)-pow(b*-1, 5) == x:
            print(a, end=" ")
            print(b*-1)
            exit()
        elif pow(-1*a, 5)-pow(b, 5) == x:
            print(-1*a, end=" ")
            print(b*-1)
            exit()
        elif pow(-1*a, 5)-pow(b*-1, 5) == x:
            print(-1*a, end=" ")
            print(b*-1)
            exit()

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
sys.setrecursionlimit(2000000)
# import itertools
# import statistics
# import numpy as np
x = int(input())
#n, k = list(map(int, input().split()))
# a, b, c = list(map(int, input().split()))
#a = 0
#b = 0
for b in range(0, x+1):
    for a in range(0, x+1):
        if pow(a, 5)-pow(b, 5) == x:
            print(a, end=" ")
            print(b)
            exit()
        elif pow(a, 5)-pow(b*-1, 5) == x:
            print(a, end=" ")
            print(b*-1)
            exit()
        elif pow(a, 5)-pow(b*-1, 5) > x or pow(a, 5)-pow(b*-1, 5) < 0:
            break


Fixed submission:
x = int(input())
#n, k = list(map(int, input().split()))
# a, b, c = list(map(int, input().split()))
#a = 0
#b = 0
for a in range(0, 1000):
    for b in range(0, 1000):
        if pow(a, 5)-pow(b, 5) == x:
            print(a, end=" ")
            print(b)
            exit()
        elif pow(a, 5)-pow(b*-1, 5) == x:
            print(a, end=" ")
            print(b*-1)
            exit()
        elif pow(-1*a, 5)-pow(b, 5) == x:
            print(-1*a, end=" ")
            print(b*-1)
            exit()
        elif pow(-1*a, 5)-pow(b*-1, 5) == x:
            print(-1*a, end=" ")
            print(b*-1)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
if int(s) < 2019:
    print(0)
else:
    ruiseki = [0]*(len(s)+1)
    a = 0
    for i in range(len(s)):
        t = int(s[i])
        ruiseki[i+1] = a+t
        a = ruiseki[i+1]

    count = 0
    for i in range(n-3):
        for j in range(i+4, n+1):
            b = ruiseki[j]-ruiseki[i]
            if b % 3 == 0:
                c = int(s[i:j])
                if c % 2019 == 0:
                    count += 1
                    # print(s[i:j])

    # print(ruiseki)
    # print(n)
    print(count)


Fixed submission:
s = input()
ans = 0
# 2019までの余りの分布
U = [0 for i in range(2019)]
mod = 2019
sum_i_to_n = 0
for i in range(len(s)-1, -1, -1):
    # 後ろから見てく
    sum_i_to_n += int(s[i]) * pow(10, len(s)-i-1, mod)
    sum_i_to_n %= mod
    if sum_i_to_n % mod == 0:
        # 2019で割り切れたら
        ans += 1
    # 1817181712114と81712114はあまりが同じ。
    # 二つの差の1817100000000は2019の倍数よって18171も2019の倍数
    ans += U[sum_i_to_n]
    U[sum_i_to_n] += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
#n, m = list(map(int, input().split()))
a = list(map(int, input().split()))

for i in range(n):
    print(a.count(i+1))


Fixed submission:
n = int(input())
#n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
count = [0]*n
for i in range(n-1):
    count[a[i]-1] += 1

for i in range(n):
    print(count[i])
Buggy python submission (verdict: Runtime Error):
k = int(input())
#n, k = list(map(int, input().split()))
#a = list(map(int, input().split()))
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
for i in range(k):
    x = q.popleft()
    a = 10*x+(x % 10)
    if x % 10 != 0:
        q.append(a-1)
    q.append(a)
    if x % 10 != 9:
        q.append(a+1)

print(x)

Fixed submission:
from collections import deque
k = int(input())
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
for i in range(k):
    x = q.popleft()
    a = 10*x+(x % 10)
    if x % 10 != 0:
        q.append(a-1)
    q.append(a)
    if x % 10 != 9:
        q.append(a+1)

print(x)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import itertools
n = int(input())
#n, d = list(input().split())
A = list(map(int, input().split()))
check = [0]
for i in range(n):
    if A[i] in check:
        print("NO")
        exit()
    
    check.append(A[i])

print("YES")


Fixed submission:
import math
import itertools
n = int(input())
#n, d = list(input().split())
A = list(map(int, input().split()))
A.sort()
for i in range(n-1):
    if A[i]==A[i+1]:
        print("NO")
        exit()

print("YES")
Buggy python submission (verdict: Runtime Error):
import math
import itertools
#n = int(input())
#n, d = list(input().split())
n, k= list(map(int, input().split()))
p = list(map(int, input().split()))
point = []
rui = []

def s(n):
    if(n==1):
        return 1
    else:
        return n+s(n-1)


#for は一重まで
for i in range(n):
    point.append(s(p[i])/p[i])
    if i==0:
        rui.append(point[0])
    else:
        rui.append(rui[i-1]+point[i])


m = 0
a = 0
for i in range(n-k+1):
    if i==0:
        a = rui[i+k-1]
    else:
        a = rui[i+k-1]-rui[i-1]
    
   # print(a)
    if a > m:
        m = a



#print(point)
#print(rui)
print(m)


Fixed submission:
import math
import itertools
#n = int(input())
#n, d = list(input().split())
n, k= list(map(int, input().split()))
p = list(map(int, input().split()))
point = []
rui = []

def s(n):
    if(n==1):
        return 1
    else:
        return (n*(n+1))/2


#for は一重まで
for i in range(n):
    point.append(s(p[i])/p[i])
    if i==0:
        rui.append(point[0])
    else:
        rui.append(rui[i-1]+point[i])


m = 0
a = 0
for i in range(n-k+1):
    if i==0:
        a = rui[i+k-1]
    else:
        a = rui[i+k-1]-rui[i-1]
    
   # print(a)
    if a > m:
        m = a



#print(point)
#print(rui)
print(m)

Buggy python submission (verdict: Runtime Error):
import math
import itertools
#n = int(input())
#n, d = list(input().split())
n, k= list(map(int, input().split()))
p = list(map(int, input().split()))
point = []
rui = []

def s(n):
    if(n==1):
        return 1
    else:
        return n+s(n-1)


#for は一重まで
for i in range(n):
    point.append(s(p[i])/p[i])
    if i==0:
        rui.append(point[0])
    else:
        rui.append(rui[i-1]+point[i])


m = 0
a = 0
for i in range(n-k+1):
    if i==0:
        a = rui[i+k-1]
    else:
        a = rui[i+k-1]-rui[i-1]
    
    print(a)
    if a > m:
        m = a



#print(point)
#print(rui)
print(m)


Fixed submission:
import math
import itertools
#n = int(input())
#n, d = list(input().split())
n, k= list(map(int, input().split()))
p = list(map(int, input().split()))
point = []
rui = []

def s(n):
    if(n==1):
        return 1
    else:
        return (n*(n+1))/2


#for は一重まで
for i in range(n):
    point.append(s(p[i])/p[i])
    if i==0:
        rui.append(point[0])
    else:
        rui.append(rui[i-1]+point[i])


m = 0
a = 0
for i in range(n-k+1):
    if i==0:
        a = rui[i+k-1]
    else:
        a = rui[i+k-1]-rui[i-1]
    
   # print(a)
    if a > m:
        m = a



#print(point)
#print(rui)
print(m)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))

count = 0
for i in range(N-1):
    if i+1 != a[i]:
        del a[i]
        count += 1

ans = True
for i in range(int(len(a))-1):
    if i+1!=a[i]:
        ans = False

if ans:
    print(count)
else:
    print(-1)


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


count = 0
c = 1

for i in range(N):
    #print(a)
    if c != a[i]:
       # del a[i]
        count += 1
    else:
        c+=1

#print(c-1)
#print(count)
#print(len(a)-count)
if c-1==0 and count > 1:
    print(-1)
else:
    print(count)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())

if A <= 9 and B <= 9:
    print(A*B)
else:
    print("-1")


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

if  data[0]<= 9 and data[1] <= 9:
    print(data[0]*data[1])
else:
    print("-1")
Buggy python submission (verdict: Runtime Error):
a, b = list(map(int, input().split()))

if b==1:
    print(0)
else:
    tap = 1
    n = a
    while n < b:
        n -= 1
        n += a
        tap+=1

print(tap)


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

if b==1:
    print(0)
else:
    tap = 1
    n = a
    while n < b:
        n -= 1
        n += a
        tap+=1

    print(tap)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
s_count = []
for i in range(n):
    s = input()
    cnt = collections.Counter(s)
    cnt_list = list(cnt.items())
    c_sorted = sorted(cnt_list)
    s_count.append(c_sorted)
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        if s_count[i] == s_count[j]:
            ans += 1
print(ans)


Fixed submission:
import collections
n = int(input())
#a, b, x = list(map(int, input().split()))
#b = list(map(int, input().split()))
s_dic = {}
ans = 0
for i in range(n):
    s = input()
    s = ''.join(sorted(list(s)))
    if s in s_dic:
        # 辞書のキーで管理
        ans += s_dic[s]
        s_dic[s] += 1
    else:
        s_dic[s] = 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
#a = list(map(int, input().split()))
#b = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(int(input()))

for i in range(n):
    if i==0:
        print(max(a[1:]))
    elif i==n-1:
        print(max(a[:-1]))
    else:
        b = max(a[:i])
        c = max(a[i+1:])
        print(max(b, c))

Fixed submission:
n = int(input())
#a = list(map(int, input().split()))
#b = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(int(input()))

b = sorted(a)
m = max(b)

for i in range(n):
    if a[i]==m:
        print(b[-2])
    else:
        print(m)
Buggy python submission (verdict: Runtime Error):
if r-l >= 2019:  # 2019の倍数がある
    ans = 0
elif r-l >= 673:  # 673の倍数,3の倍数がある
    ans = 0
elif l <= 2019 and 2019 <= r:  # 2019がある
    ans = 0
elif l <= 673 and 673 <= r and r-l >= 3:  # 673があって,3の倍数もある
    ans = 0
elif r-l >= (r % 2019):  # lとrの間に2019の倍数がある
    ans = 0
elif r-l >= (r % 673) and r-l >= 3:  # lとrの間に673の倍数があって,3の倍数もある
    ans = 0
else:
    ans = (l*(l+1)) % 2019

print(ans)

Fixed submission:
l, r = list(map(int, input().split()))
# b = list(map(int, input().split()))
# 2019=3*673
ans = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        if (i*j) % 2019 == 0:
            print(0)
            exit()
        else:
            if (i*j) % 2019 < ans:
                ans = (i*j) % 2019

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
from fractions import gcd
#import math
#import itertools
#import statistics
#import numpy as np
#import collections
#n = int(input())
a, b, c, d = list(map(int, input().split()))
#b = list(map(int, input().split()))

#10 11  13 14 15  17  19 20 21 22 23  25 26 27 28 29 
# 31  33 34 35  37 38 39  
lcm = a*b/gcd(a, b)
diff = b-a+1
d1 = (b//c - a//c)
d2 = (b//d - a//d)
a1 =  int((b//lcm-a//lcm))

print(diff-d1-d2+a1)


Fixed submission:

S = list(input())
count = 0
bad = False

for i in range(len(S)-1):
    if S[i]==S[i+1]:
        bad = True


#print(bad)

if bad:
    print("Bad")
else:
    print("Good")