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:
#B
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):
        if L[j]>L[i]:
            for k in range(j+1,N):
                if L[k]>L[j]:
                    if 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+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]:
                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[k]!=l[i]:
                if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[k]+l[i]>l[j]:
                    ans+=1

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    L = list(map(int, input().split()))
    cnt = 0
    import itertools
    for x, y, z in itertools.combinations(L, 3):
        if x != y and y != z and z != x:
            M = max(x, y, z)
            if M < sum([x, y, z]) - M:
                cnt += 1
    print(cnt) 

    
if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
N = int(input())
l = [int(x) for x in input().split()]
l.sort(reverse = True)
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] or l[j] == l[k]:
                continue
            if l[i] >= l[j]+l[k]:
                continue
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
ans = 0
if n == 1:
  print(0)
  exit()
if n == 2:
  print(0)
  exit()
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]:
        continue
      if l[i] == l[k]:
        continue
      if l[j] == l[k]:
        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()))
from itertools import combinations
ns=[i for i in range(n)]
ans=0
for i in combinations(ns,3):
    if L[i[0]]!=L[i[1]] and L[i[0]]!=L[i[2]] and L[i[1]]!=L[i[2]]:
        new=[L[i[0]],L[i[1]],L[i[2]]]
        new=sorted(new)
        if new[0]+new[1]>new[2]:
            ans+=1
        
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    l = [int(v) for v in 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):
                l3 = sorted([l[i],l[j],l[k]])
                if l3[0]!=l3[1] and l3[1]!=l3[2] and l3[0]+l3[1]>l3[2]:
                    ans += 1
    print(ans)

main()

Submission status: Accepted

Solution code:
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy


def solve(lst):  # fix inputs here
    console("----- solving ------")

    res = 0

    lst = sorted(lst)
    for i,x in enumerate(lst):
        for j,y in enumerate(lst[i+1:], start=i+1):
            for _,z in enumerate(lst[j+1:], start=j+1):
                if x == y or y == z or x == z:
                    continue
                if x+y > z:
                    res += 1

    # return a string (i.e. not a list or matrix)
    return res


def console(*args):  # the judge will not read these print statement
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

# fast read all
# sys.stdin.readlines()

for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
    k = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    # grid = []
    # for _ in range(nrows):
    #     grid.append(list(map(int,input().split())))

    res = solve(lst)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
    print(res)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
#l = list(set(l))
#l.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            #print(i,j,k)
            if (l[i]+l[j] > l[k]):
                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()))
L.sort()
ans = 0
n = len(L)
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] < L[k]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
L = tuple(map(int, input().split()))
from collections import Counter
LC = Counter(L)
L = sorted(list(set(L)))
n = len(L)

ans = 0
for i in range(n-2):
    ci = LC[L[i]]
    for j in range(i+1, n):
        cj = LC[L[j]]
        for k in range(j+1, n):
            ck = LC[L[k]]
            if L[k] < L[i] + L[j]:
                ans += ci*cj*ck
print(ans)

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:
                le=[l[i],l[j],l[k]]
                le.sort()
                if le[0]+le[1]>le[2] and le[0]!=le[1] and le[1]!=le[2] and le[2]!=le[0]:
#                    print(i+1,j+1,k+1)
                    ans+=1
print(ans)

Submission status: Accepted

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

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] < a[k] and a[k] < a[i] + a[j]:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import combinations
def main():
    n = int(input())
    L = list(map(int, input().split()))
    c = Counter(L)
    ans = 0
    for e in combinations(c.keys(), 3):
        i, j, k = sorted(list(e))
        if k < i + j:
            ans += c[i] * c[j] * c[k]
    print(ans)




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools
import sys

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

if N<3:
  print(0)
  sys.exit()

ans=0

for i in itertools.combinations(L,3):
  t=list(i)
  t.sort()
  x,y,z=t

  if len(set(i))!=3:
    continue
  
  if x+y>z:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline
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]:
                continue
            if L[j] == L[k]:
                continue
            if L[k] == L[i]:
                continue
            if L[i] + L[j] <= L[k]:
                continue
            if L[j] + L[k] <= L[i]:
                continue
            if L[k] + L[i] <= L[j]:
                continue
            ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from itertools import combinations

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

ans = 0
for x,y,z in combinations(L, 3):
    x,y,z = sorted((x,y,z))
    if x < y < z and x + y > z:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys
input = lambda:sys.stdin.readline().strip()
n = int(input())
l = list(map(int,input().split()))
ans = 0
for l1 in range(n):
    for l2 in range(l1+1,n):
        for l3 in range(l2+1,n):
            if l[l1]!=l[l2] and l[l2]!=l[l3] and l[l1]!=l[l3]:
                if l[l1]+l[l2]>l[l3] and l[l2]+l[l3]>l[l1] and l[l1]+l[l3]>l[l2]:
                    # print(l1+1,l2+1,l3+1)
                    ans+=1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = [int(hoge) for hoge in input().split()]
ans = 0
for k in range(2,N):
    K = L[k]
    for j in range(1,k):
        J = L[j]
        for i in range(j):
            I = L[i]
            M = max(max(I,J),K)
            if I+J+K-M > M and I!=J and J!=K and K!=I:
                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):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if abs(L[j]-L[k])<L[i] and L[i]<L[j]+L[k] and L[i]!=L[j] and L[i]!=L[k] and L[k]!=L[j]:
        ans+=1
        #print(L[i],L[j],L[k])
print(ans)

Submission status: Accepted

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

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


n = int(input())
l = lmp()
l.sort()
from collections import Counter
lc = list(Counter(l).items())
if len(lc) <= 2:
    print(0)
    exit()
cnt = 0
for i in range(len(lc)-2):
    for j in range(i+1,len(lc)-1):
        for k in range(j+1,len(lc)):
            if lc[i][0] + lc[j][0] > lc[k][0]:
                cnt += lc[i][1] * lc[j][1] * lc[k][1]
print(cnt)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import Counter


def read():
    N = int(input().strip())
    L = list(map(int, input().strip().split()))
    return N, L


def solve(N, L):
    ans = 0
    L.sort()
    for k in range(N):
        for j in range(k):
            for i in range(j):
                if L[i] < L[j] and L[j] < L[k] and L[i] + L[j] > L[k]:
                    ans += 1
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

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 len(set([l[i],l[j],l[k]]))==3:
                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:
import itertools
N = int(input())
elist = list(map(int, input().split()))

result = 0
if len(elist) > 2:
    for comb in itertools.combinations(elist, 3):
        x, y, z = comb
        if x == y or y == z or z == x:
            continue
        m = max(x, y, z)
        if m < x+y+z - m:
            result += 1

print(result)

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    L = LI()

    ans = 0
    for i, j, k in itertools.combinations(L, 3):
        if i != j and j != k and k != i:
            if i + j > k and j + k > i and k + i > j:
                ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
import itertools

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

    if len(L) < 3:
        print(0)
        exit()

    cnt = 0
    for a, b, c in itertools.combinations(L, 3):
        if a==b or b==c or c==a:
            continue
        if a + b > c:
            cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

N = int(input())
Ls = [int(i) for i in input().split()]


count = 0
for i in range(N):
    for j in range(i,N):
        for k in range(j,N):
            a = Ls[i] 
            b = Ls[j]
            c = Ls[k]
            if a!=b and a!=c and b!=c:
                if a+b > c and a+c > b and b+c > a:
                    count += 1

print(count)

Submission status: Accepted

Solution code:
def main():
    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):
                l = [L[i], L[j], L[k]]
                l.sort()
                if l[0] + l[1] > l[2]:
                    if l[0] != l[1] and l[1] != l[2]:
                        # print(l, i, j, 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
if n < 3:
    print(0)
    exit()
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[k] or l[j] == l[k]:
                continue
            if l[i] < l[j]+l[k] and l[j] < l[i]+l[k] and l[k] < l[i] + l[j]:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
def main():
	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 k in range(j + 1, N):
				if L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
					if L[i] + L[j] > L[k]:
						ans += 1

	print(ans)

 
if __name__ == "__main__":
  	main()

Submission status: Accepted

Solution code:
## coding: UTF-8
N = int(input())
L = 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):
            #print(i,j,k)
            #count+=1
            l = [L[i], L[j], L[k]]
            l = sorted(l)
            if(l[0] != l[1] and l[1] != l[2] and l[0] + l[1] > l[2]):
                count += 1

print(count)

Submission status: Accepted

Solution code:


N = int(input())

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

s=0
for i in range(0,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] and L[j]<L[i]+L[k] and L[k]<L[j]+L[i]:
                s+=1

print(s)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
ans=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            pro=[0,0,0]
            pro[0]=lis[i]
            pro[1]=lis[j]
            pro[2]=lis[k]
            if pro[0]==pro[1] or pro[0]==pro[2] or pro[1]==pro[2]:
                continue
            pro.sort()
            if pro[0]+pro[1]>pro[2]:
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    Ls = [int(item) for item in input().split()]
    Ls.sort()
    res = 0
    if N >= 3:
        for i in range(N):
            for j in range(i+1, N):
                for k in range(j+1, N):
                    if Ls[i] + Ls[j] > Ls[k] and Ls[i] != Ls[j] and Ls[j] != Ls[k] and Ls[k] != Ls[i] :
                        res += 1
    print(res)

if __name__ == "__main__":
    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+1, n):
    for k in range(j+1, n):
      x, y, z = sorted([l[i], l[j], l[k]])
      if x + y > z and x != y and y != z:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools


def main():
    num = int(input())
    array = [int(x) for x in input().split()]
    array.sort()
    ans = 0
    for ls in itertools.combinations(array, 3):
        if ls[0] != ls[1] and ls[1] != ls[2]:
            if ls[0] + ls[1] > ls[2]:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
l = sorted(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] > l[k]:
                if l[i] != l[j] != l[k]:
                    ans += 1

print(ans)

Submission status: Accepted

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

c = 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[j] + L[k] > L[i] and\
            L[k] + L[i] > L[j] and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                c += 1
print(c)

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
L.sort()
d={}
for l in L:
    if l in d:
        d[l]+=1
    else:
        d[l]=1

ans=0
for a in d:
    for b in d:
        for c in d:
            if a<b<c and a+b>c:
                ans+=d[a]*d[b]*d[c]
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=sorted(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[i]!=l[k]:
        if l[i]+l[j]>l[k]:
          cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
from itertools import combinations

N = int(input())
L = list(map(int, input().split()))
if len(L) < 3:
    print(0)
    exit()
cnt = 0
for edges in combinations(L, 3):
    if len(set(edges)) == 3:
        edges = list(edges)
        edges.sort()
        a, b, c = edges
        if c < a + b:
            cnt += 1
print(cnt)

Submission status: Accepted

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

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] or L[j] == L[k] or L[i] == L[k]:
                continue

            if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[i] + L[k] > L[j]:
                cnt += 1

print(cnt)

Submission status: Accepted

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

for i in range(n):
  for j in range(n):
    if i==j:
      break
    for k in range(n):
      if i==k or j==k:
        break
      
      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[i]!=l[k]:
          count+=1
print(count)

Submission status: Accepted

Solution code:
N = int(input())
L = [int(x) for x in input().split()]
L.sort()

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

ans = 0
for v in combinations(L, 3):
    v = sorted(v)
    if v[0] == v[1] or v[1] == v[2]:
        continue

    if v[0] >= v[1] + v[2] or v[2] >= v[1] + v[0]:
        continue

    ans += 1

print(ans)

Submission status: Accepted

Solution code:
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
n = ni()
L = lma()
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] or L[i] ==L[k] or L[j] ==L[k]:
                continue
            if L[i] +L[j]>L[k] and L[k] +L[j]>L[i] and L[i] +L[k]>L[j] :
                cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
l =list(map(int,input().split()))
l.sort()
ans=0
for p in range(0,n-2):
    for q in range(p,n-1):
        if l[p]==l[q]:
            continue
        for r in range(q,n):
            if l[q]==l[r]:
                continue
            if l[p]+l[q]>l[r]:
                ans+=1
            else:
                break
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations
N = int(input())
L = list(map(int, input().split()))

ans = 0
for lst in combinations(L, 3):
    if len(set(lst)) == 3 and max(lst) < sum(lst)-max(lst):
        ans += 1
print(ans)

Submission status: Accepted

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

if len(set(L)) < 3:
  print(0)
else:
  ans = 0
  for i in range(len(L)-2):
    for j in range(i+1, len(L)-1):
      for k in range(j+1, len(L)):
        if (L[i]!=L[j]) and (L[j]!=L[k]) and (L[i]+L[j]>L[k]):
          ans += 1
  print(ans)

Submission status: Accepted

Solution code:
def Istraiangle(A,B,C):
    if (A==B)|(B==C)|(A==C):
        return False
    if A+B>C:
        if A+C>B:
            if B+C>A:
                return True
    return False
count=0
N=int(input())
L=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 Istraiangle(L[i],L[j],L[k]):
                count+=1
print(count)

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[k] != l[i] and 2 * max(l[i], l[j], l[k]) < l[i] + l[j] + l[k]:
                ans += 1
print(ans)

Submission status: Accepted

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

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):
            if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                continue
            if abs(L[i]-L[j]) < L[k] and L[k] < L[i]+L[j]:
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int, input().split()))
m=sorted(l)
z=0
if n<3:
    print(0)
else:
    for i in range (n-2):
        for j in range (i,n-1):
            for k in range (j,n):
                if m[i]!=m[j] and m[j]!=m[k] and m[i]+m[j]>m[k]:
                    z+=1
    print(z)

Submission status: Accepted

Solution code:
n = int(input())
#a, b = map(int,input().split())
l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

import itertools
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 len(set([a,b,c]))==3:
                if a+b>c and b+c>a and a+c > b:
                    ans+=1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import math
def main():
    n = int(input())
    res = 0
    a=[int(i) for i in input().split()]
    if(n<3):
        print(0)
        exit()
    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[i]!=a[k] and a[j]!=a[k] and (a[i]+a[j] > a[k] and a[j]+a[k]>a[i] and a[i]+a[k]>a[j])):
                    res+=1
    print(res)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

cnt = 0
for i in range( n ):
    li = l[ i ]
    for j in range( i + 1, n ):
        lj = l[ j ]
        for k in range( j + 1, n ):
            lk = l[ k ]
            if ( li - lj ) * ( lj - lk ) * ( lk - li ) == 0:
                continue
            if li + lj > lk and lj + lk > li and lk + li > lj:
                cnt += 1

print( cnt )

Submission status: Accepted

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    #l,r,d=map(int,input().split())
    n=int(input())
    l=list(map(int,input().split()))
    l=sorted(l)
    ans=0
    if n>=3:
        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]:
                        if l[i]!=l[j] and l[j]!=l[k] and l[i]!=l[k]:
                            ans+=1
    print(ans)


if __name__ == "__main__":

    main()

Submission status: Accepted

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

Submission status: Accepted

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

arr.sort()
ans=0
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[i]+arr[j]>arr[k]:
                ans+=1
print(ans)

Submission status: Accepted

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

count=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            b=[a[i], a[j], a[k]]
            b.sort()
            if b[0]+b[1]>b[2]:
                if b[0]<b[1] and b[1]<b[2]:
                    count+=1
print(count)