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:
n = int(input())
l = [ int(x) for x in input().split() ]
l.sort()

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

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

print(c)

Submission status: Accepted

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

N = int(readline().strip())
l = list(map(int, readline().split()))

L = {}
S = []
for i in range(N):
  if l[i] not in L:
    L[l[i]] = 1
    S.append(l[i])
  else:
    L[l[i]] += 1
S.sort()

n = len(S)
ans = 0

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

for i in range(n):
  for j in range(i+1, n):
    for k in range(j+1, n):
      if S[k] < S[i] + S[j]:
        ans += L[S[i]] * L[S[j]] * L[S[k]]
print(ans)

Submission status: Accepted

Solution code:
import itertools

n = int(input())

s = list(map(int,input().split()))
p = list(itertools.combinations(s, 3))
#print(p)

ans = 0
for i in range(len(p)):
    if sum(p[i]) - max(p[i]) > max(p[i]) and len(p[i]) == len(set(p[i])):
        ans = ans + 1
        #print(i,ans)

#print(set(p[0]),len(set(p[0])))
print(ans)

Submission status: Accepted

Solution code:
import itertools
N=int(input())
L=sorted(list(map(int,input().split())))
S=list(itertools.combinations(L,3))
n=int(N*(N-1)*(N-2)/6)
ans=0

for i in range(n) :
    if S[i][0]==S[i][1] or S[i][1]== S[i][2] :
        continue
    if S[i][0]+S[i][1]>S[i][2] :
        ans+=1

print(ans)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
li = list(map(int, input().split()))
c = 0
for a in itertools.combinations(li, 3):
  b = sorted(a, reverse=True)
  if b[0] != b[1] and b[1] != b[2] and b[2] != b[0]:
    if b[0] < b[1] + b[2]:
      c = c + 1
print(c)

Submission status: Accepted

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

N=int(input())

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

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

Submission status: Accepted

Solution code:
import sys
import collections
import itertools
import operator
import bisect
import heapq
import fractions
import math as mt
import copy
import numpy
import scipy

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

lst=list(itertools.combinations(L,3))
cnt=0
for a in lst:
  if a[0]>abs(a[1]-a[2]) and a[0]<a[1]+a[2] and a[0]!=a[1] and a[0]!=a[2] and a[1]!=a[2]:
    cnt+=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
li = 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 li[i]!=li[j] and li[i]!=li[k] and li[j]!=li[k]:
                q=[]
                q.append(li[i])
                q.append(li[j])
                q.append(li[k])
                q.sort(reverse=True)
                if q[0]<q[1]+q[2]:
                    cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
nums = list(map(int, input().split()))
cnt = 0

for i in range(N):
    for j in range(N):
        for k in range(N):
            tmp_list = [nums[i], nums[j], nums[k]]
            if i >= j or j >= k:
                continue
            if len(tmp_list) != len(set(tmp_list)):
                continue
            else:
                tmp_list.sort()
                if tmp_list[-1] >= sum(tmp_list[:-1]):
                    continue
                else:
                    cnt += 1
print(cnt)

Submission status: Accepted

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

def exist(l1, l2, l3):
    array = [l1, l2, l3]
    array.sort()
    return array[0] + array[1] > array[2]

count = 0
for i in range(N - 2):
    Li = Ln[i]
    for j in range(i + 1, N - 1):
        Lj = Ln[j]
        if Li == Lj:
            continue
        for k in range(j + 1, N):
            Lk = Ln[k]
            if Li == Lk or Lj == Lk:
                continue
            if exist(Li, Lj, Lk):
                count += 1

print(count)

Submission status: Accepted

Solution code:
N = int(input())
l = list(map(int, input().split()))
q = 0
c = 0
l.sort()
for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      n1 = l[i]
      n2 = l[j]
      n3 = l[k]
      c += 1
      if n1 == n2 or n2 == n3 or n3 == n1:
        continue
      if n1 + n2 > n3:
        q += 1
print(q)

Submission status: Accepted

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

count = 0

if N <=2:
  print(0)
else:
  for i in range(N-2):
    for j in range(i, N-1):
      if L[i] != L[j]:
        for k in range(j,N):
          if L[i] != L[k]:
            if L[j] != L[k]:

              if L[i] < L[j]:
                if L[j]<L[k]:
                  if L[i] + L[j] > L[k]:
                    count = count + 1
                else:
                  if L[i] + L[k] > L[j]:
                    count = count + 1
              else:
                if L[i]<L[k]:
                  if L[i] + L[j] > L[k]:
                    count = count + 1
                else:
                  if L[j] + L[k] > L[i]:
                    count = count + 1
  print(count)

Submission status: Accepted

Solution code:
""" B
    https://atcoder.jp/contests/abc175/tasks/abc175_b
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return [readIntegerSet(m) for _ in range(0, n)]

def main(N, L):
    count = 0

    for i in range(0, N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                lines = [L[i], L[j], L[k]]
                if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
                    continue
                max_line = max(lines)
                sum_line = sum(lines) 
                if max_line < sum_line - max_line:
                    count += 1

    return count

if __name__ == "__main__":
    _N = readInteger()
    _L = readIntegerSet(_N)

    print(main(_N, _L))

Submission status: Accepted

Solution code:
n = int(input())
ls = list(map(int, input().split()))
ans = 0
san = []

for i in range(len(ls)):
    for j in range(i+1, len(ls)):
        for k in range(j+1, len(ls)):
            temp1 = ls[i] != ls[j] and ls[j] != ls[k] and ls[i] != ls[k]
            temp2 = ls[i] + ls[j] > ls[k] > abs(ls[i]-ls[j])
            temp3 = ls[j] + ls[k] > ls[i] > abs(ls[j]-ls[k])
            temp4 = ls[i] + ls[k] > ls[j] > abs(ls[i]-ls[k])
            if temp1 and (temp2 or temp3 or temp4):
                san.append([ls[i], ls[j], ls[k]])

                ans += 1

print(ans)

Submission status: Accepted

Solution code:


def solve():
	n=int(input())
	arr=[int(i) for i in input().split()]
	#arr=list(set(arr))
	arr.sort()
	count=0
	for i in range(len(arr)):
		for j in range(i+1,len(arr)):
			for k in range(j+1,len(arr)):
				if(arr[i]+arr[j]>arr[k]):
					if(arr[i]!=arr[j] and arr[j]!=arr[k]):
						count+=1
					
	print(count)




	


	   
	    
	
	
#test=int(input())
test=1
while test:

	solve()
	test-=1

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
l.sort()
l.reverse()
c = 0
for i in range(n-2):
    for k in range(i+1,n-1):
        if l[i] == l[k]:continue
        a = l[i] - l[k]
        for m in range(k+1,n):
            if (l[i] == l[m] or l[k] == l[m]):continue
            if a - l[m] < 0:
                c += 1
            else:
                break
print(c)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
l = list(map(int, input().split()))
cnt = 0
for a, b, c in itertools.combinations(l, 3) :
    if max([a, b, c]) < (sum([a, b, c]) - max([a, b, c])) :
        if len([a, b, c]) == len(set([a, b, c])) :
            cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import itertools
import numpy as np

N = int(input(''))
L = (list(map(int, input('').split(' '))))
L = np.array(sorted(L))
set_L = set(L)

if len(set_L) <= 2:
    print(0)
else:
    K = {i:len(L[L==i]) for i in set_L}
    
    i = 0
    for team in itertools.combinations(K.keys(), 3):
        if (team[0] < team[1] + team[2]) & (team[1] < team[0] + team[2]) & (team[2] < team[0] + team[1]):
            i += K[team[0]]*K[team[1]]*K[team[2]]
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = [int(i) for i in input().split()]
l.sort()
d = {}
dd = set()
for i in l:
    if i in d:
        d[i] += 1
        dd.add(i)
    else:
        d[i] = 1
r = list(d.keys())
m = len(set(l))
c = 0
x = 0
for i in range(m):
    for j in range(i + 1, m):
        for k in range(j + 1, m):
            x = 0
            if r[i] + r[j] > r[k]:
                x = 1
            if r[i] in dd:
                x *= d[r[i]]
            if r[j] in dd:
                x *= d[r[j]]
            if r[k] in dd:
                x *= d[r[k]]
            c += x
print(c)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
cnt = 0
l.sort()
for i in l:
    for j in l:
        for k in l:
            if (i != j and i != k and j != k) and (i+j > k and j+k > i and k+i > j):
                cnt += 1
print(int(cnt/6))

Submission status: Accepted

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

cnt = 0

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

print(cnt)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#B
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[k]<l[i]+l[j] and l[i]<l[j]+l[k] and l[j]<l[i]+l[k]:
                if l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
                    cnt += 1
print(cnt)

Submission status: Accepted

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

import itertools
C = itertools.combinations(L,3)

for c in C: 
  if len(set(c)) != 3: continue
  if sum(c) > 2*max(c): a += 1
    
print(a)

Submission status: Accepted

Solution code:
def same_hantei(a, b, c):
    if a==b or b==c or c==a:
        return 0
    else:
        return 1

def is_triangle(a, b, c):
    ret = same_hantei(a, b, c)
    if ret == 0:
        return 0
    if a+b > c and b+c > a and c+a > b:
        return 1
    else:
        return 0

num = int(input())
arr = [int(e) for e in input().split()]

count = 0
for i in range(0, num-2):
    for j in range(i+1, num-1):
        for k in range(j+1, num):
            res = is_triangle(arr[i], arr[j], arr[k])
            count += res

print(count)

Submission status: Accepted

Solution code:
import itertools

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

count = 0

l.sort()

kumiawase = list(itertools.combinations(l,3))

for i in range(len(kumiawase)):
  if kumiawase[i][0] != kumiawase[i][1] and kumiawase[i][1] != kumiawase[i][2]:
    if kumiawase[i][0] + kumiawase[i][1] > kumiawase[i][2]:
      count += 1
      
print(count)

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

L.sort()

counter=0

for i in L:
  for j in L:
    if i==j:
      continue
    for k in L:
      if i==k or j==k:
        continue
      else:
        if i+j>k and j+k>i and k+i> j:
          counter=counter+1

print(counter//6)

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

cnt = 0
for i in range(n):
    a = l[i]
    for j in range(i+1, n):
        b = l[j]
        for k in range(j+1, n):
            c = l[k]
            if a == b or a == c or b == c:
                continue
            m = max(a, b, c)
            if m == a and a < b + c:
                cnt += 1
            elif m == b and b < a + c:
                cnt += 1
            elif m == c and c < a + b:
                cnt += 1
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import combinations
n=int(input())
l=list(map(int, input().split()))
base = list(combinations(l,3))
c = len(base)
ans=0
for i in range(c):
  if base[i][0]==base[i][1] or base[i][0]==base[i][2] or base[i][1]==base[i][2]:
    continue
  ct1 = base[i][0]+base[i][1]
  ct2 = base[i][0]+base[i][2]
  ct3 = base[i][1]+base[i][2]
  if ct1>base[i][2] and ct2>base[i][1] and ct3>base[i][0]:
    ans+=1
    #print(base[i])
print(ans)
#print(ct1)

Submission status: Accepted

Solution code:
import itertools

N = input()
L = input().split()
count = 0

for v_s in itertools.combinations(L, 3):
    v = [int (vv) for vv in v_s]
    if (v[0] != v[1]) and (v[1] != v[2]) and (v[2] != v[0]): 
        if (v[0]+v[1]>v[2]) and (v[1]+v[2]>v[0]) and (v[2]+v[0]>v[1]):
            count += 1

print(count)

Submission status: Accepted

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

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            tmp = [l[i], l[j], l[k]]
            tmp.sort()
            if tmp[0] == tmp[1] or tmp[1] == tmp[2]:
                continue
            if tmp[0] + tmp[1] <= tmp[2]:
                continue
            cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

l.sort()

cnt=0
for i in l:
    for j in l:
        for k in l:
            if i<j<k and i+j>k:
                cnt+=1

print(cnt)

Submission status: Accepted

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

for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
        continue
      if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[k]+l[i]>l[j]:
        ans = ans + 1
print(ans)

Submission status: Accepted

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

ans = 0

for i in range(n):
    for j in range(1,n):
        for k in range(2,n):
            tmp = []
            if i != j != k and i < j < k:
                tmp.append(a[i])
                tmp.append(a[j])
                tmp.append(a[k])
                tmp.sort()
                if len(tmp) == 3 and abs(tmp[0]-tmp[1]) < tmp[2] and tmp[2] < tmp[0]+tmp[1] and tmp[0] != tmp[1] != tmp[2]:
                    ans += 1

print(ans)

Submission status: Accepted

Solution code:

N = int(input())
L = [int(a) for a in input().split()]
count = 0

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

res = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if i == j: continue
        for k in range(j+1, n):
            if i == k or j == k:
                continue;
            if l[i] + l[j] > l[k] and l[k] + l[j] > l[i] and l[i] + l[k] > l[j] \
                    and l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
                #  print(l[i], l[j], l[k])
                #  print(i+1, j+1, k+1)
                res += 1


print(res)

Submission status: Accepted

Solution code:
import itertools
from collections import Counter

n = int(input())
l = list(map(int,input().split()))
a = sorted(list(set(l)))
b = Counter(l)
ans = 0
for v in itertools.combinations(a, 3):
    if v[0]+v[1]>v[2]:
        ans += b[v[0]]*b[v[1]]*b[v[2]]
print(ans)

Submission status: Accepted

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    res = 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]) | (L[k] == L[i]):
                    continue
                temp = [L[i], L[j], L[k]]
                temp = sorted(temp)
                if temp[0] + temp[1] > temp[2]:
                    res += 1

    print(res)



main()

Submission status: Accepted

Solution code:
n=int(input())
L=sorted(map(int,input().split()))
x=0
for i in L:
  for j in L[:i]:
    if j==i:
      break
    for k in L[:j]:
      if k==j:
        break
      if i<j+k:
        x+=1
print(x)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import combinations
from bisect import bisect_left

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

S = sorted(L.keys())

count = 0
for i, j in combinations(range(len(S) - 1), 2):
  for k in range(j + 1, bisect_left(S, S[i] + S[j])):
    count += L[S[i]] * L[S[j]] * L[S[k]]

print(count)

Submission status: Accepted

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

ans = 0
for x, y, z in itertools.combinations(range(N), 3):
    if nums[x] != nums[y] and nums[x] != nums[z] and nums[z] != nums[y]:
        if nums[x] > nums[y] and nums[x] > nums[z]:
            if nums[x] < nums[y]+nums[z]:
                ans += 1
        elif nums[y] > nums[x] and nums[y] > nums[z]:
            if nums[y] < nums[x]+nums[z]:
                ans += 1
        elif nums[z] > nums[x] and nums[z] > nums[y]:
            if nums[z] < nums[x]+nums[y]:
                ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

c=0
n=len(L)
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if L[i]==L[j] or L[j]==L[k]:
                continue
            if L[i]+L[j]>L[k] :
                c+=1           
print(c)

Submission status: Accepted

Solution code:
import itertools
N=input()
L=list(map(int,input().split()))
L.sort()
C=list(itertools.combinations(L,3))
ans=0
for a in C:
    if a[0]==a[1] or a[0]==a[2] or a[1]==a[2]:
        continue
    else:
        # print(a)
        if (a[0]+a[1])>a[2]:
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
L = sorted(map(int, input().split()))
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if L[i] == L[j]:
            continue
        for k in range(j+1, n):
            if L[j] == L[k]:
                continue
            if L[k] < L[i] + L[j]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
iter = 0
if len(l)<3:
  print(iter)
  exit()
for i in range(n):
  lst = [j for j in l if j > l[i]]
  if len(lst)<2:
    break
  else:
    #print(lst)
    for k in range(len(lst)):
      for m in range(len(lst)):
        if l[i]+lst[k]>lst[m] and l[i]+lst[m]>lst[k] and lst[m]+lst[k]>l[i] and l[i]!=lst[k] and lst[k]!=lst[m] and lst[m]!=l[i]:
          iter+=1
  
print(int(iter/2))

Submission status: Accepted

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

if n <= 2:
    print(0)
else:
    cnt = 0
    c = list(itertools.combinations(l, 3))
    for i in range(len(c)):
        if c[i][0] != c[i][1] and c[i][0] != c[i][2] and c[i][1] != c[i][2]:
            if c[i][0] + c[i][1] > c[i][2] and c[i][0] + c[i][2] > c[i][1] and c[i][2] + c[i][1] > c[i][0]:
                cnt += 1
    print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

def sankakuteiri(a, b, c):
    #a > b > cにする
    list = [a, b, c]
    list.sort(reverse=True)

    if (list[0] == list[1]) or (list[1] == list[2]):
        return False
    elif(list[1] + list[2] > list[0]):
        return True
    else:
        return False


n = int(input())
numbers = input().split(" ")
l = [int(x) for x in numbers]


r = 0
if len(l) >= 3:
    for i in range(len(l)):
        for j in range(i + 1, len(l)):
            for k in range(j + 1, len(l)):
                if sankakuteiri(l[i], l[j], l[k]):
                    r += 1

print(r)

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[j] != l[k] and l[i] != l[k]:
                if abs(l[i] - l[j]) < l[k] and l[k] < l[i] + l[j]:
                    count += 1
                else:
                    continue
            else:
                continue
print(count)

Submission status: Accepted

Solution code:
param_n = int(input())
param_list = list(map(int, input().split()))

if param_n in [0,1,2]:
  print(0)

else:
  param_list.sort()
  
  #print(param_list)
  
  param_count = 0
  int_len = len(param_list)
  
  for small in range(0, int_len):
    for middle in range(small+1, int_len):
      for large in range(middle+1, int_len):
        list_tmp = list()
        list_tmp.append(param_list[small])
        list_tmp.append(param_list[middle])
        list_tmp.append(param_list[large])
        
        # print(len(set(list_tmp)) == 3)
        
        if (len(set(list_tmp)) == 3) & (list_tmp[0] + list_tmp[1] > list_tmp[2]):
          param_count = param_count + 1
          
  print(param_count)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = list(map(int,input().split()))
t = list(itertools.combinations(l,3))
ans = 0
for i in range(len(t)):
    x = t[i][0]
    y = t[i][1]
    z = t[i][2]
    if x != y and y != z and z != x:
        if x < y+z and y < z+x and z < x+y:
            ans+=1
print(ans)

Submission status: Accepted

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

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

L_set = list(set(L))
L_set.sort()
N_set = len(L_set)

L_count = [0] * N_set
for i in range( N_set ):
  L_count[i] = L.count( L_set[i] )

#print(L_set)
#print(L_count)

ans = 0

for i in range( N_set-2 ):
  for j in range( i+1, N_set-1 ):
    for k in range( j+1, N_set ):
      
      if ( L_set[i]+L_set[j] > L_set[k] ):
        ans += L_count[i]*L_count[j]*L_count[k]

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import io, sys

def main():
    N = int( sys.stdin.readline() )
    L_list = list(map(int, sys.stdin.readline().split()))

    cnt = 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)):
                a,b,c = sorted( [L_list[i], L_list[j], L_list[k]] )

                if c < (a + b)  and  (a != b) and (b != c):
                    cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
arr = list(map(int, stdin.readline().rstrip().split()))
tmp = []
count = 0

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

for i in range(0, len(arr)):
    for j in range(i+1, len(arr)):
        for k in range(j+1, len(arr)):
            tmp = sorted([arr[i],arr[j],arr[k]])
            if (tmp[2] < tmp[0] + tmp[1]) and (has_duplicates(tmp)):
                count += 1
print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import (
    accumulate, combinations, combinations_with_replacement, groupby,
    permutations, product)
from math import (
    acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians,
    sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits


def inp():
    return(int(input()))


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


def instr():
    s = input()
    return(list(s[:len(s)]))


def invr():
    return(map(int, input().split()))


def main():
    n = inp()
    a = inlist()
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                x = a[i]
                y = a[j]
                z = a[k]
                if x + y > z and y + z > x and z + x > y and (x != y and y != z and z != x):
                    ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a = int(input())
b = list(input().split(" "))

for i in range(a):
    b[i] = int(b[i])

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

print(c)