Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
P, Q = [], [0]*(N+1)
for i in range(1,N+1):
    p = int(input())
    P.append(p)
    Q[p] = i
cnt = 1
res = []
for i in range(1,N):
    if Q[i] < Q[i+1]:
        cnt += 1
    else:
        res.append(cnt)
        cnt = 1
print(N-max(res))

Fixed submission:
N = int(input())
P, Q = [], [0]*(N+1)
for i in range(1,N+1):
    p = int(input())
    P.append(p)
    Q[p] = i
Q.append(0)
cnt = 1
res = []
for i in range(1,N+1):
    if Q[i] < Q[i+1]:
        cnt += 1
    else:
        res.append(cnt)
        cnt = 1
if res:
    print(N-max(res))
else:
    print(N)
Buggy python submission (verdict: Runtime Error):
S = input().rstrip()
N = len(S)
K = int(input())
A = set()
if N == 1:
    print(S)
    exit()
for i in range(N-1):
    A.add(S[i:])
A = list(A)
A.sort()
print(A)
cnt, i = 0, 0
while cnt + len(A[i]) < K:
    cnt += len(A[i])
    i += 1
print(A[i][:K-cnt])



Fixed submission:
S = input().rstrip()
N = len(S)
K = int(input())
A = []
for i in range(N):
    A.append(S[i:])
A.sort()
B = set()
flg = False
for i in range(len(A)):
    for j in range(1,len(A[i])+1):
        B.add(A[i][:j])
        if len(B)==K:
            flg = True
            break
    if flg: break
B = list(B)
B.sort()
print(B[-1])
Buggy python submission (verdict: Runtime Error):
a, b, c, x, y = list(map(int, input().split()))
res = a * x + b * y
for i in range(1, max(x, y) + 1):
    res = min(res, a * max(x - i, 0) + b * max(y - i, 0) + 2 * c * i)
print(res)

Fixed submission:
S = input().rstrip()
print(700 + S.count("o")*100)
Buggy python submission (verdict: Runtime Error):
    a, b, c, x, y = list(map(int, input().split()))
    res = a * x + b * y
    for i in range(1, max(x, y) + 1):
        res = min(res, a * max(x - i, 0) + b * max(y - i, 0) + 2 * c * i)
    print(res)

Fixed submission:
a, b, c, x, y = list(map(int, input().split()))
res = a * x + b * y
for i in range(1, max(x, y) + 1):
    res = min(res, a * max(x - i, 0) + b * max(y - i, 0) + 2 * c * i)
print(res)

Buggy python submission (verdict: Runtime Error):
while(True):

    a, b, c, x, y = list(map(int, input().split()))
    res = a * x + b * y
    for i in range(1, max(x, y) + 1):
        res = min(res, a * max(x - i, 0) + b * max(y - i, 0) + 2 * c * i)
    print(res)

Fixed submission:
a, b, c, x, y = list(map(int, input().split()))
res = a * x + b * y
for i in range(1, max(x, y) + 1):
    res = min(res, a * max(x - i, 0) + b * max(y - i, 0) + 2 * c * i)
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc084/tasks/abc084_d

Nmax = 10**6 + 1

def prime_test(n):
    if n == 1:
        return False
    i = 2
    while i*i<=n:
        if n%i:
            i += 1
        else:
            return False
    return True

cum = [0]*Nmax

for n in range(1,Nmax,2):
    if prime_test(n) and prime_test((n + 1)/2):
        cum[n] = cum[n-2] + 1
    else:
        cum[n] = cum[n - 2]

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(cum[r] - cum[l-2])


Fixed submission:
# https://atcoder.jp/contests/abc084/tasks/abc084_d

Nmax = 10**5 + 1

def prime_test(n):
    if n == 1:
        return False
    i = 2
    while i*i<=n:
        if n%i:
            i += 1
        else:
            return False
    return True

cum = [0]*Nmax

for n in range(1,Nmax,2):
    cum[n] = cum[n-2] + (prime_test(n) and prime_test((n + 1)/2))

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(cum[r] - cum[l-2])

Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc084/tasks/abc084_d

Nmax = 10**6 //2 + 1

def prime_test(n):
    i = 2
    while i*i<=n:
        if n%i:
            i += 1
        else:
            return False
    if n == 1:
        return False
    return True

cum = [0]*(Nmax+1)

for n in range(Nmax):
    m = 2*n + 1
    if prime_test(m) and prime_test((m + 1)/2):
        cum[n] = cum[n-1] + 1
    else:
        cum[n] = cum[n-1]

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(cum[r//2] - cum[l//2-1])

Fixed submission:
# https://atcoder.jp/contests/abc084/tasks/abc084_d

Nmax = 10**5 + 1

def prime_test(n):
    if n == 1:
        return False
    i = 2
    while i*i<=n:
        if n%i:
            i += 1
        else:
            return False
    return True

cum = [0]*Nmax

for n in range(1,Nmax,2):
    cum[n] = cum[n-2] + (prime_test(n) and prime_test((n + 1)/2))

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(cum[r] - cum[l-2])

Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc084/tasks/abc084_d

Nmax = 10**6 + 1

def prime_test(n):
    i = 2
    while i*i<=n:
        if n%i:
            i += 1
        else:
            return False
    if n == 1:
        return False
    return True

cum = [0]*Nmax

for n in range(1,Nmax,2):
    cum[n] = cum[n-2] + (prime_test(n) and prime_test((n + 1)/2))

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(cum[r] - cum[l-2])

Fixed submission:
# https://atcoder.jp/contests/abc084/tasks/abc084_d

Nmax = 10**5 + 1

def prime_test(n):
    if n == 1:
        return False
    i = 2
    while i*i<=n:
        if n%i:
            i += 1
        else:
            return False
    return True

cum = [0]*Nmax

for n in range(1,Nmax,2):
    cum[n] = cum[n-2] + (prime_test(n) and prime_test((n + 1)/2))

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(cum[r] - cum[l-2])
Buggy python submission (verdict: Runtime Error):
import sys
from bisect import *
input = sys.stdin.readline
N = int(input())
A = [0] + list(map(int, input().split()))
P = [[] for _ in range(N+1)]
for i in range(1,N+1):
    for j in range(N+1):
        for k in range(N+1):
            P[i].append((A[i]+A[j]+A[k],j,k))
B = [-float("inf")]
res = []
for i in range(1,N+1):
    P[i].sort(key=lambda x:x[0])
    tmp = [p for p, _, _ in P[i]]
    k = bisect_left(tmp,B[-1])
    B.append(P[i][k][0])
    b,c = P[i][k][1], P[i][k][2]
    if b: res.append((b,i))
    if c: res.append((c,i))
print(len(res))
for b, i in res:
    print(b,i)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
mi, ma = min(A), max(A)
print(2*N)
if abs(mi)<=ma:
    k = A.index(ma)
    print(k+1,1)
    print(k+1,1)
    for i in range(N-1):
        print(i+1,i+2)
        print(i+1,i+2)
else:
    k = A.index(mi)
    print(k+1,N)
    print(k+1,N)
    for i in reversed(range(N-1)):
        print(i+2,i+1)
        print(i+2,i+1)

Buggy python submission (verdict: Runtime Error):
import sys
from bisect import *
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
P = [[] for _ in range(N)]
Q = [[] for _ in range(N)]
for i in range(N):
    for j in range(N):
        for k in range(N):
            P[i].append((A[i]+A[j]+A[k],j+1,k+1))
B = [-float("inf")]
print(2*N)
for i in range(N):
    P[i].sort(key=lambda x:x[0])
    tmp = [p for p, _, _ in P[i]]
    k = bisect_left(tmp,B[-1])
    B.append(P[i][k][0])
    b,c = P[i][k][1], P[i][k][2]
    print(b,i+1)
    print(c,i+1)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
mi, ma = min(A), max(A)
print(2*N)
if abs(mi)<=ma:
    k = A.index(ma)
    print(k+1,1)
    print(k+1,1)
    for i in range(N-1):
        print(i+1,i+2)
        print(i+1,i+2)
else:
    k = A.index(mi)
    print(k+1,N)
    print(k+1,N)
    for i in reversed(range(N-1)):
        print(i+2,i+1)
        print(i+2,i+1)
Buggy python submission (verdict: Runtime Error):
from itertools import product
from collections import Counter
N=int(input())
D=list(map(int, input().split()))
print(list(sorted(D)))
res=0
c=Counter(D).values()
if c[0]>0 or max(c)>2:print(0);exit()
if N>13:print(1);exit()
for b in product(*((d,24-d) for d in D)):
    d0, m= 0,1<<30
    for d in sorted(b):
        m=min((d-d0),24-(d-d0),m)
        d0=d
    m=min(d0,24-d0,m)
    res = max(res,m)
print(res)

Fixed submission:
from collections import Counter
import marshal
N = int(input())
D = Counter(list(map(int, input().split())))
P = [[0]]
for i in range(13):
    if D.get(i,0) == 0:
        continue
    if D.get(i,0) == 1:
        Q = marshal.loads(marshal.dumps(P))
        for p in P:
            p.append(i)
        for q in Q:
            q.append(24-i)
        P += Q
    if D.get(i,0) == 2:
        for p in P:
            p.append(i)
            p.append(24-i)
    if D.get(i,0) >= 3:
        print(0)
        exit()
res = 0
for p in P:
    m = float("inf")
    for i in range(len(p)):
        for j in range(i+1,len(p)):
            if abs(p[i]-p[j])>12:
                m = min(24-abs(p[i]-p[j]),m)
            else:
                m = min(abs(p[i]-p[j]),m)
    res = max(m,res)
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc074/tasks/arc083_b

import sys
input = sys.stdin.buffer.readline

def floyd_warshall(V, dist):                                               # 動的計画法。頂点 k まで経由することが可能な場合の最短距離という部分問題を考えて、k = 0 から漸化式的に計算する
    res = 0
    for i in range(V):
        for j in range(i+1,V):
            flg = 0
            for k in range(V):
                if k==i or k==j:
                    continue
                if dist[i][j] > dist[i][k] + dist[k][j]:
                    return -1
                if dist[i][j] < dist[i][k] + dist[k][j]:
                    flg += 1
                if flg == V-2:
                    res += dist[i][j]
    return res

N = int(input())

dist = [list(map(int, input().split())) for _ in range(N)]

if N ==2:
    print(dist[0][1])
else:
    print(floyd_warshall(N, dist))

Fixed submission:
# https://atcoder.jp/contests/abc074/tasks/arc083_b

import sys
input = sys.stdin.buffer.readline

def floyd_warshall(V, dist):                                               # 動的計画法。頂点 k まで経由することが可能な場合の最短距離という部分問題を考えて、k = 0 から漸化式的に計算する
    res = 0
    for i in range(V):
        for j in range(i+1,V):
            flg = 0
            for k in range(V):
                if k==i or k==j:
                    continue
                if dist[i][j] > dist[i][k] + dist[k][j]:
                    return -1
                if dist[i][j] < dist[i][k] + dist[k][j]:
                    flg += 1
                if flg == V-2:
                    res += dist[i][j]
    return res

N = int(input())

dist = [list(map(int, input().split())) for _ in range(N)]

if N ==2:
    print(dist[0][1])
else:
    print(floyd_warshall(N, dist))
Buggy python submission (verdict: Runtime Error):
from bisect import *
N, A, B, C, D = map(int, input().split())
P = [A + (N-1-i)*D - C*i for i in reversed(range(N))]
Q = [A + (N-1-i)*C - D*i for i in reversed(range(N))]
j = bisect_left(P,B)
if B >= Q[j]:
    print("YES")
else:
    print("NO")

Fixed submission:
from bisect import *
N, A, B, C, D = map(int, input().split())
P = [A + (N-1-i)*D - C*i for i in reversed(range(N))]
Q = [A + (N-1-i)*C - D*i for i in reversed(range(N))]
j = bisect_left(P,B)
if j < N and B >= Q[j]:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    ll c = A + B;
    if (c % 2 == 1)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << c / 2 << endl;
    return 0;
}

Fixed submission:
A, B = map(int, input().split())
C = A + B
if C % 2 == 0:
    print(C // 2)
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
f=lambda:map(int,input().split())
N,Q=f()
a,b=N,N
black=(N-2)*(N-2)
B=[-1]*(N+1)
W=[-1]*(N+1)
for _ in range(Q):
    q,x=f()
    if q==1:
        if B[x]>0:
            black-=B[x]
            B[x]=0
        else:
            black-=b-2
            a=x
            for j in range(a+1,N+1):
                if B[j]==-1:
                    B[j]=b-2
                if j==N-1:
                    break
    else:
        if W[x]>0:
            black-=W[x]
            W[x]=0
        else:
            black-=a-2
            b=x
            for j in range(b+1,N+1):
                if W[j]==-1:
                    W[j]=a-2
                else:
                    break
                if j==N-1:
                    break
print(black)

Fixed submission:
f=lambda:map(int,input().split())
N,Q=f()
a,b=N,N
black=(N-2)*(N-2)
B=[-1]*(N+1)
W=[-1]*(N+1)
for _ in range(Q):
    q,x=f()
    if q==1:
        if B[x]>0:
            black-=B[x]
            B[x]=0
        else:
            black-=b-2
            a=x
            for j in range(a+1,N+1):
                if B[j]==-1:
                    B[j]=b-2
                else:
                    break
                if j==N-1:
                    break
    else:
        if W[x]>0:
            black-=W[x]
            W[x]=0
        else:
            black-=a-2
            b=x
            for j in range(b+1,N+1):
                if W[j]==-1:
                    W[j]=a-2
                else:
                    break
                if j==N-1:
                    break
print(black)

Buggy python submission (verdict: Time Limit Exceeded):
f=lambda:map(int,input().split())
N,Q=f()
a,b=N,N
black=(N-2)*(N-2)
B=[-1]*(N+1)
W=[-1]*(N+1)
for _ in range(Q):
    q,x=f()
    if q==1:
        if B[x]>0:
            black-=B[x]
            B[x]=0
        else:
            black-=b-2
            a=x
            for j in range(a+1,N+1):
                if B[j]==-1:
                    B[j]=b-2
                if j==N-1:
                    break
    else:
        if W[x]>0:
            black-=W[x]
            W[x]=0
        else:
            black-=a-2
            b=x
            for j in range(b+1,N+1):
                if W[j]==-1:
                    W[j]=a-2
                if j==N-1:
                    break
print(black)

Fixed submission:
f=lambda:map(int,input().split())
N,Q=f()
a,b=N,N
black=(N-2)*(N-2)
B=[-1]*(N+1)
W=[-1]*(N+1)
for _ in range(Q):
    q,x=f()
    if q==1:
        if B[x]>0:
            black-=B[x]
            B[x]=0
        else:
            black-=b-2
            a=x
            for j in range(a+1,N+1):
                if B[j]==-1:
                    B[j]=b-2
                else:
                    break
                if j==N-1:
                    break
    else:
        if W[x]>0:
            black-=W[x]
            W[x]=0
        else:
            black-=a-2
            b=x
            for j in range(b+1,N+1):
                if W[j]==-1:
                    W[j]=a-2
                else:
                    break
                if j==N-1:
                    break
print(black)
Buggy python submission (verdict: Runtime Error):
# B

S=input()
T=input()

def check(i,T):
    ns=S[i:i+len(T)]
    res=0
    for i in range(len(T)):
        if ns[i]!=T[i]:
            res+=1
    return res

print(min([check(i,T) for i in range(len(S)-len(T))]))

Fixed submission:
# B

S=input()
T=input()

def check(i,T):
    ns=S[i:i+len(T)]
    res=0
    for i in range(len(T)):
        if ns[i]!=T[i]:
            res+=1
    return res

print(min([check(i,T) for i in range(len(S)-len(T)+1)]))
Buggy python submission (verdict: Time Limit Exceeded):
# C

N=int(input())
A=list(map(int,input().split()))
p=10**9+7

Asum=[sum(A[i+1:])%p for i in range(len(A))]
print(sum((A[i]*Asum[i])%p for i in range(N))%p)

Fixed submission:
# C

N=int(input())
A=list(map(int,input().split()))
p=10**9+7

sumA = sum(A)

sumA_2 = sum([a**2 for a in A])

print(((sumA**2-sumA_2)//2)%p)
Buggy python submission (verdict: Time Limit Exceeded):
# E
from collections import Counter

H,W,M=map(int,input().split())
h,w,bomb=[0]*M,[0]*M,[]
for i in range(M):
    h[i],w[i]=map(int,input().split())
    bomb.append((h[i],w[i]))

most_h,most_w=Counter(h).most_common(),Counter(w).most_common()

def max_values(lis):
    max_num=lis[0][1]
    for i in range(len(lis)):
        if lis[i][1]<max_num:
            res=lis[:i]
            break
    else:
        res=lis
    return res

most_h=max_values(most_h)
most_w=max_values(most_w)

res=-1
k=0
for i,i_n in most_h:
    for j,j_n in most_w:
        if not (i,j) in bomb or k>M:
            res=i_n+j_n
            break
        k+=1
    if res>-1:
        break
else:
    res=i_n+j_n-1
print(res)


Fixed submission:
H,W,M=map(int,input().split())
h,w,bomb=[0]*H,[0]*W,[]
for i in range(M):
    a,b=map(int,input().split())
    bomb.append((a-1,b-1))
    h[a-1]+=1
    w[b-1]+=1
    
max_h=max(h)
max_w=max(w)

bomb_and_max=0
for i,j in bomb:
    if h[i]==max_h and w[j]==max_w:
        bomb_and_max+=1
    
if bomb_and_max==h.count(max_h)*w.count(max_w):
    print(max_h+max_w-1)
else:
    print(max_h+max_w)

Buggy python submission (verdict: Time Limit Exceeded):
# E
from collections import Counter

H,W,M=map(int,input().split())
h,w,bomb=[0]*M,[0]*M,[]
for i in range(M):
    h[i],w[i]=map(int,input().split())
    bomb.append((h[i],w[i]))

most_h,most_w=Counter(h).most_common(),Counter(w).most_common()

def max_values(lis):
    max_num=lis[0][1]
    for i in range(len(lis)):
        if lis[i][1]<max_num:
            res=lis[:i]
            break
    else:
        res=lis
    return res

most_h=max_values(most_h)
most_w=max_values(most_w)

res=-1
for i,i_n in most_h:
    for j,j_n in most_w:
        if not (i,j) in bomb:
            res=i_n+j_n
            break
    if res>-1:
        break
else:
    res=i_n+j_n-1
print(res)


Fixed submission:
H,W,M=map(int,input().split())
h,w,bomb=[0]*H,[0]*W,[]
for i in range(M):
    a,b=map(int,input().split())
    bomb.append((a-1,b-1))
    h[a-1]+=1
    w[b-1]+=1
    
max_h=max(h)
max_w=max(w)

bomb_and_max=0
for i,j in bomb:
    if h[i]==max_h and w[j]==max_w:
        bomb_and_max+=1
    
if bomb_and_max==h.count(max_h)*w.count(max_w):
    print(max_h+max_w-1)
else:
    print(max_h+max_w)
Buggy python submission (verdict: Time Limit Exceeded):
# ABC174 C

K=int(input())

res=1
r=7
while 1:
    if not r%K:
        break
    r=(10*r+7)%K
    res+=1
print(res)

Fixed submission:
# ABC174 C

K=int(input())

res=1
r=7%K
flg=(K%2==0 or K%5==0)
if flg:
    res=-1
while not flg:
    if not r:
        break
    r=(10*r+7)%K
    res+=1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
# ABC174 D
import sys
sys.setrecursionlimit(3*10**5)

N=int(input())
S=input()

def search(s):
    if s=='':
        return 0
    if s[0]=='R':
        return search(s[1:])
    if s[-1]=='W':
        return search(s[:-1])
    return search(s[1:-1])+1
print(search(S))

Fixed submission:
# ABC174 D
import sys
sys.setrecursionlimit(3*10**5)

N=int(input())
S=input()

def search(l,r):
    # 半開区間
    if l==r:
        return 0
    if S[l]=='R':
        return search(l+1,r)
    if S[r-1]=='W':
        return search(l,r-1)
    return search(l+1,r-1)+1
print(search(0,N))

Buggy python submission (verdict: Runtime Error):
# ABC174 D

N=int(input())
S=input()

def search(s):
    if s=='':
        return 0
    if s[0]=='R':
        return search(s[1:])
    if s[-1]=='W':
        return search(s[:-1])
    return search(s[1:-1])+1
print(search(S))

Fixed submission:
# ABC174 D
import sys
sys.setrecursionlimit(3*10**5)

N=int(input())
S=input()

def search(l,r):
    # 半開区間
    if l==r:
        return 0
    if S[l]=='R':
        return search(l+1,r)
    if S[r-1]=='W':
        return search(l,r-1)
    return search(l+1,r-1)+1
print(search(0,N))
Buggy python submission (verdict: Runtime Error):
f=lambda:map(int,input().split())
N,K=f()
A=list(f())

def isOK(X):
    return sum([-a//X*-1-1 for a in A])<=K


ok=10**10
ng=-1
while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if isOK(mid):
        ok=mid
    else:
        ng=mid
print(ok)

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

def isOK(X):
    if X<=0:
        return False
    return sum([-a//X*-1-1 for a in A])<=K


ok=10**10
ng=-1
while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if isOK(mid):
        ok=mid
    else:
        ng=mid
print(ok)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
A.sort()

F=[0]*(10**6+11)

for a in A:
    if F[a]==2:
        F[a]=1
        continue
    elif F[a]==0:
        F[a]=2
    k=2*a
    while 1:
        F[k]=1
        k+=a
        if not k<=10**6+10:
            break
res=0
for a in A:
    if F[a]==2:res+=1
print(res)

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

F=[0]*(10**6+11)
# 0:OK/未調査 1:NG 2:調査した頂点 3:二度調査した頂点

for a in A:
    if F[a]==1:
        continue
    if F[a]==2:
        F[a]=1
        continue
    elif F[a]==0:
        F[a]=2
    k=2*a
    while k<=10**6+1:
        F[k]=1
        k+=a
            
res=0
for a in A:
    if F[a]==2:
        res+=1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
a,b=open(0);c=1;
for i in b.split():c=[d:=int(i)*c,-1][10**18<d or d*c<0]
print(c)

Fixed submission:
a,b=open(0);c=1;
for i in sorted(b.split()):
    c*=int(i)
    if c>10**18:print(-1);exit()
print(c)

Buggy python submission (verdict: Runtime Error):
a,b=open(0);print([x:=eval(b.replace(*' *')),-1][x>10**18or len(b)>=99])

Fixed submission:
a,b=open(0);c=1;
for i in sorted(b.split()):
    c*=int(i)
    if c>10**18:print(-1);exit()
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
a,b=open(0);c=1;
for i in b.split():c*=int(i)
if c>10**18:print(-1);exit()
print(c)

Fixed submission:
a,b=open(0);c=1;
for i in sorted(b.split()):
    c*=int(i)
    if c>10**18:print(-1);exit()
print(c)

Buggy python submission (verdict: Runtime Error):
a,b=open(0);c=1;
for i in range(int(a)):c*=int(b[2*i])
if c>10**18:print(-1);exit()
print(c)

Fixed submission:
a,b=open(0);c=1;
for i in sorted(b.split()):
    c*=int(i)
    if c>10**18:print(-1);exit()
print(c)

Buggy python submission (verdict: Runtime Error):
a,b=open(0);print([x:=eval(b.replace(*' *')),-1][x>10**18])

Fixed submission:
a,b=open(0);c=1;
for i in sorted(b.split()):
    c*=int(i)
    if c>10**18:print(-1);exit()
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()

res=0
for i in range(N):
    for j in range(N):
        for k in range(N):
            if not i<j<k:
                continue
            if len(set([S[i],S[j],S[k]]))==3 and 2*j!=i+k:
                res+=1
print(res)

Fixed submission:
N=int(input())
S=input()

res=0
R=[]
G=[]
B=[]
r,g,b=0,0,0
for i in range(N):
    if S[i]=='R':
        r+=1
    elif S[i]=='G':
        g+=1
    else:
        b+=1
    R.append(r)
    G.append(g)
    B.append(b)
    
for i in range(N):
    for j in range(N):
        if not i<j:
            continue
        k=S[2*j-i] if 2*j-i<N else 'A'
        if set([S[i],S[j]])==set(['R','G']):
            res+=B[-1]-B[j]-(k=='B')
        elif set([S[i],S[j]])==set(['B','G']):
            res+=R[-1]-R[j]-(k=='R')
        elif set([S[i],S[j]])==set(['R','B']):
            res+=G[-1]-G[j]-(k=='G')
print(res)