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 B(N, L):
    if N < 3:
        return 0

    answer = 0

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

    return answer
  
  
N = int(input())
L = [int(n) for n in input().split(' ')]
print(B(N, L))

Submission status: Accepted

Solution code:
import math
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]):
                if(L[i]!=L[k]):
                    if(L[j]!=L[k]):
                        ans+=1
                        print('{},{},{}'.format(i,j,k))
            else:
                break
print(ans)
'''
count=0
ss=[]
S=[0]*N
for i in range(len(L)):
    if(not (L[i] in ss)):

        ss.append(L[i])
        if(S[ss.index(L[i])]==0):
            S[ss.index(L[i])]=1
    else:

        S[ss.index(L[i])]=S[ss.index(L[i])]+1

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans=0
for i in range(len(ss)-2):
    for j in range(i+1,len(ss)-1):
        for k in range(j+1,len(ss)):
            if(ss[i]+ss[j]>ss[k] and ss[j]+ss[k]>ss[i] and ss[k]+ss[i]>ss[j]):
                ans=ans+S[i]*S[j]*S[k]

print(ans)
'''
print(count)
print(combinations_count(count, 3))
'''

Submission status: Accepted

Solution code:
n = int(input())
ls = list(map(int, input().split()))
if n < 3:
    print(0)
    exit()
def checkValidity(a, b, c):  
    # check condition  
    if (a + b <= c) or (a + c <= b) or (b + c <= a) : 
        return False
    else: 
        return True  
r = 0
for i in range(n):
    for j in range(i+1, n):
        if ls[i] != ls[j]:
            for k in range(j+1, n):
                if ls[j] != ls[k] and ls[k] != ls[i]:
                    if checkValidity(ls[i],ls[j],ls[k]):
                        r += 1

print(r)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = list(map(int, input().split()))
ans = 0
for a, b, c in itertools.combinations(l, 3):
    if a != b and b != c and a != c:
        if abs(a-b) < c < a+b:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools

n=int(input())
L=list(map(int,input().split()))
M=[]
N=[]

for v in itertools.combinations(L,3):
    M.append(list(map(int,v)))

if n==1 or n==2:
       print(0)
else :
    for i in range(len(M)):
        if M[i][0]==M[i][1] or M[i][0]==M[i][2] or M[i][1]==M[i][2]:
            continue
        if M[i][0]+M[i][1]>M[i][2] and M[i][0]+M[i][2]>M[i][1] and M[i][1]+M[i][2]>M[i][0]:
            N.append(M[i])
    print(len(N))

Submission status: Accepted

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

Submission status: Accepted

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

L = sorted(L, reverse=True)
cnt=0
for i in range(len(L)-2):
    a = L[i]
    for j in range(i+1,len(L)-1):
        b = L[j]
        if a==b:
            continue
        for k in range(j+1, len(L)):
            c=L[k]
            if b==c:
                continue
            if a < b+c:
                cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
d=dict()
for i in l:
  if i in d:
    d[i]+=1
  else:
    d[i]=1
#print(d)
li=list(d.keys()) 
ans=0
for i in range(len(li)-1,0,-1):
  a,b=0,i-1
  while(a<b):
    if li[a]+li[b]>li[i]:
      #print(li[a],li[b],li[i])
      for kk in range(a,b):
      	ans+=d[li[kk]]*d[li[b]]*d[li[i]]
      b-=1
    else:
      a+=1
print(ans)

Submission status: Accepted

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

import itertools
if N<3:
  print(0)
else:
  count=0
  h = itertools.combinations(L, 3)
  for v in h:
    lst=sorted(list(v))
    if lst[0]+lst[1]>lst[2]:
      if lst.count(lst[0])==1:
        if lst.count(lst[1])==1:
          if lst.count(lst[2])==1:
            count+=1
  print(count)

Submission status: Accepted

Solution code:
import itertools as it
n = int(input())
l = list(map(int, input().split()))
s = []
ans = 0
l.sort()
seed = list(range(0,n))
cmt = list(it.combinations(seed, 3))
for i in range(len(cmt)):
  a = cmt[i]
  if l[a[1]] + l[a[0]] > l[a[2]] and l[a[0]] != l[a[1]] and l[a[1]] != l[a[2]] and l[a[0]] != l[a[2]]:
    ans += 1
print (ans)

Submission status: Accepted

Solution code:
N = int(input()) #1行目のNを取得する
list = list(map(int, input().split()))
i=0
j=1
k=2
kosuu=0

while i<=N-3:
  while j<=N-2:
    while k<=N-1:
      x=list[i]
      y=list[j]
      z=list[k]
      if x+y>z and y+z>x and z+x>y and x!=y and y!=z and z!=x:
        kosuu+=1
      k+=1
      
    j+=1
    k=j+1
  i+=1
  j=i+1
  k=j+1
print(kosuu)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0

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

L.sort(reverse=True)

for i in range(len(L)-2):
    for j in range(i, len(L)-1):
        for k in range(j, len(L)):
            if L[i] < L[j] + L[k] and (L[i] != L[j] and L[i] != L[k] and L[j] != L[k]):
                # print(L[i] , L[j] , L[k])
                cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    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 j < k and (i+j) > k and (i+k) > j and (j+k) >i:
                    ans +=1
    print(ans)




    
if __name__ == "__main__":
    main()

Submission status: Accepted

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


def solve():
    if n < 3:
        return 0

    llen = len(ls)
    cnt = 0
    # c = set()

    for i in range(0, llen):
        for j in range(0, llen):
            for k in range(0, llen):
                if not (i < j < k):
                    continue

                xs = [ls[i], ls[j], ls[k]]
                xs.sort()
                ii, jj, kk = xs
                if len(set(xs)) < 3:
                    continue

                if ii + jj > kk and jj + kk > ii and kk + ii > jj:
                    # c.add(f"{ii}{jj}{kk}")
                    cnt += 1

    return cnt


print(solve())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 175
# B - Making Triangle

import bisect

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):
            # print(i,j,k)
            a=min(L[i],L[j],L[k])
            c=max(L[i],L[j],L[k])
            b=(L[i]+L[j]+L[k]-a-c)
            if a+b>c and a<b<c:
                ans+=1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
c = 0
if N == 1 or N ==2 :
  c == 0
else:
  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] :
          l = [L[i], L[j], L[k]]
          ld = sorted(l, reverse=True)
          if ld[0] < ld[1] + ld[2]:
            c = c + 1

print(c)

Submission status: Accepted

Solution code:
import itertools

N = int(input().strip())
L = [int(i) for i in input().strip().split(' ')]

cnt = 0
for i in itertools.combinations(L, r=3):
  i = sorted(i)
  if len(set(i)) == 3:
    if sum(i[:2]) > i[2]:
      cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import sys
import math
import itertools

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

cnt = 0

L = list(itertools.combinations(L,3))

for l in L:
    if l[0] + l[1] > l[2] and l[1] + l[2] > l[0] and l[2] + l[0] > l[1] and l[0] != l[1] and l[1] != l[2] and l[2] != l[0]:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import collections
N = int(input())
L = list(map(int, input().split()))
L = collections.Counter(L)
L = list(L.items())
L = sorted(L)
N = len(L)

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][0]+L[j][0] > L[k][0]:
                ans += L[i][1]*L[j][1]*L[k][1]

print(ans)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = list(map(int,input().split()))
l = sorted(l)
count = 0
ans = list(itertools.combinations(l, 3))
for i in ans:
    if i[0] + i[1] > i[2]:
        if len(i) == len(set(i)):
            count += 1

print(count)

Submission status: Accepted

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

for i in range(n):
    a = l[i]
    for j in range(n):
        b = l[j]
        for k in range(n):
            c = l[k]
            if i < j and j < k:
                m = [a,b,c]
                m = sorted(m)
                f = max(m)
                h = min(m)
                m.pop(0)
                m.pop(1)
                if f<m[0]+h and f != m[0] and m[0] != h:
                    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
x=eval(input())
num=sorted(list(map(int,input().split())))
res=0
for i in range(x):
    for j in range(i):
        for k in range(x-1,i,-1):
            if num[i]==num[j] or num[i]==num[k] or num[j]==num[k]:
                continue
            else:
                if num[j]-num[k]<num[i] and num[j]+num[i]>num[k]:
                    res+=1
print(res)

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
setL=set(L)
dicL=dict()
ans=0
for i in L:
    if i in dicL:
        dicL[i]+=1
    else:
        dicL[i]=1
L=list(setL)
length=len(L)
for i in range(length):
    for j in range(i+1,length):
        for k in range(j+1,length):
            if L[i]+L[j]>L[k] and L[i]+L[k]>L[j] and L[j]+L[k]>L[i]:
                ans+=dicL[L[i]]*dicL[L[j]]*dicL[L[k]]
print(ans)

Submission status: Accepted

Solution code:
import itertools
N = int(input())

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

LL= list(itertools.combinations(L, 3))

cnt = 0

for suji in LL:
    a = suji[0]
    b = suji[1]
    c = suji[2]

    if a != b and b != c and c != a:
        if a + b > c and b + c > a and c + a > b:
            cnt = cnt + 1

print(cnt)

Submission status: Accepted

Solution code:
n = input()
if int(n) < 3:
  print(0)
  exit()
a = [int(i) for i in input().split()]
l = len(a)
sum = 0
s = 0
for i in range(l):
  for j in range(i + 1, l):
    for k in range(j + 1, l):
      if not (a[i] == a[j] or a[j] == a[k] or a[k] == a[i]):
        if (a[i] + a[j]) > a[k] and (a[j] + a[k]) > a[i] and (a[k] + a[i]) > a[j]:
          sum += 1
print(sum)

Submission status: Accepted

Solution code:
import numpy as np

N = int(input().rstrip())
if N > 3:
  line = input().rstrip().split()
  L = [int(i) for i in line]
  L.sort(reverse = True)

  count = 0

  for i in range(len(L)):
    for j in range(len(L)):
      for k in range(len(L)):
        if i != j and j != k and k != i:
          if i < j and j < k:
            x = L[i]
            y = L[j]
            z = L[k]
            if x < y+z:
              if y-z < x:
                if x != y and y != z and z !=x:
                  count += 1

  print(count)
  
else:
  print(0)

Submission status: Accepted

Solution code:
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)):
      n1 = l[i]
      n2 = l[j]
      n3 = l[k]
      if n1 < n2 + n3 and n2 < n1 + n3 and n3 < n1 + n2:
        if n1 != n2 and n1 != n3 and n2 != n3:
          count = count + 1
      else:
        continue

print(count)

Submission status: Accepted

Solution code:
# B - Making Triangle
def main():
    n = int(input())
    l = list(map(int, input().split()))
    cnt = 0

    for i in range(n):
        for j in range(n):
            for k in range(n):
                if i < j < k:
                    if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[i]+l[k]>l[j]:
                        if l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
                            cnt += 1
    else:
        print(cnt)


if __name__ ==  "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
L = [int(s) for s in input().split()]
L.sort()
count = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            len0 = L[i] + L[j] + L[k]
            max0 = max(L[i],L[j],L[k])
            rest = len0 - max0
            if (max0 < rest) and L[i] != L[j] and L[j]!=L[k]:
                count += 1
print(count)

Submission status: Accepted

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

print(c)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = list(map(int,input().split()))
ans=0
for v in itertools.combinations(list(range(N)), 3):
  if max(L[v[0]],L[v[1]],L[v[2]])<L[v[0]]+L[v[1]]+L[v[2]]-max(L[v[0]],L[v[1]],L[v[2]]):
    if L[v[0]]!=L[v[1]] and L[v[1]]!=L[v[2]] and L[v[2]]!=L[v[0]]:
      ans+=1
    
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
from itertools import combinations

N = ii()
A = li()
cnt = 0

for c in combinations(A, 3):
    c = sorted(c)
    if c[0] != c[1] and c[1] != c[2]:
        if c[0] + c[1] > c[2]:
            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
ssl = list(map(int, input().split()))
le = n
#sl = set(l)
#ssl = sorted(list(sl))
#le = len(ssl)
ans = 0
for i in range(le):
  a = ssl[i]
  for j in range(le-1):
    if i+j+1 < le and a != ssl[i+j+1]:
      b = ssl[i+j+1]
      for k in range(le-2):
        if i+j+k+2 < le and b != ssl[i+j+k+2] and a != ssl[i+j+k+2]:
          c = ssl[i+j+k+2]
          if a + b > c and b + c > a and c + a > b:
            #print(a, b, c)
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
L.sort(reverse=True)
count=0
for x in L:
    for y in L:
        for z in L:
            if x<y+z and x>y and y>z:
                count+=1
print(count)

Submission status: Accepted

Solution code:
def main():
    import sys
    N=int(sys.stdin.readline())
    L=list(map(int,sys.stdin.readline().split()))
    count=0
    for i in L:
        for j in L:
            if i==j:
                continue
            for k in L:
                if i==k or j==k:
                    continue
                
                lst=sorted([i,j,k])
                if lst[2]<lst[1]+lst[0]:
                    count+=1
  
    print(count//6)
main()

Submission status: Accepted

Solution code:
N = int(input())
LL = list(map(int,input().split()))
cnt = 0
L = sorted(list(set(LL)))
for i in range(len(L)-2):
    for j in range(1, len(L)-1-i):
        for k in range(1, len(L)-i-j):
#             print(L)
#             print(L[i],L[i+j],L[i+j+k])
            if L[i] + L[i+j] > L[i+j+k] and L[i+j] - L[i] < L[i+j+k]:
#                 print("------------")
#                 print(L[i],L[i+j],L[i+j+k])
#                 print(LL.count(L[i]),LL.count(L[i+j]),LL.count(L[i+j+k]))
                cnt += LL.count(L[i])*LL.count(L[i+j])*LL.count(L[i+j+k])
                
print(cnt)

Submission status: Accepted

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

count = 0
for i in L:
    for j in L:
        for k in L:
            if i < j < k:
                if i != j != k:
                    if (i + j > k) and (j + k > i) and (i + k > j):
                        count+=1

print(count)

Submission status: Accepted

Solution code:
import itertools

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

cnt = 0
for v in itertools.combinations(l, 3):
    t = set(v)
    if len(t) == len(v) and (abs(v[0] - v[1]) < v[2] < v[0] + v[1]):
        cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0

for i in range(len(L)):
    for k in range(i + 1, len(L), 1):
        for l in range(k + 1, len(L), 1):
            A = [L[i], L[k], L[l]]
            if (2 * max(A) < sum(A)) & (len(A) == len(set(A))):
                ans = ans + 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

l.sort()
ans = 0

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

Submission status: Accepted

Solution code:
import itertools

n = int(input())
nums = list(map(int, input().split()))
count = 0
for i, j, k in itertools.combinations(nums, 3):
    if i != j and i != k and j != k:
        L = [i, j, k]
        L = sorted(L)
        if L[2] < L[0] + L[1]:
            count += 1


print(count)

Submission status: Accepted

Solution code:
n = int(input())
data = list(map(int, input().split()))
result = 0
re = []

for i in range(len(data)):
  for j in range(i + 1, len(data)):
    for k in range(j + 1, len(data)):
      if data[i] == data[j] or data[i] == data[k] or data[j] == data[k] or data[i]== data[j] == data[k]:
        result += 0
      else:
        lists = [data[i],data[j],data[k]]
        lists = sorted(lists)
        if lists[0]+lists[1] > lists[2] :
          result += 1


print(result)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0

def all_not_equals(i, j, k):
    return li[i] != li[j] and li[j] != li[k] and li[k] != li[i]

def could_be_triangle(i, j, k):
    e = max(li[i], li[j], li[k])

    return ((li[i] + li[j] + li[k]) - e) > e

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if all_not_equals(i, j, k) and could_be_triangle(i, j, k):
                # print(i + 1, j + 1, k + 1)
                cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

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

#print(N)
#print(x)

def hantei(x):
    count_1 = 0
    x_sort = sorted(x)
    number_1 = range(len(x))
    list_2 = [(x_sort[i],x_sort[j],x_sort[k]) for i in number_1 for j in number_1 for k in number_1 if i < j < k]
    for a in list_2:
        if a[0] + a[1] > a[2] and a[0] != a[1] and a[1] != a[2]:
            count_1 += 1
    return count_1

print(hantei(x))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N = input()
L = list(map(int, input().split()))
def triangle(a, b, c):
    # 三角形が存在するか確認
    if a+b > c and b+c > a and c+a > b:
        # 直角三角形
        if a**2 == b**2 + c**2:
            return 0
        # 鋭角三角形
        elif a**2 < b**2 + c**2:
            return 1
        # 鈍角三角形
        elif a**2 > b**2 + c**2:
            return 2
    else:
        # 三角形が存在しない
        return 3
count = 0
for trio in itertools.combinations(L,3):
    if trio[0]==trio[1] == trio[2]:
        count += 0
    elif trio[0]==trio[1]:
        count += 0
    elif trio[0]==trio[2]:
        count += 0
    elif trio[2]==trio[1]:
        count += 0
    elif triangle(trio[0], trio[1], trio[2]) != 3:
        count += 1
    
print(count)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
y=0
z=1
ans=0
for i in range(n-2):
    y+=1
    z=i
    for x in range(y,n-1):
        z+=1
        for w in range(z,n):
            if a[i]!=a[x] and a[i]!=a[w] and a[w]!=a[x]:
                if a[i]+a[x]>a[w] and a[w]+a[x]>a[i] and a[i]+a[w]>a[x]:
                    ans+=1
                    
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 21:15:44 2020

@author: naoki
"""

N = int(input())
L = list(map(int, input().split()))
count = 0 # 条件を満たす要素のカウント
L2 = sorted(L) # 小さい順に長さをソートする
# i + j > k and i > k - j 
if len(L2) <= 2: 
    count =  0
else:
    for i in range(len(L2)-2):
        for j in range(i+1,len(L2)-1):
            for k in range(j+1,len(L2)):
                if (int(L2[i]) + int(L2[j]) > int(L2[k])) and (int(L2[i]) > int(L2[k]) - int(L2[j])) and int(L2[i]) != int(L2[j]) and int(L2[j]) != int(L2[k]):
                    count+=1
print(count)

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())
ls = [int(s) for s in input().split()]

count = 0

for i in range(0, N-2):
  for j in range(i+1, N-1):
    l1 = ls[i]
    l2 = ls[j]
    if l2 == l1:
      continue
    for k in range(j+1, N):
      l3 = ls[k]
      if l3 in {l1, l2}:
        continue
      max_num = max((l1, l2, l3))
      if 2 * max_num < l1 + l2 + l3:
        count += 1

print(count)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

if N<=2:
    print(0)
else:
    answer=0
    for l in range(N-2):
        for m in range(l+1,N-1):
            for n in range(m+1,N):
                a=sorted([L[l],L[m],L[n]])
                if a[2]<a[0]+a[1]:
                    if a[0]!=a[1] and a[1]!=a[2] and a[2]!=a[0]:
                        answer+=1
    print(answer)

Submission status: Accepted

Solution code:
from sys import stdin,stdout
input = stdin.readline
def write(n,sep="\n"):
	stdout.write(str(n))
	stdout.write(sep)
def gil():
	return list(map(int, input().split()))
import itertools
N = int(input())
L = list(map(int, input().split()))
if N < 3:
    print(0)
    exit()
ans = 0
for bars in itertools.combinations(L, 3):
    if max(bars) >= sum(bars) - max(bars):
        continue
    if bars[0] == bars[1]:
        continue
    if bars[1] == bars[2]:
        continue
    if bars[0] == bars[2]:
        continue
    ans += 1
print(ans)

Submission status: Accepted

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

cnt = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        for k in range(j+1, N):
            c = L[k]
            if a != b and b != c and c != a:
                m = [a, b, c]
                o = max(m)
                m.remove(o)
                if o < sum(m):
                    cnt += 1
#cnt = list(map(list, set(map(tuple, cnt))))
print(cnt)

Submission status: Accepted

Solution code:
import itertools

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

p = list(itertools.combinations(array, 3))

count = 0

for p_i in p:
    if p_i[0] + p_i[1] > p_i[2]:
        if p_i[1] + p_i[2] > p_i[0]:
            if p_i[2] + p_i[0] > p_i[1]:
                if p_i[0] != p_i[1] and p_i[1] != p_i[2] and p_i[2] != p_i[0]:
                    count = count + 1

print(count)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    L = sorted([int(x) for x in input().split()])
    cnt = 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]) and (L[b] != L[c]) and (L[c] != L[a]) and \
                    L[a] + L[b] > L[c]:
                    cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
L = [int(i) for i in input().split()]
L.sort()
Ln = []
cnt = 1
for j in range(1,N):
    if L[j-1]==L[j]:
        cnt+=1
        if j==N-1:
            Ln.append(cnt)
    else:
        Ln.append(cnt)
        cnt=1
        if j==N-1:
            Ln.append(cnt)
L1 = list(set(L))
L1.sort()
len_L1 = len(L1)
tri = 0
for k in range(len_L1-2):
    for l in range(k+1,len_L1-1):
        for m in range(l+1,len_L1):
            if (L1[k]+L1[l])>L1[m]:
                tri += Ln[k]*Ln[l]*Ln[m]
print(tri)

Submission status: Accepted

Solution code:
a=int(input())
arr=list(map(int,input().split()))
count=0
s=set(arr)
brr=[]
d=dict()
count=0
for i in range(0,len(arr)):
    for j in range(i+1,len(arr)):
        for k in range(j+1,len(arr)):
            brr=[arr[i],arr[j],arr[k]]
            brr.sort()
            if(brr[0]+brr[1]>brr[2]):
                if((not brr[0]==brr[1]) and (not brr[1]==brr[2]) and (not brr[2]==brr[1])):
                    count=count+1
                

print(count)

Submission status: Accepted

Solution code:
from statistics import median
import itertools
N = int(input())
L = list(map(int, input().split()))
L = list(itertools.combinations(L,3))
c = len(L)
for l in L:
  l = list(l)
  m = max(l)
  if len(set(l)) < 3:
    c -= 1
  elif m >= (median(l) + min(l)):
    c -= 1

print(c)

Submission status: Accepted

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

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if a[i] != a[j] and a[j] != a[k] and a[k] != a[i]:
                if a[i] + a[j] > a[k] and a[j] + a[k] > a[i] and a[k] + a[i] > a[j]:
                    c += 1

print(c)

Submission status: Accepted

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

    ans = 0
    for L in list(itertools.combinations(Ls, 3)):

        if L[0] + L[1] > L[2] and  L[1] + L[2] > L[0] and  L[2] + L[0] > L[1] and len(L) == len(set(L)):
            ans += 1

    print(ans)
    
main()

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

print(ans)