Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
c = list(input())

while True:
    if len(c) >= 1 and c[0] == 'R':
        del c[0]
    else:
        N = len(c)
        break

if N <= 1:
    print(0)
else:
    ans = 0
    r = N
    for w in range(N):
        if c[w] == 'R':
            continue
        else:
            while True:
                r += -1
                if r == -1 or c[r] == 'R':
                    break
            if r < w:
                break
            else:
                ans += 1
    print(ans)

Fixed submission:
N = int(input())
c = list(input())

if N <= 1:
    print(0)
else:
    ans = 0
    r = N
    for w in range(N):
        if c[w] == 'R':
            continue
        else:
            while True:
                r += -1
                if r == -1 or c[r] == 'R':
                    break
            if r < w:
                break
            else:
                ans += 1
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
c = list(input())

while True:
    if len(c) >= 1 and c[0] == 'R':
        del c[0]
    else:
        N = len(c)
        break

if N <= 1:
    print(0)
else:
    ans = 0
    r = N
    for w in range(N):
        if c[w] == 'R':
            continue
        else:
            while True:
                r += -1
                if r == -1 or c[r] == 'R':
                    break
            if r < w:
                break
            else:
                ans += 1
    print(ans)

Fixed submission:
N = int(input())
c = list(input())

if N <= 1:
    print(0)
else:
    ans = 0
    r = N
    for w in range(N):
        if c[w] == 'R':
            continue
        else:
            while True:
                r += -1
                if r == -1 or c[r] == 'R':
                    break
            if r < w:
                break
            else:
                ans += 1
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

q = []

for i in range(Q):
    B, C = list(map(int, input().split()))
    for i in range(N):
        if A[i] > B:
            break
        if A[i] == B:
            A[i] = C

    A.sort()
    q.append(sum(A))

for i in q:
    print(i)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
a = [0]*100000
for i in A:
    a[i-1] += 1
Q = int(input())

ans = sum(A)

q = []

for i in range(Q):
    B, C = list(map(int, input().split()))
    if a[B-1] >= 1:
        ans = ans - B*a[B-1] + C*a[B-1]
        a[C-1] += a[B-1]
        a[B-1] = 0
    q.append(ans)

for i in q:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

P_ = []

for i in p:
    P_.append((1+i)/2)

ma = 0

for i in range(N-K+1):
    if ma < sum(P_[i:i+K]):
        ma = sum(P_[i:i+K])

print(ma)


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

ma = sum(p[:K])
tmp = ma

for i in range(K,N):
    tmp += p[i]
    tmp -= p[i-K]
    if ma < tmp:
        ma = tmp

print((ma + K)/2)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

P_ = []

for i in p:
    P_.append((1+i)/2)

ma = 0

for i in range(N-K+1):
    if ma < sum(P_[i:i+K]):
        ma = sum(P_[i:i+K])

print(ma)


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

ma = sum(p[:K])
tmp = ma

for i in range(K,N):
    tmp += p[i]
    tmp -= p[i-K]
    if ma < tmp:
        ma = tmp

print((ma + K)/2)
Buggy python submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))

p = []
tmp_p = [0]*N
S = []

wa = 0
ac = 0

for i in range(M):
    P, s = list(map(str, input().split()))

    if s == 'AC' and P not in p:
        ac += 1
        p.append(P)
        wa += tmp_p[int(P)-1]
    if s == 'WA' and P not in p:
        tmp_p[int(P)-1] += 1


print(ac, wa)



Fixed submission:
C = input()

print(chr(ord(C)+1))
Buggy python submission (verdict: Runtime Error):
S, T = list(map(int, input().split()))

print(T+S)

Fixed submission:
S, T = list(map(str, input().split()))

print(T+S)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

ans = 0

for i in range(1000):
    t = str(i)
    t = t.zfill(3)
    now = t[0]
    count = 0
    for j in S:
        if count == 0 and now == j:
            now = t[1]
            count += 1
            continue
        if count == 1 and now == j:
            now = t[2]
            count += 1
            continue
        if count == 2 and now == j:
            ans += 1
            break

print(ans)

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

ans = 0

for i in range(1000):
    t = str(i)
    t = t.zfill(3)
    now = t[0]
    count = 0
    for j in S:
        if count == 0 and now == j:
            now = t[1]
            count += 1
            continue
        if count == 1 and now == j:
            now = t[2]
            count += 1
            continue
        if count == 2 and now == j:
            ans += 1
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

a = []
ans = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            t = S[i]+S[j]+S[k]
            if not t in a:
                a.append(t)
                ans += 1
print(ans)

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

ans = 0

for i in range(1000):
    t = str(i)
    t = t.zfill(3)
    now = t[0]
    count = 0
    for j in S:
        if count == 0 and now == j:
            now = t[1]
            count += 1
            continue
        if count == 1 and now == j:
            now = t[2]
            count += 1
            continue
        if count == 2 and now == j:
            ans += 1
            break

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
 
if S = 'Sunny':
  print('Cloudy')
elif S = 'Cloudy':
  print('Rainy')
else:
  print('Sunny')

Fixed submission:
S = input()
 
if S == 'Sunny':
    print('Cloudy')
elif S == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')

Buggy python submission (verdict: Runtime Error):
S = input()

if S = 'Sunny':
    print('Cloudy')
elif S = 'Cloudy':
    print('Rainy')
else:
    print('Sunny')

Fixed submission:
S = input()
 
if S == 'Sunny':
    print('Cloudy')
elif S == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

ans = (A[0] * A[1]) / (A[0] + A[1])

for i in range(2, N):
    ans += (ans * A[i]) / (ans + A[i])

print(ans)

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

ans = 0

for i in range(N):
    ans += 1 / A[i]

print(1/ans)
Buggy python submission (verdict: Runtime Error):
#include<iostream>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i)
#define rep(i,n) REP(i,0,n)
int main(){
    int K, X;
    cin >> K >> X;
    X -= K - 1;
    rep(i,2*K-1) cout<<X+i<<" ";
    cout<<endl;

    return 0;

}

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

T = X - K + 1

ans = []

for i in range(K*2 - 1):
    ans.append(T)
    T += 1

print(' '.join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
N, X = list(map(int, input().split()))

L = list(map(int, input().split()))


now = 0
i = 0
ans = 0
while True:
    if now > X:
        break
    now += L[i]
    i += 1
    ans += 1

print(ans)

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

L = list(map(int, input().split()))

count = 0
now = 0
for i in L:
    if now > X:
        break
    now += i
    count += 1
if now <= X:
    count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
N, X = list(map(int, input().split()))

L = list(map(int, input().split()))


now = 0
i = 0
while True:
    if now > X:
        break
    now += L[i]
    i += 1

print(i)

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

L = list(map(int, input().split()))

count = 0
now = 0
for i in L:
    if now > X:
        break
    now += i
    count += 1
if now <= X:
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
r, D, x = list(map(int, input()))

x_ = [0] * 10

for i in range(10):
    if i == 0:
        x_[i] = r*x - D
    else:
        x_[i] = r*x[i-1] - D
    print(x_[i])



Fixed submission:
r, D, x = list(map(int, input().split()))

x_ = [0] * 10

for i in range(10):
    if i == 0:
        x_[i] = r*x - D
    else:
        x_[i] = r*x_[i-1] - D
    print(x_[i])
Buggy python submission (verdict: Runtime Error):
S = input()

if len(S) <= 2:
    print(0)

else:
    ans1 = 0
    ans2 = 0
    flag1 = 0
    flag2 = 1
    for i in S:
        if flag1 % 2 == int(i):
            pass
        else:
            ans1 += 1
        flag1 += 1
    for i in S:
        if flag2 % 2 == int(i):
            pass
        else:
            ans2 += 1
        flag2 += 1

print(min(ans1,ans2))

Fixed submission:
S = input()

if len(S) <= 2:
    print(0)

else:
    ans1 = 0
    ans2 = 0
    flag1 = 0
    flag2 = 1
    for i in S:
        if flag1 % 2 == int(i):
            pass
        else:
            ans1 += 1
        flag1 += 1
    for i in S:
        if flag2 % 2 == int(i):
            pass
        else:
            ans2 += 1
        flag2 += 1

    print(min(ans1,ans2))
Buggy python submission (verdict: Runtime Error):
A, B, K = list(map(int, input().split()))

S = [1]

for i in range(2,min(A,B)):
    if A % i == 0 or B % i == 0:
        S.append(i)

S.sort(reverse=True)

print(S[K-1])

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

S = [1]

for i in range(2,min(A+1,B+1)):
    if A % i == 0 and B % i == 0:
        S.append(i)

S.sort(reverse=True)

print(S[K-1])

Buggy python submission (verdict: Runtime Error):
A, B, K = list(map(int, input().split()))

S = [1]

for i in range(2,min(A,B)):
    if A % i == 0 and B % i == 0:
        S.append(i)

S.reverse()

print(S[K-1])

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

S = [1]

for i in range(2,min(A+1,B+1)):
    if A % i == 0 and B % i == 0:
        S.append(i)

S.sort(reverse=True)

print(S[K-1])

Buggy python submission (verdict: Runtime Error):
A, B, K = list(map(int, input().split()))

S = [1]

for i in range(2,min(A,B)):
    if A % i == 0 and B % i == 0:
        S.append(i)

S.append()

print(S[K-1])

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

S = [1]

for i in range(2,min(A+1,B+1)):
    if A % i == 0 and B % i == 0:
        S.append(i)

S.sort(reverse=True)

print(S[K-1])

Buggy python submission (verdict: Runtime Error):
A, B, K = list(map(int, input().split()))

S = [1]

for i in range(2,min(A,B)):
    if A % i == 0 and B % i == 0:
        S.append(i)

print(S[K-1])

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

S = [1]

for i in range(2,min(A+1,B+1)):
    if A % i == 0 and B % i == 0:
        S.append(i)

S.sort(reverse=True)

print(S[K-1])

Buggy python submission (verdict: Runtime Error):
A, B, K = list(map(int, input().split()))

S = [1]

for i in range(2,min(A,B)):
    if A % i == 0 or B % i == 0:
        S.append(i)

print(S[K-1])

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

S = [1]

for i in range(2,min(A+1,B+1)):
    if A % i == 0 and B % i == 0:
        S.append(i)

S.sort(reverse=True)

print(S[K-1])

Buggy python submission (verdict: Runtime Error):
A, B, K = list(map(int, input().split()))

S = []

for i in range(1, min(A,B)):
    if (A % i == 0) or (B % i == 0):
        S.append(i)
        

if A == 1 and B == 1 and K == 1:
    print(1)
else:
    print(S[K-1])

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

S = [1]

for i in range(2,min(A+1,B+1)):
    if A % i == 0 and B % i == 0:
        S.append(i)

S.sort(reverse=True)

print(S[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

counter = 0
arr = list(S)
while True:
    x = 0
    for i in range(len(arr)-1):
        if arr[i] == 'B' and arr[i+1] == 'W':
            arr[i] = 'W'
            arr[i+1] = 'B'
            counter += 1
            x = 1
            break
    if x == 0:
        break

print(counter)

Fixed submission:
S = input()

steps = 0
accumulated_W = 0

for i, x in enumerate(list(S)):
    if x == 'W':
        steps += i - accumulated_W
        accumulated_W += 1

print(steps)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()

counter = 0
arr = list(S)
while True:
    x = 0
    for i in range(len(arr)-1):
        if arr[i] == 'B' and arr[i+1] == 'W':
            arr[i] = 'W'
            arr[i+1] = 'B'
            counter += 1
            x = 1
    if x == 0:
        break

print(counter)

Fixed submission:
S = input()

steps = 0
accumulated_W = 0

for i, x in enumerate(list(S)):
    if x == 'W':
        steps += i - accumulated_W
        accumulated_W += 1

print(steps)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())

if N == 1:
    print("Hello World")
if N == 2:
    print(A + B)

Fixed submission:
N = int(input())

if N == 1:
    print("Hello World")
if N == 2:
    A = int(input())
    B = int(input())
    print(A + B)

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

if N == 1:
    print("Hello World")
else:
    print(A + B)

Fixed submission:
N = int(input())

if N == 1:
    print("Hello World")
if N == 2:
    A = int(input())
    B = int(input())
    print(A + B)
Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())

c = [0 for i in range(N)]
t = [0 for i in range(N)]

count = 0

for i in range(N):
    c[i], t[i] = map(int, input().split())
    
for i in range(N):
    if t[i] > T:
        del c[i]
        count += 1
        
c.sort()

if count != N:
    print(c[0])
else:
    print("TLE")

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

ans = 10**9

for i in range(N):
    c, t = list(map(int, input().split()))
    if t <= T:
        if c < ans:
            ans = c

if ans == 10**9:
    print('TLE')
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())

c = [0 for i in range(N)]
t = [0 for i in range(N)]

for i in range(N):
    c[i], t[i] = map(int, input().split())
    
for i in range(N):
    if t[i] > T:
        del c[i]
        
c.sort()

print(c[0])

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

ans = 10**9

for i in range(N):
    c, t = list(map(int, input().split()))
    if t <= T:
        if c < ans:
            ans = c

if ans == 10**9:
    print('TLE')
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N <= 104 and N >= 1:
  print(0)
elif N >= 105:
  print(1)
elif N >= 135:
  print(2)
elif N >= 145:
  print(3)
elif N >= 165:
  print(4)
elif N >= 189:
  print(5)
elif N >= 195:
  print(6)

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

print((A - 1) * (B - 1))
Buggy python submission (verdict: Runtime Error):
N K = map(int, inpur().split())

if N % K => 1:
  print(1)
else:
  print(0)

Fixed submission:
N, K = map(int, input().split())
 
if N % K >= 1:
  print(1)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce


N = int(input())

a = list(map(int, input().split()))

ans = 0
    
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

for i in range(len(a)):
    ans += (lcm_list(a) - 1) % a[i]
    
print(ans)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
print(sum(a) - N)
Buggy python submission (verdict: Runtime Error):
N = int(input())

gcd = lambda a, b: gcd(b, a % b)

lcm = lambda a, b: a * b // math.gcd(a, b)

lcm(2, N)

Fixed submission:
N = int(input())

if N % 2 == 0:
    print(N)
else:
    print(2*N)

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

import math

lcm = lambda a, b: a * b // math.gcd(a, b)

print(lcm(2, N))

Fixed submission:
N = int(input())

if N % 2 == 0:
    print(N)
else:
    print(2*N)

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

import math

lcm = lambda a, b: a * b // math.gcd(a, b)

print(lcm(2, N))

Fixed submission:
N = int(input())

if N % 2 == 0:
    print(N)
else:
    print(2*N)

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

import math

lcm = lambda a, b: a * b // math.gcd(a, b)

lcm(2, N)

Fixed submission:
N = int(input())

if N % 2 == 0:
    print(N)
else:
    print(2*N)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
max_len = 0

for i in range(len(t)):
    for j in range(i, len(t)+1):
        print(t[i:j])
        if t[i:j] in s[i:len(s)-j+1]:
            max_len = max(max_len, j-i)

print(len(t) - max_len)

Fixed submission:
s = input()
t = input()
max_count = 0

for i in range(len(s)-len(t)+1):
    count = 0
    s_ = s[i:i+len(t)+1]
    for j in range(len(t)):
        if s_[j] == t[j]:
            count += 1
    max_count = max(max_count, count)

print(len(t) - max_count)
Buggy python submission (verdict: Runtime Error):
sum_ = 0
temp = 0
for i in range(len(a)-1):
    temp += a[-i-1]
    sum_ += temp * a[-i-2]

print(sum_%(10**9 + 7))

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

sum_ = 0
temp = 0
for i in range(len(a)-1):
    temp += a[-i-1]
    sum_ += temp * a[-i-2]

print(sum_%(10**9 + 7))
Buggy python submission (verdict: Runtime Error):
import itertools
min_price = 10**9
for k in range(n):
    for comb in itertools.combinations(range(m), k+1):
        sums = [0] * m
        price = 0
        for c in comb:
            price += C[c]
            for i in range(m):
                sums[i] += A[c][i]

#         print(comb)
#         print(sums)
        if sum([y >= x for y in sums]) == len(A):
            min_price = min(min_price, price)

if min_price == 10**9:
    print('-1')
else:
    print(min_price)

Fixed submission:
import itertools

n,m,x = map(int,input().split())
C, A = [], []
for i in range(n):
    ca = list(map(int, input().split()))
    C.append(ca[0])
    A.append(ca[1:])

min_price = 10**9
for k in range(n):
    for comb in itertools.combinations(range(n), k+1):
        sums = [0] * m
        price = 0
        for c in comb:
            price += C[c]
            for i in range(m):
                sums[i] += A[c][i]

#         print(comb)
#         print(sums)
#         print(min_price)
        if sum([y >= x for y in sums]) == m:
            min_price = min(min_price, price)

if min_price == 10**9:
    print('-1')
else:
    print(min_price)
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
H = [int(a) for a in input().split()]
ans= [1] * n
for i in range(m):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        ans[b] = 0
    elif H[a-1] == H[b-1]:
        ans[a-1] = 0
        ans[b-1] = 0
    else:
        ans[a-1] = 0
print(sum(ans))

Fixed submission:
n,m = map(int, input().split())
H = [int(a) for a in input().split()]
ans= [1] * n
for i in range(m):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        ans[b-1] = 0
    elif H[a-1] == H[b-1]:
        ans[a-1] = 0
        ans[b-1] = 0
    elif H[a-1] < H[b-1]:
        ans[a-1] = 0
print(sum(ans))
Buggy python submission (verdict: Runtime Error):
a. b. x = map(int, input().split())
def f(x):
  return (a*x)//b - a*(x//b)

print(f(min(b-1, n))

Fixed submission:
a, b, n = map(int, input().split())
def f(x):
  return (a*x)//b - a*(x//b)
 
print(f(min(b-1, n)))
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans = 0
k = int(input())
for i in range(1,k+1):
    for j in range(1,k+1):
        for p in range(1,k+1):
            ans += gcd(i,j,p)
print(ans)


Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans = 0
k = int(input())
for i in range(1,k+1):
    for j in range(i,k+1):
        for p in range(j,k+1):
            if (i!=j) and (j!=p) and (i!=p):
                #print(i,j,p, 'pattern3')
                ans += gcd(i,j,p) * 6
            elif (i==j) and (j==p):
                #print(i,j,p, 'pattern1')
                ans += gcd(i,j,p)
            else:
                #elif (i==j) or (j==k) or (i==k):
                #print(i,j,p, 'pattern2')
                ans += gcd(i,j,p) * 3

print(ans)
Buggy python submission (verdict: Runtime Error):
k = int(input())
old = [1,2,3,4,5,6,7,8,9]
new = []
count = 9
if k <= count:
    print(ans[k])
while count < k:
    if len(old) > 0:
        i = old.pop(0)
        last = i%10
        if last != 0:
            new.append(i*10 + (last-1))
            count += 1
            if count == k:
                break
        new.append(i*10 + last)
        count += 1
        if count == k:
            break
        if last != 9:
            new.append(i*10 + (last+1))
            count += 1
            if count == k:
                break
    else:
        old = new
        new = []
print(new[-1])

Fixed submission:
import sys
k = int(input())
old = [1,2,3,4,5,6,7,8,9]
new = []
count = 9
if k <= count:
    print(old[k-1])
    sys.exit()
else:
    while count < k:
        if len(old) > 0:
            i = old.pop(0)
            last = i%10
            if last != 0:
                new.append(i*10 + (last-1))
                count += 1
                if count == k:
                    break
            new.append(i*10 + last)
            count += 1
            if count == k:
                break
            if last != 9:
                new.append(i*10 + (last+1))
                count += 1
                if count == k:
                    break
        else:
            old = new
            new = []
    print(new[-1])
Buggy python submission (verdict: Runtime Error):
s = input()
nq = int(input())
flg = 0
front = []
back = []
for i in range(nq):
    q = input()
    if len(q) == 1:
        #flg += 1
        flg = (flg+1)%2
    else:
        if flg == 0:
            if q[2] == '1':
                front = [q[-1]] + front
            else:
                back = back + [q[-1]]
        else:
            if q[2] == '1':
                back = back + [q[-1]]
            else:
                front = [q[-1]] + front
                
s = ''.join(front) + s + ''.join(back)
# if flg % 2 == 1:
#     s = s[::-1]
print(s)

Fixed submission:
N=[s for s in input()]
if 'A' in N and 'B' in N:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans=0
for i in range(N):
    ans+=i
print(ans)

Fixed submission:
N = int(input())
ans=N*(N-1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[i for i in map(int,input().split())]

from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

ans=[]
for i in range(N):
    B=A.copy()
    del B[i]
    ans.append(gcd_list(B))
    
print(max(ans))    

Fixed submission:
from fractions import gcd
from functools import reduce

N=int(input())
A=[i for i in map(int,input().split())]

ans=[]
L={}
L[0]=0
R={}
R[N+1]=0
R[N+2]=0

def gcd2(x,a):
    if x==0:
        return a
    else:
        return gcd(x,a)

for i in  range(N):
    L[i+1]=gcd2(L[i],A[i])
    R[N-i]=gcd2(R[N-i+1],A[-(i+1)])

for i in range(N):
    ans.append(gcd2(L[i],R[i+2]))
print(max(ans))

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

from math import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

ans=[]
for i in range(N):
    B=A.copy()
    del B[i]
    ans.append(gcd_list(B))
    
print(max(ans))    

Fixed submission:
from fractions import gcd
from functools import reduce

N=int(input())
A=[i for i in map(int,input().split())]

ans=[]
L={}
L[0]=0
R={}
R[N+1]=0
R[N+2]=0

def gcd2(x,a):
    if x==0:
        return a
    else:
        return gcd(x,a)

for i in  range(N):
    L[i+1]=gcd2(L[i],A[i])
    R[N-i]=gcd2(R[N-i+1],A[-(i+1)])

for i in range(N):
    ans.append(gcd2(L[i],R[i+2]))
print(max(ans))