Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
q = 1000003
N = int(input())
queries = [list(map(int, input().split())) for _ in range(N)]
for x, d, n in queries:
    prod = 1
    ans = reduce(lambda prod, next: prod * next % q, [x + i*d for i in range(n)], prod)
    print(ans)


Fixed submission:
from sys import exit, setrecursionlimit, stderr, stdin
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect
import functools
 
setrecursionlimit(10**7)
 
def input():
  return stdin.readline().strip()
 
def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]
 
MOD = 10**6 + 3
 
fact = [1] * MOD
for i in range(1, MOD):
  fact[i] = (fact[i-1] * i) % MOD
invfact = [0] * MOD; invfact[-1] = pow(fact[-1], MOD-2, MOD)
for i in range(MOD-2, -1, -1):
  invfact[i] = invfact[i+1] * (i+1) % MOD
# print(invfact[:10])
 
def inv(n):
  return pow(n, MOD-2, MOD)
 
def solve(x, d, n):
  if x == 0:
    return 0
  if d == 0:
    return pow(x, n, MOD)
  k = x * inv(d) % MOD
  if n + k - 1 >= MOD:
    return 0
  return fact[n + k - 1] * invfact[k-1] % MOD * pow(d, n, MOD) % MOD
 
Q = read()
for _ in range(Q):
  x, d, n = reads()
  ans = solve(x, d, n)
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
q = 1000003
N = int(input())
queries = [list(map(int, input().split())) for _ in range(N)]
for query in queries:
    prod = 1
    init = query[0]
    for i in range(query[2]):
        prod = prod * (init + i * query[1]) % q
    print(prod)


Fixed submission:
from sys import exit, setrecursionlimit, stderr, stdin
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect
import functools
 
setrecursionlimit(10**7)
 
def input():
  return stdin.readline().strip()
 
def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]
 
MOD = 10**6 + 3
 
fact = [1] * MOD
for i in range(1, MOD):
  fact[i] = (fact[i-1] * i) % MOD
invfact = [0] * MOD; invfact[-1] = pow(fact[-1], MOD-2, MOD)
for i in range(MOD-2, -1, -1):
  invfact[i] = invfact[i+1] * (i+1) % MOD
# print(invfact[:10])
 
def inv(n):
  return pow(n, MOD-2, MOD)
 
def solve(x, d, n):
  if x == 0:
    return 0
  if d == 0:
    return pow(x, n, MOD)
  k = x * inv(d) % MOD
  if n + k - 1 >= MOD:
    return 0
  return fact[n + k - 1] * invfact[k-1] % MOD * pow(d, n, MOD) % MOD
 
Q = read()
for _ in range(Q):
  x, d, n = reads()
  ans = solve(x, d, n)
  print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
to = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = [int(x) for x in input().split()]
    u -= 1
    v -= 1
    to[u].append([v, w])
    to[v].append([u, w])
ans = [-1] * N
ans[0] = 0
def dfs(v, p=-1, c=0):
    for u, w in to[v]:
        if u == p: continue
        if (w%2 != 0):
            c ^= 1
        ans[u] = c
        dfs(u, v, c)
dfs(0)
for v in ans:
    print(v)


Fixed submission:
N=int(input())
to = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = [int(x) for x in input().split()]
    u -= 1
    v -= 1
    to[u].append([v, w])
    to[v].append([u, w])
ans = [-1] * N
ans[0] = 0
q = [0]
while(len(q) != 0):
    v = q.pop()
    for u, w in to[v]:
        if (ans[u] != -1): continue
        ans[u] = (ans[v]+w) % 2
        q.append(u)
for v in ans:
    print(v)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N =list(map(int, input().split()))
# R = 13
# G = 1
# B = 4
# N = 3000
X, Y, Z = sorted([R, G, B], reverse=True)
cnt = 0
for i in range(N//X+1):
    for j in range(N+1):
        if (X*i+Y*j>N): break
        cnt += ((N-X*i-Y*j)%Z == 0)
print(cnt)


Fixed submission:
R, G, B, N =list(map(int, input().split()))
# R = 13
# G = 1
# B = 4
# N = 3000
X, Y, Z = sorted([R, G, B], reverse=True)
cnt = 0
for i in range(N//X+1):
    for j in range(N+1):
        tmp = X*i+Y*j 
        if (tmp>N): break
        cnt += ((N-tmp)%Z == 0)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N =list(map(int, input().split()))
# R = 13
# G = 1
# B = 4
# N = 3000
X, Y, Z = sorted([R, G, B], reverse=True)
cnt = 0
for i in range(N+1):
    if (X*i>N): break
    for j in range(N+1):
        if (X*i+Y*j>N): break
        cnt += ((N-X*i-Y*j)%Z == 0)
print(cnt)


Fixed submission:
R, G, B, N =list(map(int, input().split()))
# R = 13
# G = 1
# B = 4
# N = 3000
X, Y, Z = sorted([R, G, B], reverse=True)
cnt = 0
for i in range(N//X+1):
    for j in range(N+1):
        tmp = X*i+Y*j 
        if (tmp>N): break
        cnt += ((N-tmp)%Z == 0)
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce
 
N=int(input())
a_list = list(map(int, input().split()))
lst = []
for i, a in enumerate(a_list):
    tmp = a_list[:i] + a_list[i+1:]
    lst.append(reduce(gcd, tmp))
print(max(lst))

Fixed submission:
from fractions import gcd
N=int(input())
a_list = list(map(int, input().split()))
gcd_l = [0] * (N+1) 
gcd_r = [0] * (N+1) 
for i, a in enumerate(a_list):
    gcd_l[i+1] = gcd(gcd_l[i], a)
for i in range(N, 0, -1):
    a = a_list[i-1]
    gcd_r[i-1] = gcd(gcd_r[i], a)
ans = 1
# print(gcd_l, gcd_r)
for i in range(N):
    tmp = gcd(gcd_l[i], gcd_r[i+1])
    if (ans < tmp):
        ans = tmp
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

N=int(input())
a_list = list(map(int, input().split()))
lst = []
for i, a in enumerate(a_list):
    tmp = a_list[:i] + a_list[i+1:]
    lst.append(reduce(math.gcd, tmp))
print(max(lst))


Fixed submission:
from fractions import gcd
N=int(input())
a_list = list(map(int, input().split()))
gcd_l = [0] * (N+1) 
gcd_r = [0] * (N+1) 
for i, a in enumerate(a_list):
    gcd_l[i+1] = gcd(gcd_l[i], a)
for i in range(N, 0, -1):
    a = a_list[i-1]
    gcd_r[i-1] = gcd(gcd_r[i], a)
ans = 1
# print(gcd_l, gcd_r)
for i in range(N):
    tmp = gcd(gcd_l[i], gcd_r[i+1])
    if (ans < tmp):
        ans = tmp
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
a_list = list(map(int, input().split()))
lst = []
for i, a in enumerate(a_list):
    tmp = a_list[:i] + a_list[i+1:]
    lst.append(reduce(math.gcd, tmp))
print(max(lst))


Fixed submission:
from fractions import gcd
N=int(input())
a_list = list(map(int, input().split()))
gcd_l = [0] * (N+1) 
gcd_r = [0] * (N+1) 
for i, a in enumerate(a_list):
    gcd_l[i+1] = gcd(gcd_l[i], a)
for i in range(N, 0, -1):
    a = a_list[i-1]
    gcd_r[i-1] = gcd(gcd_r[i], a)
ans = 1
# print(gcd_l, gcd_r)
for i in range(N):
    tmp = gcd(gcd_l[i], gcd_r[i+1])
    if (ans < tmp):
        ans = tmp
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = [int(x) for x in input().split()]
S = input()
lst = []
if (S[0] == '0'): lst.append(0)
cnt = 1
for i in range(N-1):
    if (S[i] == S[i+1]):
        cnt += 1
    else:
        lst.append(cnt)
        cnt = 1 
lst.append(cnt)
if (S[-1] == '0'): lst.append(0)
tmp = []
ans = 0 if (len(lst) != 1) else lst[0] 
for i in range(0, len(lst)-1, 2):
    s = sum(lst[i:(i+1+2*K)])
    if (ans < s):
        ans = s
print(ans)


Fixed submission:
N, K = [int(x) for x in input().split()]
S = input()
lst = []
if (S[0] == '0'): lst.append(0)
cnt = 1
for i in range(N-1):
    if (S[i] == S[i+1]):
        cnt += 1
    else:
        lst.append(cnt)
        cnt = 1 
lst.append(cnt)
if (S[-1] == '0'): lst.append(0)
tmp = [0] + lst[:]
ans = 0 if (len(lst) != 1) else lst[0] 
for i in range(len(lst)):
    tmp[i+1] += tmp[i]
if (((len(lst)+1)//2-K) < 1):
    ans = tmp[-1]
else:
    for i in range(0, (len(lst)+1)//2-K):
        l = 2*i
        r = l + 1 + 2*K
        s = tmp[r] - tmp[l]
        if (ans < s):
            ans = s
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = [int(x) for x in input().split()]
S = input()
lr = [[int(x) for x in input().split()] for _ in range(Q)]
for l, r in lr:
    cnt = 0
    for i in range(r-l):
        cnt += (S[l-1+i] == 'A' and S[l+i] == 'C')
    print(cnt)


Fixed submission:
N, Q = [int(x) for x in input().split()]
S = input()
lr = [[int(x)-1 for x in input().split()] for _ in range(Q)]
lst = [0] * N
for i in range(N-1):
    lst[i+1] = lst[i] + (S[i] == 'A' and S[i+1] == 'C')
for l, r in lr:
    print(lst[r]-lst[l])

Buggy python submission (verdict: Runtime Error):
    N, Q = [int(x) for x in input().split()]
    S = input()
    lr = [[int(x) for x in input().split()] for _ in range(Q)]
    for l, r in lr:
        cnt = 0
        for i in range(r-l):
            cnt += (S[l-1+i] == 'A' and S[l+i] == 'C')
        print(cnt)


Fixed submission:
N, Q = [int(x) for x in input().split()]
S = input()
lr = [[int(x)-1 for x in input().split()] for _ in range(Q)]
lst = [0] * N
for i in range(N-1):
    lst[i+1] = lst[i] + (S[i] == 'A' and S[i+1] == 'C')
for l, r in lr:
    print(lst[r]-lst[l])
Buggy python submission (verdict: Runtime Error):
A, B = [int(x) for x in input().split('/')]
print(A+B if (B%A == 0) else B-A)


Fixed submission:
A, B = [int(x) for x in input().split()]
print(A+B if (B%A == 0) else B-A)
Buggy python submission (verdict: Runtime Error):
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
i = 0
ans = 0
if (K == 0):
    return print(sum(A))
while((1<<i) <= K):
    tmp = [(a>>i)%2 for a in A]
    cnt = sum(tmp)
    ans += (max(cnt, N-cnt) << i)
    i += 1
i -= 1
if (1 << i == K):
    print(ans)
else:
    for j in range(1<<i+1, K+1):
        ans = max(ans, sum([j ^ a for a in A]))
    print(ans)


Fixed submission:
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
MAX_DIGIT = 50
dp = [[-1, -1] for _ in range(MAX_DIGIT+1)]
dp[MAX_DIGIT][0] = 0
# print(dp)
# print([bin(a) for a in A])
for d in range(MAX_DIGIT-1, -1, -1):
    # print([(a>>d)%2 for a in A])
    cnt = sum([(a>>d)%2 for a in A])
    c0 = cnt << d
    c1 = (N - cnt) << d
    # print(1 << d+1, c0, c1)
    if (dp[d+1][1] != -1):
        dp[d][1] = max(dp[d][1], dp[d+1][1] + max(c0, c1))
    if (dp[d+1][0] != -1 and (K>>d)%2 == 1):  
        dp[d][1] = max(dp[d][1], dp[d+1][0] + c0)
    if (dp[d+1][0] != -1):
        if (K>>d)%2 == 1:
            dp[d][0] = max(dp[d][0], dp[d+1][0] + c1)
        else:
            dp[d][0] = max(dp[d][0], dp[d+1][0] + c0)
    # print(dp)
print(max(dp[0][0], dp[0][1]))

Buggy python submission (verdict: Runtime Error):
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
i = 0
ans = 0
if (K == 0):
    return print(sum(A))
while((1<<i) <= K):
    tmp = [(a>>i)%2 for a in A]
    cnt = sum(tmp)
    ans += (max(cnt, N-cnt) << i)
    i += 1
i -= 1
if (1 << i == K):
    print(ans)
else:
    for j in range(1<<i+1, K+1):
        ans = max(ans, [j ^ a for a in A])
    print(ans)


Fixed submission:
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
MAX_DIGIT = 50
dp = [[-1, -1] for _ in range(MAX_DIGIT+1)]
dp[MAX_DIGIT][0] = 0
# print(dp)
# print([bin(a) for a in A])
for d in range(MAX_DIGIT-1, -1, -1):
    # print([(a>>d)%2 for a in A])
    cnt = sum([(a>>d)%2 for a in A])
    c0 = cnt << d
    c1 = (N - cnt) << d
    # print(1 << d+1, c0, c1)
    if (dp[d+1][1] != -1):
        dp[d][1] = max(dp[d][1], dp[d+1][1] + max(c0, c1))
    if (dp[d+1][0] != -1 and (K>>d)%2 == 1):  
        dp[d][1] = max(dp[d][1], dp[d+1][0] + c0)
    if (dp[d+1][0] != -1):
        if (K>>d)%2 == 1:
            dp[d][0] = max(dp[d][0], dp[d+1][0] + c1)
        else:
            dp[d][0] = max(dp[d][0], dp[d+1][0] + c0)
    # print(dp)
print(max(dp[0][0], dp[0][1]))
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
N, M = [int(x) for x in input().split()]
ans = 1
for i in range(M//N, 1, -1):
    if (i < ans): break
    rest = M - N*i
    ans = max(ans, gcd(i, rest))
print(ans)


Fixed submission:
from fractions import gcd
N, M = [int(x) for x in input().split()]
ans = 1
d = 1
if (N == 1):
    print(M)
else:
    while (d*d <= M):
        if (M//d * d != M): 
            d += 1
            continue
        d2 = M//d
        if (d*N <= M):
            ans = max(ans, d)
        if (d2*N <= M):
            ans = max(ans, d2)
        d += 1
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
N, M = [int(x) for x in input().split()]
ans = 1
for i in range(M//N, 1, -1):
    rest = M - N*i
    ans = max(ans, gcd(i, rest))
print(ans)


Fixed submission:
from fractions import gcd
N, M = [int(x) for x in input().split()]
ans = 1
d = 1
if (N == 1):
    print(M)
else:
    while (d*d <= M):
        if (M//d * d != M): 
            d += 1
            continue
        d2 = M//d
        if (d*N <= M):
            ans = max(ans, d)
        if (d2*N <= M):
            ans = max(ans, d2)
        d += 1
    print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
S = [0] * (N+1)
m = [0] * (M+1)
ans = 0
for i in range(N):
    S[i+1] = (S[i] + A[i]) % M
for s in S:
    ans += m[s]
    m[s] += 1
print(ans)


Fixed submission:
from collections import defaultdict
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
S = [0] * (N+1)
m = defaultdict(int)
ans = 0
for i in range(N):
    S[i+1] = (S[i] + A[i]) % M
for s in S:
    ans += m[s]
    m[s] += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
print('Yes' if (sorted(input()) == sorted(input()) else 'No'))


Fixed submission:
S = input()
T = input() * 2
for i in range(len(S)):
    for j in range(len(S)):
        s, e = [i+j, i+j+len(S)]
        if (T[s:e] == S):
            print('Yes')
            exit()
print('No')
Buggy python submission (verdict: Runtime Error):
A, B=list(map(int, input().split()))
print(math.ceil((A+B)/2))

Fixed submission:
import math

A, B=list(map(int, input().split()))
# A = 5
# B = 5
print(math.ceil((A+B)/2))
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
# S = "cd"
# T = "abc"
sS = "".join(sorted(S))
sT = "".join(sorted(T, reverse = True))
if (sS < sT):
  print("Yes")
  else:
    print("No")


Fixed submission:
S = input()
T = input()
# S = "cd"
# T = "abc"
sS = "".join(sorted(S))
sT = "".join(sorted(T, reverse = True))
if (sS < sT):
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
	input_str=input()
	# input_str="QWERTYASDFZXCV"
	# input_str="ZABCZ"
	# input_str="HASFJGHOGAKZZFEGA"
	b=0
	e=0
	length=len(input_str)
	for i, s in enumerate(input_str):
		if s=="A":
			b=i
			# print(b)
			break
	for i, s in enumerate(input_str[::-1]):
		if s=="Z":
			e=length-i
			# print(e)
			break
	print(e-b)


Fixed submission:
input_str=input()
# input_str="QWERTYASDFZXCV"
# input_str="ZABCZ"
# input_str="HASFJGHOGAKZZFEGA"
b=0
e=0
length=len(input_str)
for i, s in enumerate(input_str):
	if s=="A":
		b=i
		# print(b)
		break
for i, s in enumerate(input_str[::-1]):
	if s=="Z":
		e=length-i
		# print(e)
		break
print(e-b)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll result = 1;
    for(int i=0;i<N;i++) {
        cin >> A.at(i);
    }

    if(find(A.begin(),A.end(),0) != A.end()) {
        cout << "0" << endl;
        exit(0);
    }
    for(int i=0;i<N;i++) {
        result = result * A.at(i);
        if (result > (ll)pow(10,18)) {
            cout << "-1" << endl;
            exit(0);
        }
    }
    cout << result << endl;
}

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]

if 0 in A :
    print("0")
    exit()
result = 1
for i in range(N) :
    result *= A[i]
    if result > 10**18 :
        print("-1")
        exit()

print(result)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0;i<N;i++) {
        cin >> S.at(i);
    }
    sort(S.begin(),S.end());
    S.erase(unique(S.begin(),S.end()),S.end());
    cout << (int)S.size() << endl;
}

Fixed submission:
N = int(input())
S = []
for i in range(N) :
    S.append(input())

print(len(set(S)))
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> p(M);
    vector<string> S(M);
    for(int i=0;i<M;i++) {
        cin >> p.at(i) >> S.at(i);
    }
    vector<vector<int>> submits(N,vector<int>(2,0));
    for(int i=0;i<M;i++) {
        if(submits.at(p.at(i)-1).at(0) != 0) {
            continue;
        }
        if(S.at(i) == "WA") {
            submits.at(p.at(i)-1).at(1)++;
        }else{
            submits.at(p.at(i)-1).at(0)++;
        }
    }
    int ac = 0;
    int pena = 0;

    for(int i=0;i<N;i++) {
        ac += submits.at(i).at(0);
        pena += submits.at(i).at(1);
    }
    cout << ac <<" " << pena << endl;
}

Fixed submission:
from operator import itemgetter

N,M = map(int,input().split())
PS = [list(map(str,input().split())) for i in range(M)]

for i in range(M) :
    PS[i][0] = int(PS[i][0])

submits = [["null"] for i in range(N)]
for i in range(M) :
    submits[PS[i][0]-1][0] = PS[i][0]-1
    submits[PS[i][0]-1].append(PS[i][1])

ac = 0
pena = 0
for i in range(len(submits)) :
    if submits[i][0] == "null" :
        continue

    flag = False
    wabuf1 = 0
    for j in range(1,len(submits[i])) :
        if submits[i][j] == "AC" :
            ac += 1
            flag = True
            break
        else :
            wabuf1 += 1
    if flag == True :
        pena += wabuf1

print(ac,pena)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}
int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    vector<int> nums(N);
    int a=0,b=0,j=0;
    for(int i=0;i<N;i++) {
        cin >> P.at(i);
    }
    for(int i=0;i<N;i++) {
        cin >> Q.at(i);
    }
    for(int i=0;i<N;i++) {
        nums.at(i) = i+1;
    }
    do{
        j++;
        if(nums == P) {
            a = j;
        }
        if(nums == Q) {
            b = j;
        }
    }while(next_permutation(nums.begin(), nums.end()));
    cout << abs(b-a) << endl;
}

Fixed submission:
import itertools

N = int(input())
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]

a = 0
b = 0
j = 0
for i in itertools.permutations([int(x+1) for x in range(N)]):
    j += 1
    if(list(i) == P) :
        a = j
    if(list(i) == Q) :
        b = j

print(abs(a-b))
Buggy python submission (verdict: Runtime Error):
import math
s = int(input())
if s < 6:
    print("0")
else:
    bar = (s // 3) - 1
    ans = 0
    for i in range(bar+1):
        if i == 0:
            ans += 1
        else:
            val = s - 3 * (i+1)
            count = math.factorial(val+i) // (math.factorial(val) * math.factorial(i))
            ans += count % (10**9+7)
print(ans%(10**9+7))

Fixed submission:
import math
s = int(input())
if s < 3:
    print("0")
else:
    bar = (s // 3) - 1
    ans = 0
    for i in range(bar+1):
        if i == 0:
            ans += 1
        else:
            val = s - 3 * (i+1)
            count = math.factorial(val+i) // (math.factorial(val) * math.factorial(i))
            ans += count % (10**9+7)
    print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
from math import factorial
n = int(input())
l = list(map(int, input().split()))
l.sort()
disabled = 0
for i in range(n-2):
    for j in range(i+1,n-1):
            for k in range(j+1,n):
                if (l[i] + l[j]) <= l[k] or l[i] == l[j] or l[j] == l[k]:
                    disabled += 1
print(int(factorial(n) / factorial(3) / factorial(n-3) - disabled))

Fixed submission:
from math import factorial
n = int(input())
l = list(map(int, input().split()))
l.sort()
disabled = 0
for i in range(n-2):
    for j in range(i+1,n-1):
            for k in range(j+1,n):
                if (l[i] + l[j]) <= l[k] or l[i] == l[j] or l[j] == l[k]:
                    disabled += 1
if n >= 3:
    print(int(factorial(n) / factorial(3) / factorial(n-3) - disabled))
else:
    print("0")
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
if 0 in x:
	ans = 0
else:
	for i in range(1,n):
		ans = ans * x[i]
		if ans > 10 ** 18:
			ans = -1
            break
print(ans)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
if 0 in x:
	ans = 0
else:
	for i in range(1,n):
		ans = ans * x[i]
		if ans > 10 ** 18:
			ans = -1
			break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
if 0 in x:
	ans = 0
else:
	for i in range(1,n):
		ans = ans * x[i]
		if ans > 10 ** 18:
			ans = -1
print(ans)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
if 0 in x:
	ans = 0
else:
	for i in range(1,n):
		ans = ans * x[i]
		if ans > 10 ** 18:
			ans = -1
			break
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
if 0 in x:
	ans = 0
	break
else:
	for i in range(1,n):
		ans = ans * x[i]
		if ans > 10 ** 18:
			ans = -1
			break
print(ans)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
if 0 in x:
	ans = 0
else:
	for i in range(1,n):
		ans = ans * x[i]
		if ans > 10 ** 18:
			ans = -1
			break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
if 0 in x:
	ans = 0
else:
	for i in range(1,n):
		ans = ans * x[i]
if ans > 10 ** 18:
	ans = -1
print(ans)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
if 0 in x:
	ans = 0
else:
	for i in range(1,n):
		ans = ans * x[i]
		if ans > 10 ** 18:
			ans = -1
			break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
for i in range(1,n):
	if 0 in x:
		ans = 0
		break
	ans = ans * x[i]
	if ans > 10 ** 18:
		ans = -1
		break
print(ans)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
if 0 in x:
	ans = 0
else:
	for i in range(1,n):
		ans = ans * x[i]
		if ans > 10 ** 18:
			ans = -1
			break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
for i in range(1,n):
	ans = ans * x[i]
	if ans > 10 ** 18 and 0 not in x:
		ans = -1
		break
print(ans)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
if 0 in x:
	ans = 0
else:
	for i in range(1,n):
		ans = ans * x[i]
		if ans > 10 ** 18:
			ans = -1
			break
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
for i in range(1,n):
	ans = ans * x[i]
	if ans > 10 ** 18 and x not in 0:
		ans = -1
		break
print(ans)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
if 0 in x:
	ans = 0
else:
	for i in range(1,n):
		ans = ans * x[i]
		if ans > 10 ** 18:
			ans = -1
			break
print(ans)