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:
def main():
    import itertools
    N = int(input())
    A_list = list(map(int, input().split()))

    comb = list(itertools.combinations(A_list, 3))
    #print(comb)

    count = 0

    for val in comb :
        if val[0] != val[1] and val[0] != val[2] and val[1] != val[2] :
            if val[0] < val[1] + val[2] and val[1] < val[0] + val[2] and val[2] < val[1] + val[0] :
                count += 1

    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
L_dict = Counter(map(int, input().split()))
L = sorted(L_dict.keys())

count = 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[k] < L[i]+L[j]:
                count += L_dict[L[k]] * L_dict[L[j]] * L_dict[L[i]]
print(count)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    L = list(map(int, input().split()))
    ans = 0
    L.sort()
    for i, li in enumerate(L[:-2]):
        for j, lj in enumerate(L[i+1:-1], i+1):
            if li == lj:
                continue
            for k, lk in enumerate(L[j+1:], j+1):
                if lk == lj:
                    continue
                if li + lj > lk:
                    ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

if N <= 2:
    print(0)
else:
    L = list(map(int,input().split()))
    L.sort()
    ans = 0
    for i in range(N):
        for j in range(i+1,N):
            if L[i] == L[j]:
                continue
            else:
                for k in range(j+1,N):
                    if L[i] == L[k] or L[j]==L[k]:
                        continue
                    else:
                        if L[k] < L[i] + L[j]:
                            ans += 1
    
    print(ans)

Submission status: Accepted

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

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):
            li = ls[i]
            lj = ls[j]
            lk = ls[k]

            if li != lj and lj != lk and lk != li and li + lj > lk and lj + lk > li and lk + li > lj:
                count += 1

print(count)

Submission status: Accepted

Solution code:
import itertools

N = int(input())
l = sorted(list(map(int, input().split())))

cnt = 0
for v in itertools.combinations(l, 3):
  if int(v[0]) != int(v[1]) and int(v[1]) != int(v[2]) and int(v[2]) != int(v[0]):
    if int(v[1]) - int(v[0]) < int(v[2]) < int(v[0]) + int(v[1]):
      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):
      a,b,c=l[i],l[j],l[k]
      if a+b>c and a+c>b and b+c>a and a!=b and a!=c and b!=c:
        ans+=1
print(ans)

Submission status: Accepted

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

for l1 in range(len(l)):
    for l2 in range(l1+1, len(l)):
        for l3 in range(l2+1, len(l)):
            if len({l[l1], l[l2], l[l3]}) == 3 and l[l3] <l[l1]+l[l2]:
                count += 1
print(count)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
len_l = len(L)
ans = 0

for i in range(len_l):
    for j in range(i+1, len_l):
        for k in range(j+1, len_l):
            if abs(L[i]-L[j]) < L[k] < L[i] + L[j] and L[i] != L[j] != L[k] != L[i]:
                ans += 1

print(ans)

Submission status: Accepted

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

Llist = sorted(Llist)

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

print(outnum)

Submission status: Accepted

Solution code:
n=int(input())
*l,=map(int,input().split())
c=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            L=[l[i],l[j],l[k]]
            if max(L)<sum(L)-max(L) and len(L)==len(set(L)):
                c+=1
print(c)

Submission status: Accepted

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

cnt=0
for i in range(N-2):
    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]:
                tmp=[L[i],L[j],L[k]]
                if max(tmp)<sum(tmp)-max(tmp):
                    cnt+=1
print(cnt)

Submission status: Accepted

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

if n<3:
    print(0)
    exit()

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if a[i]==a[j] or a[j]==a[k] or a[k]==a[i]:
                continue
            if a[i]+a[j]<=a[k] or a[j]+a[k]<=a[i] or a[k]+a[i]<=a[j]:
                continue
            ans += 1

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 - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            if (not L[i] == L[j]) and (not L[j] == L[k]) and (not 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:
import itertools
n = int(input())
l = [int(each) for each in input().split()]
if len(l) < 3:
    print(0)
else:
    result = 0

    l2 = sorted(l)

    for pair in itertools.combinations(l, 3):
        if len(set(pair)) < 3:
            continue
        l2 = sorted(list(pair))
        if l2[0]+l2[1] > l2[2]:
            result += 1
    print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n = int(input())
    l = list(map(int, input().split()))
    c = list(itertools.combinations(l, 3))
    cnt = 0
    for i in c:
        if i[0] == i[1] or i[1] == i[2] or i[0] == i[2]: # 辺の長さ同じ
            continue
        if i[0]+i[1]>i[2] and i[1]+i[2]>i[0] and i[2]+i[0]>i[1]:
            cnt += 1
    print(cnt)



if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import itertools

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    ans=0
    for aa in itertools.combinations(arr,3):
        aa=list(aa)
        aa.sort()
        if aa[2] == aa[0]:
            continue
        if aa[2] == aa[1]:
            continue
        if aa[1] == aa[0]:
            continue
        if aa[2] < (aa[0]+aa[1]):
            ans+=1
    print(ans)

    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

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[i] != L[j] and L[j] != L[k]:
                if L[i] + L[j] > L[k]:
                    ans += 1
if N < 3:
    ans = 0
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] != l[k]:
                ans += 1

print(ans)

Submission status: Accepted

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

def tri(a, b, c):
    l = [a,b,c]
    if (a == b or b == c) or c == a:
        return False
    x = min(l)
    l.pop(l.index(x))
    y = min(l)
    l.pop(l.index(y))
    z = l[0]
    if x + y > z:
        return True
    else:
        return False

count = 0

for x in list(combinations(L, 3)):
    a = x[0]
    b = x[1]
    c = x[2]
    if tri(a,b,c):
        count += 1

print(count)

Submission status: Accepted

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

def main(n,l):
    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] or l[i]==l[k] or l[j]==l[k]:
                    continue
                lmax=max(l[i],l[j],l[k])
                sonota=l[i]+l[j]+l[k]-lmax
                if sonota>lmax:
                    #print(i,j,k)
                    count+=1
    return count

if __name__=='__main__':
    n,l=readinput()
    ans=main(n,l)
    print(ans)

Submission status: Accepted

Solution code:
import itertools
N=int(input())
L = list(map(int, input().split()))
ans=0
for i in itertools.combinations(L, 3):
    x,y,z=i
    if x==y or x==z or y==z:
        continue
    if x+y>z and x+z>y and y+z>x:
        ans+=1

print(ans)

Submission status: Accepted

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

OKs = 0
import itertools
for c in itertools.combinations(L, 3):
  if len(set(c))==3:
    c = sorted(list(c))
    c1, c2 = c[2], c[:2]
    if sum(c2) > c1:
      OKs += 1

print(OKs)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
if n<=2:
  print(0)
  exit()
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]>l[k] and len(set([l[i],l[j],l[k]]))==3:
        cnt+=1
print(cnt)

Submission status: Accepted

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


def check(a, b, c):
    return (a + b) > c and (b + c) > a and (a + c) > b


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

Submission status: Accepted

Solution code:
def main():
  N = int(input())
  L_lst = list(map(int, input().split()))
  count = 0
  if N > 2:
    for i in range(N):
      for j in range(N-i-1):
        for k in range(N-i-j-2):
          A = L_lst[i]
          B = L_lst[j+i+1]
          C = L_lst[k+j+i+2]
          if A != B and B != C and C != A:
            if A+B>C and A+C>B and B+C>A:
              count +=1
    print(count)
  else:
    print(0)
          

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:


import sys
from io import StringIO
import unittest

def resolve():
    N = int(input())
    # スペース区切りの整数の入力
    ls = list(map(int, input().split()))
    ls.sort()
    num =0
    for i in range(0,N-2):
        for j in range(i+1, N-1):
            for k in range(j+1, N):
                if ls[i]==ls[j] or ls[j]==ls[k]:
                    continue
                elif (ls[i]+ls[j])>ls[k]:
                    num=num+1

    # 文字列の入力

    # 出力
    print("{}".format(num))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
4 4 9 7 5"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """6
4 5 4 3 3 5"""
        output = """8"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10
9 4 6 1 9 6 10 6 6 8"""
        output = """39"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """2
1 1"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
N = int(input())
L = sorted([int(s) for s in input().split()])
cnt = 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[j] == L[k]:
                continue
            cnt += 1 if L[i] + L[j] > L[k] else 0
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
L = sorted(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):
            if L[i] != L[j] and L[j] != L[k] and L[i] != 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()))
cnt = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if not (L[i] == L[j] or L[j] == L[k] or L[k] == L[i]):
                if L[i]+L[j]-L[k]>0 and L[i]-L[j]+L[k]>0 and -L[i]+L[j]+L[k]>0:
                    cnt += 1
print(cnt)

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 x in range(j + 1, n):
            if L[i] == L[j] or L[i] == L[x] or L[j] == L[x]:
                continue
            if L[i] + L[j] > L[x]:
                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, N):
        for k in range(j, N):
            flag = True
            L_max = max(L[i], L[j], L[k])
            L_nokori = L[i] + L[j] + L[k] - L_max
            if L_max >= L_nokori:
                flag = False
            if L[i]==L[j] or L[j]==L[k] or L[i]==L[k]:
                flag = False
            if flag:
                ans += 1
                
print(ans)

Submission status: Accepted

Solution code:
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()
    L = LI()
    ans = 0

    for i in range(0, 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]:
                    LS = [L[i],L[j],L[k]]
                    if 2*max(LS) < L[i]+L[j]+L[k] :
                        ans += 1

    
    print(ans)

if __name__ == "__main__":
	main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#coding:utf-8

N = int(input())

L = [int(y) for y 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):
            Lon = [L[i],L[j],L[k]]
            Lon.sort()
            L1 = Lon[0]
            L2 = Lon[1]
            L3 = Lon[2]
            if(L1 != L2 and L2 != L3 and L3 != L1)and(L1 + L2 > L3)and(abs(L1 - L2) < L3):
                ans += 1

print("{}".format(ans))

Submission status: Accepted

Solution code:
import itertools

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

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

ans = 0

for bars in itertools.combinations(L, 3):
    if max(bars) >= sum(bars) - max(bars):
        continue
    if bars[0] == bars[1]:
        continue
    if bars[1] == bars[2]:
        continue
    if bars[0] == bars[2]:
        continue
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
L=sorted(list(map(int,input().split())))
a=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:
        a+=1
      elif L[i]+L[j]<=L[k]:
        break
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

        ans=ans+1
        
print(ans)

Submission status: Accepted

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

ans = 0
for i,n in enumerate(L[:-2]):
    for j,m in enumerate(L[i+1:]):
        for k,o in enumerate(L[i+j+2:]):
            if n + m <= o or n >= m + o or m >= n + o:
                continue
            if n == m or m == o or o == n:
                continue

            ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest

from itertools import combinations

def resolve():
    # s = input()
    n = int(input())
    # a, b = map(int, input().split())
    l = list(map(int, input().split()))
    cnt = 0

    for ll in combinations(l, 3):
        if ll.count(ll[0]) > 1 or ll.count(ll[1]) > 1 or ll.count(ll[2]) > 1:
            pass
        elif ll[0] + ll[1] > ll[2] and ll[1] + ll[2] > ll[0] and ll[0] + ll[2] > ll[1]:
            cnt += 1

    print(cnt)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
4 4 9 7 5"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """6
4 5 4 3 3 5"""
        output = """8"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10
9 4 6 1 9 6 10 6 6 8"""
        output = """39"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """2
1 1"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
from itertools import combinations

N = int(input())
L = [int(_) for _ in input().split()]

count = 0
for li, lj, lk in combinations(L, 3):
  if li == lj or lj == lk or lk == li:
    continue
  tmp = sorted([li, lj, lk],reverse=True)
  if tmp[1] + tmp[2] >tmp[0]:
    count += 1
print(count)

Submission status: Accepted

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

ans = 0

A.sort()

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]:
                ans+=1
                #print(i,j,k)
            else:
                break

print(ans)

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

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 len( set([ L[i], L[j], L[k] ])) != 3:
        continue
      if L[i] + L[j] > L[k]:
        cnt += 1

print( cnt )

Submission status: Accepted

Solution code:
import numpy as np
#import functools
#import operator
from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections as C #most_common
#import math
#import sympy

N = int(input())
#N,K,d= map(int,input().split())
L = list(map(int,input().split()))
#S = str(input())
#T = str(input())
c,C=0,0

def has_duplicates(seq):
    return len(seq) != len(set(seq))

for v in comb(L,3):
    if has_duplicates(v):
        continue

    if sum(v)-max(v)>max(v):
        c+=1

print(c)

Submission status: Accepted

Solution code:
N = int(input())
L = [int(x) for x in input().split()]
#L = list(set(L))
L.sort()
n = len(L)
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] > L[k] and L[i] != L[j] != L[k]:
                cnt += 1
            #print(L[i], L[j], L[k])
print(cnt)

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,n-1):
        for k in range(j,n):
            if len(set([l[i],l[j],l[k]]))<3:
                continue
            if l[i]<l[j]+l[k] and l[j]<l[i]+l[k] and l[k]<l[i]+l[j]:
                count+=1
print(count)

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
      x,y,z=sorted([L[i],L[j],L[k]])
      if x + y > z:
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

als = list(set(al))

from collections import Counter
count = Counter(al)

import itertools
ll = list(itertools.combinations(als, 3))

res = 0
for i in ll:
    if sum(i) -max(i)*2 >0:
        res += count[i[0]]*count[i[1]]*count[i[2]]
print(res)

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                if abs(L[j] - L[k]) < L[i] 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()))
count = 0
for i in range(n):
  for j in range(n):
    for k in range(n):
      if(i != j and i != k and j != k):
        if(l[i] != l[j] and l[i] != l[k] and l[j] != l[k]):
          t = [l[i], l[j], l[k]]
          t.sort()
          if(t[2] < t[1]+t[0]):
            count += 1
          
print(count//6)

Submission status: Accepted

Solution code:
def checklen(a,b,c):
    return a+b>c

n=int(input())
l=[int(i) for i in input().split()]

res=0

for i in range(n):
    for j in range(i):
        for k in range(j):
            a,b,c=l[i],l[j],l[k]
            if checklen(a,b,c) and checklen(b,c,a) and checklen(c,a,b) and len(set([a,b,c]))==3:
                res+=1

print(res)

Submission status: Accepted

Solution code:
import itertools
n=int(input())
l=[int(i) for i in input().split()]
ans=0
for i,j,k in itertools.combinations(l,3):
  if i!=j!=k and k!=i:
    if i==max(i,j,k):
      if i<j+k:
        ans+=1
    elif j==max(i,j,k):
      if j<i+k:
        ans+=1
    elif k==max(i,j,k):
      if k<j+i:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    num_list = i_list()

    if n < 3:
        print(0)
        exit()

    count = 0

    for i in range(n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                tmp_list = [num_list[i], num_list[j], num_list[k]]
                if len(set(tmp_list)) != 3:
                    continue
                tmp_list.sort()
                if tmp_list[0] + tmp_list[1] > tmp_list[2]:
                    count += 1

    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
cnt = 0
for i_1 in range(N):
    for i_2 in range(i_1+1, N):
        for i_3 in range(i_2 + 1, N):
            if (L[i_1] != L[i_2] != L[i_3]) and (abs(L[i_1] - L[i_2]) < L[i_3] < L[i_1]+L[i_2]):
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
from itertools import combinations

N = int(input())
L = list(map(int, input().split()))
cnt = 0
for i in combinations(L, 3):
    if i[0] != i[1] and i[1] != i[2] and i[2] != i[0]:
        if i[0] + i[1] > i[2] and i[0] + i[2] > i[1] and i[1] + i[2] > i[0]:
            cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
from itertools import combinations

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

def f(a, b, c):
    return len(set([a, b, c])) == 3 and a+b>c and b+c>a and c+a>b

ans = 0
for a, b, c in combinations(L, 3):
    if f(a, b, c):
        ans += 1
print(ans)

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(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[i]+L[j] > L[k] and L[i]+L[k] > L[j] and L[j]+L[k] > L[i]:
          count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

l_c = list(itertools.combinations(l,3))
l_c = list(map(list, l_c))
ans = 0
for i in l_c:
  i.sort()
  if sorted(list(set(i))) == i:
    if i[0] + i[1] > i[2]:
      ans += 1
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

n = int(input())
L =  list(map(int, input().split()))
if n < 3:
    print(0)
    exit(0)
ans = 0
for i, j, k in combinations(L, 3):
    if i != j and j != k and k != i:
        com = sorted([i,j,k])
        if com[0] + com[1] > com[2]:
            ans += 1
print(ans)