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:
from itertools import combinations


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

    answer = solve(N, L)

    print(answer)


def solve(N, L):
    three_bar_combinations = tuple(combinations(L, 3))

    if not three_bar_combinations:
        return 0

    count = 0
    for c in three_bar_combinations:
        if len(c) != len(set(c)):
            continue

        if max(c) < sum(c) - max(c):
            count += 1

    return count


if __name__ == "__main__":
    main()

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

print(c)

Submission status: Accepted

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

import itertools

ans = 0
for tmpr in itertools.combinations(list(range(len(L))),3):
    a,b,c = L[tmpr[0]],L[tmpr[1]],L[tmpr[2]]
    if a!=b and b!=c and a!=c:
        if a+b>c and a+c>b and b+c > a:
            ans+=1
   
print(ans)

Submission status: Accepted

Solution code:
import itertools

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

count = 0
for a in itertools.combinations(L, 3):
    if len(set(a)) != 3:
        continue
    a = sorted(a)
    if a[2] < a[0] + a[1]:
        count += 1
print(count)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
sort_L = sorted(L)
count = 0

for i in range(N - 2):
  a = sort_L[i]
  for j in range(i + 1,N - 1):
    b = sort_L[j]
    for k in range(j + 1,N):
      c = sort_L[k]
      if (a != b) and (b != c) and (a != c) and (abs(a-b) < c < (a + b)):
        count = count + 1
      
print(count)

Submission status: Accepted

Solution code:
import itertools

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

print(cnt)

Submission status: Accepted

Solution code:
# from pprint import pprint
# import math
# import collections

n = int(input())
# n, k = map(int, input().split(' '))
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[i] + l[k] and l[k] <= l[i] + l[j] and l[i] != l[j] and l[j] != l[k] and \
                    l[i] != l[k]:
                if max(l[i], l[j], l[k]) < (l[i] + l[j] + l[k]) / 2:
                    ans += 1
                    # print(l[i], l[j], l[k], i,j,k)

print(ans)

Submission status: Accepted

Solution code:
#ABC175 B
N = int(input())
L = list(map(int,input().split()))
ans = 0
frag = 0
if len(L) <= 2:
  ans = 0
else:
  for a in range(0,N-2):
    for b in range(a+1,N-1):
      for c in range(b+1,N):
        if L[a] == L[b] or L[a] == L[c] or L[b] == L[c]:
          continue
        if L[a]+L[b] > L[c] and L[b]+L[c] > L[a] and L[c]+L[a] > L[b]:
          ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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 k != i and k != j:
                max_t = max(l[i], l[j], l[k])
                if l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
                    count += (l[i] + l[j] + l[k] - max_t) > max_t
print(count)

Submission status: Accepted

Solution code:
n = int(input())
L = list(map(int, input().split()))
ans = 0
if n<3:
    print(0)

else:
    for i in range(n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                max_L = max(L[i],L[j],L[k])
                min_L = min(L[i],L[j],L[k])
                mid_L = L[i]+L[j]+L[k]-max_L-min_L
                if (((min_L+mid_L)>max_L) & (min_L!=mid_L!=max_L)):
                    ans+=1
    print(ans)

Submission status: Accepted

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

L = sorted(L, reverse=False)
cnt = 0

for i in range(N):
    l_i = L[i]
    for j in range(N-i):
        if L[i+j] != l_i:
            l_j = L[i+j]
            for k in range(N-i-j):
                if (L[i+j+k] != l_j) and (l_i + l_j > L[i+j+k]):
                    l_k = L[i+j+k]
                    cnt += 1
                    # print(i, i+j, i+j+k)
print(cnt)

Submission status: Accepted

Solution code:
num = int(input())
len = list(map(int,input().split()))
count = 0
max = 0
m1 = 0
m2 = 0

#print(num)
#print(len[0],len[1])

for i in range(num):
    for j in range(num):
        for k in range (num):
            if (len[i] != len[j]) and (len[i] != len[k]) and (len[j] != len[k]):
                if len[i] > len[j]:
                    max = len[i]
                    m1  = len[j]
                else:
                    max = len[j]
                    m1  = len[i]
                if len[k] > max:
                    m2  = max
                    max = len[k]
                else:
                    m2 = len[k]

                if (m1 + m2) > max:
                    if (i>j) and (j>k):
                        count += 1

print(count)

Submission status: Accepted

Solution code:
def main():
    N = input()
    L = input().split()

    cnt = 0

    for i in range(len(L)):
        iValue = L[i]
        for j in range(i + 1, len(L)):
            jValue = L[j]
            for k in range(j + 1, len(L)):
                kValue = L[k]
                rl = [int(iValue), int(jValue), int(kValue)]
                rl.sort()
                if iValue != jValue and jValue != kValue and iValue != kValue:
                    if (int(rl[0]) + int(rl[1])) > int(rl[2]):
                        # print(rl)
                        cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

    if n < 3:
        print(0)
        return
        
    count = 0
    for a in range(n-2):
        for b in range(a+1,n-1):
            for c in range(b+1,n):
                if ((l[a] + l[b] > l[c] and l[b] + l[c] > l[a] and l[a] + l[c] > l[b])and 
                    (l[a] != l[b] and l[b] != l[c] and l[a] != l[c])):
                    count += 1

    print(count)
main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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


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


print(count)

Submission status: Accepted

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

count = 0
ans = []
for i in range(N-2):
  for s in range(1,N-1):
    for k in range(2,N):
      if a[k]<a[i]+a[s] and a[s]<a[i]+a[k] and a[i]<a[k]+a[s]:
        if i<s<k:
          if a[k]!=a[i] and a[k]!=a[s] and a[i]!=a[s] :
       
            count+=1
      
print(count)

Submission status: Accepted

Solution code:
def check(a,b,c):
    if abs(a-b)<c<a+b:
        return True
    else:
        return False

count=0

import collections

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

c = collections.Counter(L)
l=sorted(list(c.keys()))

le=len(l)

for i in range(le-2):
    for j in range(i+1,le-1):
        for k in range(j+1,le):
            if check(l[i],l[j],l[k]):
                count+=c[l[i]]*c[l[j]]*c[l[k]]
                
print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
score = 0
for f in range(n-2):
	for s in range(f+1,n-1):
		for t in range(s+1,n):
			if a[f]+a[s]>a[t] and a[f] != a[s] and a[f]!=a[t] and a[s]!=a[t]:
				score += 1
print(score)

Submission status: Accepted

Solution code:
from collections import Counter
import itertools

n, *l = map(int, open(0).read().split())
c = Counter(l)
c_key = c.keys()
ans = 0
for v in itertools.combinations(c_key, 3):
    v_sorted = sorted(list(v))
    if v_sorted[0] + v_sorted[1] > v_sorted[2]:
        ans += c[v[0]]*c[v[1]]*c[v[2]]
print(ans)

Submission status: Accepted

Solution code:
def resolve():
	count = 0
	N = int(input())
	L = sorted(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):
				if L[i] == L[j]:
					None
				elif L[j] == L[k]:
					None
				elif L[i] == L[k]:
					None
				elif (L[i] + L[j]) > L[k]:
					# print(i,j,k, file=sys.stderr)
					count += 1
	print(count)
resolve()

Submission status: Accepted

Solution code:
import itertools

N = int(input())
li = list(map(int, input().split()))
if N <= 2:
    print('0')
else:
    cnt = 0
    for team in itertools.combinations(li, 3):
        i = team[0]
        j = team[1]
        k = team[2]
        if i + j > k and j + k > i and k + i > j:
            if i != j and j != k and k != i:
                cnt += 1
    print(cnt)

Submission status: Accepted

Solution code:
import itertools
import math

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

if n <= 2 :
    print(0)
    exit()
per = list(itertools.combinations(length, 3))
count = 0
for i in range(len(per)):
    if len(per[i]) == len(set(per[i])) :
       if (math.fabs(per[i][0] - per[i][1]) < per[i][2]) and (per[i][2] < per[i][0] + per[i][1]):
           count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# cook your dish here
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[i]+l[k]>l[j] and l[i]<l[j] and l[j]<l[k]:
                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):
    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:
import itertools
N = int(input())
L = list(map(int, input().split(' ')))
lengths = list(itertools.combinations(L, 3))
count = 0
for tri in lengths:
    tri = list(tri)
    tri.sort()
    if (tri[0]+tri[1]>tri[2]) and (tri[0]!=tri[1]) and (tri[1]!=tri[2]) and (tri[0]!=tri[2]):
        count+=1
print(count)

Submission status: Accepted

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

cnt = 0

if len(M) >= 3:
  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[j] >  L[k]:
          cnt += 1
print(cnt)

Submission status: Accepted

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

import itertools

cnt=0

for pair in itertools.combinations(L, 3):
    lis = sorted(list(pair))
    max_value=lis[2]
    mid_value=lis[1]
    min_value=lis[0]
    if (max_value < mid_value+min_value) and (max_value>mid_value>min_value):cnt+=1

print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int, input("").split()))
out=0
c=0
for i in  range(n):
    for j in range(i+1,n):
        if l[i] !=l[j]:
            c+=1
            for k in range(j+1,n):
                if 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]:
                        out+=1
print(out)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input())
lists = list(map(int, list(input().split())))
sets = list(set(lists))
lensets = len(sets)

total = 0

for i in range(lensets):
  for j in range(i+1, lensets):
    for k in range(j+1, lensets):
      
      
      if (sets[i] + sets[j] > sets[k]) and (sets[j] + sets[k] > sets[i]) and (sets[k] + sets[i] > sets[j]):
        
        
        number = lists.count(sets[i]) * lists.count(sets[j]) * lists.count(sets[k])
        
        total += number
print(total)

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    L = sorted(list(map(int, input().split())))
    cnt = 0
    checker = [[[0 for i in range(n)] for j in range(n)] for k in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                if (i < j < k) and (L[i] != L[j] and L[i] != L[k] and L[j] != L[k]) and L[i] + L[j] > L[k]:
                    cnt += 1

    print(cnt)

resolve()

Submission status: Accepted

Solution code:
import itertools

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

count=0
y=[]

for x in itertools.combinations(a, 3):
  if (x[0]==x[1] or x[0]==x[2] or x[1]==x[2]):
    pass
  else:
    if(x[0]+x[1]>x[2] and x[0]+x[2]>x[1] and x[1]+x[2]>x[0]):
      count+=1
    else:
      pass

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

Submission status: Accepted

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

l.sort(reverse=True)
c=0

for x in range(0,n-2):
    max1=l[x]
    for y in range(x+1,n-1):
        max2=l[y]
        for z in range(y+1,n):
            max3=l[z]

            if(max1<max2+max3 and max1!=max2 and max2!=max3):
                c+=1

print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
#print(L)
Ans = 0

for i in range(0,N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
        if max(L[i],L[j],L[k]) < (L[i]+L[j]+L[k]) - max(L[i],L[j],L[k]):
          Ans += 1
#          print(str(L[i]) + " " + str(L[j]) + " " + str(L[k]))

print(Ans)

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int, input().split()))
L.sort(reverse=True)
unique_vals=sorted(set(L), reverse=True)

count=0
#print(unique_vals)
for i, first in enumerate(unique_vals):
    for j, second in enumerate(unique_vals[i+1:]):
        for third in unique_vals[i+j+2:]:
            if third > first - second:
                count+=1*L.count(first)*L.count(second)*L.count(third)
                #print(first, second, third)
                #print(count)
            else:
                break
print(count)

Submission status: Accepted

Solution code:
n = int(input())
L = input().split()
L.sort()
count = 0
if n<=2:
    print(0)
    exit()
    
for i in range(n):
  for j in range(i + 1,n):
    for k in range(j + 1 ,n):
        if ((int(L[k]) < int(L[i]) + int(L[j])) & (L[k] != L[i])& (L[k] != L[j])& (L[j] != L[i]) & (abs(int(L[i]) - int(L[j])) < int(L[k]))):
            count += 1
        
print(count)

Submission status: Accepted

Solution code:
n=int(input())
l=input().split()
r=0
if n<3:
  print(0)
else:
  for x in range(n):
    l[x]=int(l[x])

  for i in range(n):
    a=l[i]
    for j in range(n-i-1):
      y=i+j+1
      b=l[y]
    
      for k in range(n-y-1):
        if a<b:
          d=a
          a=b
          b=d
        c=l[k+y+1]
        if a<c:
          f=a
          a=c
          c=b
          b=f
        elif b<c:
          f=b
          b=c
          c=f
        if b+c>a and a-b<c and a!=b and b!=c:
          r=r+1
          
        a=l[i]
        b=l[y]
        c=l[k+1]
  print(r)

Submission status: Accepted

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

for i in range(N):
    for j in range(N):
        for k in range(N):
            a=[]
            if A[i]!=A[j] and A[i]!=A[k] and A[j]!=A[k]:
                if i<j and j<k:
                    a.append(A[i])
                    a.append(A[j])
                    a.append(A[k])
                    a.sort()
                    
                    if a[1]-a[0]<a[2] and a[2]<a[0]+a[1]:
                        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    l = list(map(int,input().split()))
    out = 0
    if n >= 3:
        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[k] + l[j] > l[i]:
                            out += 1
    print(out)
resolve()

Submission status: Accepted

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

@author: saito
"""

# %% import phase

# %% define phase

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

# %% process phase
cnt = 0
if N >= 3:
    for i in range(len(L)-2):
        for j in range(i+1, len(L)-1):
            for k in range(j+1, len(L)):
                a = [L[i], L[j], L[k]]
                if len(set(a)) < len(a):
                    continue
                ami = a.index(max(a))
                am = a.pop(ami)
                if am < sum(a):
                    cnt += 1


# %%output phase
print(cnt)

Submission status: Accepted

Solution code:
import itertools

n=int(input())

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

count=0

for i in range(len(l)-2):
    for j in range(i+1,len(l)-1):
        for k in range(j+1,len(l)):
            #print(i,j,k)
            a=l[i]
            b=l[j]
            c=l[k]
            if abs(a-b)<c and c<a+b:
                if a!=b and b!=c and c!=a:
                    count+=1

print(count)

Submission status: Accepted

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

# print(n, s)

def is_triangle(a, b, c):
	nums = []
	if a > b:
		if a > c:
			n_max = a
			nums = [b, c]
		else:
			n_max = c
			nums = [a, b]
	elif b > c:
		n_max = b
		nums = [a, c]
	else:
		n_max = c
		nums = [a, b]
	return(n_max < sum(nums))

ans = 0
for i in range(n):
	for j in range(i + 1, n):
		for k in range(j + 1, n):
			num_1 = s[i]
			num_2 = s[j]
			num_3 = s[k]
			if (num_1 == num_2) or (num_1 == num_3) or (num_2 == num_3):
				continue
			if is_triangle(num_1, num_2, num_3):
				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]+l[k] and l[j]<l[i]+l[k] and l[k]<l[i]+l[j] and l[i]!=l[j] and l[i]!=l[k] and l[j]!=l[k]:
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n=int(input())
if n<3:
  print(0)
else:
  cnt=0
  l_list=list(map(int,input().split()))
  sl_list=sorted(l_list)
  for i in range(n):
    for j in range(i+1,n):
      for g in range(j+1,n):
        m=sl_list[i]
        f=sl_list[j]
        d=sl_list[g]
        if m!=f and f!=d and d!=m:
          if d<m+f:
            cnt+=1
  print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

anss = set()
for ix in range(len(SL)):
    for jx in range(ix+1,len(SL)):
        for ux in range(jx+1,len(SL)):
            if SL[ix] != SL[jx] != SL[ux] and SL[ix]+SL[jx] > SL[ux]:
                anss.add((ix+1, jx+1, ux+1))

print(len(anss))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
# print(N)
L = [int(x) for x in stdin.readline().rstrip().split()]
# print(L)
count = 0
for i in range(N):
  for j in range(i,N):
    if L[j]!=L[i]:
      for k in range(j,N):
        if L[k]!=L[i] and L[k]!=L[j]:
          if L[i] == max(L[i],L[j],L[k]):
            # print('i')
            if L[i]<L[j]+L[k]:
              # print(i+1,j+1,k+1)
              count += 1
          elif L[j] == max(L[i],L[j],L[k]):
            # print('j')
            if L[j]<L[i]+L[k]:
              # print(i+1,j+1,k+1)
              count += 1
          elif L[k] == max(L[i],L[j],L[k]):
            # print('k')
            if L[k]<L[j]+L[i]:
              # print(i+1,j+1,k+1)
              count += 1
print(count)

Submission status: Accepted

Solution code:
import itertools as it
N=int(input())
llist=list(map(int, input().split()))
#llist.sort()
ans=0
ijk=it.combinations(range(N),3)
for ls in ijk:
    [i,j,k]=list(ls)
    li=llist[i]
    lj=llist[j]
    lk=llist[k]
    lll=[li,lj,lk]
    #print(lll)
    if li==lj or li==lk or lj==lk:
        pass
    elif max(lll)<sum(lll)-max(lll):
        ans+=1
    #    print(i+1,j+1,k+1)
    #    print(li,lj,lk)
print(ans)

Submission status: Accepted

Solution code:


import itertools

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

L = sorted(L,reverse=True)

M = list(itertools.combinations(L, 3))
#print(M)
#M = list(set(M))
#print(M)

c = 0
for i,j,k in M:
    #print(i,j,k)
    
    if i!=j and j !=k and i < j+k:
        #print(i,j,k)
        c += 1
        
print(c)

Submission status: Accepted

Solution code:
n=int(input())
a=[s for s in input().split()]
a=[int(s) for s in a]
a=sorted(a)
ans=0
def nini(e,f,g):
    b=[e,f,g]
    b=sorted(b)
    h=b[1]
    return h
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[k]!=a[i]:
                if max(a[i],a[j],a[k])<min(a[i],a[j],a[k])+nini(a[i],a[j],a[k]):
                    ans+=1
print(int(ans/6))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
numList = []
result = []

user = int(input())
user2 = list(map(int, input().split()))
count = 0

for i in range(user - 2):
    for j in range(user - i - 1):
        jIndex = j + i + 1
        for k in range(user - jIndex - 1):
            kIndex = k + jIndex + 1
            if user2[i] != user2[jIndex] and user2[i] != user2[kIndex] and user2[jIndex] != user2[kIndex]:
                dum = []
                dum.append(user2[i])
                dum.append(user2[jIndex])
                dum.append(user2[kIndex])
                dum.sort()

                if dum[2] < dum[1] + dum[0]:
                    count += 1
print(count)

Submission status: Accepted

Solution code:
import collections

if __name__ == "__main__":
    N = int(input())
    L = list(map(int, input().split()))

    set_L = list(set(L))
    set_L.sort()
    count_L = collections.Counter(L)

    count = 0
    for i in range(len(set_L)):
        for j in range(i+1, len(set_L)):
            for k in range(j+1, len(set_L)):
                if set_L[i] + set_L[j] > set_L[k]:
                    count = count + count_L[set_L[i]] * count_L[set_L[j]] * count_L[set_L[k]]

    print(count)

Submission status: Accepted

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

for i in range(n):
  for j in range(i+1,n):
    for h in range(j+1,n):
      if l[i]!=l[j] and l[h]!=l[j] and l[i]!=l[h]:
        a = [l[i],l[j],l[h]]
        #print(a)
        a.sort()
        if a[0]+a[1]>a[2]:
          #print(c,a)
          c+=1
        
print(c)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
import itertools
N = int(input())
L = input().split()
LS = [int(i) for i in L]
count = 0
itr = list(itertools.combinations(LS, 3))

for s in itr:
    if s[0] + s[1] > s[2] and s[1] + s[2] > s[0] and s[2] + s[0] > s[1] \
        and s[0] != s[1] and s[1] != s[2] and s[2] != s[0]:
        count = count + 1
print(count)

Submission status: Accepted

Solution code:
from itertools import combinations

n = int(input())
lList = list(map(int, input().split()))
cou = 0
combList = list(map(list, combinations(list(range(n)), 3)))
for [i, j, k] in combList:
    if lList[i] != lList[j] and lList[i]!=lList[k] and lList[j]!=lList[k]:
        if lList[i] + lList[j] > lList[k] and lList[i] + lList[k] > lList[j] and lList[j] + lList[k] > lList[i]:
            cou += 1
print(cou)

Submission status: Accepted

Solution code:
#!/usr/local/bin/python3
from collections import Counter

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

L = sorted(L)
cnt = Counter(L)
ans = 0

i = 0
while i < len(L):
    j = i + 1
    if cnt[L[i]] != 1:
        j += cnt[L[i]] - 1
    while j < len(L):
        k = j + 1
        if cnt[L[j]] != 1:
            k += cnt[L[j]] - 1
        while k < len(L):
            a, b, c = L[i], L[j], L[k]
            if (a + b > c) and (b + c > a) and (c + a > b):
                ans += cnt[a] * cnt[b] * cnt[c]
            k += cnt[L[k]]
        j += cnt[L[j]]
    i += cnt[L[i]]

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

d = [i for i in range(N)]
#print(d)

L = dict(zip(d,li))

#print(L)

import itertools
x = (list(itertools.combinations(d, 3)))
#print(x)
#print(x[0][0])
#print(x[0][1])
cnt = 0
num = len(x)
for i in range(num):
    a = L[x[i][0]]
    b = L[x[i][1]]
    c = L[x[i][2]]
   # print(a,b,c)
    if ((a + b >c) and (a+c >b) and (b+c>a)) and (a!=b and b!=c and a!=c):
        cnt = cnt+1
    else:
        pass
    a = 0
    b = 0
    c = 0
    
print(cnt)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

def combination(n,r):
    return int(math.factorial(n)/math.factorial(r)/math.factorial(n-r))
 
N=int(input())
L = list(map(int, input().split()))

L.sort()

if N<=2 or len(Counter(L))<3:
    print(0)
    sys.exit()

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


for i in range(len(tmp)):
    if tmp[i][0] == tmp[i][1] or tmp[i][1] == tmp[i][2] or tmp[i][2] == tmp[i][0] or tmp[i][0] + tmp[i][1] <= tmp[i][2]:
        continue
    else:
        ans += 1

print(ans)

Submission status: Accepted

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



for i in L:
    for j in L:
        for k in L:
            if i != j and i != k and j != k:
                if i + j > k and i + k > j and j + k > i:
                    if i > j > k:
                        ans += 1
                        
                    
print(ans)