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

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

com = list(itertools.combinations(list(range(n)), 3))

cnt = 0
for i, j, k in com:
    a = [l[i], l[j], l[k]]
    if len(set(a)) != 3:
        continue
    if sum(a) > 2*max(a):
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
l = [int(a) for a in input().split()]
l.sort()
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] > l[k] )&( l[i] != l[j] != l[k])):
                count += 1
print(count)

Submission status: Accepted

Solution code:
N, *L = map(int, open(0).read().split())

count = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            a = L[i]
            b = L[j]
            c = L[k]
            if a == b or b == c or c == a:
                continue
            if abs(b - c) < a < b + c:
                count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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


ans = 0
if len(l) < 3:
    print(0)
else:
    prelst = list(itertools.combinations(l,3))

    for lst in prelst:
        lst = sorted(lst)
        if lst[0] + lst[1] > lst[2] and lst[0] != lst[1] != lst[2]:
            ans += 1
    print(ans)

Submission status: Accepted

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

result = 0
ind = range(len(L_list))
for i_1 in ind:
  ind_2 = range(i_1 + 1, len(L_list))
  for i_2 in ind_2:
    ind_3 = range(i_2 + 1, len(L_list))
    for i_3 in ind_3:
      if (L_list[i_1] + L_list[i_2] > L_list[i_3]) and (L_list[i_1] + L_list[i_3] > L_list[i_2]) and (L_list[i_3] + L_list[i_2] > L_list[i_1]):
        if (L_list[i_1] != L_list[i_2]) and (L_list[i_3] != L_list[i_2]) and (L_list[i_1] != L_list[i_3]): 
          result += 1
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def function(N, L):
    ans = 0
    for i in range(len(L)):
        M = L[len(L)-1-i]
        for j in range(len(L)-i-2):
            for k in range(j+1, len(L)-i-1):
                if not (L[j] == L[k]):
                    if not (M == L[k]):
                        if not (L[j] == M):
                            if L[j]+L[k] > M:
                                ans += 1
    return ans


if __name__ == '__main__':
    N = int(input())
    L = input().split()
    L = [int(i) for i in L]
    L = sorted(L)
    print(function(N, L))

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
count=0
dic = {}
for i in range(len(l)):
    if l[i] in dic:
        dic[l[i]]+=1
    else:
        dic[l[i]]=1
l_set = list(set(l))
m = len(l_set)
for i in range(m-2):
    for j in range(i+1, m-1):
        for k in range(j+1, m):
            x = l_set[i]
            y = l_set[j]
            z = l_set[k]
            if max(x, y, z) < x + y + z - max(x, y, z):
                count+=dic[x]*dic[y]*dic[z]
print(count)

Submission status: Accepted

Solution code:
import itertools

n=int(input())
c=list(map(int, input().split())) 
c.sort()
ans = 0

for r in itertools.combinations(c, 3):
    if r[0] + r[1] > r[2] and r[0] != r[1] and r[1] != r[2] and r[2] != r[0]:
        ans += 1
        #print(r)

print(ans)

Submission status: Accepted

Solution code:
n,*l=map(int,open(0).read().split())
count=0
if n<3:
    print(count)
else:
    import itertools
    for i,j,k in list(itertools.combinations(range(len(l)),3)):
        t=sorted([l[i],l[j],l[k]])
        if len(set(t))==3:
            if t[2]<t[0]+t[1]:
                count+=1
    print(count)

Submission status: Accepted

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

n=int(input())
L=list(map(int,input().split()))
L.sort()
count=0
for i in range(n):
    for j in range(i+1,n):
        if L[i]==L[j]:
            continue
        val = L[i]+L[j]
        for k in range(j+1,n):
            if L[k]==L[i] or L[k]==L[j]:
                continue
            if val>L[k]:
                count+=1

print(count)

Submission status: Accepted

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

count = 0
for c in b:
    for d in b:
        if c >= d:
            continue
        for e in b:
            if d >= e:
                continue

            if c + d > e and d + e > c and e + c > d:
                count += 1
print(count)

Submission status: Accepted

Solution code:
import itertools

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

cnt = 0
for pair in itertools.combinations(L, 3):
    t = list(pair)
    t.sort()
    if t[0]==t[1] or t[0] == t[2] or t[1] == t[2]:
        continue
    if t[2] < (t[0] + t[1]):
        cnt +=1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
aa = list(map(int, input().split()))
from collections import Counter

dic = Counter(sorted(aa))
aa = list(dic.keys())

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

Submission status: Accepted

Solution code:
import itertools

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

hen_list = list(itertools.combinations(L, 3))
ans = 0

for i in range(len(hen_list)):
  if len(hen_list[i]) == len(set(hen_list[i])):
    l = sorted(hen_list[i])
    if l[2] < (l[0] + l[1]):
      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):
    if l[i]!=l[j]:
      s=l[i]+l[j]
      for k in range(j+1,n):
        if l[i]!=l[k] and l[j]!=l[k]:
          if l[k]<s 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())
if n < 3:
    print(0)
    exit()
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):
            p =[l[i],l[j],l[k]]
            if p[0] == p[1]:
                continue
            if p[0] == p[2]:
                continue
            if p[1] == p[2]:
                continue
            #p.sort()
            if p[0] + p[1] > p[2]:
                ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

input()

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

ans = 0
for a,b,c in itertools.combinations(l, 3):
    if a == b or b == c or c == a:
        continue
    if a+b>c and b+c>a and c+a>b:
        ans+=1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2020/08/15
# AtCoder Beginner Contest 175 - B

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

# Calc
cnt = 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[j] != l[k] and l[i] != l[k]:
                wkl = list()
                wkl.append(l[i])
                wkl.append(l[j])
                wkl.append(l[k])
                wkl.sort()
                if wkl[0] + wkl[1] > wkl[2]:
                    cnt = cnt + 1

# Output
print(cnt)

Submission status: Accepted

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

ans=0
for pair in itertools.combinations(l,3):
    pair=list(pair)
    pair.sort()
    #print(pair)
    if pair[0]+pair[1]>pair[2]>abs(pair[0]-pair[1]) and pair[0]!=pair[1]!=pair[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):
    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] and  l[k] + l[j] > l[i] and  l[i] < l[j] + l[k]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    l = list(map(int, input().split()))

    l = sorted(l)[::-1]
    count = 0
    ans = [(l[i], l[j], l[k]) 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[j] < l[i] + l[k] and l[k] < l[i] + l[j]
               and not l[i] == l[j] and not l[i] == l[k] and not l[j] == l[k]]
    print(len(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n = int(input())

ls = 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 = ls[i]
            b = ls[j]
            c = ls[k]

            nums = [a,b,c]
            nums.sort()

            maxi = nums[2]
            mid = nums[1]
            mini = nums[0]

            if maxi < mid + mini and maxi != mid and mid != mini:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = [int(i) for i in input().split()]
l = sorted(l)
total = 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]:
                    total += 1
print(total)

Submission status: Accepted

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

import itertools
comb = itertools.combinations(L, 3)
ans = 0
for c in comb:
  if len(set(c)) !=3:
    continue
  tmp = sorted(c)
  if tmp[2] < tmp[1] + tmp[0]:
    ans +=1
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

c = 0
if n < 3:
    print(0)
else:
    for i in range(len(l)-2):
        x = l[i]
        for j in range(i+1, len(l)-1):
            y = l[j]
            for k in range(j+1, len(l)):
                z = l[k]
                if x != y and y != z and z != x:
                    if x + y > z and y + z > x and z + x > y:
                        c += 1
    print(c)

Submission status: Accepted

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

count = 0
for i in itertools.combinations(range(N), 3):
    Lx = sorted([L[i[0]], L[i[1]], L[i[2]]])
    if not (Lx[0] == Lx[1] or Lx[1] == Lx[2] or Lx[2] == Lx[0]):
        if Lx[0] + Lx[1] > Lx[2] :
            count += 1
    # print(Lx)
print(count)

Submission status: Accepted

Solution code:
import collections
N=int(input())
L=list(map(int,input().split()))
ans=0
for i in range(N):
    for j in range(i+1,N):
        for h in range(j+1,N):
            A=L[i]
            B=L[j]
            C=L[h]
            if abs(A-B)<C<A+B and A!=B and B!=C and C!=A:
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
import itertools
N=int(input())
L=list(map(int,input().split()))
d=list(itertools.combinations(L,3))
count=0
for i in range(len(d)):
  a=d[i][0]
  b=d[i][1]
  c=d[i][2]
  if a==b or b==c or c==a:
    continue
  elif a+b>c and b+c>a and c+a>b:
      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):
    for j in range(i,n):
        for k in range(j,n):
            if i != j and (j != k and k != i):
                if l[i] != l[j] and (l[j] != l[k] and l[k] != l[i]):  
                    abc = []
                    abc.append(l[i])
                    abc.append(l[j])
                    abc.append(l[k])
                    abc.sort()
                    if abc[0] + abc[1] > abc[2]:
                        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = list(map(int,input().split()))
combi = itertools.combinations(list(range(n)),3)
ans = 0

for i in combi:
    l_1 = [l[i[0]],l[i[1]],l[i[2]]]
    l_1.sort()
    flag_1 = l_1[0]+l_1[1]>l_1[2] and l_1[1]+l_1[2]>l_1[0] and l_1[0]+l_1[2]>l_1[1]
    flag_2 = l_1[0] != l_1[1] and l_1[1] != l_1[2] and l_1[0] != l_1[2]
    if flag_1 and flag_2:
        ans += 1

print(ans)

Submission status: Accepted

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

import itertools

out = 0

for a, b, c in itertools.combinations(L, 3):
    if a != b and b != c and a != c and a + b + c > 2 * max(a,b,c):
        out += 1

print(out)

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
arr = list(map(int, input().split()))
count = 0
for i, j, k in combinations(arr, 3):
    if i == j or j == k or k == i:
        continue
    elif (i + j) > k and (j + k) > i and (k + i) > j:
        count += 1
print(count)

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):
    #print(i)
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
        if i[0] != i[1] and i[1] != i[2] and i[2] != i[0]:
            ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    L = list(map(int, input().split()))
    count = 0
    for i, l1 in enumerate(L):
        for j in range(i+1, len(L)):
            for k in range(j+1, len(L)):
                lengths = sorted([L[i], L[j], L[k]])
                if sum(lengths[:2]) > lengths[2]:
                    if len(set(lengths)) == 3:
                        count += 1
    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if __name__ == '__main__':
    print(main())

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

import itertools
L.sort()
cL = list(itertools.combinations(L,3))

ans = 0
for tri in cL:
    if len(set(tri)) != 3:
        continue
    if tri[0] + tri[1] > tri[2]:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = list(map(int,input().split()))
if n<3:
  print(0)
  quit()

cmb = list(itertools.combinations(l,3))
count = 0
for a,b,c in cmb:
  if (a!=b and b!=c and c!=a) and (a+b>c and b+c>a and c+a>b):
    count += 1
print(count)

Submission status: Accepted

Solution code:

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

ans=0
from itertools import combinations
for a,b,c in combinations(L,3):
    if a+b>c and a!=b and b!=c:
        ans+=1
    
print(ans)

Submission status: Accepted

Solution code:
import itertools

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

li=itertools.combinations(l,3)
ans=0
for i in li:
    if i[0]==i[1] or i[1]==i[2] or i[0]==i[2]:
        continue

    temp=list(i)
    temp.sort()
    if temp[0]+temp[1]>temp[2]:
        ans+=1
        # print(temp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    n = int(si())
    l = [int(e) for e in si().split()]
    if n < 3:
        print(0)
        return
    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]:
                    temp = sorted([l[i], l[j], l[k]])
                    if temp[0]+temp[1] > temp[2]:
                        cnt += 1
    print(cnt)


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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import itertools

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

for x in itertools.combinations(L, 3):
    if len(set(x)) == 3:
        x = list(x)
        x.sort()
        if x[0] + x[1] > x[2]:
            ans += 1

#
# # print(L)
# L = list(set(L))
# L.sort()

# print(L)
# # for i in range(len(L)):
# for x in itertools.combinations(L, 3):
#     # print(x)
#     # print(x[0] ** 2 + x[1] ** 2)
#     # if x[0] ** 2 + x[1] ** 2 == x[2] ** 2:
#     ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i] + l[j] > l[k] and len(set([l[i], l[j], l[k]])) == 3:
                # print(i+1, j+1, k+1)
                count += 1
                
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

L.sort()
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 L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                continue   
            if L[i]+L[j] > L[k]:
                ans+=1
                #print(i,j,k)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations
_, l = input(), sorted(int(i) for i in input().split())
if len(l) < 3:
    print(0)
else:
    ans = 0
    for v in combinations(l, 3):
        if v[0] + v[1] > v[2] and len(set(v)) == 3:
            ans += 1
    print(ans)

Submission status: Accepted

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

def ok(a, b, c):
    return a < b + c and a > abs(b - c) and a != b and b != c and c != a

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if ok(l[i], l[j], l[k]):
                ans += 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
import itertools

# 標準入力を取得
N = int(input())
L = list(map(int, input().split()))

# 求解処理
ans = 0
for L_i, L_j, L_k in itertools.combinations(L, 3):
    if (L_i == L_j) or (L_j == L_k) or (L_k == L_i):
        continue
    if L_i + L_j + L_k > 2 * max(L_i, L_j, L_k):
        ans += 1

# 結果出力
print(ans)

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest
import os
import itertools

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


def triangle(a, b, c):
    # 三角形が存在するか確認
    if a + b > c and b + c > a and c + a > b:
        # 直角三角形
        if a ** 2 == b ** 2 + c ** 2:
            return 0
        # 鋭角三角形
        elif a ** 2 < b ** 2 + c ** 2:
            return 1
        # 鈍角三角形
        elif a ** 2 > b ** 2 + c ** 2:
            return 2
    else:
        # 三角形が存在しない
        return 3


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル
    n = int(input())
    l_s = list(map(int, input().split()))
    l_s.sort()

    # l_s = list(set(l_s))
    # aaa = list(itertools.combinations(l_s, 3))

    cnt = 0
    aaa = list(range(n))

    for a in aaa:
        an = l_s[a]
        for b in aaa[a + 1:]:
            bn = l_s[b]
            if an == bn:
                continue
            for c in aaa[b + 1:]:
                cn = l_s[c]
                if bn == cn:
                    continue
                if triangle(an, bn, cn) < 3:
                    cnt += 1
    print(cnt)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """5
4 4 9 7 5"""
        output = """5"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """6
4 5 4 3 3 5"""
        output = """8"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """10
9 4 6 1 9 6 10 6 6 8"""
        output = """39"""
        self.assertIO(test_input, output)

    def test_input_4(self):
        test_input = """2
1 1"""
        output = """0"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
a = input().split()
nl=np.array(a, dtype=int)
count=0

for i in range(0,n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      three=[nl[i],nl[j],nl[k]]
      three.sort()
      if (three[0] != three[1] and three[1]!=three[2] and three[2] < three[0]+three[1]): count+=1

print (count)

Submission status: Accepted

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

res = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            tmp = sorted([L[i], L[j], L[k]])
            if tmp[0] < tmp[1] < tmp[2] and (tmp[0] + tmp[1]) > tmp[2]:
                res += 1
print(res)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
L = LI()

"""
|A - B| < C |A + B|
"""

import itertools
cnt = 0
for v in itertools.permutations(L, 3):
    # print(len(set(v)))
    if len(set(v)) != 3 :
        continue

    a,b,c = v
    if abs(a - b) < c < a + b:
        cnt += 1
        # print(a,b,c)



print(cnt // 6)

Submission status: Accepted

Solution code:
from itertools import combinations

N = int(input())
L = list(map(int, input().split()))
ans = 0
for items in combinations(L, 3):
    if sum(items) - max(items) > max(items):
        a, b, c = items
        if a != b and b != c and a != c:
            ans += 1
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np
import itertools


def solve(N: int, L: "List[int]"):
    ans = 0
    if len(L)>2:
        for c in itertools.combinations(L,3):
            if len(set(c))==3:
                if (c[0]+c[1]>c[2]) and (c[1]+c[2]>c[0]) and (c[2]+c[0]>c[1]):
                    ans += 1
    else:
        ans = 0
    print(ans)
    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


def main():
    n = int(input())
    L = [int(e) for e in input().split()]

    ans = 0
    for t in combinations(range(n), 3):
        i, j, k = t
        if L[i] < L[j] + L[k] and L[j] < L[i] + L[k] and L[k] < L[i] + L[j] \
                and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools

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

combs = list(itertools.combinations(l, 3))
cnt = 0
for comb in combs:
    a = comb[0]
    b = comb[1]
    c = comb[2]
    if a == b or b == c or c == a:
        continue
    if a + b > c and b + c > a and c + a > b:
        cnt += 1
print(cnt)