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 itertools
import sys
input = sys.stdin.readline

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

cnt = 0
for i,j,k in itertools.combinations(list(range(n)), 3):
    if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
        if 2 * max(l[i],l[j],l[k]) < l[i]+l[j]+l[k]:
            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
L = l()
L.sort()
ans = 0
for i in range(N):
    for j in range(i+1,N):
        if L[i] != L[j]:
            num = L[i]+L[j]
            for k in range(j,N):
                if L[j] != L[k] and num > L[k]:
                    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-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 min(L[i] + L[j], L[j] + L[k], L[k] + L[i]) > max(L[k], L[i], L[j])):
                # print(i, j, k)
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import itertools

N = int(input())

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

result = 0

for c in itertools.combinations(L, 3):
    if len(set(c)) == 3:
        s = sorted(c)
        if s[0] + s[1] > s[2]:
            result += 1

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
Ss = list(map(int, input().split()))
dic = Counter(Ss)
Ss = set(Ss)
Ss = list(Ss)
Ss.sort()

cnt = 0
for i in range(len(Ss)):
  for j in range(i+1, len(Ss)):
    for k in range(j+1,len(Ss)):
      if Ss[i] + Ss[j] > Ss[k]:
        cnt += dic[Ss[i]]*dic[Ss[j]]*dic[Ss[k]]
        
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
L = list(map(int,input().split()))
L.sort(reverse = True)
#print(L)
from itertools import combinations
cnt = 0
for v in combinations(L,3):
    #print(v)
    if (v[0]!=v[1] and v[1] != v[2]) and v[0] < v[1] + v[2]:
        cnt +=1
print(cnt)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = [int(i) for i in input().split()]
cnt = 0;
L.sort()

for v in itertools.combinations(L, 3):
  if v[2] < v[0] + v[1] and len(set(v)) == 3:
    cnt += 1
    
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
dum = [0]*3
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
           dum[0],dum[1],dum[2] = l[i],l[j],l[k]
           dum.sort()
           if dum[2]-(dum[1]+dum[0]) < 0 and (dum[0] != dum[1] and dum[1] != dum[2] and dum[2] != dum[0]):
               cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
al = sorted(map(int, input().split()))

r = 0
for i in range(n-2):
  for j in range(i+1, n):
    for k in range(j+1, n):
      if al[k] < al[j] + al[i]:
        if al[k] != al[j] and al[k] != al[i] and al[i] != al[j]:
          r += 1
print(r)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

N=int(input())

L=np.array(input().split(" "),dtype=np.int64)

cnt=0
for idx in range(N):
    for jdx in range(idx,N):
        for kdx in range(jdx,N):
            a=L[idx]
            b=L[jdx]
            c=L[kdx]
            if(a!=b and b!=c and a!=c):
                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 = 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[j] + L[k] > L[i] and L[k] + L[i] > L[j] and L[i] != L[j] and L[i] != L[k] and L[j] != L[k]: 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 (l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[i]+l[k]>l[j] and l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]):
				ans+=1

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
def ip(): return [int(i) for i in stdin.readline().split()]
def sp(): return [str(i) for i in stdin.readline().split()]


def ti(i,j,k):
    if i == j or i == k or j == k: 
        return False
    if (i+j) > k and (i+k) > j and (j+k) > i:
        return True
    return False

def solve(A):
    if len(A) < 3: return 0
    ans = 0
    for i in range(len(A)):
        for j in range(i+1, len(A)):
            for k in range(j+1, len(A)):
                if ti(A[i], A[j], A[k]):
                    ans += 1
    return ans

n = input()
A = ip()
print(solve(A))

Submission status: Accepted

Solution code:
n = int(input())
l = [int(_) for _ in input().split()]
if n < 3:
    print(0)
    exit()
ans = 0
l.sort()
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            a, b, c = l[i], l[j], l[k]
            if not (a == b or b == c or c == a):
                if a + b > c:
                    ans += 1
                    #print(i+1, j+1, k+1)
print(ans)

Submission status: Accepted

Solution code:
import itertools


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

C = list(itertools.combinations(L, 3))
count = 0
for c in C:
    a, b, c = sorted(c)
    if a == b or a == c or b == c:
        continue
    if c < a + b and a < b + c and b < c + a:
        count += 1
print(count)

Submission status: Accepted

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

cnt = 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]:
                    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import itertools
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i in itertools.combinations(l, 3):
    i = sorted(list(i))
    # print(i)
    if i[0] == i[1] or i[1] == i[2]:
        continue
    if i[0]+i[1] > i[2]:
        # print(i)
        ans += 1

print(ans)

Submission status: Accepted

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

ans=0

if n<3:
  print(ans)

else:
  for x in range(0,n-2):
    for y in range(x,n-1):
      for z in range(y,n):
        if l[x]!=l[y] and l[x]!=l[z] and l[y]!=l[z]:
          if l[x]<l[y]+l[z] and l[y]<l[x]+l[z] and l[z]<l[x]+l[y]:
            ans+=1
            
  print(ans)

Submission status: Accepted

Solution code:
N = int(input())
cc = 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 cc[i] != cc[j] and cc[i] != cc[k] and cc[j] != cc[k]:
        if cc[i] + cc[j] > cc[k] and cc[j] + cc[k] > cc[i] and cc[i] + cc[k] > cc[j]:
          count += 1
print(count)

Submission status: Accepted

Solution code:
#--b--#
import sys,math,collections,itertools
input = sys.stdin.readline

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

for i in range(1,len(L)-1):
    for j in range(0,i):
        for k in range(i+1,len(L)):
            a = L[i]
            b = L[j]
            c = L[k]
            if a+b>c and b+c>a and c+a>b and a!=b and b!= c and c!= a:
                cnt +=1
print(cnt)

Submission status: Accepted

Solution code:
import sys
N = int(input())
L = list(map(int, input().split()))
if N <= 2:
    print(0)
    sys.exit()
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]:
                if L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
c = 0
if n <= 2:
    print(0)
    exit()
li = list(map(int,input().split()))

lis = list(itertools.combinations(li,3))
for i in range(len(lis)):
    if max(lis[i]) >= (sum(lis[i])-max(lis[i])):
        c += 0
    else:
        if len(lis[i]) == len(set(lis[i])):
            c += 1
        else:
            c += 0
print(c)

Submission status: Accepted

Solution code:
import sys, math, bisect


if(__name__ == "__main__"):
    """
    N = int( input().strip() )
    Length = list( map(int, input().strip().split() ) )
    """
    N = int( input().strip() )
    Length = list( map(int, input().strip().split() ) )
    Length.sort()
    comb = 0
    if(N<3):
        print(0)
    else:
        for i in range(N-1, 1, -1):
            c = Length[i]
            for j in range(i-1, 0, -1):
                b = Length[j]
                if(c>b):
                    for k in range(j-1, -1, -1):
                        if(Length[k] < b and Length[k]+b > c):
                            comb += 1
                            
        print(comb)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    s = int(input())
    a = [int(i) for i in input().split()]
    count = 0

    for i in range(0,s-2):
        for j in range(i,s-1):
            if a[i] != a[j]:
                for k in range(j,s):
                    if 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[k] +a[i]>a[j]:
                        count+=1
    print(count)

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,n):
        for k in range(j,n):
            l1 = l[i]
            l2 = l[j]
            l3 = l[k]
            if (l1 != l2 and l2 != l3 and l1 != l3) and (l1+l2 >l3 and l2+l3 > l1 and l1+l3 > l2):
               # print("{}[{}]/{}[{}]/{}[{}]".format(i,l1,j,l2,k,l3))
                cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
import itertools

count = 0
x = int(input())
line = list(map(int, input().split()))
for i in itertools.combinations(line,3):
  if i[0] != i[1] and i[1] != i[2] and i[2] != i[0] and i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
    count += 1
print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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 i == j or j == k or k == i:
                continue
            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:
                # print(a, b, c)
                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 k in range(j+1, N):
      if L[k] < (L[i] + L[j]):
        if L[i] == L[j] or L[j] == L[k]:
          continue
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for K in itertools.combinations(L, 3):
    if K[0] != K[1] and K[1] != K[2] and K[2] != K[0]:
        k_sorted= sorted(K)
        #print(k_sorted)
        if k_sorted[2] < k_sorted[0] + k_sorted[1]:
            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):
        # if i == j:
        #     continue
        for k in range(j+1, N):
            # if i == k or j == k:
            #     continue
            if L[i] == L[j] or L[i] == L[k] or L[k] == L[j]:
                continue

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

    print(ans)
main()

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
ans=0
for x in range(n-2):
    for y in range(x+1,n-1):
        for z in range(y+1,n):
            if not (l[x]==l[y] or l[y]==l[z] or l[x]==l[z]):
                p=sorted([l[x],l[y],l[z]])
                if p[0]+p[1]>p[2]:
                    ans+=1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = [int(x) for x in input().split()]

l.sort()

ans=0

import itertools
for seq in itertools.combinations(range(n),3):
    if l[seq[2]]!=l[seq[1]] and l[seq[1]]!=l[seq[0]] and l[seq[0]]!=l[seq[2]]:
        if l[seq[2]]<l[seq[0]]+l[seq[1]]:
            ans+=1  

print(ans)

Submission status: Accepted

Solution code:
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7
#DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    n=iRaw()
    Ls = isRaw()
    ans = 0
    for l1idx in range(n):
        for l2idx in range(l1idx,n):
            for l3idx in range(l2idx,n):
                l1 = Ls[l1idx]
                l2 = Ls[l2idx]
                l3 = Ls[l3idx]
                if l1 == l2 or l2==l3 or l3==l1:
                    continue
                if l1<l2+l3 and l2 <l1+l3 and l3<l1+l2:
                    ans+=1
    print(ans)     
main()

Submission status: Accepted

Solution code:
input = raw_input

from collections import Counter
n = int(input())

#ls = sorted(map(int, input().split(" ")))
c = Counter(map(int, input().split(" ")))
ls = c.keys()
n = len(ls)

out = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            a, b, d = sorted([ls[i], ls[j], ls[k]])
            if a+b > d:
                out += c[ls[i]] * c[ls[j]] * c[ls[k]]

print(out)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
cnt = 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]:
                    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from itertools import combinations


def solve(N: int, L: "List[int]"):
    l1 = list(combinations(L, 3))
    cnt = 0
    for l in l1:
        s = set(l)
        if len(s) == 3:
            M = max(l)
            if sum(l) - M > M:
                cnt += 1
    print(cnt)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for t in combinations(l, 3):
    if len(set(t))==3:
        m = max(t)
        if m < sum(t)-m:
            cnt += 1
            #print(t)
print(cnt)

Submission status: Accepted

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

cnt = 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[k] - l[j] < l[i] < l[j] + l[k]:
                cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

comb = list(itertools.combinations(L, 3))

ans = 0
for a, b, c in comb:
    if a + b > c and b + c > a and c + a > b and a != b and b != c and c != a:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import math
import fractions
import collections
import itertools
N=int(input())
L=list(map(int,input().split()))
cnt=0
for i in range(N):
    x=L[i]
    for j in range(i+1,N):
        y=L[j]
        for k in range(j+1,N):
            z=L[k]
            if ((x+y>z)and(y+z>x)and(x+z>y))and(x!=y)and(y!=z)and(z!=x):
                cnt=cnt+1
            #print(cnt,i,j,k)
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
c = 0
for i in range(len(L)):
    for j in range(i+1,len(L)):
        for k in range(j+1, len(L)):
            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[k] > L[i]
                and L[k] + L[i] > L[j]):
                c += 1
print(c)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 21:05:46 2020

@author: NEC-PCuser
"""

N = int(input())

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

L.sort()

count = 0

for i in range(len(L)):
	for j in range(i + 1, len(L)):
		if L[i] == L[j]:
			continue
		for k in range(j + 1, len(L)):
			if L[j] == L[k]:
				continue
			if L[i] + L[j] > L[k]:
				count += 1
			else:
				break
print(count)

Submission status: Accepted

Solution code:
from sys import stdin,stdout
from collections import defaultdict
import math
#input=stdin.readline
#def print(x):stdout.write(str(x)+'\n')
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
c=set()
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            s=(l[i],l[j],l[k])
            if len(set(s))==3 and (l[i]+l[j]>l[k]):
                ans+=1
            elif l[i]+l[j]<=l[k]:
                break
print(ans)

Submission status: Accepted

Solution code:
def solve():
    from itertools import combinations
    from collections import Counter
    n = int(input())
    s = list(map(int, input().split()))
    co = Counter(s)
    uni = set(s)
    cnt = 0
    for a, b, c in combinations(uni, 3):
        # print(a, b, c)
        if not(a + b <= c or b + c <= a or c + a <= b):
            cnt += co[a] * co[b] * co[c]
    print(cnt)

solve()

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):
            t = [L[i], L[j], L[k]]
            t.sort()
            if len(set(t)) == 3 and (t[0] + t[1]) > t[2]:
                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):
        cnt = 0
        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[k] != L[i]:
                    cnt += 1
        ans += cnt

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 k in range(j + 1, n ):
            if l[k] <l[i] + l[j] and l[k] != l[i] and l[i] != l[j] and 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()))

stick = combinations(L,3)

cnt = 0
for x, y, z in stick:
    l = sorted([x, y, z])
    if x - y != 0 and x - z != 0 and y - z != 0:
        if l[2] < l[0]+l[1]:
            cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
"""
    Satwik_Tiwari ;) .
    14th AUGUST , 2020  - FRIDAY
"""

#===============================================================================================
#importing some useful libraries.
from __future__ import division, print_function

from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase

from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]
from itertools import permutations as permutate
from bisect import bisect_left as bl
#If the element is already present in the list,
# the left most position where element has to be inserted is returned.
from bisect import bisect_right as br
from bisect import bisect
#If the element is already present in the list,
# the right most position where element has to be inserted is returned

#==============================================================================================
#fast I/O region
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")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

# inp = lambda: sys.stdin.readline().rstrip("\r\n")

#===============================================================================================
### START ITERATE RECURSION ###
from types import GeneratorType
def iterative(f, stack=[]):
  def wrapped_func(*args, **kwargs):
    if stack: return f(*args, **kwargs)
    to = f(*args, **kwargs)
    while True:
      if type(to) is GeneratorType:
        stack.append(to)
        to = next(to)
        continue
      stack.pop()
      if not stack: break
      to = stack[-1].send(to)
    return to
  return wrapped_func
#### END ITERATE RECURSION ####

#===============================================================================================
#some shortcuts

mod = 1000000007
def inp(): return sys.stdin.readline().rstrip("\r\n") #for fast input
def out(var): sys.stdout.write(str(var))  #for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
# def graph(vertex): return [[] for i in range(0,vertex+1)]
def zerolist(n): return [0]*n
def nextline(): out("\n")  #as stdout.write always print sring.
def testcase(t):
    for p in range(t):
        solve()
def printlist(a) :
    for p in range(0,len(a)):
        out(str(a[p]) + ' ')
def lcm(a,b): return (a*b)//gcd(a,b)
def power(x, y, p) :
    res = 1     # Initialize result
    x = x % p  # Update x if it is more , than or equal to p
    if (x == 0) :
        return 0
    while (y > 0) :
        if ((y & 1) == 1) : # If y is odd, multiply, x with result
            res = (res * x) % p

        y = y >> 1      # y = y/2
        x = (x * x) % p
    return res
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))
def isPrime(n) :
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

#===============================================================================================
# code here ;))
def chck(a,b,c):
    if(a+b>c and b+c>a and c+a>b):
        return True
    return False

def solve():
    n = int(inp())
    a = lis()
    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[i]!=a[k]):
                    if(chck(a[i],a[j],a[k])):
                        # print(i+1,j+1,k+1)
                        ans+=1
    print(ans)






testcase(1)
# testcase(int(inp()))

Submission status: Accepted

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