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 solve():
    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(L[i]+L[j] > L[k] and L[j]+L[k] > L[i] and L[k]+L[i] > L[j]):
                        count += 1
 
    print(count)
 
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
from itertools import combinations
N = int(input())
nums = list(map(int,input().split()))
tcount = 0
numset = set(nums)
comb = combinations(numset,3)
for i in list(comb):
	a = i[0]
	b = i[1]
	c = i[2]
	if(a+b>c and b+c>a and a+c>b):
		tcount += nums.count(a)*nums.count(b)*nums.count(c)
print(tcount)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input())
nums = input().split()
nums = [int(x) for x in nums]
nums = sorted(nums)
count = 0

for i in range(len(nums)-2):
  num1 = nums[i]

  for j in range(len(nums)-2-i):
    num2 = nums[j+i+1]

    for k in range(len(nums)-2-i-j):
      num3 = nums[k+j+i+2]
      
      if (num1 + num2) > num3 and num1 < num2 and num2 < num3:
        count += 1
        
      #print('1: {}, 2: {}, 3: {}'.format(num1,num2,num3))

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

ans = 0

for a, b, c in combinations(L, 3):
    if a == b or b ==c or a == c:
        continue
    if a + b + c - max(a, b, c) > max(a, b, c):
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

le = len(L)

score = 0

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

print(score)

Submission status: Accepted

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

ans = 0
for i in range(n - 2):
    for j in range(i + 1,n - 1):
        for k in range(j + 1,n):
            if l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
                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=sorted(list(map(int,input().split())))

c=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
            if L[i]+L[j]>L[k]:
                c+=1
            else:
                break
print(c)

Submission status: Accepted

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

count = 0

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

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]:
                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()))
ans = 0
if N < 3 :
    ans = ans
else :
    for m in range(N-2) :
        for n in range(m+1,N-1) :
            for k in range(n+1,N) :
                if len(set([l[m],l[n],l[k]])) == 3 and 2 * max(l[m],l[n],l[k]) < sum([l[m],l[n],l[k]]) :
                    ans += 1
                else :
                    continue
print(ans)

Submission status: Accepted

Solution code:
import itertools
import sys
N = int(input())
if N < 3:
  print(0)
  sys.exit()

#辺を取得してint型に変換
hen_list = input().split()
for i in range(len(hen_list)):
    hen_list[i] = int(hen_list[i])

#組み合わせ
count = 0
for tri in itertools.combinations(hen_list, 3):
    sort_tri = sorted(tri)
    if sort_tri[0] + sort_tri[1] > sort_tri[2]:
        if tri[0] != tri[1] and tri[0] != tri[2] and tri[1] != tri[2]:
            #print(sort_tri)
            count += 1
print(count)

Submission status: Accepted

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

if(n<3):
    print(0)
    exit()
l.sort(reverse=True)
ln = len(l)
cnt = 0
for i in range(ln):
    for j in range(i+1,ln):
        for k in range(j+1,ln):
            a,b,c = l[i],l[j],l[k]
            if(a==b or b==c or a==c):
                continue
            if(a<(b+c)):
                cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
line = input().split()

length = [int(line[i]) for i in range(n)]
length.sort(reverse = True)

count = 0

for i in range(n-2):
  long = length[i]
  
  for j in range(i+1,n-1):
    middle = length[j]
    if middle == long:
      continue
    if middle*2 <= long :
      break
      
    for k in range(j+1,n):
      short = length[k]
      if short == middle:
        continue
      if short + middle > long:
        count += 1
      else:
        break

print(count)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split())) #リストで複数行作るには？

count = 0

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(N: int, L: "List[int]"):
    L.sort()
    return sum(L[i] not in [L[j], L[k]] and L[j] != L[k] and L[i] + L[j] > L[k] for i in range(N) for j in range(i+1, N) for k in range(j+1, N))


def main():

    sys.setrecursionlimit(10 ** 6)

    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]"
    print(f'{solve(N, L)}')


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

Submission status: Accepted

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

l.sort()

for i in range(len(l)):
    for j in range(len(l)):
        for k in range(len(l)):
            if i == j or j == k or k==i:
                pass
            else:
                if l[i] >= l[j] or l[j] >= l[k] or l[k] <= l[i]:
                    pass
                else:
                    s[0] = l[i]
                    s[1] = l[j]
                    s[2] = l[k]
                  
                    if s[2] < s[1] + s[0]:
                        count += 1
                    else:
                        pass

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
M=list(map(int,input().split()))
M.sort()
dic={}
dic[M[0]]=1
for i in range(1,n):
	if(M[i]!=M[i-1]):
		dic[M[i]]=1
	else:
		dic[M[i-1]]+=1

L=list(dic.keys())
l=len(L)
L.sort()
count=0
for i in range(0,l):
	for j in range(0,i):
		for k in range(0,j):
			if(L[i]<L[j]+L[k]):
				count+=dic[L[i]]*dic[L[j]]*dic[L[k]]
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+1, N):
        for k in range(j+1, N):
            a = sorted([L[i], L[j], L[k]])
            if a[0] == a[1] or a[1] == a[2] or a[2] == a[0]:
                continue
            if a[0] + a[1] > a[2]:
                ans += 1
 
print(ans)

Submission status: Accepted

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

for i in range(len(l_list)):
    for j in range(i + 1, len(l_list)):
        for k in range(j + 1, len(l_list)):
            if l_list[i] + l_list[j] > l_list[k] \
                    and l_list[i] != l_list[j] \
                    and l_list[j] != l_list[k] \
                    and l_list[k] != l_list[i]:
                ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = int(readline())
    L = [int(i) for i in readline().split()]
    #まず三角形ができる組みを考える
    #三重ループでも間に合うので三重ループを回す
    L.sort()
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                if L[k] < L[i] + L[j]:
                    if (L[i] != L[j]) & (L[j] != L[k]) & (L[k] != L[i]):
                        cnt += 1
    print(cnt)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools

n = int(input())
l = list(map(int, input().split()))
p_list = list(itertools.permutations(l, 3))
results = [x for x in p_list if max(x) < (sum(x) - max(x)) and len(x) == len(set(x))]
print(int(len(results) / 6))

Submission status: Accepted

Solution code:
import itertools

def main(L):
    ans = 0
    for pair in itertools.combinations(L, 3):
        if len(set(pair)) < 3:
            continue
        lines = list(pair)
        a = max(lines)
        lines.remove(a)
        b, c = lines
        if a < b + c:
            ans += 1
    return ans

if __name__ == '__main__':
    N = int(input())
    L = list(map(int, input().split()))
    ans = main(L)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#B問題

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

for i in range(0,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[j] + A[k] > A[i] and A[k] + A[i] > A[j] and A[i] != A[j] and A[j] != A[k] and A[k] != A[i] :
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())
l_list = [int(x) for x in input().split()]

d = defaultdict(int)
for l in l_list:
    d[l] += 1

n = len(d)
l_list = sorted(d.keys())
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_list[i], l_list[j], l_list[k]
            if a + b <= c:
                continue
            ans += d[a] * d[b] * d[c]
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):
            if l[i] == l[j]:
                continue
            if l[j] == l[k]:
                continue
            if l[i] == l[k]:
                continue
            if max(l[i], l[j], l[k]) * 2 < l[i] + l[j] + l[k]:
                ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

N = int(input())
L = list(map(int, input().split()))
ans = 0
for v in combinations(L, 3):
    if len(set(v)) == 3:
        a, b, c = v
        if a + b > c and c + a > b and b + c > a:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = [int(i) for i in 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):
            l1 = l[i]
            l2 = l[j]
            l3 = l[k]
            if (l1 != l2) &(l2 != l3)&(l1 + l2 > l3):
                count += 1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
s = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j, n):
            if (l[i] == l[j]) | (l[j] == l[k]) | (l[i] == l[k]):
                continue
            if l[i] + l[j] <= l[k]:
                continue
            if abs(l[i]- l[j]) >= l[k]:
                continue
            s += 1
print(s)

Submission status: Accepted

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

X = 0
Y = 0

B = []

for i in range(N-2):
    X = i + 1
    for j in range(X,N-1):
        Y = j + 1
        for k in range(Y, N):
            if A[k] < A[i] + A[j]:
                if A[k] != A[i] and A[i] != A[j] and A[k] != A[j]:
                    B.append((A[i],A[j],A[k]))

print(len(B))

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
L = list(map(int,input().split()))
ans = 0
for a,b,c in combinations(L,3):
    ans += (2*max(a,b,c) < a+b+c)*(a != b and b != c and c != a)
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
L = list(map(int,input().split()))
ans = 0
for x in combinations(L,3):
    a,b,c = map(int,x)
    if a == b or b == c or c == a:
        continue
    ans += (2*max(a,b,c) < a+b+c)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = [int(i) for i in 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):
            l1 = l[i]
            l2 = l[j]
            l3 = l[k]
            if l1 != l2:
                if l2 != l3:
                    if l1 + l2 > l3:
                        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+1, n):
        for k in range(j+1, n):
            a = sorted([l[i], l[j], l[k]])
            if a[0] == a[1] or a[1] == a[2] or a[2] == a[0]:
                continue
            if a[0] + a[1] > a[2]:
                ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

result = 0

for a_i in range(n):
  for b_i in range(a_i+1, n):
    for c_i in range(b_i+1, n):
      l_a = a[a_i]
      l_b = a[b_i]
      l_c = a[c_i]
      
      if l_a == l_b or l_b == l_c or l_a == l_c:
        continue

      if l_a + l_b > l_c and l_b + l_c > l_a and l_c + l_a > l_b:
        result += 1
print(result)

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):
      a = l[i]
      b = l[j]
      c = l[k]
      if a == b or b == c or c == a:
        continue
      if l[i] + l[j] > l[k]:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
a = [input() for i in range(2)]
b = a[1].split(" ")
ans = 0

num = int(a[0])
if num>2:
  for i in range (0,num-2):
    for j in range (i+1,num-1):
      for k in range (j+1, num):
        if int(b[i])!=int(b[j]):
          if int(b[j])!=int(b[k]):
            if int(b[k])!=int(b[i]):
              if int(b[i])+int(b[j])>int(b[k]):
                if int(b[j])+int(b[k])>int(b[i]):
                  if int(b[k])+int(b[i])>int(b[j]):
                    ans=ans+1
print(ans)

Submission status: Accepted

Solution code:
sticks=int(input())
lengths=input()
new_list=lengths.split()
list=[]
for item in new_list:
    list.append(int(item))
i=len(list)-1
j=i-1
k=i-2
count=0
empty=[]
while i>=2:
    while j>=1:
        while k>=0:
            if list[i]!=list[j]and list[i]!=list[k]and list[j]!=list[k]:
                empty.append((list[i],list[j],list[k]))
            k=k-1
        j=j-1
        k=j-1
    i=i-1
    j=i-1
    k=j-1
for items in empty:
    if items[0]+items[1]>items[2]and items[1]+items[2]>items[0]and items[2]+items[0]>items[1]:
        count=count+1
print(count)

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

print(cnt)

Submission status: Accepted

Solution code:
from itertools import combinations

def main():
    _ = int(input())
    A = list(map(int, input().split()))
    if len(set(A)) < 3:
        print(0)
        return
    C = combinations(A, 3)
    ans = 0
    for c in C:
        c = sorted(c)
        if c[0] != c[1] and c[0] != c[1] and c[1] != c[2]:
            if c[2] < c[1] + c[0]:
                ans += 1
    print(ans)
    
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
from itertools import combinations

data1 = input()
data2 = [int(i) for i in input().split(" ")]

count = 0
if len(data2) >= 3:
  for d1, d2, d3 in combinations(data2, 3):
    if d1 == d2 or d2 == d3 or d1 == d3:
      continue
    if d1 + d2 <= d3 or d1 + d3 <= d2 or d2 + d3 <= d1:
      continue
    count += 1

  print(count)
else:
  print(0)

Submission status: Accepted

Solution code:
def check(a,b,c):
    if a == b:
        return False
    if b == c:
        return False
    if c == a:
        return False
    m = max(a,b,c)
    if m >= (a+b+c)-m:
        return False
    return True

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

Submission status: Accepted

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

def is_valid(a, b, c):
    valid = a != b and a != c and b != c
    is_triangle = a + b > c and b + c > a and c + a > b

    return valid and is_triangle


count = 0
for i in range(N):
    for j in range(i, N):
        for k in range(j, N):
            if is_valid(ls[i], ls[j], ls[k]):
                # print(i+1, j+1, k+1)
                count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
l = input()
l = l.split()
a = 0
b = 1
c = 2
e = [0]
for d in range(int(n*(n-1)*(n-2)/6)):
    e.append(int(l[a]))
    e.append(int(l[b]))
    e.append(int(l[c]))
    if b == n - 2 and c == n - 1:
        a = a + 1
        b = a + 1
        c = a + 2
    elif c == n - 1:
        b = b + 1
        c = b + 1
    else:
        c = c + 1
j = 0
for f in range(int((len(e)-1)/3)):
    g = e[f*3+1]
    h = e[f*3+2]
    i = e[f*3+3]
    if g != h and h != i and g != i:
        if g + h > i and h + i > g and g + i > h:
            j = j + 1
print(j)

Submission status: Accepted

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

print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
L = [int(i)for i in input().split()]
ans = 0
L.sort(reverse=True)
for i,l in enumerate(L[:-2]):
    for j,l2 in enumerate(L[i+1:N-1]):
        for l3 in L[i+j+2:]:
            if l < l2 + l3:
                if l > l2 > l3:
                    ans += 1
            else:
                break
print(ans)

Submission status: Accepted

Solution code:
count = 0

length = int(input())
length_list = list(map(int, input().split()))

for i in range(length - 2):
    for j in range(i + 1, length - 1):
        if length_list[i] != length_list[j]:
            for k in range(j + 1, length):
                if length_list[j] != length_list[k] and length_list[k] != length_list[i]:
                    half_length_sum = (length_list[i] + length_list[j] + length_list[k]) / 2
                    if half_length_sum > max(length_list[i], length_list[j], length_list[k]):
                        count += 1
print(count)

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
Ls = list(map(int,input().split()))
score=0
for i in range(0,N-2):
  a = Ls[i]
  for j in range(i+1, N-1):
      b = Ls[j]
      for k in range(j+1, N):
        c = Ls[k]
        if ((a+b>c)&(a+c>b)&(b+c>a)&(a!=b)&(a!=c)&(b!=c)):
          score+=1

print(score)

Submission status: Accepted

Solution code:
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):
            m = max(Ls[i],Ls[j],Ls[k])
            if Ls[i] + Ls[j] + Ls[k] - 2*m > 0 and Ls[i] != Ls[j] and Ls[i] != Ls[k] and Ls[j] != Ls[k]:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:

N = int(input())
Ns = list(map(int, input().split()))
Ns.sort()
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(Ns[i] == Ns[j] or Ns[k] == Ns[j]):
				continue

			if(Ns[i] + Ns[j] > Ns[k] and Ns[j] + Ns[k] > Ns[i] and Ns[k] + Ns[i] > Ns[j]):
				ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = int(input())
l_list = list(map(int, input().split()))
l_combo = itertools.combinations(l_list, 3)
ans = 0
for i in l_combo:
    if i[0] + i[1] > i[2] and i[1]+i[2] > i[0] and i[0] + i[2] > i[1] and i[0] != i[1] and i[1] != i[2] and i[0] != i[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):
      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]: ans += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
if n<=2:
    print(0)
else:
    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]:
                    a=[l[i],l[j],l[k]]
                    a.sort()
                    if a[2]<a[0]+a[1]:
                        count+=1
    print(count)

Submission status: Accepted

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

kosu = 0

if N <= 2:
    print(kosu)

else:
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            for k in range(j + 1, N):
                if hen[i] != hen[j] and hen[j] != hen[k] and hen[k] != hen[i]\
                and hen[i] + hen[j] > hen[k] and hen[k] + hen[i] > hen[j] and hen[j] + hen[k] > hen[i]\
                and i < j < k:
                    kosu += 1

    print(kosu)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n=int(input())
s=list(map(int,input().split()))
s.sort()
ans=0
for i in range(n):
  for j in range(n):
    if s[i]<s[j]:
      for k in range(n):
        if s[j]<s[k] and s[i]+s[j]>s[k]:
          ans+=1
print(ans)