Problem:


Score : 200 points

Problem Statement

We have sticks numbered 1, \cdots, N. The length of Stick i (1 \leq i \leq N) is L_i.

In how many ways can we choose three of the sticks with different lengths that can form a triangle?

That is, find the number of triples of integers (i, j, k) (1 \leq i < j < k \leq N) that satisfy both of the following conditions:

L_i, L_j, and L_k are all different.

There exists a triangle whose sides have lengths L_i, L_j, and L_k.

Constraints

1 \leq N \leq 100

1 \leq L_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
L_1 L_2 \cdots L_N

Output

Print the number of ways to choose three of the sticks with different lengths that can form a triangle.

Sample Input 1

5
4 4 9 7 5

Sample Output 1

5

The following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).

Sample Input 2

6
4 5 4 3 3 5

Sample Output 2

8

We have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.

There is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.

Sample Input 3

10
9 4 6 1 9 6 10 6 6 8

Sample Output 3

39

Sample Input 4

2
1 1

Sample Output 4

0

No triple (i, j, k) satisfies 1 \leq i < j < k \leq N, so we should print 0.



Sample input:
5
4 4 9 7 5


Sample output:
5

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline



def main():
    n = int(input())
    l = [int(x) for x in input().split()]
    
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                a, b, c = l[i], l[j], l[k]
                if a == b or b == c or c == a:
                    continue
                if a+b>c and b+c>a and c+a>b:
                    ans += 1
                
    
    print(ans)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            T = [L[i],L[j],L[k]]
            T.sort()
            s,m,l = T
            if s != m and m != l and l != s:
                if l < s+m:
                    ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ls = list(map(int, input().split()))
ls.sort()
ans = 0 
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            li = ls[i]
            lj = ls[j]
            lk = ls[k]
            if (li-lj)*(lj-lk)*(lk-li) == 0:
                continue
            if li + lj > lk and lj + lk > li and lk+li > lj:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
from itertools import*
n, *l = map(int, open(0).read().split())
cnt = 0
for a, b, c in combinations(l, 3):
    if a != b != c != a and a + b > c and b + c > a and c + a > b:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for l1 in L:
    for l2 in L:
        for l3 in L:
            ans += (l1 !=l2) and (l2 != l3) and (l3 != l1) and (2*max(l1, l2, l3) < l1+l2+l3)
print(ans//6)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))

count = 0
for i in range(len(L)-2):
    l1 = L[i]
    for j in range(i+1,len(L)-1):
        l2 = L[j]
        for k in range(j+1,len(L)):
            l3 = L[k]
            if (l1-l2)*(l2-l3)*(l3-l1) == 0:
                continue
            l_max = max(l1,l2,l3)
            l_left = l1+l2+l3-l_max
            if l_left > l_max:
                count += 1
print(count)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
L = LI()

ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        for k in range(j+1,N):
            c = L[k]
            if a == b or b == c or c == a:
                continue
            else:
                if a+b > c and b+c > a and c+a > b:
                    ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i,N):
        for k in range(j,N):
            if (L[i] != L[j] != L[k]) and (L[i] + L[j] > L[k]):
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

n = int(input())
A = list(map(int, input().split()))

count = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if A[i] < A[j]+A[k] and A[j] < A[i]+A[k] and A[k] < A[j]+A[i] and A[i] != A[j] and A[i] != A[k] and A[j] != A[k]:
                count += 1

print(count)

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in combinations(l, 3):
    # print(i)
    a, b, c = i
    # print(a, b, c)
    if (a != b and b != c and c != a) and \
        (a+b>c and b+c > a and c+a>b):
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
Ls = list(map(int, input().split()))

Ls.sort()

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            A, B, C = Ls[i], Ls[j], Ls[k]
            if A == B or B == C or C == A:
                continue
            if A + B > C:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split()))
x.sort()

cnt = 0
for i in range(n):
   for j in range(i+1, n):
      if x[i] == x[j]:
         continue
      for k in range(j+1, n):
         if x[i] != x[k] and x[j] != x[k]:
            y = [x[i], x[j], x[k]]
            y.sort()
            if y[0] + y[1] > y[2]:
               cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N = int(input())
ans = 0
L = list(map(int,input().split()))
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            l1 = L[i]
            l2 = L[j]
            l3 = L[k]
            if l1 == l2 or l2 == l3 or l3 == l1:
                continue
            if abs(l1-l2) < l3 and l3 < l1+l2:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))

c = 0
for i, Li in enumerate(L):
    for j, Lj in enumerate(L):
        for k, Lk in enumerate(L):
            if i < j < k and len(set([Li, Lj, Lk])) == 3:
                max_e, *else_e = sorted([Li, Lj, Lk], reverse=True)
                if sum(else_e) > max_e:
                    c += 1

print(c)

Submission status: Accepted

Solution code:
n = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                continue
            if L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and L[j] + L[k] > L[i]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
L = list(map(int, input().split()))
cnt = 0
for i in range(n):
    a = L[i]
    for j in range(i + 1, n):
        b = L[j]
        if a == b:
            continue
        for k in range(j + 1, n):
            c = L[k]
            if a == b or b == c or c == a:
                continue
            if a + b > c and b + c > a and c + a > b:
                cnt += 1
                # print(i, j, k)
print(cnt)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
l = list(map(int, input().split()))

x = 0
for ls in itertools.combinations(l, 3):
    if len(set(ls)) != 3:
        continue
    if ls[0] + ls[1] > ls[2] and ls[1] + ls[2] > ls[0] and ls[0] + ls[2] > ls[1]:
        x += 1
print(x)

Submission status: Accepted

Solution code:
import itertools

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

L = list(itertools.combinations(A,3))
ans = 0
for x in L:
  x = list(x)
  x.sort()
  if x[0] == x[1] or x[1] == x[2] or x[2] == x[0]:
    continue
  if x[0]+x[1] > x[2]:
    #print(x)
    ans +=1
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    L = LI()

    cnt = 0
    for (i, j, k) in comb(range(N), r=3):
        if i == j or j == k or k == i:
            continue
        tmp = sorted([L[i], L[j], L[k]])
        if tmp[0] == tmp[1] or tmp[1] == tmp[2] or tmp[2] == tmp[0]:
            continue
        if tmp[0] + tmp[1] > tmp[2]:
            # print(i, j, k)
            cnt = cnt + 1
    print(cnt)



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                continue
            if l[k] < l[i] + l[j]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
l_list = [int(i) for i in input().split()]
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l_list[i] + l_list[j] > l_list[k] > abs(l_list[i] - l_list[j]):
                if (l_list[i] != l_list[j]) & (l_list[j] != l_list[k]) & (l_list[k] != l_list[i]):
                    ans += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=sorted([int(i) for i in input().split()])
if(n<3):
  print(0)
else:
  c=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] and len(set([l[i],l[j],l[k]]))==3):
          c+=1
  print(c)

Submission status: Accepted

Solution code:
n=int(input())
A=[int(i) for i in input().split()]

ans=0
for i in range(n-2):
    for q in range(i,n-1):
        for r in range(q,n):
            ck=[A[i],A[q],A[r]]
            ck.sort()
            if len(set(ck))==3 and ck[0]+ck[1]>ck[2]:
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            a = l[i]
            b = l[j]
            c = l[k]
            # print(a, b, c, (a+b > c and a+c > b and  b+c > a))
            if a+b > c and a+c > b and  b+c > a and a != b and b != c and c != a:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ans = 0
    arr = list(map(int, input().split()))
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if arr[i] < arr[j] + arr[k] and arr[j] < arr[i] + arr[k] and arr[k] < arr[i] + arr[j] and arr[i] != arr[j] and arr[j] != arr[k] and arr[k] != arr[i]:
                    ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

n = n_in()
L = l_in()


from itertools import combinations

print(sum(i + j > k and j + k > i and k + i > j and i != j and j != k and k != i for i,j,k in combinations(L, 3)))

Submission status: Accepted

Solution code:
N = int(input())
L  = list(map(int, input().split()))

ans = 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] and L[i] != L[k] and L[j] != L[k]:
                sum_L = L[i] + L[j] + L[k]
                max_L = max(L[i], L[j], L[k])
                if sum_L - max_L > max_L:
                    ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ls = list(map(int, input().split()))

count = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            tmp = []
            tmp.append(ls[i])
            tmp.append(ls[j])
            tmp.append(ls[k])
            tmp.sort()
            if tmp[0] + tmp[1] > tmp[2]:
                if tmp[0] != tmp[1] and tmp[1] != tmp[2] and tmp[2] != tmp[0]:
                    count += 1

print(count)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,*a = map(int,read().split())

ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if a[i]!=a[j] and a[j]!=a[k] and a[k]!=a[i] and a[i]+a[j]+a[k] > 2*max(a[i],a[j],a[k]):
                ans += 1
                #print(a[i],a[j],a[k])

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
yokolist = list(map(int, input().split()))

count = 0
for i in range(n-2):
    for j in range(i,n-1):
        for k in range(j,n):
            x = yokolist[i]
            y = yokolist[j]
            z = yokolist[k]
            if x != y and y != z and z != x:
                if x < y + z and y < x + z and z < x+ y:
                    count += 1

print(count)

Submission status: Accepted

Solution code:
def resolve():
    import itertools
    n = int(input())
    l = list(map(int, input().split()))
    l = sorted(l)
    ans = 0
    for a, b, c in itertools.combinations(range(1, n + 1), 3):
        x = l[a-1]
        y = l[b-1]
        z = l[c-1]
        if x != y and y != z and z != x and z < x + y:
            ans += 1
    print(ans)
resolve()

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i):
        for k in range(j):
            ans += abs(l[i] - l[j]) < l[k] < abs(l[i] + l[j]) and len({l[i], l[j], l[k]}) == 3
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]: continue
            if l[i] >= l[j] + l[k]: continue
            if l[j] >= l[i] + l[k]: continue
            if l[k] >= l[i] + l[j]: continue
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] + l[j] > l[k] and l[i] != l[j] and l[j] != l[k]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      s = set([a[i],a[j],a[k]])
      if len(s) == 3:
        if (a[i]+a[j] > a[k]) and (a[i]+a[k] > a[j]) and (a[j]+a[k] > a[i]):
          ans += 1
print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    L = list(map(int, input().split()))
    cnt = 0
    for i in range(N):
        for j in range(i+1,N):
            for k in range(j+1,N):
                if (L[i] != L[j]) and (L[j] != L[k]) and (L[k] != L[i]):
                    if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                        cnt += 1

    print(cnt)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from itertools import combinations

n = int(input())
l = list(map(int, input().split()))

combi = combinations(l, 3)

ans = 0
for a, b, c in combi:
    if a != b and b != c and c != a:
        if a + b > c and b + c > a and c + a > b:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int( input())
    L = list( map( int, input().split()))
    L.sort()
    ans = 0
    if N <= 2:
        print(0)
        return
    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] or L[j] == L[k] or L[k] == L[i]:
                    continue
                if L[i] + L[j] > L[k]:
                    ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(N):
        for k in range(N):
            if i < j and j < k:
                if L[i] < L[j] + L[k] and L[j] < L[k] + L[i] and L[k] < L[i] + L[j]:
                    if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                        ans += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))

cnt = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            a = l[i]
            b = l[j]
            c = l[k]
            if a == b or b == c or c == a:
                continue
            if a + b > c and b + c > a and c + a > b:
                cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] < l[j] < l[k] and l[k] < l[i] + l[j]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = list(map(int,input().split()))
cnt = 0
for i in itertools.combinations(l,3):
  if i[0] != i[1] and i[1] != i[2] and i[2] != i[0]:
    if (sum(i)-max(i)) > max(i):
      cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))

ans = 0

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    for k in range(j + 1, N):
      ii = L[i]
      jj = L[j]
      kk = L[k]
      if ii == jj: continue
      if jj == kk: continue
      if kk == ii: continue
      if ii + jj <= kk: continue
      if jj + kk <= ii: continue
      if kk + ii <= jj: continue
      ans += 1

print(ans)

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
l = lr()
l.sort()
ans = 0
for i in range(n-2):
    a = l[i]
    for j in range(i+1, n-1):
        b = l[j]
        for k in range(j+1, n):
            c = l[k]
            if a != b and b != c and c != a and c < a+b:
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    L = list(map(int,input().split()))

    L.sort()
    count=0
    for i in range(N-2):
        for j in range(i+1,N-1):
            if L[i] ==L[j]:
                continue

            for k in range(j+1,N):
                if L[i] +L[j] >L[k] and L[j] != L[k]:
                    count+=1

    print(count)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i] and L[i] + L[j] + L[k] > 2 * max(L[i], L[j], L[k]):
                ans += 1
                # print(i, j, k)

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[j] and L[i] + L[j] > L[k]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
cnt=0

for i in range(n):
    for j in range(i,n):
        for k in range(j,n):
            if l[i]+l[j]>l[k] and l[i]!=l[j] and l[i]!=l[k] and l[k]!=l[j]:
                cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if a[i]!=a[j] and a[j]!=a[k]:
        if a[i]+a[j]>a[k]:
          ans+=1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for a in range(j+1,n):
      if l[i]+l[j]>l[a] and l[i]!=l[j] and l[j]!=l[a]:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            b = [L[i], L[j], L[k]]
            b.sort()
            if b[0] == b[1]:
                continue
            if b[1] == b[2]:
                continue
            if b[0]+b[1] > b[2]:
                cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
ans = 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] and l[j] != l[k] and l[i] != l[k] and l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[i] + l[k] > l[j]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N = int(input())
    A = list(map(int, input().split()))
    count = 0
    for i in range(N):
        for j in range(i + 1, N):
            if A[i] == A[j]:
                continue
            for k in range(j + 1, N):
                if A[i] == A[k] or A[j] == A[k]:
                    continue
                if A[i] + A[j] > A[k] and A[j] + A[k] > A[i] and A[k] + A[i] > A[j]:
                    count += 1
    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))


ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            a = l[i], l[j], l[k]
            a = sorted(a, reverse=True)
            if a[0] == a[1] or a[1] == a[2]:
                continue
            if a[0] < a[1] + a[2]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
L=[int(i) for i in input().split()]
ans=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      A=[L[i],L[j],L[k]]
      A.sort()
      a,b,c=A
      if a<b<c and c<a+b:
        ans+=1

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

L.sort()

ANS=0

for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i]==L[j] or L[j]==L[k]:
                continue
            if L[i]+L[j]>L[k]:
                ANS+=1

print(ANS)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(a) for a in input().split()]
ans = 0
for i in range(N):
    for j in range(i):
        for k in range(j):
            if abs(A[i] - A[j]) < A[k] < A[i] + A[j] and A[i] != A[j] and A[j] != A[k] and A[k] != A[i]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()


n = int(ri())
a = Ri()
ans = 0
a.sort()
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if a[i] != a[j] and a[j] != a[k] and a[i] + a[j] > a[k]:
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      b = [a[i],a[j],a[k]]
      b.sort()
      if b[0] == b[1] or b[1] == b[2]:
        pass
      elif b[0] + b[1] > b[2]:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))

ans=0
for i in range(N):
    a=L[i]
    for j in range(i+1,N):
        b=L[j]
        for k in range(j+1,N):
            c=L[k]
            if a!=b and b!=c and c!=a:
                if abs(a-b)<c and c<a+b:
                    ans+=1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      a=l[i]
      b=l[j]
      c=l[k]
      if a==b or b==c or a==c:
        continue
      t=[a,b,c]
      t.sort()
      if t[0]+t[1]>t[2]:
        ans+=1
print(ans)